[ Index ] |
PHP Cross Reference of Textpattern 4.0.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 $HeadURL: https://textpattern.googlecode.com/svn/releases/4.0.8/source/textpattern/update/_to_4.0.5.php $ 5 $LastChangedRevision: 2894 $ 6 */ 7 8 if (!defined('TXP_UPDATE')) 9 { 10 exit("Nothing here. You can't access this file directly."); 11 } 12 13 safe_alter('txp_lang', 'DELAY_KEY_WRITE = 0'); 14 15 if (!safe_field('name', 'txp_prefs', "name = 'lastmod_keepalive'")) 16 safe_insert('txp_prefs', "prefs_id = 1, name = 'lastmod_keepalive', val = '0', type = '1', html='yesnoradio'"); 17 18 // new Status field for file downloads 19 $txpfile = getThings('describe `'.PFX.'txp_file`'); 20 if (!in_array('status',$txpfile)) { 21 safe_alter('txp_file', 22 "add status smallint NOT NULL DEFAULT '4'"); 23 } 24 $update_files = 0; 25 if (!in_array('modified',$txpfile)) { 26 safe_alter('txp_file', 27 "add modified datetime NOT NULL default '0000-00-00 00:00:00'"); 28 $update_files = 1; 29 } 30 if (!in_array('created',$txpfile)) { 31 safe_alter('txp_file', 32 "add created datetime NOT NULL default '0000-00-00 00:00:00'"); 33 $update_files = 1; 34 } 35 if (!in_array('size',$txpfile)) { 36 safe_alter('txp_file', 37 "add size bigint"); 38 $update_files = 1; 39 } 40 if (!in_array('downloads',$txpfile)) { 41 safe_alter('txp_file', "ADD downloads INT DEFAULT '0' NOT NULL"); 42 } 43 if (array_intersect(array('modified', 'created'), $txpfile)) { 44 safe_alter('txp_file', "MODIFY modified datetime NOT NULL default '0000-00-00 00:00:00', MODIFY created datetime NOT NULL default '0000-00-00 00:00:00'"); 45 } 46 47 // copy existing file timestamps into the new database columns 48 if ($update_files) { 49 $prefs = get_prefs(); 50 $rs = safe_rows('*', 'txp_file', '1=1'); 51 foreach ($rs as $row) { 52 $path = build_file_path(@$prefs['file_base_path'], @$row['filename']); 53 if ($path and ($stat = @stat($path))) { 54 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'])."'"); 55 } 56 } 57 58 } 59 60 safe_update('textpattern', "Keywords=TRIM(BOTH ',' FROM REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Keywords,'\n',','),'\r',','),'\t',','),' ',' '),' ',' '),' ',' '),' ,',','),', ',','),',,,,',','),',,',','),',,',','))", "Keywords != ''"); 61 62 // shift preferences to more intuitive spots 63 // give positions, leave enough room for later additions 64 65 safe_update('txp_prefs', "position = 20", "name in( 66 'sitename', 67 'comments_on_default', 68 'img_dir', 69 'comments_require_name', 70 'syndicate_body_or_excerpt', 71 'title_no_widow' 72 )"); 73 74 safe_update('txp_prefs', "position = 40", "name in( 75 'siteurl', 76 'comments_default_invite', 77 'file_base_path', 78 'comments_require_email', 79 'rss_how_many', 80 'articles_use_excerpts' 81 )"); 82 83 safe_update('txp_prefs', "position = 60", "name in(' 84 site_slogan', 85 'comments_moderate', 86 'never_display_email', 87 'file_max_upload_size', 88 'show_comment_count_in_feed', 89 'allow_form_override' 90 )"); 91 92 safe_update('txp_prefs', "position = 80", "name in( 93 'production_status', 94 'comments_disabled_after', 95 'tempdir', 96 'comment_nofollow', 97 'include_email_atom', 98 'attach_titles_to_permalinks' 99 )"); 100 101 safe_update('txp_prefs', "position = 100", "name in( 102 'gmtoffset', 103 'comments_auto_append', 104 'plugin_cache_dir', 105 'permalink_title_format', 106 'use_mail_on_feeds_id' 107 )"); 108 109 safe_update('txp_prefs', "position = 120", "name in( 110 'is_dst', 111 'comments_mode', 112 'override_emailcharset' 113 )"); 114 115 safe_update('txp_prefs', "position = 120, event = 'publish'", "name = 'send_lastmod'"); 116 117 safe_update('txp_prefs', "position = 140", "name in( 118 'dateformat', 119 'comments_dateformat', 120 'spam_blacklists', 121 'lastmod_keepalive' 122 )"); 123 124 safe_update('txp_prefs', "position = 160", "name in( 125 'archive_dateformat', 126 'comments_are_ol', 127 'comment_means_site_updated', 128 'ping_weblogsdotcom' 129 )"); 130 131 safe_update('txp_prefs', "position = 180", "name in('permlink_mode','comments_sendmail','ping_textpattern_com')"); 132 safe_update('txp_prefs', "position = 200", "name in('use_textile','expire_logs_after')"); 133 safe_update('txp_prefs', "position = 220", "name in('logging','use_dns')"); 134 safe_update('txp_prefs', "position = 240", "name in('use_comments','max_url_len')"); 135 136 safe_update('txp_prefs', "position = 260", "name = 'use_plugins'"); 137 safe_update('txp_prefs', "position = 280", "name = 'admin_side_plugins'"); 138 safe_update('txp_prefs', "position = 300", "name = 'allow_page_php_scripting'"); 139 safe_update('txp_prefs', "position = 320", "name = 'allow_article_php_scripting'"); 140 safe_update('txp_prefs', "position = 340", "name = 'allow_raw_php_scripting'"); 141 142 safe_update('txp_prefs', "position = 120, type = 1", "name = 'comments_disallow_images'"); 143 144 safe_update('txp_prefs', "event = 'comments'", "name in( 145 'never_display_email', 146 'comment_nofollow', 147 'spam_blacklists', 148 'comment_means_site_updated' 149 )"); 150 151 safe_update('txp_prefs', "event = 'feeds'", "name in( 152 'syndicate_body_or_excerpt', 153 'rss_how_many', 154 'show_comment_count_in_feed', 155 'include_email_atom', 156 'use_mail_on_feeds_id' 157 )"); 158 159 # 'Textile links' feature removed due to unclear specs. 160 safe_delete('txp_prefs', "event='link' and name='textile_links'"); 161 162 # Use TextileRestricted lite/fat in comments? 163 if (!safe_field('name', 'txp_prefs', "name = 'comments_use_fat_textile'")) 164 safe_insert('txp_prefs', "prefs_id = 1, name = 'comments_use_fat_textile', val = '0', type = '1', event='comments', html='yesnoradio', position='130'"); 165 166 167 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu May 21 23:03:01 2009 | Cross-referenced by PHPXref 0.7 |