| Textpattern | PHP Cross Reference | Content Management Systems |
1 <?php 2 /* 3 $HeadURL: https://textpattern.googlecode.com/svn/releases/4.5.4/source/textpattern/update/_to_1.0.0.php $ 4 $LastChangedRevision: 4011 $ 5 */ 6 if (!defined('TXP_UPDATE')) 7 exit("Nothing here. You can't access this file directly."); 8 9 safe_delete("txp_category","name=''"); 10 safe_delete("txp_category","name=' '"); 11 12 $txpcat = getThings('describe `'.PFX.'txp_category`'); 13 14 if (!in_array('id',$txpcat)) { 15 safe_alter('txp_category', 16 'add `id` int(6) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST'); 17 } 18 19 if (!in_array('parent',$txpcat)) { 20 safe_alter("txp_category", "add `parent` varchar(64) not null default ''"); 21 } 22 23 if (!in_array('lft',$txpcat)) { 24 safe_alter("txp_category", "add `lft` int(6) not null default '0'"); 25 } 26 27 if (!in_array('rgt',$txpcat)) { 28 safe_alter("txp_category", "add `rgt` int(6) not null default '0'"); 29 } 30 31 if (in_array('level',$txpcat)) { 32 safe_alter("txp_category", "drop `level`"); 33 } 34 35 36 $txp = getThings('describe `'.PFX.'textpattern`'); 37 38 if (!in_array('Keywords',$txp)) { 39 safe_alter("textpattern", "add `Keywords` varchar(255) not null"); 40 } 41 42 if (in_array('Listing1',$txp) && !in_array('textile_body',$txp)) { 43 safe_alter("textpattern", 44 "change Listing1 textile_body INT(2) DEFAULT '1' NOT NULL"); 45 } 46 47 if (in_array('Listing2',$txp) && !in_array('textile_excerpt',$txp)) { 48 safe_alter("textpattern", 49 "change Listing2 textile_excerpt INT(2) DEFAULT '1' NOT NULL"); 50 } 51 52 if (!in_array('url_title',$txp)) { 53 safe_alter("textpattern", "add `url_title` varchar(255) not null"); 54 } 55 56 if (!in_array('Excerpt',$txp)) { 57 safe_alter("textpattern", "add `Excerpt` mediumtext not null after `Body_html`"); 58 } 59 60 // Excerpt_html added in 1.0 61 if (!in_array('Excerpt_html',$txp)) { 62 safe_alter("textpattern", "add `Excerpt_html` mediumtext not null after `Excerpt` "); 63 } 64 65 // comments count cache field 66 if (!in_array('comments_count',$txp)) { 67 safe_alter("textpattern", "add `comments_count` int(8) not null after `AnnotateInvite` "); 68 } 69 70 // custom fields added for g1.19 71 72 if (!in_array('custom_1',$txp)) { 73 safe_alter("textpattern", "add `custom_1` varchar(255) not null"); 74 } 75 76 if (!in_array('custom_2',$txp)) { 77 safe_alter("textpattern", "add `custom_2` varchar(255) not null"); 78 } 79 80 if (!in_array('custom_3',$txp)) { 81 safe_alter("textpattern", "add `custom_3` varchar(255) not null"); 82 } 83 84 if (!in_array('custom_4',$txp)) { 85 safe_alter("textpattern", "add `custom_4` varchar(255) not null"); 86 } 87 88 if (!in_array('custom_5',$txp)) { 89 safe_alter("textpattern", "add `custom_5` varchar(255) not null"); 90 } 91 92 if (!in_array('custom_6',$txp)) { 93 safe_alter("textpattern", "add `custom_6` varchar(255) not null"); 94 } 95 96 if (!in_array('custom_7',$txp)) { 97 safe_alter("textpattern", "add `custom_7` varchar(255) not null"); 98 } 99 100 if (!in_array('custom_8',$txp)) { 101 safe_alter("textpattern", "add `custom_8` varchar(255) not null"); 102 } 103 104 if (!in_array('custom_9',$txp)) { 105 safe_alter("textpattern", "add `custom_9` varchar(255) not null"); 106 } 107 108 if (!in_array('custom_10',$txp)) { 109 safe_alter("textpattern", "add `custom_10` varchar(255) not null"); 110 } 111 112 113 114 $txpsect = getThings('describe `'.PFX.'txp_section`'); 115 116 if (!in_array('searchable',$txpsect)) { 117 safe_alter("txp_section", "add `searchable` int(2) not null default 1"); 118 } 119 120 $txpuser = getThings('describe `'.PFX.'txp_users`'); 121 122 if (!in_array('nonce',$txpuser)) { 123 safe_alter("txp_users", "add `nonce` varchar(64) not null"); 124 }; 125 126 127 // 1.0rc: checking nonce in txp_users table 128 129 $txpusers = safe_rows_start('name, nonce','txp_users','1'); 130 if ($txpusers) { 131 while ($a = nextRow($txpusers)) { 132 extract($a); 133 if (!$nonce){ 134 $nonce = md5( uniqid( rand(), true ) ); 135 safe_update('txp_users',"nonce='$nonce'", "name = '$name'"); 136 } 137 } 138 } 139 140 // 1.0rc: expanding password field in txp_users 141 142 safe_alter('txp_users',"CHANGE `pass` `pass` VARCHAR( 128 ) NOT NULL"); 143 144 safe_alter('textpattern',"CHANGE `Body` `Body` MEDIUMTEXT NOT NULL"); 145 146 safe_alter('textpattern',"CHANGE `Body_html` `Body_html` MEDIUMTEXT NOT NULL"); 147 148 safe_alter('textpattern',"CHANGE `Excerpt` `Excerpt` TEXT NOT NULL"); 149 150 $popcom = fetch("*",'txp_form','name',"popup_comments"); 151 152 if (!$popcom) { 153 154 $popform = <<<eod 155 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 156 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 157 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 158 <head> 159 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 160 <link rel="Stylesheet" href="<txp:css />" type="text/css" /> 161 <title><txp:page_title /></title> 162 </head> 163 <body> 164 <div style="text-align: left; padding: 1em; width:300px"> 165 166 <txp:popup_comments /> 167 168 </div> 169 </body> 170 </html> 171 eod; 172 $popform = addslashes($popform); 173 safe_insert("txp_form","name='popup_comments',type='comment',Form='$popform'"); 174 } 175 176 safe_update("txp_category", "lft=0,rgt=0","name!='root'"); 177 178 safe_delete("txp_category", "name='root'"); 179 180 safe_update("txp_category", "parent='root'","parent = ''"); 181 182 safe_insert("txp_category", "name='root',parent='',type='article',lft=1,rgt=0"); 183 rebuild_tree('root',1,'article'); 184 185 safe_insert("txp_category", "name='root',parent='',type='link',lft=1,rgt=0"); 186 rebuild_tree('root',1,'link'); 187 188 safe_insert("txp_category", "name='root',parent='',type='image',lft=1,rgt=0"); 189 rebuild_tree('root',1,'image'); 190 191 if (!safe_field('val','txp_prefs',"name='article_list_pageby'")) { 192 safe_insert('txp_prefs',"prefs_id=1,name='article_list_pageby',val=25"); 193 } 194 195 if (!safe_field('val','txp_prefs',"name='link_list_pageby'")) { 196 safe_insert('txp_prefs',"prefs_id=1,name='link_list_pageby',val=25"); 197 } 198 199 if (!safe_field('val','txp_prefs',"name='image_list_pageby'")) { 200 safe_insert('txp_prefs',"prefs_id=1,name='image_list_pageby',val=25"); 201 } 202 203 if (!safe_field('val','txp_prefs',"name='log_list_pageby'")) { 204 safe_insert('txp_prefs',"prefs_id=1,name='log_list_pageby',val=25"); 205 } 206 207 if (!safe_field('val','txp_prefs',"name='comment_list_pageby'")) { 208 safe_insert('txp_prefs',"prefs_id=1,name='comment_list_pageby',val=25"); 209 } 210 211 if (!safe_field('val','txp_prefs',"name='permlink_mode'")) { 212 safe_insert('txp_prefs',"prefs_id=1,name='permlink_mode',val='section_id_title'"); 213 } 214 215 if (!safe_field('val','txp_prefs',"name='comments_are_ol'")) { 216 safe_insert('txp_prefs',"prefs_id=1,name='comments_are_ol',val='1'"); 217 } 218 219 if (!safe_field('name','txp_prefs',"name='path_to_site'")) { 220 safe_insert('txp_prefs',"prefs_id=1,name='path_to_site',val=''"); 221 } 222 223 // 1.0: need to get non-manually set url-only titles into the textpattern table, 224 // so we can start using title as an url search option 225 226 $rs = mysql_query("select ID, Title from `".PFX."textpattern` where url_title like ''"); 227 228 while ($a = mysql_fetch_array($rs)){ 229 extract($a); 230 $url_title = addslashes(stripSpace($Title,1)); 231 safe_update("textpattern","url_title = '$url_title'","ID=$ID"); 232 } 233 234 235 // 1.0: properly i18n 236 //Change current language names by language codes 237 $lang = fetch('val','txp_prefs','name','language'); 238 switch($lang){ 239 case 'czech': 240 $rs = safe_update("txp_prefs", "val= 'cs-cs'", "name='language' AND val= 'czech'"); 241 break; 242 case 'danish': 243 $rs = safe_update("txp_prefs", "val= 'da-da'", "name='language' AND val= 'danish'"); 244 break; 245 case 'dutch': 246 $rs = safe_update("txp_prefs", "val= 'nl-nl'", "name='language' AND val= 'dutch'"); 247 break; 248 case 'finish': 249 $rs = safe_update("txp_prefs", "val= 'fi-fi'", "name='language' AND val= 'finish'"); 250 break; 251 case 'french': 252 $rs = safe_update("txp_prefs", "val= 'fr-fr'", "name='language' AND val= 'french'"); 253 break; 254 case 'german': 255 $rs = safe_update("txp_prefs", "val= 'de-de'", "name='language' AND val= 'german'"); 256 break; 257 case 'italian': 258 $rs = safe_update("txp_prefs", "val= 'it-it'", "name='language' AND val= 'italian'"); 259 break; 260 case 'polish': 261 $rs = safe_update("txp_prefs", "val= 'pl-pl'", "name='language' AND val= 'polish'"); 262 break; 263 case 'portuguese': 264 $rs = safe_update("txp_prefs", "val= 'pt-pt'", "name='language' AND val= 'portuguese'"); 265 break; 266 case 'russian': 267 $rs = safe_update("txp_prefs", "val= 'ru-ru'", "name='language' AND val= 'russian'"); 268 break; 269 case 'scotts': 270 //I'm not sure of this one 271 $rs = safe_update("txp_prefs", "val= 'gl-gl'", "name='language' AND 'val' = 'scotts'"); 272 break; 273 case 'spanish': 274 $rs = safe_update("txp_prefs", "val= 'es-es'", "name='language' AND val= 'spanish'"); 275 break; 276 case 'swedish': 277 $rs = safe_update("txp_prefs", "val= 'sv-sv'", "name='language' AND val= 'swedish'"); 278 break; 279 case 'tagalog': 280 $rs = safe_update("txp_prefs", "val= 'tl-tl'", "name='language' AND val= 'tagalog'"); 281 break; 282 case 'english': 283 default: 284 $rs = safe_update("txp_prefs", "val= 'en-gb'", "name='language' AND val= 'english'"); 285 break; 286 } 287 288 // 1.0: new time zone offset 289 //If we check for a val, and the val is 0, this add another empty one 290 if (!safe_field('name','txp_prefs',"name='is_dst'")) { 291 safe_insert('txp_prefs',"prefs_id=1,name='is_dst',val=0"); 292 } 293 294 // FIXME: this presupposes 'gmtoffset' won't be set at clean install (RC4+ probably will) 295 296 if (!safe_field('val','txp_prefs',"name='gmtoffset'")) { 297 $old_offset = safe_field('val', 'txp_prefs', "name='timeoffset'"); 298 $serveroffset = gmmktime(0,0,0) - mktime(0,0,0); 299 $gmtoffset = sprintf("%+d", $serveroffset + $old_offset); 300 safe_insert('txp_prefs',"prefs_id=1,name='gmtoffset',val='$gmtoffset'"); 301 } 302 303 // 1.0: locale support 304 if (!safe_field('val','txp_prefs',"name='locale'")) { 305 safe_insert('txp_prefs',"prefs_id=1,name='locale',val='en_GB'"); 306 } 307 308 // 1.0: temp dir 309 if (!safe_field('val','txp_prefs',"name='tempdir'")) { 310 $tempdir = addslashes(find_temp_dir()); 311 safe_insert('txp_prefs',"prefs_id=1,name='tempdir',val='$tempdir'"); 312 } 313 314 //non image file upload tab: 315 if (!safe_field('val', 'txp_prefs',"name='file_list_pageby'")){ 316 safe_insert('txp_prefs',"val=25,name='file_list_pageby',prefs_id=1"); 317 } 318 319 // 1.0: max file upload size 320 if (!safe_field('val', 'txp_prefs',"name='file_max_upload_size'")){ 321 safe_insert('txp_prefs',"prefs_id=1,name='file_max_upload_size',val=2000000"); 322 } 323 324 // 1.0: txp_file root cat 325 if (!safe_field('name', 'txp_category',"type='file' AND name='root'")){ 326 safe_insert('txp_category',"name='root',type='file',lft=1,rgt=0"); 327 } 328 rebuild_tree('root',1,'file'); 329 330 // 1.0: txp_file folder 331 if (!safe_field('val', 'txp_prefs',"name='file_base_path'")){ 332 safe_insert('txp_prefs',"val='$tempdir',name='file_base_path',prefs_id=1"); 333 } 334 335 // 1.0: txp_file table 336 if (!safe_query("SELECT 1 FROM `".PFX."txp_file` LIMIT 0")) { 337 // do install 338 safe_query("CREATE TABLE `".PFX."txp_file` ( 339 `id` int(11) NOT NULL auto_increment, 340 `filename` varchar( 255 ) NOT NULL default '', 341 `category` varchar( 255 ) NOT NULL default '', 342 `permissions` varchar( 32 ) NOT NULL DEFAULT '0', 343 `description` text NOT NULL default '', 344 `downloads` int(4) unsigned NOT NULL default '0', 345 PRIMARY KEY ( `id` ) , 346 UNIQUE KEY `filename` ( `filename` ) 347 ) $tabletype PACK_KEYS=0 AUTO_INCREMENT=1 "); 348 } 349 350 if (!safe_field('name', 'txp_form', "type='file'")){ 351 safe_insert('txp_form'," 352 name='files', 353 type='file', 354 Form='<txp:text item=\"file\" />: \n<txp:file_download_link>\n<txp:file_download_name /> [<txp:file_download_size format=\"auto\" decimals=\"2\" />]\n</txp:file_download_link>\n<br />\n<txp:text item=\"category\" />: <txp:file_download_category /><br />\n<txp:text item=\"download\" />: <txp:file_download_downloads />'"); 355 } 356 //eof: non image file upload tab 357 358 // 1.0: improved comment spam nonce 359 $txpnonce = getThings('describe `'.PFX.'txp_discuss_nonce`'); 360 if (!in_array('secret', $txpnonce)) 361 safe_alter('txp_discuss_nonce', "ADD `secret` varchar(255) NOT NULL default ''"); 362 363 // 1.0: flag for admin-side plugins 364 $txpplugin = getThings('describe `'.PFX.'txp_plugin`'); 365 if (!in_array('type', $txpplugin)) 366 safe_alter('txp_plugin', "ADD `type` int(2) NOT NULL default '0'"); 367 368 // 1.0: log status & method 369 $txplog = getThings('describe `'.PFX.'txp_log`'); 370 if (!in_array('status', $txplog)) 371 safe_alter('txp_log', "ADD `status` int NOT NULL default '200'"); 372 if (!in_array('method', $txplog)) 373 safe_alter('txp_log', "ADD `method` varchar(16) NOT NULL default 'GET'"); 374 if (!in_array('ip', $txplog)) 375 safe_alter('txp_log', "ADD `ip` varchar(16) NOT NULL default ''"); 376 377 // 1.0: need to get Excerpt_html values into the textpattern table, 378 // so, catch empty ones and populate them 379 $rs = mysql_query("select ID, Excerpt, textile_excerpt from `".PFX."textpattern` where Excerpt_html like ''"); 380 require_once txpath.'/lib/classTextile.php'; 381 $textile = new Textile(); 382 while ($a = @mysql_fetch_assoc($rs)){ 383 extract($a); 384 $lite = ($textile_excerpt)? '' : 1; 385 $Excerpt_html = $textile->TextileThis($Excerpt,$lite); 386 safe_update("textpattern","Excerpt_html = '$Excerpt_html'","ID=$ID"); 387 } 388 389 //1.0 feed unique ids 390 //blog unique id 391 if (!safe_field('val','txp_prefs',"name='blog_uid'")) 392 { 393 $prefs['blog_uid'] = md5(uniqid(rand(),true)); 394 safe_insert('txp_prefs',"name='blog_uid', val='".$prefs['blog_uid']."', prefs_id='1'"); 395 } 396 if (!safe_field('name','txp_prefs',"name='blog_mail_uid'")) 397 { 398 $mail = safe_field('email', 'txp_users', "privs='1' LIMIT 1"); 399 safe_insert('txp_prefs',"name='blog_mail_uid', val='$mail', prefs_id='1'"); 400 } 401 if (!safe_field('val','txp_prefs',"name='blog_time_uid'")) 402 { 403 safe_insert('txp_prefs',"name='blog_time_uid', val='".date("Y")."', prefs_id='1'"); 404 } 405 //Articles unique id 406 if (!in_array('uid',$txp)) 407 { 408 safe_alter('textpattern',"add `uid` varchar(32) not null"); 409 safe_alter('textpattern',"add `feed_time` DATE not null DEFAULT '0000-00-00'"); 410 411 $rs = safe_rows_start('ID,Posted','textpattern','1'); 412 if ($rs) 413 { 414 while ($a = nextRow($rs)) 415 { 416 $feed_time = substr($a['Posted'],0,10); 417 safe_update('textpattern',"uid='".md5(uniqid(rand(),true))."', feed_time='$feed_time'","ID={$a['ID']}"); 418 } 419 } 420 } 421 422 // 1.0: populate comments_count field 423 424 $rs = safe_rows_start('parentid, count(*) as thecount','txp_discuss','visible=1 group by parentid'); 425 if ($rs) { 426 while ($a = nextRow($rs)) { 427 safe_update('textpattern',"comments_count=".$a['thecount'],"ID=".$a['parentid']); 428 } 429 } 430 431 // 1.0: Human-friendly title for sections and categories, to solve i18n problems 432 if (!in_array('title',$txpsect)) { 433 safe_alter("txp_section", "add `title` varchar(255) not null default ''"); 434 } 435 if (!in_array('title',$txpcat)) { 436 safe_alter("txp_category", "add `title` varchar(255) not null default ''"); 437 } 438 if (safe_count('txp_section', "title=''") > 0) 439 safe_update('txp_section', 'title=name', "title=''"); 440 if (safe_count('txp_category', "title=''") > 0) 441 safe_update('txp_category', 'title=name', "title=''"); 442 443 // 1.0: Unique key and 'type' field for the txp_prefs table 444 $has_prefs_idx = 0; 445 $rs = getRows('show index from `'.PFX.'txp_prefs`'); 446 foreach ($rs as $row) 447 if ($row['Key_name'] == 'prefs_idx') 448 $has_prefs_idx = 1; 449 if (!$has_prefs_idx) 450 safe_query('alter ignore table `'.PFX.'txp_prefs` add unique prefs_idx(prefs_id,name)'); 451 452 $txpprefs = getThings('describe `'.PFX.'txp_prefs`'); 453 if (!in_array('type', $txpprefs)) 454 safe_alter('txp_prefs', "add `type` smallint unsigned not null default '2'"); 455 # update the updated with default hidden type for old plugins prefs 456 safe_alter('txp_prefs',"change `type` `type` smallint unsigned not null default '2'"); 457 if (!in_array('event', $txpprefs)) 458 safe_alter('txp_prefs', "add `event` varchar(12) not null default 'publish'"); 459 if (!in_array('html', $txpprefs)) 460 safe_alter('txp_prefs', "add `html` varchar(64) not null default ''"); 461 if (!in_array('position', $txpprefs)) 462 { 463 safe_alter('txp_prefs', "add `position` smallint unsigned not null default '0'"); 464 465 # add new column values to prefs 466 $prefs_new_cols = array( 467 'attach_titles_to_permalinks' => array('html' => 'yesnoradio', 'event'=> 'publish', 'type' => '1', 'position' => '1'), 468 'sitename' => array('html' => 'text_input', 'event'=> 'publish', 'type' => '0', 'position' => '1'), 469 'siteurl' => array('html' => 'text_input', 'event'=> 'publish', 'type' => '0', 'position' => '2'), 470 'site_slogan' => array('html' =>'text_input', 'event' => 'publish', 'type' => '0', 'position' => '3'), 471 'language' => array('html' => 'languages','event'=> 'publish', 'type' => '0', 'position' => '4'), 472 'gmtoffset' => array('html' => 'gmtoffset_select','event'=> 'publish', 'type' => '0', 'position' => '5'), 473 'is_dst' => array('html' => 'yesnoradio','event'=> 'publish', 'type' => '0', 'position' => '6'), 474 'dateformat' => array('html' => 'dateformats','event'=> 'publish', 'type' => '0', 'position' => '7'), 475 'archive_dateformat' => array('html' => 'dateformats','event'=> 'publish', 'type' => '0', 'position' => '8'), 476 'permlink_mode' => array('html' => 'permlinkmodes','event'=> 'publish', 'type' => '0', 'position' => '9'), 477 'send_lastmod' => array('html' => 'yesnoradio','event'=> 'admin', 'type' => '1', 'position' => '0'), 478 'ping_weblogsdotcom' => array('html' => 'yesnoradio','event'=> 'publish', 'type' => '1', 'position' => '0'), 479 'use_comments' => array('html' => 'yesnoradio','event'=> 'publish', 'type' => '0', 'position' => '12'), 480 'logging' => array('html' => 'logging','event'=> 'publish', 'type' => '0', 'position' => '10'), 481 'use_textile' => array('html' => 'pref_text','event'=> 'publish', 'type' => '0', 'position' => '11'), 482 'tempdir' => array('html' => 'text_input','event'=> 'admin', 'type' => '1', 'position' => '0'), 483 'file_base_path' => array('html' => 'text_input','event'=> 'admin', 'type' => '1', 'position' => '0'), 484 'file_max_upload_size' => array('html' => 'text_input','event'=> 'admin', 'type' => '1', 'position' => '0'), 485 'comments_moderate' => array('html' => 'yesnoradio','event'=> 'comments', 'type' => '0', 'position' => '13'), 486 'comments_on_default' => array('html' => 'yesnoradio','event'=> 'comments', 'type' => '0', 'position' => '14'), 487 'comments_are_ol' => array('html' => 'yesnoradio','event'=> 'comments', 'type' => '0', 'position' => '15'), 488 'comments_sendmail' => array('html' => 'yesnoradio','event'=> 'comments', 'type' => '0', 'position' => '16'), 489 'comments_disallow_images' => array('html' => 'yesnoradio','event'=> 'comments', 'type' => '0', 'position' => '17'), 490 'comments_default_invite' => array('html' => 'text_input','event'=> 'comments', 'type' => '0', 'position' => '18'), 491 'comments_dateformat' => array('html' => 'dateformats','event'=> 'comments', 'type' => '0', 'position' => '19'), 492 'comments_mode' => array('html' => 'commentmode','event'=> 'comments', 'type' => '0', 'position' => '20'), 493 'comments_disabled_after' => array('html' => 'weeks','event'=> 'comments', 'type' => '0', 'position' => '21'), 494 'img_dir' => array('html' => 'text_input','event'=> 'admin', 'type' => '1', 'position' => '0'), 495 'rss_how_many' => array('html' => 'text_input','event'=> 'admin', 'type' => '1', 'position' => '0'), 496 ); 497 498 foreach ($prefs_new_cols as $pref_key => $pref_val) 499 { 500 safe_update('txp_prefs', "html='$pref_val[html]',event='$pref_val[event]',type='$pref_val[type]', position='$pref_val[position]'", "name='$pref_key' AND prefs_id='1'"); 501 } 502 503 $prefs_hidden_rows = array('prefs_id','use_categories','use_sections','path_from_root','url_mode','record_mentions', 504 'locale','file_base_path','lastmod','version','path_to_site','dbupdatetime','timeoffset','article_list_pageby', 505 'blog_mail_uid','blog_time_uid','blog_uid','comment_list_pageby','file_list_pageby','image_list_pageby','link_list_pageby', 506 'log_list_pageby',); 507 508 foreach ($prefs_hidden_rows as $hidden_pref) 509 { 510 safe_update('txp_prefs', "type='2'", "name='$hidden_pref' AND prefs_id='1'"); 511 } 512 513 global $txpac; 514 #advanced prefs 515 foreach ($txpac as $key => $val) 516 { 517 if (!in_array($key, array_keys($prefs))) 518 { 519 switch ($key) 520 { 521 case'custom_1_set': 522 case'custom_2_set': 523 case'custom_3_set': 524 case'custom_4_set': 525 case'custom_5_set': 526 case'custom_6_set': 527 case'custom_7_set': 528 case'custom_8_set': 529 case'custom_9_set': 530 case'custom_10_set': 531 $evt = 'custom'; 532 $html = 'text_input'; 533 break; 534 535 case 'edit_raw_css_by_default': 536 $evt = 'css'; 537 $html = 'yesnoradio'; 538 break; 539 case 'spam_blacklists': 540 case 'expire_logs_after': 541 case 'max_url_len': 542 $html = 'text_input'; 543 $evt = 'publish'; 544 break; 545 case 'textile_links': 546 $html = 'yesnoradio'; 547 $evt = 'link'; 548 break; 549 case 'show_article_category_count': 550 $html = 'yesnoradio'; 551 $evt = 'category'; 552 break; 553 case 'comments_require_name': 554 case 'comments_require_email': 555 $html = 'yesnoradio'; 556 $evt = 'comments'; 557 break; 558 default: 559 $html = 'yesnoradio'; 560 $evt = 'publish'; 561 break; 562 } 563 safe_insert('txp_prefs',"val = '$val', name = '$key' , prefs_id ='1', type='1', html='$html', event='$evt'"); 564 } 565 } 566 } 567 568 safe_alter('txp_prefs',"CHANGE `html` `html` VARCHAR( 64 ) DEFAULT 'text_input' NOT NULL"); 569 safe_update('txp_prefs',"html='text_input'","html=''"); 570 571 if (!fetch('form','txp_form','name','search_results')) { 572 $form = <<<EOF 573 <h3><txp:permlink><txp:title /></txp:permlink></h3> 574 <p><txp:search_result_excerpt /><br/> 575 <small><txp:permlink><txp:permlink /></txp:permlink> · 576 <txp:posted /></small></p> 577 EOF; 578 safe_insert('txp_form', "name='search_results', type='article', Form='$form'"); 579 } 580 581 if (!safe_query("SELECT 1 FROM `".PFX."txp_lang` LIMIT 0")) { 582 // do install 583 safe_query("CREATE TABLE `".PFX."txp_lang` ( 584 `id` INT( 9 ) NOT NULL AUTO_INCREMENT , 585 `lang` VARCHAR(16), 586 `name` VARCHAR(64), 587 `event` VARCHAR( 64 ) , 588 `data` TINYTEXT, 589 `lastmod` timestamp, 590 PRIMARY KEY ( `id` ), 591 UNIQUE INDEX (`lang`,`name`), 592 INDEX (`lang`, `event`) 593 ) $tabletype;"); 594 595 require_once txpath.'/lib/IXRClass.php'; 596 597 $client = new IXR_Client('http://rpc.textpattern.com'); 598 599 if (!$client->query('tups.getLanguage',$prefs['blog_uid'],LANG)) 600 { 601 echo '<p style="color:red">Error trying to install language. Please, try it again again.<br /> 602 If problem connecting to the RPC server persists, you can go to <a href="http://rpc.textpattern.com/lang/">http://rpc.textpattern.com/lang/</a>, download the 603 desired language file and place it in the /lang/ directory of your textpattern install. You can then install the language from file.</p>'; 604 }else { 605 $response = $client->getResponse(); 606 $lang_struct = unserialize($response); 607 function install_lang_key($value, $key) 608 { 609 $q = "name='$value[name]', event='$value[event]', data='$value[data]', lastmod='".strftime('%Y%m%d%H%M%S',$value['uLastmod'])."'"; 610 safe_insert('txp_lang',$q.", lang='".LANG."'"); 611 } 612 array_walk($lang_struct,'install_lang_key'); 613 } 614 } 615 616 $maxpos = safe_field('max(position)', 'txp_prefs', '1'); 617 // 1.0: production_status setting to control error reporting 618 if (!safe_field('val','txp_prefs',"name='production_status'")) 619 { 620 safe_insert('txp_prefs',"name='production_status', val='testing', prefs_id='1', type='0', position='".doSlash($maxpos)."', html='prod_levels'"); 621 } 622 623 # multiply position on prefs to allow easy reordering 624 if(intval($maxpos) < 100) 625 { 626 safe_update('txp_prefs','position = position*10','1'); 627 } 628 # remove, remove 629 if (safe_field('name','txp_prefs',"name='logs_expire'")) 630 { 631 safe_delete('txp_prefs',"name='logs_expire'"); 632 } 633 634 // Let's make this visible in advanced prefs 635 safe_update('txp_prefs',"type = '1'","name = 'file_base_path'"); 636 637 // 1.0: add option to override charset for emails (ISO-8559-1 instead of UTF-8) 638 if (!safe_field('name','txp_prefs',"name='override_emailcharset'")) 639 { 640 safe_insert('txp_prefs',"name='override_emailcharset', val='0', prefs_id='1', type='1', event='admin', position='".doSlash($maxpos)."', html='yesnoradio'"); 641 } 642 643 if (safe_field('val', 'txp_prefs', "name='comments_auto_append'") === false) { 644 safe_insert('txp_prefs',"val = '1', name = 'comments_auto_append' , prefs_id ='1', type='0', html='yesnoradio', event='comments', position='211'"); 645 646 $form = <<<EOF 647 <txp:comments /> 648 <txp:if_comments_allowed> 649 <txp:comments_form /> 650 </txp:if_comments_allowed> 651 EOF; 652 safe_insert('txp_form', "name='comments_display', type='article', Form='$form'"); 653 } 654 655 // /tmp is bad for permanent storage of files, 656 // if no files are uploaded yet, switch to the files directory in the top-txp dir. 657 if (!safe_count('txp_file',"1")){ 658 $tempdir = find_temp_dir(); 659 if ($tempdir == safe_field('val','txp_prefs',"name='file_base_path'")) 660 safe_update('txp_prefs',"val='".doSlash(dirname(txpath).DS.'files')."',prefs_id=1","name='file_base_path'"); 661 } 662 663 // After this point the changes after RC4 664 665 // let's get the advanced fields in the right order 666 for ($i = 1; $i <= 10; $i++) { 667 safe_update("txp_prefs","position=$i","name='custom_$i}_set'"); 668 } 669 670 // index ip column in txp_log 671 672 $ipidxset = false; 673 $i = safe_show('index','txp_log'); 674 foreach ($i as $a => $b) { 675 if ($b['Column_name'] == 'ip') $ipidxset = true; 676 } 677 if (!$ipidxset) safe_query("alter table `".PFX."txp_log` ADD INDEX `ip` (`ip`)"); 678 679 // Language selection moves to Manage languages, Hide it from prefs. 680 safe_update("txp_prefs", "type=2", "name='language'"); 681 682 // Show gmt-selection in prefs 683 safe_update('txp_prefs',"type=0, html='gmtoffset_select', position=50","name='gmtoffset'"); 684 685 if (!safe_field('name', 'txp_prefs', "prefs_id=1 and name='plugin_cache_dir'")) { 686 $maxpos = safe_field('max(position)', 'txp_prefs', '1'); 687 safe_insert('txp_prefs',"name='plugin_cache_dir', val='', prefs_id='1', type='1', event='admin', position='".doSlash($maxpos)."', html='text_input'"); 688 } 689 690 // update version 691 safe_delete('txp_prefs',"name = 'version'"); 692 safe_insert('txp_prefs', "prefs_id=1, name='version',val='4.0', type='2'"); 693 694 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title