Textpattern | PHP Cross Reference | Content Management Systems |
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * http://textpattern.com 6 * 7 * Copyright (C) 2016 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 <http://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 ($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 ); 102 103 // Shift preferences to more intuitive spots. 104 // Give positions, leave enough room for later additions. 105 106 safe_update('txp_prefs', "position = 20", "name IN( 107 'sitename', 108 'comments_on_default', 109 'img_dir', 110 'comments_require_name', 111 'syndicate_body_or_excerpt', 112 'title_no_widow' 113 )"); 114 115 safe_update('txp_prefs', "position = 40", "name IN( 116 'siteurl', 117 'comments_default_invite', 118 'file_base_path', 119 'comments_require_email', 120 'rss_how_many', 121 'articles_use_excerpts' 122 )"); 123 124 safe_update('txp_prefs', "position = 60", "name IN( 125 'site_slogan', 126 'comments_moderate', 127 'never_display_email', 128 'file_max_upload_size', 129 'show_comment_count_in_feed', 130 'allow_form_override' 131 )"); 132 133 safe_update('txp_prefs', "position = 80", "name IN( 134 'production_status', 135 'comments_disabled_after', 136 'tempdir', 137 'comment_nofollow', 138 'include_email_atom', 139 'attach_titles_to_permalinks' 140 )"); 141 142 safe_update('txp_prefs', "position = 100", "name IN( 143 'gmtoffset', 144 'comments_auto_append', 145 'plugin_cache_dir', 146 'permlink_format', 147 'use_mail_on_feeds_id' 148 )"); 149 150 safe_update('txp_prefs', "position = 120", "name IN( 151 'is_dst', 152 'comments_mode', 153 'override_emailcharset' 154 )"); 155 156 safe_update('txp_prefs', "position = 120, event = 'publish'", "name = 'send_lastmod'"); 157 158 safe_update('txp_prefs', "position = 140", "name IN( 159 'dateformat', 160 'comments_dateformat', 161 'spam_blacklists' 162 )"); 163 164 safe_update('txp_prefs', "position = 160", "name IN( 165 'archive_dateformat', 166 'comments_are_ol', 167 'comment_means_site_updated', 168 'ping_weblogsdotcom' 169 )"); 170 171 safe_update('txp_prefs', "position = 180", "name IN( 172 'permlink_mode', 173 'comments_sendmail', 174 'ping_textpattern_com' 175 )"); 176 177 safe_update('txp_prefs', "position = 200", "name IN( 178 'use_textile', 179 'expire_logs_after' 180 )"); 181 182 safe_update('txp_prefs', "position = 220", "name IN( 183 'logging', 184 'use_dns' 185 )"); 186 187 safe_update('txp_prefs', "position = 240", "name IN( 188 'use_comments', 189 'max_url_len' 190 )"); 191 192 safe_update('txp_prefs', "position = 260", "name = 'use_plugins'"); 193 safe_update('txp_prefs', "position = 280", "name = 'admin_side_plugins'"); 194 safe_update('txp_prefs', "position = 300", "name = 'allow_page_php_scripting'"); 195 safe_update('txp_prefs', "position = 320", "name = 'allow_article_php_scripting'"); 196 safe_update('txp_prefs', "position = 340", "name = 'allow_raw_php_scripting'"); 197 safe_update('txp_prefs', "position = 120, type = 1", "name = 'comments_disallow_images'"); 198 199 safe_update('txp_prefs', "event = 'comments'", "name IN( 200 'never_display_email', 201 'comment_nofollow', 202 'spam_blacklists', 203 'comment_means_site_updated' 204 )"); 205 206 safe_update('txp_prefs', "event = 'feeds'", "name IN( 207 'syndicate_body_or_excerpt', 208 'rss_how_many', 209 'show_comment_count_in_feed', 210 'include_email_atom', 211 'use_mail_on_feeds_id' 212 )"); 213 214 // 'Textile links' feature removed due to unclear specs. 215 safe_delete('txp_prefs', "event = 'link' AND name = 'textile_links'"); 216 217 // Use TextileRestricted lite/fat in comments? 218 if (!safe_field("name", 'txp_prefs', "name = 'comments_use_fat_textile'")) { 219 safe_insert('txp_prefs', "prefs_id = 1, name = 'comments_use_fat_textile', val = '0', type = '1', event = 'comments', html = 'yesnoradio', position = '130'"); 220 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title