Textpattern | PHP Cross Reference | Content Management Systems |
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * https://textpattern.com/ 6 * 7 * Copyright (C) 2020 The Textpattern Development Team 8 * 9 * This file is part of Textpattern. 10 * 11 * Textpattern is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation, version 2. 14 * 15 * Textpattern is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with Textpattern. If not, see <https://www.gnu.org/licenses/>. 22 */ 23 24 if (!defined('TXP_UPDATE')) { 25 exit("Nothing here. You can't access this file directly."); 26 } 27 28 safe_alter('txp_lang', 'DELAY_KEY_WRITE = 0'); 29 30 // New status field for file downloads. 31 $txpfile = getThings("DESCRIBE `".PFX."txp_file`"); 32 33 if (!in_array('status', $txpfile)) { 34 safe_alter('txp_file', "ADD status SMALLINT NOT NULL DEFAULT '4'"); 35 } 36 37 if (!in_array('modified', $txpfile)) { 38 safe_alter('txp_file', "ADD modified DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"); 39 } 40 41 safe_alter('txp_file', "MODIFY modified DATETIME NOT NULL"); 42 43 if (!in_array('created', $txpfile)) { 44 safe_alter('txp_file', "ADD created DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"); 45 } 46 47 safe_alter('txp_file', "MODIFY created DATETIME NOT NULL"); 48 49 if (!in_array('size', $txpfile)) { 50 safe_alter('txp_file', "ADD size BIGINT"); 51 } 52 53 if (!in_array('downloads', $txpfile)) { 54 safe_alter('txp_file', "ADD downloads INT DEFAULT '0' NOT NULL"); 55 } 56 57 $txpfile = getThings("DESCRIBE `".PFX."txp_file`"); 58 59 // Copy existing file timestamps into the new database columns. 60 if (array_intersect(array('modified', 'created', 'size', ), $txpfile)) { 61 $rs = safe_rows("*", 'txp_file', "1 = 1"); 62 $dir = get_pref('file_base_path', dirname(txpath).DS.'files'); 63 64 foreach ($rs as $row) { 65 if (empty($row['filename'])) { 66 continue; 67 } 68 69 $path = build_file_path($dir, $row['filename']); 70 71 if (file_exists($path) and ($stat = @stat($path))) { 72 safe_update('txp_file', "created = '".strftime('%Y-%m-%d %H:%M:%S', $stat['ctime'])."', modified = '".strftime('%Y-%m-%d %H:%M:%S', $stat['mtime'])."', size = '".doSlash(sprintf('%u', $stat['size']))."'", "id = '".doSlash($row['id'])."'"); 73 } 74 } 75 } 76 77 safe_update('textpattern', "Keywords = TRIM(BOTH ',' FROM 78 REPLACE( 79 REPLACE( 80 REPLACE( 81 REPLACE( 82 REPLACE( 83 REPLACE( 84 REPLACE( 85 REPLACE( 86 REPLACE( 87 REPLACE( 88 REPLACE(Keywords, '\n', ','), 89 '\r', ','), 90 '\t', ','), 91 ' ', ' '), 92 ' ', ' '), 93 ' ', ' '), 94 ' ,', ','), 95 ', ', ','), 96 ',,,,', ','), 97 ',,', ','), 98 ',,', ',') 99 )", 100 "Keywords != ''" 101 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title