PageRenderTime 63ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/install.php

https://github.com/danboy/Croissierd
PHP | 4187 lines | 3291 code | 626 blank | 270 comment | 128 complexity | 36c35573c12d69144550e3ae783023ff MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: install.php
  15. -----------------------------------------------------
  16. Purpose: Installation file
  17. =====================================================
  18. */
  19. error_reporting(E_ALL);
  20. @set_magic_quotes_runtime(0);
  21. if (isset($_GET) AND count($_GET) > 0)
  22. {
  23. if ( ! isset($_GET['page']) OR ! is_numeric($_GET['page']) OR count($_GET) > 1)
  24. {
  25. exit("Disallowed GET request");
  26. }
  27. }
  28. $data = array(
  29. 'app_full_version' => 'Version 1.6.8',
  30. 'app_version' => '168',
  31. 'doc_url' => 'http://expressionengine.com/docs/',
  32. 'ext' => '.php',
  33. 'ip' => '',
  34. 'database' => 'mysql',
  35. 'db_conntype' => '0',
  36. 'system_dir' => 'system',
  37. 'db_hostname' => 'localhost',
  38. 'db_username' => '',
  39. 'db_password' => '',
  40. 'db_name' => '',
  41. 'db_prefix' => 'exp',
  42. 'encryption_type' => 'sha1',
  43. 'site_name' => '',
  44. 'site_url' => '',
  45. 'site_index' => '',
  46. 'cp_url' => '',
  47. 'cp_index' => 'index.php',
  48. 'username' => '',
  49. 'password' => '',
  50. 'screen_name' => '',
  51. 'email' => '',
  52. 'webmaster_email' => '',
  53. 'deft_lang' => 'english',
  54. 'template' => '01',
  55. 'server_timezone' => 'UTC',
  56. 'daylight_savings' => '',
  57. 'redirect_method' => 'redirect',
  58. 'upload_folder' => 'uploads/',
  59. 'image_path' => '../images/',
  60. 'cp_images' => 'cp_images/',
  61. 'avatar_path' => '../images/avatars/',
  62. 'avatar_url' => 'images/avatars/',
  63. 'photo_path' => '../images/member_photos/',
  64. 'photo_url' => 'images/member_photos/',
  65. 'signature_img_path' => '../images/signature_attachments/',
  66. 'signature_img_url' => 'images/signature_attachments/',
  67. 'pm_path' => '../images/pm_attachments',
  68. 'captcha_path' => '../images/captchas/',
  69. 'theme_folder_path' => '../themes/',
  70. );
  71. foreach ($_POST as $key => $val)
  72. {
  73. if ( ! get_magic_quotes_gpc())
  74. $val = addslashes($val);
  75. if (isset($data[$key]))
  76. {
  77. $data[$key] = trim($val);
  78. }
  79. }
  80. $data['site_url'] = rtrim($data['site_url'], '/').'/';
  81. $data['system_dir'] = str_replace("/", "", $data['system_dir']);
  82. define('EXT', $data['ext']);
  83. $page = (! isset($_GET['page']) || $_GET['page'] > 7) ? 1 : $_GET['page'];
  84. if (phpversion() < '4.1.0')
  85. {
  86. $page = 0;
  87. }
  88. // HTML HEADER
  89. page_head();
  90. // Unsupported version of PHP
  91. // --------------------------------------------------------------------
  92. // --------------------------------------------------------------------
  93. if ($page == 0)
  94. {
  95. ?>
  96. <div id='innercontent'>
  97. <div class="error">Error:&nbsp;&nbsp;Unsupported PHP version</div>
  98. <p><b>In order to install ExpressionEngine, your server must be running PHP version 4.1 or newer.</b></p>
  99. <p><br />Your server is currently running PHP version: <?php echo phpversion(); ?></p>
  100. <p><br />If you would like to switch to a host that provides more current software,
  101. please consider <a href="http://www.enginehosting.com/">EngineHosting</a></p>
  102. </div>
  103. <?php
  104. }
  105. // PAGE ONE
  106. // --------------------------------------------------------------------
  107. // --------------------------------------------------------------------
  108. if ($page == 1)
  109. {
  110. ?>
  111. <div id='innercontent'>
  112. <h1>ExpressionEngine Installation Wizard</h1>
  113. <div class="botBorder">
  114. <div class="pad">
  115. <p><b>Do you need assistance?</b>&nbsp; If you have questions or problems please visit our <a href="http://expressionengine.com/support/">Support Resources</a> page</p>
  116. </div>
  117. </div>
  118. <div class="botBorder">
  119. <p><br /><span class='red'><b>Important:&nbsp;</b> Use this installation wizard <b>ONLY</b> if you are installing ExpressionEngine for the first time.&nbsp;
  120. Do <b>NOT</b> run this installation routine if you are already using ExpressionEngine and are updating to a newer version.&nbsp; You'll find
  121. update instructions in the user guide.</span><br />&nbsp;</p>
  122. </div>
  123. <div class="botBorder">
  124. <h4>Installation Instructions</h4>
  125. <p>Before proceeding please take a moment to read the
  126. <a href="http://expressionengine.com/docs/#install_docs" target="_blank">installation instructions</a> if you have not done so already.</p>
  127. <br />
  128. </div>
  129. <form method="post" action="install.php?page=2">
  130. <p class="center"><br />Are you ready to install ExpressionEngine?</p>
  131. <p class="center"><input type="submit" class="submit" value=" Click here to begin! " /></p>
  132. </form>
  133. </div>
  134. <?php
  135. }
  136. // PAGE TWO
  137. // --------------------------------------------------------------------
  138. // --------------------------------------------------------------------
  139. elseif ($page == 2)
  140. {
  141. license_agreement();
  142. }
  143. // PAGE THREE
  144. // --------------------------------------------------------------------
  145. // --------------------------------------------------------------------
  146. elseif ($page == 3)
  147. {
  148. if ( ! isset($_POST['agree']) OR $_POST['agree'] == 'no')
  149. {
  150. license_agreement();
  151. }
  152. else
  153. {
  154. system_folder_form();
  155. }
  156. }
  157. // PAGE FOUR
  158. // --------------------------------------------------------------------
  159. // --------------------------------------------------------------------
  160. elseif ($page == 4)
  161. {
  162. // Does the 'system' directory exist?
  163. // --------------------------------------------------------------------
  164. if ($data['system_dir'] == '' OR ! is_dir('./'.$data['system_dir']))
  165. {
  166. ?><div class='error'>Error: Unable to locate the directory you submitted.</div><?php
  167. system_folder_form();
  168. page_footer();
  169. exit;
  170. }
  171. // Are the various files and directories writable?
  172. // --------------------------------------------------------------------
  173. $system_path = './'.trim($data['system_dir']).'/';
  174. $writable_things = array(
  175. 'path.php',
  176. $system_path.'config.php',
  177. $system_path.'cache/'
  178. );
  179. $not_writable = array();
  180. foreach ($writable_things as $val)
  181. {
  182. if ( ! @is_writable($val))
  183. {
  184. $not_writable[] = $val;
  185. }
  186. }
  187. if ( ! @is_writable("./images/uploads"))
  188. {
  189. $not_writable[] = "images/uploads";
  190. }
  191. if ( ! @is_writable("./images/captchas"))
  192. {
  193. $not_writable[] = "images/captchas";
  194. }
  195. $i = count($not_writable);
  196. if ($i > 0)
  197. {
  198. echo "<div id='innercontent'>";
  199. $d = ($i > 1) ? 'Directories or Files' : 'Directory or File';
  200. echo "<div class='error'>Error: Incorrect Permissions for ".$d."</div>";
  201. $d = ($i > 1) ? 'directories or files' : 'directory or file';
  202. echo "<p>The following $d cannot be written to:</p>";
  203. foreach ($not_writable as $bad)
  204. {
  205. echo '<p>&nbsp;&nbsp;&nbsp;&nbsp;<strong>'.$bad.'</strong></p>';
  206. }
  207. $item = ($i > 1) ? 'items' : 'item';
  208. ?>
  209. <p>In order to run this installation, the file permissions on the above <?php echo $item; ?> must be set as indicated in the instructions.</p>
  210. <p>If you are not sure how to set permissions, <a href='http://expressionengine.com/knowledge_base/article/how_do_you_set_permissions_on_files_and_directories/' target='_blank'>click here</a>.</p>
  211. <p><b>Once you are done, please <a href='javascript:history.go(-1)'>run</a> this installation script again.</b></p>
  212. </div>
  213. <?php
  214. page_footer();
  215. exit;
  216. }
  217. if ( ! @file_exists($system_path.'config'.$data['ext']))
  218. {
  219. echo "<div class='error'><br />Error: Unable to locate your config.php file. Please make sure you have uploaded all components of this software.</div><br />";
  220. page_footer();
  221. exit;
  222. }
  223. else
  224. {
  225. require($system_path.'config'.$data['ext']);
  226. }
  227. if (isset($conf['install_lock']) AND $conf['install_lock'] == 1)
  228. {
  229. ?>
  230. <div id='innercontent'>
  231. <div class="error">Warning: Your installation lock is set</div>
  232. <p>There already appears to be an installed instance of ExpressionEngine</p>
  233. <p>If you absolutely want to install this program you must locate the file called <b>config.php</b> and delete its contents.</b>
  234. <p>Once you've done this, <a href="install.php?page=3">click here</a> to continue</p>
  235. </div>
  236. <?php
  237. }
  238. else
  239. {
  240. settings_form();
  241. }
  242. }
  243. // PAGE FIVE
  244. // --------------------------------------------------------------------
  245. // --------------------------------------------------------------------
  246. elseif ($page == 5)
  247. {
  248. if ($data['db_hostname'] == '' AND $data['db_username'] == '' AND $data['db_name'] == '')
  249. {
  250. echo "<p>An errror occured. <a href='install.php'>Click here</a> to return to the main page</a>";
  251. page_footer();
  252. exit;
  253. }
  254. $errors = array();
  255. $system_path = './'.trim($data['system_dir']).'/';
  256. if ( ! @file_exists($system_path.'config'.$data['ext']))
  257. {
  258. $errors[] = "Unable to locate the file called \"config.php\". Please make sure you have uploaded all components of this software.";
  259. }
  260. else
  261. {
  262. require($system_path.'config'.$data['ext']);
  263. }
  264. if (isset($conf['install_lock']) AND $conf['install_lock'] == 1)
  265. {
  266. $errors[] = "Your installation lock is set. Locate the file called <b>config.php</b> and delete its contents";
  267. }
  268. if (
  269. $data['db_hostname'] == '' ||
  270. $data['db_username'] == '' ||
  271. $data['db_name'] == '' ||
  272. $data['site_name'] == '' ||
  273. $data['username'] == '' ||
  274. $data['password'] == '' ||
  275. $data['email'] == ''
  276. )
  277. {
  278. $errors[] = "You left some form fields empty";
  279. }
  280. if (strlen($data['username']) < 4)
  281. {
  282. $errors[] = "Your username must be at least 4 characters in length";
  283. }
  284. if (strlen($data['password']) < 5)
  285. {
  286. $errors[] = "Your password must be at least 5 characters in length";
  287. }
  288. // Is password the same as username?
  289. $lc_user = strtolower($data['username']);
  290. $lc_pass = strtolower($data['password']);
  291. $nm_pass = strtr($lc_pass, 'elos', '3105');
  292. if ($lc_user == $lc_pass || $lc_user == strrev($lc_pass) || $lc_user == $nm_pass || $lc_user == strrev($nm_pass))
  293. {
  294. $errors[] = "Your password can not be based on the username";
  295. }
  296. if (strpos($data['db_password'], '$') !== FALSE)
  297. {
  298. $errors[] = "Your MySQL password can not contain a dollar sign (\$)";
  299. }
  300. if ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $data['email']))
  301. {
  302. $errors[] = "The email address you submitted is not valid";
  303. }
  304. if ($data['screen_name'] == '')
  305. {
  306. $data['screen_name'] = $data['username'];
  307. }
  308. // CONNECT TO DATABASE
  309. // --------------------------------------------------------------------
  310. $db_prefix = ($data['db_prefix'] == '') ? 'exp' : $data['db_prefix'];
  311. if ( ! @file_exists($system_path.'db/db.'.$data['database'].$data['ext']))
  312. {
  313. $errors[] = "Unable to locate the database file. Please make sure you have uploaded all components of this software.";
  314. }
  315. else
  316. {
  317. require($system_path.'db/db.'.$data['database'].$data['ext']);
  318. $db_config = array(
  319. 'hostname' => $data['db_hostname'],
  320. 'username' => $data['db_username'],
  321. 'password' => $data['db_password'],
  322. 'database' => $data['db_name'],
  323. 'conntype' => $data['db_conntype'],
  324. 'prefix' => $db_prefix,
  325. 'enable_cache' => FALSE
  326. );
  327. $DB = new DB($db_config);
  328. if ( ! $DB->db_connect(0))
  329. {
  330. $errors[] = "Unable to connect to your database server. ";
  331. if ($data['db_conntype'] == 1)
  332. {
  333. $errors[] = "Try switching to a non-persistent connection since some servers do not support persistent connections.";
  334. }
  335. }
  336. if ( ! $DB->select_db())
  337. {
  338. $errors[] = "Unable to select the database";
  339. }
  340. // Check for "strict mode", some queries used are incompatible
  341. if ($DB->conn_id !== FALSE && version_compare(mysql_get_server_info(), '4.1-alpha', '>=') !== FALSE)
  342. {
  343. $mode_query = $DB->query("SELECT CONCAT(@@global.sql_mode, @@session.sql_mode) AS sql_mode");
  344. if (strpos(strtoupper($mode_query->row['sql_mode']), 'STRICT') !== FALSE)
  345. {
  346. $errors[] = "ExpressionEngine will not run on a MySQL server operating in strict mode";
  347. }
  348. }
  349. }
  350. if ( ! file_exists($system_path.'language/'.$data['deft_lang'].'/email_data'.$data['ext']))
  351. {
  352. $errors[] = "Unable to locate the file containing your email templates. Make sure you have uploaded all components of this software.";
  353. }
  354. else
  355. {
  356. require($system_path.'language/'.$data['deft_lang'].'/email_data'.$data['ext']);
  357. }
  358. // DISPLAY ERRORS
  359. // --------------------------------------------------------------------
  360. if (count($errors) > 0)
  361. {
  362. $er = "<div class='error'>ERROR: The following Errors were encountered</div>";
  363. $er .= "<ol>";
  364. foreach ($errors as $doh)
  365. {
  366. $er .= "<li>".$doh."</li>";
  367. }
  368. $er .= "</ol>";
  369. $er .= "<div class='border'><p><b>Please correct the errors and resubmit the form</b><br /><br /></p></div>";
  370. settings_form($er);
  371. page_footer();
  372. exit;
  373. }
  374. // Existing Install?
  375. // --------------------------------------------------------------------
  376. // is the user trying to install to an existing installation?
  377. // This can happen if someone mistakenly copies over their config.php
  378. // during an update, and then trying to run the installer...
  379. $query = $DB->query("SHOW tables LIKE '".$DB->escape_str($db_prefix)."%'");
  380. if ($query->num_rows > 0 && ! isset($_POST['install_override']))
  381. {
  382. $fields = '';
  383. foreach($_POST as $key => $value)
  384. {
  385. if (get_magic_quotes_gpc())
  386. {
  387. $value = stripslashes($value);
  388. }
  389. $fields .= '<input type="hidden" name="'.str_replace("'", "&#39;", htmlspecialchars($key)).'" value="'.str_replace("'", "&#39;", htmlspecialchars($value)).'" />'."\n";
  390. }
  391. $er = '<div id="innercontent">
  392. <div class="error">Existing Installation Detected, Empty config.php File</div>
  393. <p>ExpressionEngine appears to be installed to your database, but your configuration file is empty.
  394. Continuing with this installation will destroy any information currently in your database.
  395. Are you sure you wish to perform a new installation?</p>
  396. <form action="install.php?page=5" method="post">
  397. '.$fields.'
  398. <input type="hidden" name="install_override" value="y" />
  399. <p><input type="submit" value="Continue Installation"></p>
  400. </form>
  401. <form action="install.php?page=6" method="post">
  402. '.$fields.'
  403. <input type="hidden" name="rebuild_config" value="y" />
  404. <p><input type="submit" value="Do NOT Install, Fix Configuration"></p>
  405. </form>
  406. </div>
  407. ';
  408. echo $er;
  409. page_footer();
  410. exit;
  411. }
  412. // Prep user submitted data for DB insertion
  413. // --------------------------------------------------------------------
  414. // --------------------------------------------------------------------
  415. /** -------------------------------------
  416. /** Get user's IP address
  417. /** -------------------------------------*/
  418. $CIP = ( ! isset($_SERVER['HTTP_CLIENT_IP'])) ? FALSE : $_SERVER['HTTP_CLIENT_IP'];
  419. $FOR = ( ! isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? FALSE : $_SERVER['HTTP_X_FORWARDED_FOR'];
  420. $RMT = ( ! isset($_SERVER['REMOTE_ADDR'])) ? FALSE : $_SERVER['REMOTE_ADDR'];
  421. if ($CIP)
  422. {
  423. $cip = explode('.', $CIP);
  424. $data['ip'] = ($cip['0'] != current(explode('.', $RMT))) ? implode('.', array_reverse($cip)) : $CIP;
  425. }
  426. elseif ($FOR)
  427. {
  428. $data['ip'] = (strstr($FOR, ',')) ? end(explode(',', $FOR)) : $FOR;
  429. }
  430. else
  431. $data['ip'] = $RMT;
  432. /** -------------------------------------
  433. /** Encrypt password and Unique ID
  434. /** -------------------------------------*/
  435. if (phpversion() >= 4.2)
  436. mt_srand();
  437. else
  438. mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
  439. $unique_id = uniqid(mt_rand());
  440. $password = stripslashes($data['password']);
  441. if ($data['encryption_type'] == 'sha1')
  442. {
  443. if ( ! function_exists('sha1'))
  444. {
  445. if ( ! function_exists('mhash'))
  446. {
  447. require './'.$data['system_dir'].'/core/core.sha1'.$data['ext'];
  448. $SH = new SHA;
  449. $unique_id = $SH->encode_hash($unique_id);
  450. $password = $SH->encode_hash($password);
  451. }
  452. else
  453. {
  454. $unique_id = bin2hex(mhash(MHASH_SHA1, $unique_id));
  455. $password = bin2hex(mhash(MHASH_SHA1, $password));
  456. }
  457. }
  458. else
  459. {
  460. $unique_id = sha1($unique_id);
  461. $password = sha1($password);
  462. }
  463. }
  464. else
  465. {
  466. $unique_id = md5($unique_id);
  467. $password = md5($password);
  468. }
  469. /** -------------------------------------
  470. /** Fetch current time as GMT
  471. /** -------------------------------------*/
  472. $time = time();
  473. $now = mktime(gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
  474. $year = gmdate('Y', $now);
  475. $month = gmdate('m', $now);
  476. $day = gmdate('d', $now);
  477. // DEFINE DB TABLES
  478. // --------------------------------------------------------------------
  479. // --------------------------------------------------------------------
  480. // Sites
  481. $D[] = "exp_sites";
  482. $Q[] = "CREATE TABLE `exp_sites` (
  483. `site_id` int(5) unsigned NOT NULL auto_increment,
  484. `site_label` varchar(100) NOT NULL default '',
  485. `site_name` varchar(50) NOT NULL default '',
  486. `site_description` text NOT NULL,
  487. `site_system_preferences` TEXT NOT NULL ,
  488. `site_mailinglist_preferences` TEXT NOT NULL ,
  489. `site_member_preferences` TEXT NOT NULL ,
  490. `site_template_preferences` TEXT NOT NULL ,
  491. `site_weblog_preferences` TEXT NOT NULL ,
  492. PRIMARY KEY (`site_id`),
  493. KEY `site_name` (`site_name`))";
  494. // Session data
  495. $D[] = 'exp_sessions';
  496. $Q[] = "CREATE TABLE exp_sessions (
  497. session_id varchar(40) default '0' NOT NULL,
  498. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  499. member_id int(10) default '0' NOT NULL,
  500. admin_sess tinyint(1) default '0' NOT NULL,
  501. ip_address varchar(16) default '0' NOT NULL,
  502. user_agent varchar(50) NOT NULL,
  503. last_activity int(10) unsigned DEFAULT '0' NOT NULL,
  504. PRIMARY KEY (session_id),
  505. KEY (`member_id`),
  506. KEY (`site_id`)
  507. )";
  508. // Throttle
  509. $D[] = 'exp_throttle';
  510. $Q[] = "CREATE TABLE exp_throttle (
  511. ip_address varchar(16) default '0' NOT NULL,
  512. last_activity int(10) unsigned DEFAULT '0' NOT NULL,
  513. hits int(10) unsigned NOT NULL,
  514. locked_out char(1) NOT NULL default 'n',
  515. KEY (ip_address),
  516. KEY (last_activity)
  517. )";
  518. // System stats
  519. $D[] = 'exp_stats';
  520. $Q[] = "CREATE TABLE exp_stats (
  521. weblog_id int(6) unsigned NOT NULL default '0',
  522. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  523. total_members mediumint(7) NOT NULL default '0',
  524. recent_member_id int(10) default '0' NOT NULL,
  525. recent_member varchar(50) NOT NULL,
  526. total_entries mediumint(8) default '0' NOT NULL,
  527. total_forum_topics mediumint(8) default '0' NOT NULL,
  528. total_forum_posts mediumint(8) default '0' NOT NULL,
  529. total_comments mediumint(8) default '0' NOT NULL,
  530. total_trackbacks mediumint(8) default '0' NOT NULL,
  531. last_entry_date int(10) unsigned default '0' NOT NULL,
  532. last_forum_post_date int(10) unsigned default '0' NOT NULL,
  533. last_comment_date int(10) unsigned default '0' NOT NULL,
  534. last_trackback_date int(10) unsigned default '0' NOT NULL,
  535. last_visitor_date int(10) unsigned default '0' NOT NULL,
  536. most_visitors mediumint(7) NOT NULL default '0',
  537. most_visitor_date int(10) unsigned default '0' NOT NULL,
  538. last_cache_clear int(10) unsigned default '0' NOT NULL,
  539. KEY (weblog_id),
  540. KEY (site_id)
  541. )";
  542. // Online users
  543. $D[] = 'exp_online_users';
  544. $Q[] = "CREATE TABLE exp_online_users (
  545. weblog_id int(6) unsigned NOT NULL default '0',
  546. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  547. member_id int(10) default '0' NOT NULL,
  548. in_forum char(1) NOT NULL default 'n',
  549. name varchar(50) default '0' NOT NULL,
  550. ip_address varchar(16) default '0' NOT NULL,
  551. date int(10) unsigned default '0' NOT NULL,
  552. anon char(1) NOT NULL,
  553. KEY (date),
  554. KEY (site_id)
  555. )";
  556. // Actions table
  557. // Actions are events that require processing. Used by modules class.
  558. $D[] = 'exp_actions';
  559. $Q[] = "CREATE TABLE exp_actions (
  560. action_id int(4) unsigned NOT NULL auto_increment,
  561. class varchar(50) NOT NULL,
  562. method varchar(50) NOT NULL,
  563. PRIMARY KEY (action_id)
  564. )";
  565. // Modules table
  566. // Contains a list of all installed modules
  567. $D[] = 'exp_modules';
  568. $Q[] = "CREATE TABLE exp_modules (
  569. module_id int(4) unsigned NOT NULL auto_increment,
  570. module_name varchar(50) NOT NULL,
  571. module_version varchar(12) NOT NULL,
  572. has_cp_backend char(1) NOT NULL default 'n',
  573. PRIMARY KEY (module_id)
  574. )";
  575. // Referrer tracking table
  576. $D[] = 'exp_referrers';
  577. $Q[] = "CREATE TABLE exp_referrers (
  578. ref_id int(10) unsigned NOT NULL auto_increment,
  579. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  580. ref_from varchar(120) NOT NULL,
  581. ref_to varchar(120) NOT NULL,
  582. ref_ip varchar(16) default '0' NOT NULL,
  583. ref_date int(10) unsigned default '0' NOT NULL,
  584. ref_agent varchar(100) NOT NULL,
  585. user_blog varchar(40) NOT NULL,
  586. PRIMARY KEY (ref_id),
  587. KEY (site_id)
  588. )";
  589. // Security Hashes
  590. // Used to store hashes needed to process forms in 'secure mode'
  591. $D[] = 'exp_security_hashes';
  592. $Q[] = "CREATE TABLE exp_security_hashes (
  593. date int(10) unsigned NOT NULL,
  594. ip_address varchar(16) default '0' NOT NULL,
  595. hash varchar(40) NOT NULL,
  596. KEY (hash)
  597. )";
  598. // Captcha data
  599. $D[] = 'exp_captcha';
  600. $Q[] = "CREATE TABLE exp_captcha (
  601. captcha_id bigint(13) unsigned NOT NULL auto_increment,
  602. date int(10) unsigned NOT NULL,
  603. ip_address varchar(16) default '0' NOT NULL,
  604. word varchar(20) NOT NULL,
  605. PRIMARY KEY (captcha_id),
  606. KEY (word)
  607. )";
  608. // Password Lockout
  609. // If password lockout is enabled, a user only gets
  610. // four attempts to log-in within a specified period.
  611. // This table holds the a list of locked out users
  612. $D[] = 'exp_password_lockout';
  613. $Q[] = "CREATE TABLE exp_password_lockout (
  614. login_date int(10) unsigned NOT NULL,
  615. ip_address varchar(16) default '0' NOT NULL,
  616. user_agent varchar(50) NOT NULL,
  617. KEY (login_date),
  618. KEY (ip_address),
  619. KEY (user_agent)
  620. )";
  621. // Reset password
  622. // If a user looses their password, this table
  623. // holds the reset code.
  624. $D[] = 'exp_reset_password';
  625. $Q[] = "CREATE TABLE exp_reset_password (
  626. member_id int(10) unsigned NOT NULL,
  627. resetcode varchar(12) NOT NULL,
  628. date int(10) NOT NULL
  629. )";
  630. $D[] = 'exp_mailing_lists';
  631. $Q[] = "CREATE TABLE exp_mailing_lists (
  632. list_id int(7) unsigned NOT NULL auto_increment,
  633. list_name varchar(40) NOT NULL,
  634. list_title varchar(100) NOT NULL,
  635. list_template text NOT NULL,
  636. PRIMARY KEY (list_id),
  637. KEY (list_name)
  638. )";
  639. // Mailing list
  640. // Notes: "authcode" is a random hash assigned to each member
  641. // of the mailing list. We use this code in the "usubscribe" link
  642. // added to sent emails.
  643. $D[] = 'exp_mailing_list';
  644. $Q[] = "CREATE TABLE exp_mailing_list (
  645. user_id int(10) unsigned NOT NULL auto_increment,
  646. list_id int(7) unsigned default '0' NOT NULL,
  647. ip_address varchar(16) NOT NULL,
  648. authcode varchar(10) NOT NULL,
  649. email varchar(50) NOT NULL,
  650. KEY (list_id),
  651. KEY (user_id)
  652. )";
  653. // Mailing List Queue
  654. // When someone signs up for the mailing list, they are sent
  655. // a confirmation email. This prevents someone from signing
  656. // up another person. This table holds email addresses that
  657. // are pending activation.
  658. $D[] = 'exp_mailing_list_queue';
  659. $Q[] = "CREATE TABLE exp_mailing_list_queue (
  660. email varchar(50) NOT NULL,
  661. list_id int(7) unsigned default '0' NOT NULL,
  662. authcode varchar(10) NOT NULL,
  663. date int(10) NOT NULL
  664. )";
  665. // Email Cache
  666. // We store all email messages that are sent from the CP
  667. $D[] = 'exp_email_cache';
  668. $Q[] = "CREATE TABLE exp_email_cache (
  669. cache_id int(6) unsigned NOT NULL auto_increment,
  670. cache_date int(10) unsigned default '0' NOT NULL,
  671. total_sent int(6) unsigned NOT NULL,
  672. from_name varchar(70) NOT NULL,
  673. from_email varchar(70) NOT NULL,
  674. recipient text NOT NULL,
  675. cc text NOT NULL,
  676. bcc text NOT NULL,
  677. recipient_array mediumtext NOT NULL,
  678. subject varchar(120) NOT NULL,
  679. message mediumtext NOT NULL,
  680. `plaintext_alt` MEDIUMTEXT NOT NULL,
  681. mailinglist char(1) NOT NULL default 'n',
  682. mailtype varchar(6) NOT NULL,
  683. text_fmt varchar(40) NOT NULL,
  684. wordwrap char(1) NOT NULL default 'y',
  685. priority char(1) NOT NULL default '3',
  686. PRIMARY KEY (cache_id)
  687. )";
  688. // Cached Member Groups
  689. // We use this table to store the member group assignments
  690. // for each email that is sent. Since you can send email
  691. // to various combinations of members, we store the member
  692. // group numbers in this table, which is joined to the
  693. // table above when we need to re-send an email from cache.
  694. $D[] = 'exp_email_cache_mg';
  695. $Q[] = "CREATE TABLE exp_email_cache_mg (
  696. cache_id int(6) unsigned NOT NULL,
  697. group_id smallint(4) NOT NULL,
  698. KEY (cache_id)
  699. )";
  700. // We do the same with mailing lists
  701. $D[] = 'exp_email_cache_ml';
  702. $Q[] = "CREATE TABLE exp_email_cache_ml (
  703. cache_id int(6) unsigned NOT NULL,
  704. list_id smallint(4) NOT NULL,
  705. KEY (cache_id)
  706. )";
  707. // Email Console Cache
  708. // Emails sent from the member profile email console are saved here.
  709. $D[] = 'exp_email_console_cache';
  710. $Q[] = "CREATE TABLE exp_email_console_cache (
  711. cache_id int(6) unsigned NOT NULL auto_increment,
  712. cache_date int(10) unsigned default '0' NOT NULL,
  713. member_id int(10) unsigned NOT NULL,
  714. member_name varchar(50) NOT NULL,
  715. ip_address varchar(16) default '0' NOT NULL,
  716. recipient varchar(70) NOT NULL,
  717. recipient_name varchar(50) NOT NULL,
  718. subject varchar(120) NOT NULL,
  719. message mediumtext NOT NULL,
  720. PRIMARY KEY (cache_id)
  721. )";
  722. // Email Tracker
  723. // This table is used by the Email module for flood control.
  724. $D[] = 'exp_email_tracker';
  725. $Q[] = "CREATE TABLE exp_email_tracker (
  726. email_id int(10) unsigned NOT NULL auto_increment,
  727. email_date int(10) unsigned default '0' NOT NULL,
  728. sender_ip varchar(16) NOT NULL,
  729. sender_email varchar(75) NOT NULL ,
  730. sender_username varchar(50) NOT NULL ,
  731. number_recipients int(4) unsigned default '1' NOT NULL,
  732. PRIMARY KEY (email_id)
  733. )";
  734. // Member table
  735. // Contains the member info
  736. /*
  737. Note: The following fields are intended for use
  738. with the "user_blog" module.
  739. weblog_id int(6) unsigned NOT NULL default '0',
  740. template_id int(6) unsigned NOT NULL default '0',
  741. upload_id int(6) unsigned NOT NULL default '0',
  742. */
  743. $D[] = 'exp_members';
  744. $Q[] = "CREATE TABLE exp_members (
  745. member_id int(10) unsigned NOT NULL auto_increment,
  746. group_id smallint(4) NOT NULL default '0',
  747. weblog_id int(6) unsigned NOT NULL default '0',
  748. tmpl_group_id int(6) unsigned NOT NULL default '0',
  749. upload_id int(6) unsigned NOT NULL default '0',
  750. username varchar(50) NOT NULL,
  751. screen_name varchar(50) NOT NULL,
  752. password varchar(40) NOT NULL,
  753. unique_id varchar(40) NOT NULL,
  754. authcode varchar(10) NOT NULL,
  755. email varchar(50) NOT NULL,
  756. url varchar(75) NOT NULL,
  757. location varchar(50) NOT NULL,
  758. occupation varchar(80) NOT NULL,
  759. interests varchar(120) NOT NULL,
  760. bday_d int(2) NOT NULL,
  761. bday_m int(2) NOT NULL,
  762. bday_y int(4) NOT NULL,
  763. aol_im varchar(50) NOT NULL,
  764. yahoo_im varchar(50) NOT NULL,
  765. msn_im varchar(50) NOT NULL,
  766. icq varchar(50) NOT NULL,
  767. bio text NOT NULL,
  768. signature text NOT NULL,
  769. avatar_filename varchar(120) NOT NULL,
  770. avatar_width int(4) unsigned NOT NULL,
  771. avatar_height int(4) unsigned NOT NULL,
  772. photo_filename varchar(120) NOT NULL,
  773. photo_width int(4) unsigned NOT NULL,
  774. photo_height int(4) unsigned NOT NULL,
  775. sig_img_filename varchar(120) NOT NULL,
  776. sig_img_width int(4) unsigned NOT NULL,
  777. sig_img_height int(4) unsigned NOT NULL,
  778. ignore_list text NOT NULL,
  779. private_messages int(4) unsigned DEFAULT '0' NOT NULL,
  780. accept_messages char(1) NOT NULL default 'y',
  781. last_view_bulletins int(10) NOT NULL default 0,
  782. last_bulletin_date int(10) NOT NULL default 0,
  783. ip_address varchar(16) default '0' NOT NULL,
  784. join_date int(10) unsigned default '0' NOT NULL,
  785. last_visit int(10) unsigned default '0' NOT NULL,
  786. last_activity int(10) unsigned default '0' NOT NULL,
  787. total_entries smallint(5) unsigned NOT NULL default '0',
  788. total_comments smallint(5) unsigned NOT NULL default '0',
  789. total_forum_topics mediumint(8) default '0' NOT NULL,
  790. total_forum_posts mediumint(8) default '0' NOT NULL,
  791. last_entry_date int(10) unsigned default '0' NOT NULL,
  792. last_comment_date int(10) unsigned default '0' NOT NULL,
  793. last_forum_post_date int(10) unsigned default '0' NOT NULL,
  794. last_email_date int(10) unsigned default '0' NOT NULL,
  795. in_authorlist char(1) NOT NULL default 'n',
  796. accept_admin_email char(1) NOT NULL default 'y',
  797. accept_user_email char(1) NOT NULL default 'y',
  798. notify_by_default char(1) NOT NULL default 'y',
  799. notify_of_pm char(1) NOT NULL default 'y',
  800. display_avatars char(1) NOT NULL default 'y',
  801. display_signatures char(1) NOT NULL default 'y',
  802. smart_notifications char(1) NOT NULL default 'y',
  803. language varchar(50) NOT NULL,
  804. timezone varchar(8) NOT NULL,
  805. daylight_savings char(1) default 'n' NOT NULL,
  806. localization_is_site_default char(1) NOT NULL default 'n',
  807. time_format char(2) default 'us' NOT NULL,
  808. cp_theme varchar(32) NOT NULL,
  809. profile_theme varchar(32) NOT NULL,
  810. forum_theme varchar(32) NOT NULL,
  811. tracker text NOT NULL,
  812. template_size varchar(2) NOT NULL default '28',
  813. notepad text NOT NULL,
  814. notepad_size varchar(2) NOT NULL default '18',
  815. quick_links text NOT NULL,
  816. quick_tabs text NOT NULL,
  817. pmember_id int(10) NOT NULL default '0',
  818. PRIMARY KEY (member_id),
  819. KEY (`group_id`),
  820. KEY (`unique_id`),
  821. KEY (`password`)
  822. )";
  823. // CP homepage layout
  824. // Each member can have their own control panel layout.
  825. // We store their preferences here.
  826. $D[] = 'exp_member_homepage';
  827. $Q[] = "CREATE TABLE exp_member_homepage (
  828. member_id int(10) unsigned NOT NULL,
  829. recent_entries char(1) NOT NULL default 'l',
  830. recent_entries_order int(3) unsigned NOT NULL default '0',
  831. recent_comments char(1) NOT NULL default 'l',
  832. recent_comments_order int(3) unsigned NOT NULL default '0',
  833. recent_members char(1) NOT NULL default 'n',
  834. recent_members_order int(3) unsigned NOT NULL default '0',
  835. site_statistics char(1) NOT NULL default 'r',
  836. site_statistics_order int(3) unsigned NOT NULL default '0',
  837. member_search_form char(1) NOT NULL default 'n',
  838. member_search_form_order int(3) unsigned NOT NULL default '0',
  839. notepad char(1) NOT NULL default 'r',
  840. notepad_order int(3) unsigned NOT NULL default '0',
  841. bulletin_board char(1) NOT NULL default 'r',
  842. bulletin_board_order int(3) unsigned NOT NULL default '0',
  843. pmachine_news_feed char(1) NOT NULL default 'n',
  844. pmachine_news_feed_order int(3) unsigned NOT NULL default '0',
  845. KEY (member_id)
  846. )";
  847. // Member Groups table
  848. $D[] = 'exp_member_groups';
  849. $Q[] = "CREATE TABLE exp_member_groups (
  850. group_id smallint(4) unsigned NOT NULL,
  851. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  852. group_title varchar(100) NOT NULL,
  853. group_description text NOT NULL,
  854. is_locked char(1) NOT NULL default 'y',
  855. can_view_offline_system char(1) NOT NULL default 'n',
  856. can_view_online_system char(1) NOT NULL default 'y',
  857. can_access_cp char(1) NOT NULL default 'y',
  858. can_access_publish char(1) NOT NULL default 'n',
  859. can_access_edit char(1) NOT NULL default 'n',
  860. can_access_design char(1) NOT NULL default 'n',
  861. can_access_comm char(1) NOT NULL default 'n',
  862. can_access_modules char(1) NOT NULL default 'n',
  863. can_access_admin char(1) NOT NULL default 'n',
  864. can_admin_weblogs char(1) NOT NULL default 'n',
  865. can_admin_members char(1) NOT NULL default 'n',
  866. can_delete_members char(1) NOT NULL default 'n',
  867. can_admin_mbr_groups char(1) NOT NULL default 'n',
  868. can_admin_mbr_templates char(1) NOT NULL default 'n',
  869. can_ban_users char(1) NOT NULL default 'n',
  870. can_admin_utilities char(1) NOT NULL default 'n',
  871. can_admin_preferences char(1) NOT NULL default 'n',
  872. can_admin_modules char(1) NOT NULL default 'n',
  873. can_admin_templates char(1) NOT NULL default 'n',
  874. can_edit_categories char(1) NOT NULL default 'n',
  875. can_delete_categories char(1) NOT NULL default 'n',
  876. can_view_other_entries char(1) NOT NULL default 'n',
  877. can_edit_other_entries char(1) NOT NULL default 'n',
  878. can_assign_post_authors char(1) NOT NULL default 'n',
  879. can_delete_self_entries char(1) NOT NULL default 'n',
  880. can_delete_all_entries char(1) NOT NULL default 'n',
  881. can_view_other_comments char(1) NOT NULL default 'n',
  882. can_edit_own_comments char(1) NOT NULL default 'n',
  883. can_delete_own_comments char(1) NOT NULL default 'n',
  884. can_edit_all_comments char(1) NOT NULL default 'n',
  885. can_delete_all_comments char(1) NOT NULL default 'n',
  886. can_moderate_comments char(1) NOT NULL default 'n',
  887. can_send_email char(1) NOT NULL default 'n',
  888. can_send_cached_email char(1) NOT NULL default 'n',
  889. can_email_member_groups char(1) NOT NULL default 'n',
  890. can_email_mailinglist char(1) NOT NULL default 'n',
  891. can_email_from_profile char(1) NOT NULL default 'n',
  892. can_view_profiles char(1) NOT NULL default 'n',
  893. can_delete_self char(1) NOT NULL default 'n',
  894. mbr_delete_notify_emails varchar(255) NOT NULL,
  895. can_post_comments char(1) NOT NULL default 'n',
  896. exclude_from_moderation char(1) NOT NULL default 'n',
  897. can_search char(1) NOT NULL default 'n',
  898. search_flood_control mediumint(5) unsigned NOT NULL,
  899. can_send_private_messages char(1) NOT NULL default 'n',
  900. prv_msg_send_limit smallint unsigned NOT NULL default '20',
  901. prv_msg_storage_limit smallint unsigned NOT NULL default '60',
  902. can_attach_in_private_messages char(1) NOT NULL default 'n',
  903. can_send_bulletins char(1) NOT NULL default 'n',
  904. include_in_authorlist char(1) NOT NULL default 'n',
  905. include_in_memberlist char(1) NOT NULL default 'y',
  906. include_in_mailinglists char(1) NOT NULL default 'y',
  907. KEY (group_id),
  908. KEY (site_id)
  909. )";
  910. // Weblog access privs
  911. // Member groups assignment for each weblog
  912. $D[] = 'exp_weblog_member_groups';
  913. $Q[] = "CREATE TABLE exp_weblog_member_groups (
  914. group_id smallint(4) unsigned NOT NULL,
  915. weblog_id int(6) unsigned NOT NULL,
  916. KEY (group_id)
  917. )";
  918. // Module access privs
  919. // Member Group assignment for each module
  920. $D[] = 'exp_module_member_groups';
  921. $Q[] = "CREATE TABLE exp_module_member_groups (
  922. group_id smallint(4) unsigned NOT NULL,
  923. module_id mediumint(5) unsigned NOT NULL,
  924. KEY (group_id)
  925. )";
  926. // Template Group access privs
  927. // Member group assignment for each template group
  928. $D[] = 'exp_template_member_groups';
  929. $Q[] = "CREATE TABLE exp_template_member_groups (
  930. group_id smallint(4) unsigned NOT NULL,
  931. template_group_id mediumint(5) unsigned NOT NULL,
  932. KEY (group_id)
  933. )";
  934. // Member Custom Fields
  935. // Stores the defenition of each field
  936. $D[] = 'exp_member_fields';
  937. $Q[] = "CREATE TABLE exp_member_fields (
  938. m_field_id int(4) unsigned NOT NULL auto_increment,
  939. m_field_name varchar(32) NOT NULL,
  940. m_field_label varchar(50) NOT NULL,
  941. m_field_description text NOT NULL,
  942. m_field_type varchar(12) NOT NULL default 'text',
  943. m_field_list_items text NOT NULL,
  944. m_field_ta_rows tinyint(2) default '8',
  945. m_field_maxl smallint(3) NOT NULL,
  946. m_field_width varchar(6) NOT NULL,
  947. m_field_search char(1) NOT NULL default 'y',
  948. m_field_required char(1) NOT NULL default 'n',
  949. m_field_public char(1) NOT NULL default 'y',
  950. m_field_reg char(1) NOT NULL default 'n',
  951. m_field_fmt char(5) NOT NULL default 'none',
  952. m_field_order int(3) unsigned NOT NULL,
  953. PRIMARY KEY (m_field_id)
  954. )";
  955. // Member Data
  956. // Stores the actual data
  957. $D[] = 'exp_member_data';
  958. $Q[] = "CREATE TABLE exp_member_data (
  959. member_id int(10) unsigned NOT NULL,
  960. KEY (member_id)
  961. )";
  962. // Weblog Table
  963. $D[] = 'exp_weblogs';
  964. // Note: The is_user_blog field indicates whether the blog is
  965. // assigned as a "user blogs" weblog
  966. $Q[] = "CREATE TABLE exp_weblogs (
  967. weblog_id int(6) unsigned NOT NULL auto_increment,
  968. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  969. is_user_blog char(1) NOT NULL default 'n',
  970. blog_name varchar(40) NOT NULL,
  971. blog_title varchar(100) NOT NULL,
  972. blog_url varchar(100) NOT NULL,
  973. blog_description varchar(225) NOT NULL,
  974. blog_lang varchar(12) NOT NULL,
  975. blog_encoding varchar(12) NOT NULL,
  976. total_entries mediumint(8) default '0' NOT NULL,
  977. total_comments mediumint(8) default '0' NOT NULL,
  978. total_trackbacks mediumint(8) default '0' NOT NULL,
  979. last_entry_date int(10) unsigned default '0' NOT NULL,
  980. last_comment_date int(10) unsigned default '0' NOT NULL,
  981. last_trackback_date int(10) unsigned default '0' NOT NULL,
  982. cat_group varchar(255) NOT NULL,
  983. status_group int(4) unsigned NOT NULL,
  984. deft_status varchar(50) NOT NULL default 'open',
  985. field_group int(4) unsigned NOT NULL,
  986. search_excerpt int(4) unsigned NOT NULL,
  987. enable_trackbacks char(1) NOT NULL default 'n',
  988. trackback_use_url_title char(1) NOT NULL default 'n',
  989. trackback_max_hits int(2) unsigned NOT NULL default '5',
  990. trackback_field int(4) unsigned NOT NULL,
  991. deft_category varchar(60) NOT NULL,
  992. deft_comments char(1) NOT NULL default 'y',
  993. deft_trackbacks char(1) NOT NULL default 'y',
  994. weblog_require_membership char(1) NOT NULL default 'y',
  995. weblog_max_chars int(5) unsigned NOT NULL,
  996. weblog_html_formatting char(4) NOT NULL default 'all',
  997. weblog_allow_img_urls char(1) NOT NULL default 'y',
  998. weblog_auto_link_urls char(1) NOT NULL default 'y',
  999. weblog_notify char(1) NOT NULL default 'n',
  1000. weblog_notify_emails varchar(255) NOT NULL,
  1001. comment_url varchar(80) NOT NULL,
  1002. comment_system_enabled char(1) NOT NULL default 'y',
  1003. comment_require_membership char(1) NOT NULL default 'n',
  1004. comment_use_captcha char(1) NOT NULL default 'n',
  1005. comment_moderate char(1) NOT NULL default 'n',
  1006. comment_max_chars int(5) unsigned NOT NULL,
  1007. comment_timelock int(5) unsigned NOT NULL default '0',
  1008. comment_require_email char(1) NOT NULL default 'y',
  1009. comment_text_formatting char(5) NOT NULL default 'xhtml',
  1010. comment_html_formatting char(4) NOT NULL default 'safe',
  1011. comment_allow_img_urls char(1) NOT NULL default 'n',
  1012. comment_auto_link_urls char(1) NOT NULL default 'y',
  1013. comment_notify char(1) NOT NULL default 'n',
  1014. comment_notify_authors char(1) NOT NULL default 'n',
  1015. comment_notify_emails varchar(255) NOT NULL,
  1016. comment_expiration int(4) unsigned NOT NULL default '0',
  1017. search_results_url varchar(80) NOT NULL,
  1018. tb_return_url varchar(80) NOT NULL,
  1019. ping_return_url varchar(80) NOT NULL,
  1020. show_url_title char(1) NOT NULL default 'y',
  1021. trackback_system_enabled char(1) NOT NULL default 'n',
  1022. show_trackback_field char(1) NOT NULL default 'y',
  1023. trackback_use_captcha char(1) NOT NULL default 'n',
  1024. show_ping_cluster char(1) NOT NULL default 'y',
  1025. show_options_cluster char(1) NOT NULL default 'y',
  1026. show_button_cluster char(1) NOT NULL default 'y',
  1027. show_forum_cluster char(1) NOT NULL default 'y',
  1028. show_pages_cluster CHAR(1) NOT NULL DEFAULT 'y',
  1029. show_show_all_cluster CHAR(1) NOT NULL DEFAULT 'y',
  1030. show_author_menu char(1) NOT NULL default 'y',
  1031. show_status_menu char(1) NOT NULL default 'y',
  1032. show_categories_menu char(1) NOT NULL default 'y',
  1033. show_date_menu char(1) NOT NULL default 'y',
  1034. rss_url varchar(80) NOT NULL,
  1035. enable_versioning char(1) NOT NULL default 'n',
  1036. enable_qucksave_versioning char(1) NOT NULL default 'n',
  1037. max_revisions smallint(4) unsigned NOT NULL default 10,
  1038. default_entry_title varchar(100) NOT NULL,
  1039. url_title_prefix varchar(80) NOT NULL,
  1040. live_look_template int(10) UNSIGNED NOT NULL default 0,
  1041. PRIMARY KEY (weblog_id),
  1042. KEY (cat_group),
  1043. KEY (status_group),
  1044. KEY (field_group),
  1045. KEY (is_user_blog),
  1046. KEY (site_id)
  1047. )";
  1048. // Weblog Titles
  1049. // We store weblog titles separately from weblog data
  1050. $D[] = 'exp_weblog_titles';
  1051. $Q[] = "CREATE TABLE exp_weblog_titles (
  1052. entry_id int(10) unsigned NOT NULL auto_increment,
  1053. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1054. weblog_id int(4) unsigned NOT NULL,
  1055. author_id int(10) unsigned NOT NULL default '0',
  1056. pentry_id int(10) NOT NULL default '0',
  1057. forum_topic_id int(10) unsigned NOT NULL,
  1058. ip_address varchar(16) NOT NULL,
  1059. title varchar(100) NOT NULL,
  1060. url_title varchar(75) NOT NULL,
  1061. status varchar(50) NOT NULL,
  1062. versioning_enabled char(1) NOT NULL default 'n',
  1063. view_count_one int(10) unsigned NOT NULL default '0',
  1064. view_count_two int(10) unsigned NOT NULL default '0',
  1065. view_count_three int(10) unsigned NOT NULL default '0',
  1066. view_count_four int(10) unsigned NOT NULL default '0',
  1067. allow_comments varchar(1) NOT NULL default 'y',
  1068. allow_trackbacks varchar(1) NOT NULL default 'n',
  1069. sticky varchar(1) NOT NULL default 'n',
  1070. entry_date int(10) NOT NULL,
  1071. dst_enabled varchar(1) NOT NULL default 'n',
  1072. year char(4) NOT NULL,
  1073. month char(2) NOT NULL,
  1074. day char(3) NOT NULL,
  1075. expiration_date int(10) NOT NULL default '0',
  1076. comment_expiration_date int(10) NOT NULL default '0',
  1077. edit_date bigint(14),
  1078. recent_comment_date int(10) NOT NULL,
  1079. comment_total int(4) unsigned NOT NULL default '0',
  1080. trackback_total int(4) unsigned NOT NULL default '0',
  1081. sent_trackbacks text NOT NULL,
  1082. recent_trackback_date int(10) NOT NULL,
  1083. PRIMARY KEY (entry_id),
  1084. KEY (weblog_id),
  1085. KEY (author_id),
  1086. KEY (url_title),
  1087. KEY (status),
  1088. KEY (entry_date),
  1089. KEY (expiration_date),
  1090. KEY (site_id)
  1091. )";
  1092. $D[] = 'exp_entry_versioning';
  1093. $Q[] = "CREATE TABLE exp_entry_versioning (
  1094. version_id int(10) unsigned NOT NULL auto_increment,
  1095. entry_id int(10) unsigned NOT NULL,
  1096. weblog_id int(4) unsigned NOT NULL,
  1097. author_id int(10) unsigned NOT NULL,
  1098. version_date int(10) NOT NULL,
  1099. version_data mediumtext NOT NULL,
  1100. PRIMARY KEY (version_id),
  1101. KEY (entry_id)
  1102. )";
  1103. // Weblog Custom Field Groups
  1104. $D[] = 'exp_field_groups';
  1105. $Q[] = "CREATE TABLE exp_field_groups (
  1106. group_id int(4) unsigned NOT NULL auto_increment,
  1107. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1108. group_name varchar(50) NOT NULL,
  1109. PRIMARY KEY (group_id),
  1110. KEY (site_id)
  1111. )";
  1112. // Weblog Custom Field Definitions
  1113. $D[] = 'exp_weblog_fields';
  1114. $Q[] = "CREATE TABLE exp_weblog_fields (
  1115. field_id int(6) unsigned NOT NULL auto_increment,
  1116. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1117. group_id int(4) unsigned NOT NULL,
  1118. field_name varchar(32) NOT NULL,
  1119. field_label varchar(50) NOT NULL,
  1120. field_instructions TEXT NOT NULL,
  1121. field_type varchar(12) NOT NULL default 'text',
  1122. field_list_items text NOT NULL,
  1123. field_pre_populate char(1) NOT NULL default 'n',
  1124. field_pre_blog_id int(6) unsigned NOT NULL,
  1125. field_pre_field_id int(6) unsigned NOT NULL,
  1126. field_related_to varchar(12) NOT NULL default 'blog',
  1127. field_related_id int(6) unsigned NOT NULL,
  1128. field_related_orderby varchar(12) NOT NULL default 'date',
  1129. field_related_sort varchar(4) NOT NULL default 'desc',
  1130. field_related_max smallint(4) NOT NULL,
  1131. field_ta_rows tinyint(2) default '8',
  1132. field_maxl smallint(3) NOT NULL,
  1133. field_required char(1) NOT NULL default 'n',
  1134. field_text_direction CHAR(3) NOT NULL default 'ltr',
  1135. field_search char(1) NOT NULL default 'n',
  1136. field_is_hidden char(1) NOT NULL default 'n',
  1137. field_fmt varchar(40) NOT NULL default 'xhtml',
  1138. field_show_fmt char(1) NOT NULL default 'y',
  1139. field_order int(3) unsigned NOT NULL,
  1140. PRIMARY KEY (field_id),
  1141. KEY (group_id),
  1142. KEY (site_id)
  1143. )";
  1144. // Relationships table
  1145. $D[] = 'exp_relationships';
  1146. $Q[] = "CREATE TABLE exp_relationships (
  1147. rel_id int(6) unsigned NOT NULL auto_increment,
  1148. rel_parent_id int(10) NOT NULL default '0',
  1149. rel_child_id int(10) NOT NULL default '0',
  1150. rel_type varchar(12) NOT NULL,
  1151. rel_data mediumtext NOT NULL,
  1152. reverse_rel_data mediumtext NOT NULL,
  1153. PRIMARY KEY (rel_id),
  1154. KEY (rel_parent_id),
  1155. KEY (rel_child_id)
  1156. )";
  1157. // Field formatting definitions
  1158. $D[] = 'exp_field_formatting';
  1159. $Q[] = "CREATE TABLE exp_field_formatting (
  1160. field_id int(10) unsigned NOT NULL,
  1161. field_fmt varchar(40) NOT NULL,
  1162. KEY (field_id)
  1163. )";
  1164. // Weblog data
  1165. $D[] = 'exp_weblog_data';
  1166. $Q[] = "CREATE TABLE exp_weblog_data (
  1167. entry_id int(10) unsigned NOT NULL,
  1168. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1169. weblog_id int(4) unsigned NOT NULL,
  1170. field_id_1 text NOT NULL,
  1171. field_ft_1 tinytext NULL,
  1172. field_id_2 text NOT NULL,
  1173. field_ft_2 tinytext NULL,
  1174. field_id_3 text NOT NULL,
  1175. field_ft_3 tinytext NULL,
  1176. KEY (entry_id),
  1177. KEY (weblog_id),
  1178. KEY (site_id)
  1179. )";
  1180. // Ping Status
  1181. // This table saves the status of the xml-rpc ping buttons
  1182. // that were selected when an entry was submitted. This
  1183. // enables us to set the buttons to the same state when editing
  1184. $D[] = 'exp_entry_ping_status';
  1185. $Q[] = "CREATE TABLE exp_entry_ping_status (
  1186. entry_id int(10) unsigned NOT NULL,
  1187. ping_id int(10) unsigned NOT NULL
  1188. )";
  1189. // Comment table
  1190. $D[] = 'exp_comments';
  1191. $Q[] = "CREATE TABLE exp_comments (
  1192. comment_id int(10) unsigned NOT NULL auto_increment,
  1193. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1194. entry_id int(10) unsigned NOT NULL default '0',
  1195. weblog_id int(4) unsigned NOT NULL,
  1196. author_id int(10) unsigned NOT NULL default '0',
  1197. status char(1) NOT NULL default 'o',
  1198. name varchar(50) NOT NULL,
  1199. email varchar(50) NOT NULL,
  1200. url varchar(75) NOT NULL,
  1201. location varchar(50) NOT NULL,
  1202. ip_address varchar(16) NOT NULL,
  1203. comment_date int(10) NOT NULL,
  1204. edit_date timestamp(14),
  1205. comment text NOT NULL,
  1206. notify char(1) NOT NULL default 'n',
  1207. PRIMARY KEY (comment_id),
  1208. KEY (entry_id),
  1209. KEY (weblog_id),
  1210. KEY (author_id),
  1211. KEY (status),
  1212. KEY (site_id)
  1213. )";
  1214. // Trackback table.
  1215. $D[] = 'exp_trackbacks';
  1216. $Q[] = "CREATE TABLE exp_trackbacks (
  1217. trackback_id int(10) unsigned NOT NULL auto_increment,
  1218. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1219. entry_id int(10) unsigned NOT NULL default '0',
  1220. weblog_id int(4) unsigned NOT NULL,
  1221. title varchar(100) NOT NULL,
  1222. content text NOT NULL,
  1223. weblog_name varchar(100) NOT NULL,
  1224. trackback_url varchar(200) NOT NULL,
  1225. trackback_date int(10) NOT NULL,
  1226. trackback_ip varchar(16) NOT NULL,
  1227. PRIMARY KEY (trackback_id),
  1228. KEY (entry_id),
  1229. KEY (weblog_id),
  1230. KEY (site_id)
  1231. )";
  1232. // Status Groups
  1233. $D[] = 'exp_status_groups';
  1234. $Q[] = "CREATE TABLE exp_status_groups (
  1235. group_id int(4) unsigned NOT NULL auto_increment,
  1236. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1237. group_name varchar(50) NOT NULL,
  1238. PRIMARY KEY (group_id),
  1239. KEY (site_id)
  1240. )";
  1241. // Status data
  1242. $D[] = 'exp_statuses';
  1243. $Q[] = "CREATE TABLE exp_statuses (
  1244. status_id int(6) unsigned NOT NULL auto_increment,
  1245. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1246. group_id int(4) unsigned NOT NULL,
  1247. status varchar(50) NOT NULL,
  1248. status_order int(3) unsigned NOT NULL,
  1249. highlight varchar(30) NOT NULL,
  1250. PRIMARY KEY (status_id),
  1251. KEY (group_id),
  1252. KEY (site_id)
  1253. )";
  1254. // Status "no access"
  1255. // Stores groups that can not access certain statuses
  1256. $D[] = 'exp_status_no_access';
  1257. $Q[] = "CREATE TABLE exp_status_no_access (
  1258. status_id int(6) unsigned NOT NULL,
  1259. member_group smallint(4) unsigned NOT NULL
  1260. )";
  1261. // Category Groups
  1262. // Note: The is_user_blog field indicates whether the blog is
  1263. // assigned as a "user blogs" weblog
  1264. $D[] = 'exp_category_groups';
  1265. $Q[] = "CREATE TABLE exp_category_groups (
  1266. group_id int(6) unsigned NOT NULL auto_increment,
  1267. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1268. group_name varchar(50) NOT NULL,
  1269. sort_order char(1) NOT NULL default 'a',
  1270. `field_html_formatting` char(4) NOT NULL default 'all',
  1271. `can_edit_categories` TEXT NOT NULL,
  1272. `can_delete_categories` TEXT NOT NULL,
  1273. is_user_blog char(1) NOT NULL default 'n',
  1274. PRIMARY KEY (group_id),
  1275. KEY (site_id)
  1276. )";
  1277. // Category data
  1278. $D[] = 'exp_categories';
  1279. $Q[] = "CREATE TABLE exp_categories (
  1280. cat_id int(10) unsigned NOT NULL auto_increment,
  1281. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1282. group_id int(6) unsigned NOT NULL,
  1283. parent_id int(4) unsigned NOT NULL,
  1284. cat_name varchar(100) NOT NULL,
  1285. `cat_url_title` varchar(75) NOT NULL,
  1286. cat_description text NOT NULL,
  1287. cat_image varchar(120) NOT NULL,
  1288. cat_order int(4) unsigned NOT NULL,
  1289. PRIMARY KEY (cat_id),
  1290. KEY (group_id),
  1291. KEY (cat_name),
  1292. KEY (site_id)
  1293. )";
  1294. $D[] = 'exp_category_fields';
  1295. $Q[] = "CREATE TABLE `exp_category_fields` (
  1296. `field_id` int(6) unsigned NOT NULL auto_increment,
  1297. `site_id` int(4) unsigned NOT NULL default 1,
  1298. `group_id` int(4) unsigned NOT NULL,
  1299. `field_name` varchar(32) NOT NULL default '',
  1300. `field_label` varchar(50) NOT NULL default '',
  1301. `field_type` varchar(12) NOT NULL default 'text',
  1302. `field_list_items` text NOT NULL,
  1303. `field_maxl` smallint(3) NOT NULL default 128,
  1304. `field_ta_rows` tinyint(2) NOT NULL default 8,
  1305. `field_default_fmt` varchar(40) NOT NULL default 'none',
  1306. `field_show_fmt` char(1) NOT NULL default 'y',
  1307. `field_text_direction` CHAR(3) NOT NULL default 'ltr',
  1308. `field_required` char(1) NOT NULL default 'n',
  1309. `field_order` int(3) unsigned NOT NULL,
  1310. PRIMARY KEY (`field_id`),
  1311. KEY `site_id` (`site_id`),
  1312. KEY `group_id` (`group_id`)
  1313. )";
  1314. $D[] = 'exp_category_field_data';
  1315. $Q[] = "CREATE TABLE `exp_category_field_data` (
  1316. `cat_id` int(4) unsigned NOT NULL,
  1317. `site_id` int(4) unsigned NOT NULL default 1,
  1318. `group_id` int(4) unsigned NOT NULL,
  1319. PRIMARY KEY (`cat_id`),
  1320. KEY `site_id` (`site_id`),
  1321. KEY `group_id` (`group_id`)
  1322. )";
  1323. // Category posts
  1324. // This table stores the weblog entry ID and the category IDs
  1325. // that are assigned to it
  1326. $D[] = 'exp_category_posts';
  1327. $Q[] = "CREATE TABLE exp_category_posts (
  1328. entry_id int(10) unsigned NOT NULL,
  1329. cat_id int(10) unsigned NOT NULL,
  1330. KEY (entry_id),
  1331. KEY (cat_id)
  1332. )";
  1333. // Control panel log
  1334. $D[] = 'exp_cp_log';
  1335. $Q[] = "CREATE TABLE exp_cp_log (
  1336. id int(10) NOT NULL auto_increment,
  1337. site_id INT(4) UNSIGNED NOT NULL DEFAULT 1,
  1338. member_id int(10) unsigned NOT NULL,
  1339. username varchar(32) NOT NULL,
  1340. ip_address varchar(16) default '0' NOT NULL,
  1341. act_date int(10) NOT NULL,
  1342. action varchar(200) NOT NULL,
  1343. PRIMARY KEY (id),
  1344. KEY (site_id)
  1345. )";

Large files files are truncated, but you can click here to view the full file