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_INSTALL')) { 25 exit; 26 } 27 28 @ignore_user_abort(1); 29 @set_time_limit(0); 30 31 $ddb = $txpcfg['db']; 32 $duser = $txpcfg['user']; 33 $dpass = $txpcfg['pass']; 34 $dhost = $txpcfg['host']; 35 $dclient_flags = isset($txpcfg['client_flags']) ? $txpcfg['client_flags'] : 0; 36 $dprefix = $txpcfg['table_prefix']; 37 $dbcharset = $txpcfg['dbcharset']; 38 39 define("PFX", trim($dprefix)); 40 41 if (strpos($dhost, ':') === false) { 42 $host = $dhost; 43 $port = ini_get("mysqli.default_port"); 44 } else { 45 list($host, $port) = explode(':', $dhost, 2); 46 $port = intval($port); 47 } 48 49 if (isset($txpcfg['socket'])) { 50 $socket = $txpcfg['socket']; 51 } else { 52 $socket = ini_get("mysqli.default_socket"); 53 } 54 55 $link = mysqli_init(); 56 mysqli_real_connect($link, $host, $duser, $dpass, $ddb, $port, $socket, $dclient_flags); 57 58 $result = mysqli_query($link, "DESCRIBE `".PFX."textpattern`"); 59 60 if ($result) { 61 die("Textpattern database table already exists. Can't run setup."); 62 } 63 64 $version = mysqli_get_server_info($link); 65 66 // Use "ENGINE" if version of MySQL > 4.1.2. 67 $tabletype = (version_compare($version, '4.1.2') >= 0) ? " ENGINE = MyISAM " : " TYPE = MyISAM "; 68 69 // On 4.1 or greater use UTF-8 tables. 70 if (isset($dbcharset)) { 71 $tabletype .= " CHARACTER SET = $dbcharset "; 72 73 if ($dbcharset == 'utf8mb4') { 74 $tabletype .= " COLLATE utf8mb4_unicode_ci "; 75 } elseif ($dbcharset == 'utf8') { 76 $tabletype .= " COLLATE utf8_general_ci "; 77 } 78 79 mysqli_query($link, "SET NAMES ".$dbcharset); 80 } 81 82 // Default to messy URLs if we know clean ones won't work. 83 $permlink_mode = 'section_id_title'; 84 85 if (is_callable('apache_get_modules')) { 86 $modules = @apache_get_modules(); 87 88 if (!is_array($modules) || !in_array('mod_rewrite', $modules)) { 89 $permlink_mode = 'messy'; 90 } 91 } else { 92 $server_software = (@$_SERVER['SERVER_SOFTWARE'] || @$_SERVER['HTTP_HOST']) 93 ? ((@$_SERVER['SERVER_SOFTWARE']) ? @$_SERVER['SERVER_SOFTWARE'] : $_SERVER['HTTP_HOST']) 94 : ''; 95 96 if (!stristr($server_software, 'Apache')) { 97 $permlink_mode = 'messy'; 98 } 99 } 100 101 $siteurl = str_replace("http://", '', $_SESSION['siteurl']); 102 $siteurl = str_replace(' ', '%20', rtrim($siteurl, "/")); 103 $urlpath = preg_replace('#^[^/]+#', '', $siteurl); 104 $theme = $_SESSION['theme'] ? $_SESSION['theme'] : 'hive'; 105 $themedir = txpath.DS.'setup'; 106 107 $create_sql = array(); 108 109 $create_sql[] = "CREATE TABLE `".PFX."textpattern` ( 110 ID INT NOT NULL AUTO_INCREMENT, 111 Posted DATETIME NOT NULL, 112 Expires DATETIME NULL DEFAULT NULL, 113 AuthorID VARCHAR(64) NOT NULL DEFAULT '', 114 LastMod DATETIME NOT NULL, 115 LastModID VARCHAR(64) NOT NULL DEFAULT '', 116 Title VARCHAR(255) NOT NULL DEFAULT '', 117 Title_html VARCHAR(255) NOT NULL DEFAULT '', 118 Body MEDIUMTEXT NOT NULL, 119 Body_html MEDIUMTEXT NOT NULL, 120 Excerpt TEXT NOT NULL, 121 Excerpt_html MEDIUMTEXT NOT NULL, 122 Image VARCHAR(255) NOT NULL DEFAULT '', 123 Category1 VARCHAR(64) NOT NULL DEFAULT '', 124 Category2 VARCHAR(64) NOT NULL DEFAULT '', 125 Annotate INT NOT NULL DEFAULT '0', 126 AnnotateInvite VARCHAR(255) NOT NULL DEFAULT '', 127 comments_count INT NOT NULL DEFAULT '0', 128 Status INT NOT NULL DEFAULT '4', 129 textile_body VARCHAR(32) NOT NULL DEFAULT '1', 130 textile_excerpt VARCHAR(32) NOT NULL DEFAULT '1', 131 Section VARCHAR(255) NOT NULL DEFAULT '', 132 override_form VARCHAR(255) NOT NULL DEFAULT '', 133 Keywords VARCHAR(255) NOT NULL DEFAULT '', 134 description VARCHAR(255) NOT NULL DEFAULT '', 135 url_title VARCHAR(255) NOT NULL DEFAULT '', 136 custom_1 VARCHAR(255) NOT NULL DEFAULT '', 137 custom_2 VARCHAR(255) NOT NULL DEFAULT '', 138 custom_3 VARCHAR(255) NOT NULL DEFAULT '', 139 custom_4 VARCHAR(255) NOT NULL DEFAULT '', 140 custom_5 VARCHAR(255) NOT NULL DEFAULT '', 141 custom_6 VARCHAR(255) NOT NULL DEFAULT '', 142 custom_7 VARCHAR(255) NOT NULL DEFAULT '', 143 custom_8 VARCHAR(255) NOT NULL DEFAULT '', 144 custom_9 VARCHAR(255) NOT NULL DEFAULT '', 145 custom_10 VARCHAR(255) NOT NULL DEFAULT '', 146 uid VARCHAR(32) NOT NULL DEFAULT '', 147 feed_time DATE NOT NULL, 148 149 PRIMARY KEY (ID), 150 INDEX categories_idx (Category1(10), Category2(10)), 151 INDEX Posted (Posted), 152 INDEX Expires_idx (Expires), 153 INDEX author_idx (AuthorID), 154 INDEX section_status_idx (Section(249), Status), 155 INDEX url_title_idx (url_title(250)), 156 FULLTEXT searching (Title, Body) 157 ) $tabletype "; 158 159 $setup_comment_invite = (gTxt('setup_comment_invite') == 'setup_comment_invite') ? 'Comment' : gTxt('setup_comment_invite'); 160 161 $textile = new \Netcarver\Textile\Parser(); 162 163 $article['body'] = file_get_contents(txpath.DS.'setup'.DS.'article.body.textile'); 164 $article['excerpt'] = file_get_contents(txpath.DS.'setup'.DS.'article.excerpt.textile'); 165 $article = str_replace('siteurl', $urlpath, $article); 166 $article['body_html'] = $textile->textileThis($article['body']); 167 $article['excerpt_html'] = $textile->textileThis($article['excerpt']); 168 $article = doSlash($article); 169 170 $create_sql[] = "INSERT INTO `".PFX."textpattern` VALUES (1, NOW(), NULL, '".doSlash($_SESSION['name'])."', NOW(), '', 'Welcome to your site', '', '".$article['body']."', '".$article['body_html']."', '".$article['excerpt']."', '".$article['excerpt_html']."', '', 'hope-for-the-future', 'meaningful-labor', 1, '".$setup_comment_invite."', 1, 4, '1', '1', 'articles', '', '', '', 'welcome-to-your-site', '', '', '', '', '', '', '', '', '', '', '".md5(uniqid(rand(), true))."', NOW())"; 171 172 $create_sql[] = "CREATE TABLE `".PFX."txp_category` ( 173 id INT NOT NULL AUTO_INCREMENT, 174 name VARCHAR(64) NOT NULL DEFAULT '', 175 type VARCHAR(64) NOT NULL DEFAULT '', 176 parent VARCHAR(64) NOT NULL DEFAULT '', 177 lft INT NOT NULL DEFAULT '0', 178 rgt INT NOT NULL DEFAULT '0', 179 title VARCHAR(255) NOT NULL DEFAULT '', 180 description VARCHAR(255) NOT NULL DEFAULT '', 181 182 PRIMARY KEY (id) 183 ) $tabletype "; 184 185 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (1, 'root', 'article', '', 1, 8, 'root', '')"; 186 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (2, 'root', 'link', '', 1, 4, 'root', '')"; 187 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (3, 'root', 'image', '', 1, 4, 'root', '')"; 188 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (4, 'root', 'file', '', 1, 2, 'root', '')"; 189 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (5, 'hope-for-the-future', 'article', 'root', 2, 3, 'Hope for the future', '')"; 190 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (6, 'meaningful-labor', 'article', 'root', 4, 5, 'Meaningful labor', '')"; 191 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (7, 'reciprocal-affection', 'article', 'root', 6, 7, 'Reciprocal affection', '')"; 192 $create_sql[] = "INSERT INTO `".PFX."txp_category` VALUES (8, 'textpattern', 'link', 'root', 2, 3, 'Textpattern', '')"; 193 194 $create_sql[] = "CREATE TABLE `".PFX."txp_css` ( 195 name VARCHAR(255) NOT NULL, 196 css MEDIUMTEXT NOT NULL, 197 198 UNIQUE name (name(250)) 199 ) $tabletype "; 200 201 foreach (scandir($themedir.DS.'styles') as $cssfile) { 202 if (preg_match('/^(\w+)\.css$/', $cssfile, $match)) { 203 $css = doSlash(file_get_contents($themedir.DS.'styles'.DS.$cssfile)); 204 $create_sql[] = "INSERT INTO `".PFX."txp_css`(name, css) VALUES('".$match[1]."', '".$css."')"; 205 } 206 } 207 208 $create_sql[] = "CREATE TABLE `".PFX."txp_discuss` ( 209 discussid INT(6) ZEROFILL NOT NULL AUTO_INCREMENT, 210 parentid INT NOT NULL DEFAULT '0', 211 name VARCHAR(255) NOT NULL DEFAULT '', 212 email VARCHAR(254) NOT NULL DEFAULT '', 213 web VARCHAR(255) NOT NULL DEFAULT '', 214 ip VARCHAR(100) NOT NULL DEFAULT '', 215 posted DATETIME NOT NULL, 216 message TEXT NOT NULL, 217 visible TINYINT NOT NULL DEFAULT '1', 218 219 PRIMARY KEY (discussid), 220 INDEX parentid (parentid) 221 ) $tabletype "; 222 223 $create_sql[] = "INSERT INTO `".PFX."txp_discuss` VALUES (000001, 1, 'Donald Swain', 'donald.swain@example.com', 'example.com', '127.0.0.1', NOW(), '<p>I enjoy your site very much.</p>', 1)"; 224 225 $create_sql[] = "CREATE TABLE `".PFX."txp_discuss_nonce` ( 226 issue_time DATETIME NOT NULL, 227 nonce VARCHAR(255) NOT NULL DEFAULT '', 228 used TINYINT NOT NULL DEFAULT '0', 229 secret VARCHAR(255) NOT NULL DEFAULT '', 230 231 PRIMARY KEY (nonce(250)) 232 ) $tabletype "; 233 234 $create_sql[] = "CREATE TABLE `".PFX."txp_file` ( 235 id INT NOT NULL AUTO_INCREMENT, 236 filename VARCHAR(255) NOT NULL DEFAULT '', 237 title VARCHAR(255) DEFAULT NULL, 238 category VARCHAR(64) NOT NULL DEFAULT '', 239 permissions VARCHAR(32) NOT NULL DEFAULT '0', 240 description TEXT NOT NULL, 241 downloads INT UNSIGNED NOT NULL DEFAULT '0', 242 status SMALLINT NOT NULL DEFAULT '4', 243 modified DATETIME NOT NULL, 244 created DATETIME NOT NULL, 245 size BIGINT DEFAULT NULL, 246 author VARCHAR(64) NOT NULL DEFAULT '', 247 248 PRIMARY KEY (id), 249 UNIQUE filename (filename(250)), 250 INDEX author_idx (author) 251 ) $tabletype "; 252 253 $create_sql[] = "CREATE TABLE `".PFX."txp_form` ( 254 name VARCHAR(255) NOT NULL DEFAULT '', 255 type VARCHAR(28) NOT NULL DEFAULT '', 256 Form TEXT NOT NULL, 257 258 PRIMARY KEY (name(250)) 259 ) $tabletype "; 260 261 foreach (scandir($themedir.DS.'forms') as $formfile) { 262 if (preg_match('/^(\w+).(\w+)\.txp$/', $formfile, $match)) { 263 $form = doSlash(file_get_contents($themedir.DS.'forms'.DS.$formfile)); 264 $create_sql[] = "INSERT INTO `".PFX."txp_form`(type, name, Form) 265 VALUES('".$match[1]."', '".$match[2]."', '".$form."')"; 266 } 267 } 268 269 $create_sql[] = "CREATE TABLE `".PFX."txp_image` ( 270 id INT NOT NULL AUTO_INCREMENT, 271 name VARCHAR(255) NOT NULL DEFAULT '', 272 category VARCHAR(64) NOT NULL DEFAULT '', 273 ext VARCHAR(20) NOT NULL DEFAULT '', 274 w INT NOT NULL DEFAULT '0', 275 h INT NOT NULL DEFAULT '0', 276 alt VARCHAR(255) NOT NULL DEFAULT '', 277 caption TEXT NOT NULL, 278 date DATETIME NOT NULL, 279 author VARCHAR(64) NOT NULL DEFAULT '', 280 thumbnail INT NOT NULL DEFAULT '0', 281 thumb_w INT NOT NULL DEFAULT '0', 282 thumb_h INT NOT NULL DEFAULT '0', 283 284 PRIMARY KEY (id), 285 INDEX author_idx (author) 286 ) $tabletype "; 287 288 $create_sql[] = "CREATE TABLE `".PFX."txp_lang` ( 289 id INT NOT NULL AUTO_INCREMENT, 290 lang VARCHAR(16) NOT NULL, 291 name VARCHAR(64) NOT NULL, 292 event VARCHAR(64) NOT NULL, 293 owner VARCHAR(64) NOT NULL DEFAULT '', 294 data TEXT, 295 lastmod TIMESTAMP, 296 297 PRIMARY KEY (id), 298 UNIQUE lang (lang, name), 299 INDEX lang_2 (lang, event), 300 INDEX owner (owner) 301 ) $tabletype "; 302 303 $create_sql[] = "CREATE TABLE `".PFX."txp_link` ( 304 id INT NOT NULL AUTO_INCREMENT, 305 date DATETIME NOT NULL, 306 category VARCHAR(64) NOT NULL DEFAULT '', 307 url TEXT NOT NULL, 308 linkname VARCHAR(255) NOT NULL DEFAULT '', 309 linksort VARCHAR(128) NOT NULL DEFAULT '', 310 description TEXT NOT NULL, 311 author VARCHAR(64) NOT NULL DEFAULT '', 312 313 PRIMARY KEY (id), 314 INDEX author_idx (author) 315 ) $tabletype "; 316 317 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (1, NOW(), 'textpattern', 'http://textpattern.com/', 'Textpattern Website', '10', '', '')"; 318 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (2, NOW(), 'textpattern', 'http://docs.textpattern.io/', 'Textpattern User Documentation', '20', '', '')"; 319 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (3, NOW(), 'textpattern', 'http://textpattern.org/', 'Textpattern Resources', '30', '', '')"; 320 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (4, NOW(), 'textpattern', 'http://textpattern.com/@textpattern', '@textpattern', '40', '', '')"; 321 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (5, NOW(), 'textpattern', 'http://textpattern.com/+', '+Textpattern CMS', '50', '', '')"; 322 $create_sql[] = "INSERT INTO `".PFX."txp_link` VALUES (6, NOW(), 'textpattern', 'http://textpattern.com/facebook', 'Textpattern Facebook Group', '60', '', '')"; 323 324 $create_sql[] = "CREATE TABLE `".PFX."txp_log` ( 325 id INT NOT NULL AUTO_INCREMENT, 326 time DATETIME NOT NULL, 327 host VARCHAR(255) NOT NULL DEFAULT '', 328 page VARCHAR(255) NOT NULL DEFAULT '', 329 refer MEDIUMTEXT NOT NULL, 330 status INT NOT NULL DEFAULT '200', 331 method VARCHAR(16) NOT NULL DEFAULT 'GET', 332 ip VARCHAR(45) NOT NULL DEFAULT '', 333 334 PRIMARY KEY (id), 335 INDEX time (time), 336 INDEX ip (ip) 337 ) $tabletype "; 338 339 $create_sql[] = "CREATE TABLE `".PFX."txp_page` ( 340 name VARCHAR(255) NOT NULL DEFAULT '', 341 user_html TEXT NOT NULL, 342 343 PRIMARY KEY (name(250)) 344 ) $tabletype "; 345 346 foreach (scandir($themedir.DS.'pages') as $pagefile) { 347 if (preg_match('/^(\w+)\.txp$/', $pagefile, $match)) { 348 $page = doSlash(file_get_contents($themedir.DS.'pages'.DS.$pagefile)); 349 $create_sql[] = "INSERT INTO `".PFX."txp_page`(name, user_html) VALUES('".$match[1]."', '".$page."')"; 350 } 351 } 352 353 $create_sql[] = "CREATE TABLE `".PFX."txp_plugin` ( 354 name VARCHAR(64) NOT NULL DEFAULT '', 355 status INT NOT NULL DEFAULT '1', 356 author VARCHAR(128) NOT NULL DEFAULT '', 357 author_uri VARCHAR(128) NOT NULL DEFAULT '', 358 version VARCHAR(255) NOT NULL DEFAULT '1.0', 359 description TEXT NOT NULL, 360 help TEXT NOT NULL, 361 code MEDIUMTEXT NOT NULL, 362 code_restore MEDIUMTEXT NOT NULL, 363 code_md5 VARCHAR(32) NOT NULL DEFAULT '', 364 type INT NOT NULL DEFAULT '0', 365 load_order TINYINT UNSIGNED NOT NULL DEFAULT '5', 366 flags SMALLINT UNSIGNED NOT NULL DEFAULT '0', 367 368 UNIQUE name (name), 369 INDEX status_type_idx (status, type) 370 ) $tabletype "; 371 372 $create_sql[] = "CREATE TABLE `".PFX."txp_prefs` ( 373 prefs_id INT NOT NULL DEFAULT '1', 374 name VARCHAR(255) NOT NULL DEFAULT '', 375 val TEXT NOT NULL, 376 type SMALLINT UNSIGNED NOT NULL DEFAULT '2', 377 event VARCHAR(255) NOT NULL DEFAULT 'publish', 378 html VARCHAR(255) NOT NULL DEFAULT 'text_input', 379 position SMALLINT UNSIGNED NOT NULL DEFAULT '0', 380 user_name VARCHAR(64) NOT NULL DEFAULT '', 381 382 UNIQUE prefs_idx (prefs_id, name(185), user_name), 383 INDEX name (name(250)), 384 INDEX user_name (user_name) 385 ) $tabletype "; 386 387 $blog_uid = md5(uniqid(rand(), true)); 388 $gmtoffset = sprintf("%+d", gmmktime(0, 0, 0) - mktime(0, 0, 0)); 389 390 $prefs = array_merge_recursive(array( 391 'admin' => array( 392 array(PREF_CORE, 20, 'text_input' , 'img_dir' , 'images'), 393 array(PREF_CORE, 40, 'text_input' , 'file_base_path' , dirname(txpath).DS.'files'), 394 array(PREF_CORE, 60, 'text_input' , 'file_max_upload_size' , '2000000'), 395 array(PREF_CORE, 80, 'text_input' , 'tempdir' , find_temp_dir()), 396 array(PREF_CORE, 100, 'text_input' , 'plugin_cache_dir' , ''), 397 array(PREF_CORE, 110, 'text_input' , 'smtp_from' , ''), 398 array(PREF_CORE, 115, 'text_input' , 'publisher_email' , ''), 399 array(PREF_CORE, 120, 'yesnoradio' , 'override_emailcharset' , '0'), 400 array(PREF_CORE, 130, 'yesnoradio' , 'enable_xmlrpc_server' , '0'), 401 array(PREF_CORE, 150, 'default_event' , 'default_event' , 'article'), 402 array(PREF_CORE, 160, 'themename' , 'theme_name' , $theme), 403 ), 404 'category' => array( 405 array(PREF_HIDDEN, 0, 'yesnoradio' , 'show_article_category_count', '1'), 406 ), 407 'comments' => array( 408 array(PREF_CORE, 20, 'yesnoradio' , 'comments_on_default' , '0'), 409 array(PREF_CORE, 40, 'text_input' , 'comments_default_invite' , $setup_comment_invite), 410 array(PREF_CORE, 60, 'yesnoradio' , 'comments_moderate' , '1'), 411 array(PREF_CORE, 80, 'weeks' , 'comments_disabled_after' , '42'), 412 array(PREF_CORE, 100, 'yesnoradio' , 'comments_auto_append' , '0'), 413 array(PREF_CORE, 120, 'commentmode' , 'comments_mode' , '0'), 414 array(PREF_CORE, 140, 'dateformats' , 'comments_dateformat' , '%b %d, %I:%M %p'), 415 array(PREF_CORE, 160, 'commentsendmail' , 'comments_sendmail' , '0'), 416 array(PREF_CORE, 180, 'yesnoradio' , 'comments_are_ol' , '1'), 417 array(PREF_CORE, 200, 'yesnoradio' , 'comment_means_site_updated' , '1'), 418 array(PREF_CORE, 220, 'yesnoradio' , 'comments_require_name' , '1'), 419 array(PREF_CORE, 240, 'yesnoradio' , 'comments_require_email' , '1'), 420 array(PREF_CORE, 260, 'yesnoradio' , 'never_display_email' , '1'), 421 array(PREF_CORE, 280, 'yesnoradio' , 'comment_nofollow' , '1'), 422 array(PREF_CORE, 300, 'yesnoradio' , 'comments_disallow_images' , '0'), 423 array(PREF_CORE, 320, 'yesnoradio' , 'comments_use_fat_textile' , '0'), 424 array(PREF_CORE, 340, 'text_input' , 'spam_blacklists' , ''), 425 ), 426 'custom' => array( 427 array(PREF_CORE, 1, 'custom_set' , 'custom_1_set' , 'custom1'), 428 array(PREF_CORE, 2, 'custom_set' , 'custom_2_set' , 'custom2'), 429 array(PREF_CORE, 3, 'custom_set' , 'custom_3_set' , ''), 430 array(PREF_CORE, 4, 'custom_set' , 'custom_4_set' , ''), 431 array(PREF_CORE, 5, 'custom_set' , 'custom_5_set' , ''), 432 array(PREF_CORE, 6, 'custom_set' , 'custom_6_set' , ''), 433 array(PREF_CORE, 7, 'custom_set' , 'custom_7_set' , ''), 434 array(PREF_CORE, 8, 'custom_set' , 'custom_8_set' , ''), 435 array(PREF_CORE, 9, 'custom_set' , 'custom_9_set' , ''), 436 array(PREF_CORE, 10, 'custom_set' , 'custom_10_set' , ''), 437 ), 438 'feeds' => array( 439 array(PREF_CORE, 20, 'yesnoradio' , 'syndicate_body_or_excerpt' , '1'), 440 array(PREF_CORE, 40, 'text_input' , 'rss_how_many' , '5'), 441 array(PREF_CORE, 60, 'yesnoradio' , 'show_comment_count_in_feed' , '1'), 442 array(PREF_CORE, 80, 'yesnoradio' , 'include_email_atom' , '0'), 443 array(PREF_CORE, 100, 'yesnoradio' , 'use_mail_on_feeds_id' , '0'), 444 ), 445 'publish' => array( 446 array(PREF_CORE, 20, 'yesnoradio' , 'title_no_widow' , '0'), 447 array(PREF_CORE, 40, 'yesnoradio' , 'articles_use_excerpts' , '1'), 448 array(PREF_CORE, 60, 'yesnoradio' , 'allow_form_override' , '1'), 449 array(PREF_CORE, 80, 'yesnoradio' , 'attach_titles_to_permalinks', '1'), 450 array(PREF_CORE, 100, 'permlink_format' , 'permlink_format' , '1'), 451 array(PREF_CORE, 120, 'yesnoradio' , 'send_lastmod' , '1'), 452 array(PREF_CORE, 130, 'yesnoradio' , 'publish_expired_articles' , '0'), 453 array(PREF_CORE, 160, 'yesnoradio' , 'ping_weblogsdotcom' , '0'), 454 array(PREF_CORE, 200, 'pref_text' , 'use_textile' , '1'), 455 array(PREF_CORE, 220, 'yesnoradio' , 'use_dns' , '0'), 456 array(PREF_CORE, 260, 'yesnoradio' , 'use_plugins' , '1'), 457 array(PREF_CORE, 280, 'yesnoradio' , 'admin_side_plugins' , '1'), 458 array(PREF_CORE, 300, 'yesnoradio' , 'allow_page_php_scripting' , '1'), 459 array(PREF_CORE, 320, 'yesnoradio' , 'allow_article_php_scripting', '1'), 460 array(PREF_CORE, 340, 'text_input' , 'max_url_len' , '1000'), 461 array(PREF_HIDDEN, 0, 'text_input' , 'blog_mail_uid' , $_SESSION['email']), 462 array(PREF_HIDDEN, 0, 'text_input' , 'blog_time_uid' , '2005'), 463 array(PREF_HIDDEN, 0, 'text_input' , 'blog_uid' , $blog_uid), 464 array(PREF_HIDDEN, 0, 'text_input' , 'dbupdatetime' , '0'), 465 array(PREF_HIDDEN, 0, 'languages' , 'language' , LANG), 466 array(PREF_HIDDEN, 0, 'text_input' , 'lastmod' , '2005-07-23 16:24:10'), 467 array(PREF_HIDDEN, 0, 'text_input' , 'locale' , getlocale(LANG)), 468 array(PREF_HIDDEN, 0, 'text_input' , 'path_from_root' , '/'), 469 array(PREF_HIDDEN, 0, 'text_input' , 'path_to_site' , dirname(txpath)), 470 array(PREF_HIDDEN, 0, 'text_input' , 'prefs_id' , '1'), 471 array(PREF_HIDDEN, 0, 'text_input' , 'searchable_article_fields' , 'Title, Body'), 472 array(PREF_HIDDEN, 0, 'text_input' , 'textile_updated' , '1'), 473 array(PREF_HIDDEN, 0, 'text_input' , 'timeoffset' , '0'), 474 array(PREF_HIDDEN, 0, 'text_input' , 'timezone_key' , ''), 475 array(PREF_HIDDEN, 0, 'text_input' , 'url_mode' , '1'), 476 array(PREF_HIDDEN, 0, 'text_input' , 'use_categories' , '1'), 477 array(PREF_HIDDEN, 0, 'text_input' , 'use_sections' , '1'), 478 array(PREF_HIDDEN, 0, 'text_input' , 'sql_now_posted' , time()), 479 array(PREF_HIDDEN, 0, 'text_input' , 'sql_now_expires' , time()), 480 array(PREF_HIDDEN, 0, 'text_input' , 'sql_now_created' , time()), 481 array(PREF_HIDDEN, 0, 'text_input' , 'version' , '4.6.2'), 482 ), 483 'section' => array( 484 array(PREF_HIDDEN, 0, 'text_input' , 'default_section' , 'articles'), 485 ), 486 'site' => array( 487 array(PREF_CORE, 20, 'text_input' , 'sitename' , gTxt('my_site')), 488 array(PREF_CORE, 40, 'text_input' , 'siteurl' , $siteurl), 489 array(PREF_CORE, 60, 'text_input' , 'site_slogan' , gTxt('my_slogan')), 490 array(PREF_CORE, 80, 'prod_levels' , 'production_status' , 'testing'), 491 array(PREF_CORE, 110, 'gmtoffset_select', 'gmtoffset' , $gmtoffset), 492 array(PREF_CORE, 115, 'yesnoradio' , 'auto_dst' , '0'), 493 array(PREF_CORE, 120, 'is_dst' , 'is_dst' , '0'), 494 array(PREF_CORE, 140, 'dateformats' , 'dateformat' , 'since'), 495 array(PREF_CORE, 160, 'dateformats' , 'archive_dateformat' , '%b %d, %I:%M %p'), 496 array(PREF_CORE, 180, 'permlinkmodes' , 'permlink_mode' , $permlink_mode), 497 array(PREF_CORE, 190, 'doctypes' , 'doctype' , 'html5'), 498 array(PREF_CORE, 220, 'logging' , 'logging' , 'none'), 499 array(PREF_CORE, 230, 'text_input' , 'expire_logs_after' , '7'), 500 array(PREF_CORE, 240, 'yesnoradio' , 'use_comments' , '1'), 501 ) 502 ), new_user_prefs($_SESSION['name'])); 503 504 foreach ($prefs as $event => $event_prefs) { 505 foreach ($event_prefs as $p) { 506 $username = empty($p[5]) ? '' : doSlash($p[5]); 507 $create_sql[] = "INSERT INTO `".PFX."txp_prefs` (event, type, position, html, name, val, user_name) ". 508 "VALUES ('".$event."', ".$p[0].", ".$p[1].", '".$p[2]."', '".$p[3]."', '".doSlash($p[4])."', '".$username."')"; 509 } 510 } 511 512 $create_sql[] = "CREATE TABLE `".PFX."txp_section` ( 513 name VARCHAR(255) NOT NULL DEFAULT '', 514 page VARCHAR(255) NOT NULL DEFAULT '', 515 css VARCHAR(255) NOT NULL DEFAULT '', 516 description VARCHAR(255) NOT NULL DEFAULT '', 517 in_rss INT NOT NULL DEFAULT '1', 518 on_frontpage INT NOT NULL DEFAULT '1', 519 searchable INT NOT NULL DEFAULT '1', 520 title VARCHAR(255) NOT NULL DEFAULT '', 521 522 PRIMARY KEY (name(250)) 523 ) $tabletype "; 524 525 $create_sql[] = "INSERT INTO `".PFX."txp_section` VALUES ('articles', 'archive', 'default', '', 1, 1, 1, 'Articles')"; 526 $create_sql[] = "INSERT INTO `".PFX."txp_section` VALUES ('default', 'default', 'default', '', 1, 1, 1, 'Default')"; 527 528 $create_sql[] = "CREATE TABLE `".PFX."txp_users` ( 529 user_id INT NOT NULL AUTO_INCREMENT, 530 name VARCHAR(64) NOT NULL DEFAULT '', 531 pass VARCHAR(128) NOT NULL, 532 RealName VARCHAR(255) NOT NULL DEFAULT '', 533 email VARCHAR(254) NOT NULL DEFAULT '', 534 privs TINYINT NOT NULL DEFAULT '1', 535 last_access DATETIME NULL DEFAULT NULL, 536 nonce VARCHAR(64) NOT NULL DEFAULT '', 537 538 PRIMARY KEY (user_id), 539 UNIQUE name (name) 540 ) $tabletype "; 541 542 $create_sql[] = "INSERT INTO `".PFX."txp_users` VALUES ( 543 1, 544 '".doSlash($_SESSION['name'])."', 545 '".doSlash(txp_hash_password($_SESSION['pass']))."', 546 '".doSlash($_SESSION['realname'])."', 547 '".doSlash($_SESSION['email'])."', 548 1, 549 NOW(), 550 '".md5(uniqid(rand(), true))."')"; 551 552 $create_sql[] = "CREATE TABLE `".PFX."txp_token` ( 553 id INT NOT NULL AUTO_INCREMENT, 554 reference_id INT NOT NULL, 555 type VARCHAR(255) NOT NULL, 556 selector VARCHAR(12) NOT NULL DEFAULT '', 557 token VARCHAR(255) NOT NULL, 558 expires DATETIME NULL DEFAULT NULL, 559 560 PRIMARY KEY (id), 561 UNIQUE ref_type (reference_id, type(50)) 562 ) $tabletype "; 563 564 $GLOBALS['txp_install_successful'] = true; 565 $GLOBALS['txp_err_count'] = 0; 566 $GLOBALS['txp_err_html'] = ''; 567 568 foreach ($create_sql as $query) { 569 $result = mysqli_query($link, $query); 570 571 if (!$result) { 572 $GLOBALS['txp_err_count']++; 573 $GLOBALS['txp_err_html'] .= '<li>'.n. 574 '<b>'.htmlspecialchars(mysqli_error($link)).'</b><br />'.n. 575 '<pre>'.htmlspecialchars($query).'</pre>'.n.'</li>'.n; 576 $GLOBALS['txp_install_successful'] = false; 577 } 578 } 579 580 require_once txpath.'/lib/IXRClass.php'; 581 $client = new IXR_Client('http://rpc.textpattern.com'); 582 583 if (!$client->query('tups.getLanguage', $blog_uid, LANG)) { 584 // If cannot install from lang file, setup the English lang. 585 if (!install_language_from_file(LANG)) { 586 $lang = 'en-gb'; 587 include_once txpath.'/setup/en-gb.php'; 588 589 if (!@$lastmod) { 590 $lastmod = '1970-01-01 00:00:00'; 591 } 592 593 foreach ($en_gb_lang as $evt_name => $evt_strings) { 594 foreach ($evt_strings as $lang_key => $lang_val) { 595 $lang_val = doSlash($lang_val); 596 597 if (@$lang_val) { 598 mysqli_query($link, "INSERT DELAYED INTO `".PFX."txp_lang` SET 599 lang = 'en-gb', 600 name = '".$lang_key."', 601 event = '".$evt_name."', 602 data = '".$lang_val."', 603 lastmod = '".$lastmod."'"); 604 } 605 } 606 } 607 } 608 } else { 609 $response = $client->getResponse(); 610 $lang_struct = unserialize($response); 611 612 foreach ($lang_struct as $item) { 613 foreach ($item as $name => $value) { 614 $item[$name] = doSlash($value); 615 } 616 617 mysqli_query($link, "INSERT DELAYED INTO `".PFX."txp_lang` SET 618 lang = '".LANG."', 619 name = '".$item['name']."', 620 event = '".$item['event']."', 621 data = '".$item['data']."', 622 lastmod = '".strftime('%Y%m%d%H%M%S', $item['uLastmod'])."'"); 623 } 624 } 625 626 mysqli_query($link, "FLUSH TABLE `".PFX."txp_lang`"); 627 628 /** 629 * Stub replacement for txplib_db.php/safe_escape(). 630 * 631 * @ignore 632 */ 633 634 function safe_escape($in = '') 635 { 636 global $link; 637 return mysqli_real_escape_string($link, $in); 638 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title