b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: install ] [ index: install ] [ all elements ]

Source for file _functions_evoupgrade.php

Documentation is available at _functions_evoupgrade.php

  1. <?php
  2. /**
  3.  * This file implements upgrading of DB tables
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  *  {@internal Open Source relicensing agreement:
  10.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  11.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  12.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  13.  *  }}}
  14.  *
  15.  * @package install
  16.  */
  17. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  18.  
  19. load_funcs('_core/_param.funcs.php');
  20.  
  21.  
  22. /**
  23.  * Create a DB version checkpoint
  24.  *
  25.  * This is useful when the next operation might timeout or fail!
  26.  * The checkpoint will allow to restart the script and continue where it stopped
  27.  *
  28.  * @param string version of DB at checkpoint
  29.  */
  30. function set_upgrade_checkpoint$version )
  31. {
  32.     global $DB$script_start_time$locale;
  33.  
  34.     echo "Creating DB schema version checkpoint at $version... ";
  35.  
  36.     if$version 8060 )
  37.     {
  38.         $query 'UPDATE T_settings SET db_version = '.$version;
  39.     }
  40.     else
  41.     {
  42.         $query "UPDATE T_settings
  43.                                 SET set_value = '$version'
  44.                                 WHERE set_name = 'db_version'";
  45.     }
  46.     $DB->query$query );
  47.  
  48.  
  49.     $elapsed_time time($script_start_time;
  50.  
  51.     echo "OK. (Elapsed upgrade time: $elapsed_time seconds)<br />\n";
  52.     flush();
  53.  
  54.     $max_exe_time ini_get'max_execution_time' );
  55.     if$max_exe_time && $elapsed_time $max_exe_time 10 )
  56.     // Max exe time not disabled and we're recahing the end
  57.         echo 'We are reaching the time limit for this script. Please click <a href="index.php?locale='.$locale.'&amp;action=evoupgrade">continue</a>...';
  58.         // Dirty temporary solution:
  59.         exit(0);
  60.     }
  61. }
  62.  
  63.  
  64. /**
  65.  * @return boolean Does a given index key name exist in DB?
  66.  */
  67. function db_index_exists$table$index_name )
  68. {
  69.     global $DB;
  70.  
  71.     $index_name strtolower($index_name);
  72.  
  73.     $DB->query('SHOW INDEX FROM '.$table);
  74.     while$row $DB->get_row() )
  75.     {
  76.         ifstrtolower($row->Key_name== $index_name )
  77.         {
  78.             return true;
  79.         }
  80.     }
  81.  
  82.     return false;
  83. }
  84.  
  85.  
  86. /**
  87.  * @param string Table name
  88.  * @param array Column names
  89.  * @return boolean Does a list of given column names exist in DB?
  90.  */
  91. function db_cols_exist$table$col_names )
  92. {
  93.     global $DB;
  94.  
  95.     foreach$col_names as $k => $v )
  96.         $col_names[$kstrtolower($v);
  97.  
  98.     foreach$DB->get_results('SHOW COLUMNS FROM '.$tableas $row )
  99.         if( ($key array_search(strtolower($row->Field)$col_names)) !== false )
  100.             unset$col_names[$key);
  101.  
  102.     return count($col_names== 0;
  103. }
  104.  
  105. /**
  106.  * Drops a column, if it exists.
  107.  */
  108. function db_drop_col$table$col_name )
  109. {
  110.     global $DB;
  111.  
  112.     ifdb_col_exists($table$col_name) )
  113.         return false;
  114.  
  115.     $DB->query'ALTER TABLE '.$table.' DROP COLUMN '.$col_name );
  116. }
  117.  
  118. /**
  119.  * Add a column, if it does not already exist.
  120.  * If it exists already, a "ALTER TABLE" statement will get executed instead.
  121.  *
  122.  * @return boolean True if the column has been added, False if not.
  123.  */
  124. function db_add_col$table$col_name$col_desc )
  125. {
  126.     global $DB;
  127.  
  128.     ifdb_col_exists($table$col_name) )
  129.     // Column exists already, make sure it's the same.
  130.         $DB->query'ALTER TABLE '.$table.' MODIFY COLUMN '.$col_name.' '.$col_desc );
  131.         return false;
  132.     }
  133.  
  134.     $DB->query'ALTER TABLE '.$table.' ADD COLUMN '.$col_name.' '.$col_desc );
  135. }
  136.  
  137.  
  138. /**
  139.  * Add an INDEX. If another index with the same name already exists, it will
  140.  * get dropped before.
  141.  */
  142. function db_add_index$table$name$def$type 'INDEX' )
  143. {
  144.     global $DB;
  145.     ifdb_index_exists($table$name) )
  146.     {
  147.         $DB->query'ALTER TABLE '.$table.' DROP INDEX '.$name );
  148.     }
  149.     $DB->query'ALTER TABLE '.$table.' ADD '.$type.' '.$name.' ('.$def.')' );
  150. }
  151.  
  152.  
  153. /**
  154.  * Converts languages in a given table into according locales
  155.  *
  156.  * @param string name of the table
  157.  * @param string name of the column where lang is stored
  158.  * @param string name of the table's ID column
  159.  */
  160. function convert_lang_to_locale$table$columnlang$columnID )
  161. {
  162.     global $DB$locales$default_locale;
  163.  
  164.     if!preg_match('/[a-z]{2}-[A-Z]{2}(-.{1,14})?/'$default_locale) )
  165.     // we want a valid locale
  166.         $default_locale 'en-EU';
  167.     }
  168.  
  169.     echo 'Converting langs to locales for '$table'...<br />';
  170.  
  171.     // query given languages in $table
  172.     $query "SELECT $columnID$columnlang FROM $table";
  173.     $languagestoconvert array();
  174.     foreach$DB->get_results$queryARRAY_A as $row )
  175.     {
  176.         // remember the ID for that locale
  177.         $languagestoconvert$row$columnlang ] ][$row$columnID ];
  178.     }
  179.  
  180.     foreach$languagestoconvert as $lkey => $lIDs)
  181.     // converting the languages we've found
  182.         $converted false;
  183.         echo '&nbsp; Converting lang \''$lkey'\' '// (with IDs: '. implode( ', ', $lIDs ). ').. ';
  184.  
  185.         ifpreg_match('/[a-z]{2}-[A-Z]{2}(-.{1,14})?/'$lkey) )
  186.         // Already valid
  187.             echo 'nothing to update, already valid!<br />';
  188.             continue;
  189.         }
  190.  
  191.         if( (strlen($lkey== 2&& substr$default_locale0!= $lkey ) )
  192.         // we have an old two letter lang code to convert
  193.             // and it doesn't match the default locale
  194.             foreach$locales as $newlkey => $v )
  195.             {  // loop given locales
  196.                 ifsubstr($newlkey02== strtolower($lkey) ) # TODO: check if valid/suitable
  197.                 {  // if language matches, update
  198.                     $converted $DB->query"
  199.                         UPDATE $table
  200.                            SET $columnlang = '$newlkey'
  201.                          WHERE $columnlang = '$lkey');
  202.                     echo 'to locale \''$newlkey'\'<br />';
  203.                     break;
  204.                 }
  205.             }
  206.         }
  207.  
  208.         if!$converted )
  209.         // we have nothing converted yet, setting default:
  210.             $DB->query"UPDATE $table
  211.                                             SET $columnlang = '$default_locale'
  212.                                         WHERE $columnlang = '$lkey');
  213.             echo 'forced to default locale \''$default_locale'\'<br />';
  214.         }
  215.     }
  216.     echo "\n";
  217. }  // convert_lang_to_locale(-)
  218.  
  219.  
  220. /**
  221.  * upgrade_b2evo_tables(-)
  222.  */
  223. {
  224.     global $db_config$tableprefix;
  225.     global $baseurl$old_db_version$new_db_version;
  226.     global $Group_Admins$Group_Privileged$Group_Bloggers$Group_Users;
  227.     global $locales$default_locale;
  228.     global $DB;
  229.     global $admin_url;
  230.  
  231.     // used for defaults, when upgrading to 1.6
  232.     global $use_fileupload$fileupload_allowedtypes$fileupload_maxk$doubleCheckReferers;
  233.  
  234.     // new DB-delta functionality
  235.     global $schema_queries$inc_path;
  236.  
  237.     // Load DB schema from modules
  238.     load_db_schema();
  239.  
  240.     load_funcs('_core/model/db/_upgrade.funcs.php');
  241.  
  242.  
  243.     echo '<p>'.T_('Checking DB schema version...').' ';
  244.     $old_db_version get_db_version();
  245.  
  246.     ifempty($old_db_version) )
  247.     {
  248.         echo '<p><strong>OOPS! b2evolution doesn\'t seem to be installed yet.</strong></p>';
  249.         return;
  250.     }
  251.  
  252.     echo $old_db_version' : ';
  253.  
  254.     if$old_db_version 8000 debug_dieT_('This version is too old!') );
  255.     if$old_db_version $new_db_version debug_dieT_('This version is too recent! We cannot downgrade to the version you are trying to install...') );
  256.     echo "OK.<br />\n";
  257.  
  258.  
  259.     // Try to obtain some serious time to do some serious processing (5 minutes)
  260.     @set_time_limit300 );
  261.  
  262.  
  263.  
  264.     if$old_db_version 8010 )
  265.     {
  266.         echo 'Upgrading users table... ';
  267.         $query "ALTER TABLE T_users
  268.                             MODIFY COLUMN user_pass CHAR(32) NOT NULL";
  269.         $DB->query$query );
  270.         echo "OK.<br />\n";
  271.  
  272.         echo 'Upgrading blogs table... ';
  273.         $query "ALTER TABLE T_blogs
  274.                             MODIFY COLUMN blog_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',
  275.                             MODIFY COLUMN blog_longdesc TEXT NULL DEFAULT NULL";
  276.         $DB->query$query );
  277.         echo "OK.<br />\n";
  278.  
  279.         echo 'Upgrading categories table... ';
  280.         $query "ALTER TABLE T_categories
  281.                             ADD COLUMN cat_description VARCHAR(250) NULL DEFAULT NULL,
  282.                             ADD COLUMN cat_longdesc TEXT NULL DEFAULT NULL,
  283.                             ADD COLUMN cat_icon VARCHAR(30) NULL DEFAULT NULL";
  284.         $DB->query$query );
  285.         echo "OK.<br />\n";
  286.  
  287.         echo 'Upgrading posts table... ';
  288.         $query "ALTER TABLE {$tableprefix}posts
  289.                             MODIFY COLUMN post_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',
  290.                             ADD COLUMN post_urltitle VARCHAR(50) NULL DEFAULT NULL AFTER post_title,
  291.                             ADD COLUMN post_url VARCHAR(250) NULL DEFAULT NULL AFTER post_urltitle,
  292.                             ADD COLUMN post_comments ENUM('disabled', 'open', 'closed') NOT NULL DEFAULT 'open' AFTER post_wordcount";
  293.         $DB->query$query );
  294.         echo "OK.<br />\n";
  295.  
  296.         echo 'Generating wordcounts... ';
  297.         load_funcs('items/model/_item.funcs.php');
  298.         $query "SELECT ID, post_content FROM {$tableprefix}posts WHERE post_wordcount IS NULL";
  299.         $i 0;
  300.         foreach$DB->get_results$queryARRAY_A as $row )
  301.         {
  302.             $query_update_wordcount "UPDATE {$tableprefix}posts
  303.                                                                 SET post_wordcount = bpost_count_words($row['post_content']"
  304.                                                                 WHERE ID = " $row['ID'];
  305.             $DB->query($query_update_wordcount);
  306.             $i++;
  307.         }
  308.         echo "OK. ($i rows updated)<br />\n";
  309.  
  310.         set_upgrade_checkpoint'8010' );
  311.     }
  312.  
  313.  
  314.     if$old_db_version 8020 )
  315.     {
  316.         echo 'Encoding passwords... ';
  317.         $query "UPDATE T_users
  318.                             SET user_pass = MD5(user_pass)";
  319.         $DB->query$query );
  320.         echo "OK.<br />\n";
  321.  
  322.         set_upgrade_checkpoint'8020' );
  323.     }
  324.  
  325.  
  326.     if$old_db_version 8030 )
  327.     {
  328.         echo 'Deleting unecessary logs... ';
  329.         $query "DELETE FROM T_hitlog
  330.                             WHERE hit_ignore = 'badchar'";
  331.         $DB->query$query );
  332.         echo "OK.<br />\n";
  333.  
  334.         echo 'Updating blog urls... ';
  335.         $query "SELECT blog_ID, blog_siteurl FROM T_blogs";
  336.         $i 0;
  337.         foreach$DB->get_results$queryARRAY_A as $row )
  338.         {
  339.             $blog_ID $row['blog_ID'];
  340.             $blog_siteurl $row['blog_siteurl'];
  341.             // echo $blog_ID.':'.$blog_siteurl;
  342.             ifstrpos$blog_siteurl.'/'$baseurl !== )
  343.             // If not found at position 0
  344.                 echo ' <strong>WARNING: please check blog #'$blog_ID' manually.</strong><br /> ';
  345.                 continue;
  346.             }
  347.             // crop off the baseurl:
  348.             $blog_siteurl substr$blog_siteurl.'/'strlen$baseurl) );
  349.             // echo ' -> ', $blog_siteurl,'<br />';
  350.  
  351.             $query_update_blog "UPDATE T_blogs SET blog_siteurl = '$blog_siteurl' WHERE blog_ID = $blog_ID";
  352.             // echo $query_update_blog, '<br />';
  353.             $DB->query$query_update_blog );
  354.             $i++;
  355.         }
  356.         echo "OK. ($i rows updated)<br />\n";
  357.  
  358.         set_upgrade_checkpoint'8030' );
  359.     }
  360.  
  361.  
  362.     if$old_db_version 8040 )
  363.     // upgrade to 0.8.7
  364.         echo 'Creating table for Antispam Blackist... ';
  365.         $query "CREATE TABLE T_antispam (
  366.             aspm_ID bigint(11) NOT NULL auto_increment,
  367.             aspm_string varchar(80) NOT NULL,
  368.             aspm_source enum( 'local','reported','central' ) NOT NULL default 'reported',
  369.             PRIMARY KEY aspm_ID (aspm_ID),
  370.             UNIQUE aspm_string (aspm_string)
  371.         )";
  372.         $DB->query$query );
  373.         echo "OK.<br />\n";
  374.  
  375.         echo 'Creating default blacklist entries... ';
  376.         // This string contains antispam information that is obfuscated because some hosting
  377.         // companies prevent uploading PHP files containing "spam" strings.
  378.         // pre_dump(get_antispam_query());
  379.         $query get_antispam_query();
  380.         $DB->query$query );
  381.         echo "OK.<br />\n";
  382.  
  383.         echo 'Upgrading Settings table... ';
  384.         $query "ALTER TABLE T_settings
  385.                             ADD COLUMN last_antispam_update datetime NOT NULL default '2000-01-01 00:00:00'";
  386.         $DB->query$query );
  387.         echo "OK.<br />\n";
  388.  
  389.         set_upgrade_checkpoint'8040' );
  390.     }
  391.  
  392.  
  393.     if$old_db_version 8050 )
  394.     // upgrade to 0.8.9
  395.         echo 'Upgrading blogs table... ';
  396.         $query "ALTER TABLE T_blogs
  397.                             ADD COLUMN blog_allowtrackbacks tinyint(1) NOT NULL default 1,
  398.                             ADD COLUMN blog_allowpingbacks tinyint(1) NOT NULL default 0,
  399.                             ADD COLUMN blog_pingb2evonet tinyint(1) NOT NULL default 0,
  400.                             ADD COLUMN blog_pingtechnorati tinyint(1) NOT NULL default 0,
  401.                             ADD COLUMN blog_pingweblogs tinyint(1) NOT NULL default 0,
  402.                             ADD COLUMN blog_pingblodotgs tinyint(1) NOT NULL default 0,
  403.                             ADD COLUMN blog_disp_bloglist tinyint NOT NULL DEFAULT 1";
  404.         $DB->query$query );
  405.         echo "OK.<br />\n";
  406.  
  407.         // Create User Groups
  408.         global $Group_Admins$Group_Privileged$Group_Bloggers$Group_Users;
  409.         echo 'Creating table for Groups... ';
  410.         $query "CREATE TABLE T_groups (
  411.             grp_ID int(11) NOT NULL auto_increment,
  412.             grp_name varchar(50) NOT NULL default '',
  413.             grp_perm_admin enum('none','hidden','visible') NOT NULL default 'visible',
  414.             grp_perm_blogs enum('user','viewall','editall') NOT NULL default 'user',
  415.             grp_perm_stats enum('none','view','edit') NOT NULL default 'none',
  416.             grp_perm_spamblacklist enum('none','view','edit') NOT NULL default 'none',
  417.             grp_perm_options enum('none','view','edit') NOT NULL default 'none',
  418.             grp_perm_users enum('none','view','edit') NOT NULL default 'none',
  419.             grp_perm_templates TINYINT NOT NULL DEFAULT 0,
  420.             grp_perm_files enum('none','view','add','edit') NOT NULL default 'none',
  421.             PRIMARY KEY grp_ID (grp_ID)
  422.         )";
  423.         $DB->query$query );
  424.         echo "OK.<br />\n";
  425.  
  426.         echo 'Creating default groups... ';
  427.         $Group_Admins new Group()// COPY !
  428.         $Group_Admins->set'name''Administrators' );
  429.         $Group_Admins->set'perm_admin''visible' );
  430.         $Group_Admins->set'perm_blogs''editall' );
  431.         $Group_Admins->set'perm_stats''edit' );
  432.         $Group_Admins->set'perm_spamblacklist''edit' );
  433.         $Group_Admins->set'perm_files''all' );
  434.         $Group_Admins->set'perm_options''edit' );
  435.         $Group_Admins->set'perm_templates');
  436.         $Group_Admins->set'perm_users''edit' );
  437.         $Group_Admins->dbinsert();
  438.  
  439.         $Group_Privileged new Group()// COPY !
  440.         $Group_Privileged->set'name''Privileged Bloggers' );
  441.         $Group_Privileged->set'perm_admin''visible' );
  442.         $Group_Privileged->set'perm_blogs''viewall' );
  443.         $Group_Privileged->set'perm_stats''view' );
  444.         $Group_Privileged->set'perm_spamblacklist''edit' );
  445.         $Group_Privileged->set'perm_files''add' );
  446.         $Group_Privileged->set'perm_options''view' );
  447.         $Group_Privileged->set'perm_templates');
  448.         $Group_Privileged->set'perm_users''view' );
  449.         $Group_Privileged->dbinsert();
  450.  
  451.         $Group_Bloggers new Group()// COPY !
  452.         $Group_Bloggers->set'name''Bloggers' );
  453.         $Group_Bloggers->set'perm_admin''visible' );
  454.         $Group_Bloggers->set'perm_blogs''user' );
  455.         $Group_Bloggers->set'perm_stats''none' );
  456.         $Group_Bloggers->set'perm_spamblacklist''view' );
  457.         $Group_Bloggers->set'perm_files''view' );
  458.         $Group_Bloggers->set'perm_options''none' );
  459.         $Group_Bloggers->set'perm_templates');
  460.         $Group_Bloggers->set'perm_users''none' );
  461.         $Group_Bloggers->dbinsert();
  462.  
  463.         $Group_Users new Group()// COPY !
  464.         $Group_Users->set'name''Basic Users' );
  465.         $Group_Users->set'perm_admin''none' );
  466.         $Group_Users->set'perm_blogs''user' );
  467.         $Group_Users->set'perm_stats''none' );
  468.         $Group_Users->set'perm_spamblacklist''none' );
  469.         $Group_Users->set'perm_files''none' );
  470.         $Group_Users->set'perm_options''none' );
  471.         $Group_Users->set'perm_templates');
  472.         $Group_Users->set'perm_users''none' );
  473.         $Group_Users->dbinsert();
  474.         echo "OK.<br />\n";
  475.  
  476.  
  477.         echo 'Creating table for Blog-User permissions... ';
  478.         $query "CREATE TABLE T_coll_user_perms (
  479.             bloguser_blog_ID int(11) unsigned NOT NULL default 0,
  480.             bloguser_user_ID int(11) unsigned NOT NULL default 0,
  481.             bloguser_ismember tinyint NOT NULL default 0,
  482.             bloguser_perm_poststatuses set('published','deprecated','protected','private','draft') NOT NULL default '',
  483.             bloguser_perm_delpost tinyint NOT NULL default 0,
  484.             bloguser_perm_comments tinyint NOT NULL default 0,
  485.             bloguser_perm_cats tinyint NOT NULL default 0,
  486.             bloguser_perm_properties tinyint NOT NULL default 0,
  487.             bloguser_perm_media_upload tinyint NOT NULL default 0,
  488.             bloguser_perm_media_browse tinyint NOT NULL default 0,
  489.             bloguser_perm_media_change tinyint NOT NULL default 0,
  490.             PRIMARY KEY bloguser_pk (bloguser_blog_ID,bloguser_user_ID)
  491.         )";
  492.         $DB->query$query );
  493.         echo "OK.<br />\n";
  494.         $tablegroups_isuptodate true;
  495.         $tableblogusers_isuptodate true;
  496.  
  497.         echo 'Creating user blog permissions... ';
  498.         // Admin: full rights for all blogs (look 'ma, doing a natural join! :>)
  499.         $query "INSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,
  500.                                 bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments,
  501.                                 bloguser_perm_cats, bloguser_perm_properties)
  502.                             SELECT blog_ID, ID, 1, 'published,deprecated,protected,private,draft', 1, 1, 1, 1
  503.                             FROM T_users, T_blogs
  504.                             WHERE user_level = 10";
  505.         $DB->query$query );
  506.  
  507.         // Normal users: basic rights for all blogs (can't stop doing joins :P)
  508.         $query "INSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,
  509.                                 bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments,
  510.                                 bloguser_perm_cats, bloguser_perm_properties)
  511.                             SELECT blog_ID, ID, 1, 'published,protected,private,draft', 0, 1, 0, 0
  512.                             FROM T_users, T_blogs
  513.                             WHERE user_level > 0 AND user_level < 10";
  514.         $DB->query$query );
  515.         echo "OK.<br />\n";
  516.  
  517.         echo 'Upgrading users table... ';
  518.         $query "ALTER TABLE T_users
  519.                             ADD COLUMN user_notify tinyint(1) NOT NULL default 1,
  520.                             ADD COLUMN user_grp_ID int(4) NOT NULL default 1,
  521.                             MODIFY COLUMN user_idmode varchar(20) NOT NULL DEFAULT 'login',
  522.                             ADD KEY user_grp_ID (user_grp_ID)";
  523.         $DB->query$query );
  524.         echo "OK.<br />\n";
  525.  
  526.         echo 'Assigning user groups... ';
  527.  
  528.         // Default is 1, so admins are already set.
  529.  
  530.         // Basic Users:
  531.         $query "UPDATE T_users
  532.                             SET user_grp_ID = $Group_Users->ID
  533.                             WHERE user_level = 0";
  534.         $DB->query$query );
  535.  
  536.         // Bloggers:
  537.         $query "UPDATE T_users
  538.                             SET user_grp_ID = $Group_Bloggers->ID
  539.                             WHERE user_level > 0 AND user_level < 10";
  540.         $DB->query$query );
  541.  
  542.         echo "OK.<br />\n";
  543.  
  544.         echo 'Upgrading settings table... ';
  545.         $query "ALTER TABLE T_settings
  546.                             DROP COLUMN time_format,
  547.                             DROP COLUMN date_format,
  548.                             ADD COLUMN pref_newusers_grp_ID int unsigned DEFAULT 4 NOT NULL,
  549.                             ADD COLUMN pref_newusers_level tinyint unsigned DEFAULT 1 NOT NULL,
  550.                             ADD COLUMN pref_newusers_canregister tinyint unsigned DEFAULT 0 NOT NULL";
  551.         $DB->query$query );
  552.         echo "OK.<br />\n";
  553.  
  554.         echo 'Creating default groups... ';
  555.         $Group_Admins new Group()// COPY !
  556.         $Group_Admins->set'name''Administrators' );
  557.         $Group_Admins->set'perm_admin''visible' );
  558.         $Group_Admins->set'perm_blogs''editall' );
  559.         $Group_Admins->set'perm_stats''edit' );
  560.         $Group_Admins->set'perm_spamblacklist''edit' );
  561.         $Group_Admins->set'perm_files''all' );
  562.         $Group_Admins->set'perm_options''edit' );
  563.         $Group_Admins->set'perm_templates');
  564.         $Group_Admins->set'perm_users''edit' );
  565.         $Group_Admins->dbinsert();
  566.  
  567.         $Group_Privileged new Group()// COPY !
  568.         $Group_Privileged->set'name''Privileged Bloggers' );
  569.         $Group_Privileged->set'perm_admin''visible' );
  570.         $Group_Privileged->set'perm_blogs''viewall' );
  571.         $Group_Privileged->set'perm_stats''view' );
  572.         $Group_Privileged->set'perm_spamblacklist''edit' );
  573.         $Group_Privileged->set'perm_files''add' );
  574.         $Group_Privileged->set'perm_options''view' );
  575.         $Group_Privileged->set'perm_templates');
  576.         $Group_Privileged->set'perm_users''view' );
  577.         $Group_Privileged->dbinsert();
  578.  
  579.         $Group_Bloggers new Group()// COPY !
  580.         $Group_Bloggers->set'name''Bloggers' );
  581.         $Group_Bloggers->set'perm_admin''visible' );
  582.         $Group_Bloggers->set'perm_blogs''user' );
  583.         $Group_Bloggers->set'perm_stats''none' );
  584.         $Group_Bloggers->set'perm_spamblacklist''view' );
  585.         $Group_Bloggers->set'perm_files''view' );
  586.         $Group_Bloggers->set'perm_options''none' );
  587.         $Group_Bloggers->set'perm_templates');
  588.         $Group_Bloggers->set'perm_users''none' );
  589.         $Group_Bloggers->dbinsert();
  590.  
  591.         $Group_Users new Group()// COPY !
  592.         $Group_Users->set'name''Basic Users' );
  593.         $Group_Users->set'perm_admin''none' );
  594.         $Group_Users->set'perm_blogs''user' );
  595.         $Group_Users->set'perm_stats''none' );
  596.         $Group_Users->set'perm_spamblacklist''none' );
  597.         $Group_Users->set'perm_files''none' );
  598.         $Group_Users->set'perm_options''none' );
  599.         $Group_Users->set'perm_templates');
  600.         $Group_Users->set'perm_users''none' );
  601.         $Group_Users->dbinsert();
  602.         echo "OK.<br />\n";
  603.  
  604.         set_upgrade_checkpoint'8050' );
  605.     }
  606.  
  607.  
  608.     if$old_db_version 8060 )
  609.     // upgrade to 0.9
  610.         // Important check:
  611.         $stub_list $DB->get_col"
  612.             SELECT blog_stub
  613.               FROM T_blogs
  614.              GROUP BY blog_stub
  615.             HAVING COUNT(*) > 1" );
  616.         if!empty($stub_list) )
  617.         {
  618.             echo '<div class="error"><p class="error">';
  619.             printfT_("It appears that the following blog stub names are used more than once: ['%s']" )implode"','"$stub_list ) );
  620.             echo '</p><p>';
  621.             printfT_("I can't upgrade until you make them unique. DB field: [%s]" )$db_config['aliases']['T_blogs'].'.blog_stub' );
  622.             echo '</p></div>';
  623.             return false;
  624.         }
  625.  
  626.         // Create locales
  627.         echo 'Creating table for Locales... ';
  628.         $query "CREATE TABLE T_locales (
  629.                 loc_locale varchar(20) NOT NULL default '',
  630.                 loc_charset varchar(15) NOT NULL default 'iso-8859-1',
  631.                 loc_datefmt varchar(10) NOT NULL default 'y-m-d',
  632.                 loc_timefmt varchar(10) NOT NULL default 'H:i:s',
  633.                 loc_name varchar(40) NOT NULL default '',
  634.                 loc_messages varchar(20) NOT NULL default '',
  635.                 loc_priority tinyint(4) UNSIGNED NOT NULL default '0',
  636.                 loc_enabled tinyint(4) NOT NULL default '1',
  637.                 PRIMARY KEY loc_locale( loc_locale )
  638.             ) COMMENT='saves available locales'";
  639.         $DB->query$query );
  640.         echo "OK.<br />\n";
  641.  
  642.         echo 'Upgrading posts table... ';
  643.         $query "UPDATE {$tableprefix}posts
  644.                             SET post_urltitle = NULL";
  645.         $DB->query$query );
  646.  
  647.         $query "ALTER TABLE {$tableprefix}posts
  648.                             CHANGE COLUMN post_date post_issue_date datetime NOT NULL default '1000-01-01 00:00:00',
  649.                             ADD COLUMN post_mod_date datetime NOT NULL default '1000-01-01 00:00:00'
  650.                                         AFTER post_issue_date,
  651.                             CHANGE COLUMN post_lang post_locale varchar(20) NOT NULL default 'en-EU',
  652.                             DROP COLUMN post_url,
  653.                             CHANGE COLUMN post_trackbacks post_url varchar(250) NULL default NULL,
  654.                             MODIFY COLUMN post_flags SET( 'pingsdone', 'imported' ),
  655.                             ADD COLUMN post_renderers VARCHAR(179) NOT NULL default 'default',
  656.                             DROP INDEX post_date,
  657.                             ADD INDEX post_issue_date( post_issue_date ),
  658.                             ADD UNIQUE post_urltitle( post_urltitle )";
  659.         $DB->query$query );
  660.  
  661.         $query "UPDATE {$tableprefix}posts
  662.                             SET post_mod_date = post_issue_date";
  663.         $DB->query$query );
  664.         echo "OK.<br />\n";
  665.  
  666.         // convert given languages to locales
  667.         convert_lang_to_locale"{$tableprefix}posts"'post_locale''ID' );
  668.  
  669.         echo 'Upgrading blogs table... ';
  670.         $query "ALTER TABLE T_blogs
  671.                             CHANGE blog_lang blog_locale varchar(20) NOT NULL default 'en-EU',
  672.                             CHANGE blog_roll blog_notes TEXT NULL,
  673.                             MODIFY COLUMN blog_default_skin VARCHAR(30) NOT NULL DEFAULT 'custom',
  674.                             DROP COLUMN blog_filename,
  675.                             ADD COLUMN blog_access_type VARCHAR(10) NOT NULL DEFAULT 'index.php' AFTER blog_locale,
  676.                             ADD COLUMN blog_force_skin tinyint(1) NOT NULL default 0 AFTER blog_default_skin,
  677.                             ADD COLUMN blog_in_bloglist tinyint(1) NOT NULL DEFAULT 1 AFTER blog_disp_bloglist,
  678.                             ADD COLUMN blog_links_blog_ID INT(4) NOT NULL DEFAULT 0,
  679.                             ADD UNIQUE KEY blog_stub (blog_stub)";
  680.         $DB->query$query );
  681.  
  682.         $query "UPDATE T_blogs
  683.                             SET blog_access_type = 'stub',
  684.                                     blog_default_skin = 'custom'";
  685.         $DB->query$query );
  686.  
  687.         echo "OK.<br />\n";
  688.  
  689.         // convert given languages to locales
  690.         convert_lang_to_locale'T_blogs''blog_locale''blog_ID' );
  691.  
  692.  
  693.         echo 'Converting settings table... ';
  694.  
  695.         // get old settings
  696.         $query 'SELECT * FROM T_settings';
  697.         $row $DB->get_row$queryARRAY_A );
  698.  
  699.         #echo 'oldrow:<br />'; pre_dump($row);
  700.         $transform array(
  701.             'posts_per_page' => array(5),      // note: moved to blogsettings in 2.0
  702.             'what_to_show' => array('posts'),  // note: moved to blogsettings in 2.0
  703.             'archive_mode' => array('monthly'),// note: moved to blogsettings in 2.0
  704.             'time_difference' => array(0),
  705.             'AutoBR' => array(0),
  706.             'last_antispam_update' => array('2000-01-01 00:00:00''antispam_last_update'),
  707.             'pref_newusers_grp_ID' => array($Group_Users->ID'newusers_grp_ID'),
  708.             'pref_newusers_level'  => array(1'newusers_level'),
  709.             'pref_newusers_canregister' => array(0'newusers_canregister'),
  710.         );
  711.  
  712.         $_trans array();
  713.         foreach$transform as $oldkey => $newarr )
  714.         {
  715.             $newname isset($newarr[1]$newarr[1$oldkey );
  716.             if!isset$row[$oldkey) )
  717.             {
  718.                 echo '&nbsp;&middot;Setting '.$oldkey.' not found, using defaults.<br />';
  719.                 $_trans$newname $newarr[0];
  720.             }
  721.             else
  722.             {
  723.                 $_trans$newname $row[$oldkey];
  724.             }
  725.         }
  726.  
  727.         // drop old table
  728.         $DB->query'DROP TABLE IF EXISTS T_settings' );
  729.  
  730.         // create new table
  731.         $DB->query(
  732.             'CREATE TABLE T_settings (
  733.                 set_name VARCHAR( 30 ) NOT NULL ,
  734.                 set_value VARCHAR( 255 ) NULL ,
  735.                 PRIMARY KEY ( set_name )
  736.             )');
  737.  
  738.         // insert defaults and use transformed settings
  739.         create_default_settings$_trans );
  740.  
  741.         if!isset$tableblogusers_isuptodate ) )
  742.         {
  743.             echo 'Upgrading Blog-User permissions table... ';
  744.             $query "ALTER TABLE T_coll_user_perms
  745.                                 ADD COLUMN bloguser_ismember tinyint NOT NULL default 0 AFTER bloguser_user_ID";
  746.             $DB->query$query );
  747.  
  748.             // Any row that is created holds at least one permission,
  749.             // minimum permsission is to be a member, so we add that one too, to all existing rows.
  750.             $DB->query"UPDATE T_coll_user_perms
  751.                                             SET bloguser_ismember = 1" );
  752.             echo "OK.<br />\n";
  753.         }
  754.  
  755.         echo 'Upgrading Comments table... ';
  756.         $query "ALTER TABLE T_comments
  757.                             ADD COLUMN comment_author_ID int unsigned NULL default NULL AFTER comment_status,
  758.                             MODIFY COLUMN comment_author varchar(100) NULL,
  759.                             MODIFY COLUMN comment_author_email varchar(100) NULL,
  760.                             MODIFY COLUMN comment_author_url varchar(100) NULL,
  761.                             MODIFY COLUMN comment_author_IP varchar(23) NOT NULL default ''";
  762.         $DB->query$query );
  763.         echo "OK.<br />\n";
  764.  
  765.         echo 'Upgrading Users table... ';
  766.         $query "ALTER TABLE T_users ADD user_locale VARCHAR( 20 ) DEFAULT 'en-EU' NOT NULL AFTER user_yim";
  767.         $DB->query$query );
  768.         echo "OK.<br />\n";
  769.  
  770.         set_upgrade_checkpoint'8060' );
  771.     }
  772.  
  773.  
  774.     if$old_db_version 8062 )
  775.     // upgrade to 0.9.0.4
  776.         echo "Checking for extra quote escaping in posts... ";
  777.         $query "SELECT ID, post_title, post_content
  778.                                 FROM {$tableprefix}posts
  779.                              WHERE post_title LIKE '%\\\\\\\\\'%'
  780.                                     OR post_title LIKE '%\\\\\\\\\"%'
  781.                                     OR post_content LIKE '%\\\\\\\\\'%'
  782.                                     OR post_content LIKE '%\\\\\\\\\"%' ";
  783.         /* FP: the above looks overkill, but MySQL is really full of surprises...
  784.                         tested on 4.0.14-nt */
  785.         // echo $query;
  786.         $rows $DB->get_results$queryARRAY_A );
  787.         if$DB->num_rows )
  788.         {
  789.             echo 'Updating '.$DB->num_rows.' posts... ';
  790.             foreach$rows as $row )
  791.             {
  792.                 // echo '<br />'.$row['post_title'];
  793.                 $query "UPDATE {$tableprefix}posts
  794.                                     SET post_title = ".$DB->quotestripslashes$row['post_title') ).",
  795.                                             post_content = ".$DB->quotestripslashes$row['post_content') )."
  796.                                     WHERE ID = ".$row['ID'];
  797.                 // echo '<br />'.$query;
  798.                 $DB->query$query );
  799.             }
  800.         }
  801.         echo "OK.<br />\n";
  802.  
  803.         set_upgrade_checkpoint'8062' );
  804.     }
  805.  
  806.  
  807.     if$old_db_version 8064 )
  808.     // upgrade to 0.9.0.6
  809.         cleanup_comment_quotes();
  810.  
  811.         set_upgrade_checkpoint'8064' );
  812.     }
  813.  
  814.  
  815.     if$old_db_version 8066 )
  816.     {    // upgrade to 0.9.1
  817.         echo 'Adding catpost index... ';
  818.         $DB->query'ALTER TABLE T_postcats ADD UNIQUE catpost ( postcat_cat_ID, postcat_post_ID )' );
  819.         echo "OK.<br />\n";
  820.  
  821.         set_upgrade_checkpoint'8066' );
  822.     }
  823.  
  824.  
  825.     if$old_db_version 8800 )
  826.     // ---------------------------------- upgrade to 1.6 "phoenix ALPHA"
  827.  
  828.         echo 'Dropping old Hitlog table... ';
  829.         $DB->query'DROP TABLE IF EXISTS T_hitlog' );
  830.         echo "OK.<br />\n";
  831.  
  832.         // New tables:
  833.             echo 'Creating table for active sessions... ';
  834.             $DB->query"CREATE TABLE T_sessions (
  835.                                             sess_ID        INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  836.                                             sess_key       CHAR(32) NULL,
  837.                                             sess_lastseen  DATETIME NOT NULL,
  838.                                             sess_ipaddress VARCHAR(15) NOT NULL DEFAULT '',
  839.                                             sess_user_ID   INT(10) DEFAULT NULL,
  840.                                             sess_agnt_ID   INT UNSIGNED NULL,
  841.                                             sess_data      TEXT DEFAULT NULL,
  842.                                             PRIMARY KEY( sess_ID )
  843.                                         )" );
  844.             echo "OK.<br />\n";
  845.  
  846.  
  847.             echo 'Creating user settings table... ';
  848.             $DB->query"CREATE TABLE T_usersettings (
  849.                                             uset_user_ID INT(11) UNSIGNED NOT NULL,
  850.                                             uset_name    VARCHAR( 30 ) NOT NULL,
  851.                                             uset_value   VARCHAR( 255 ) NULL,
  852.                                             PRIMARY KEY ( uset_user_ID, uset_name )
  853.                                         )");
  854.             echo "OK.<br />\n";
  855.  
  856.  
  857.             echo 'Creating plugins table... ';
  858.             $DB->query"CREATE TABLE T_plugins (
  859.                                             plug_ID        INT(11) UNSIGNED NOT NULL auto_increment,
  860.                                             plug_priority  INT(11) NOT NULL default 50,
  861.                                             plug_classname VARCHAR(40) NOT NULL default '',
  862.                                             PRIMARY KEY ( plug_ID )
  863.                                         )");
  864.             echo "OK.<br />\n";
  865.  
  866.  
  867.             echo 'Creating table for Post Statuses... ';
  868.             $query="CREATE TABLE {$tableprefix}poststatuses (
  869.                                             pst_ID   int(11) unsigned not null AUTO_INCREMENT,
  870.                                             pst_name varchar(30)      not null,
  871.                                             primary key ( pst_ID )
  872.                                         )";
  873.             $DB->query$query );
  874.             echo "OK.<br />\n";
  875.  
  876.  
  877.             echo 'Creating table for Post Types... ';
  878.             $query="CREATE TABLE {$tableprefix}posttypes (
  879.                                             ptyp_ID   int(11) unsigned not null AUTO_INCREMENT,
  880.                                             ptyp_name varchar(30)      not null,
  881.                                             primary key (ptyp_ID)
  882.                                         )";
  883.             $DB->query$query );
  884.             echo "OK.<br />\n";
  885.  
  886.  
  887.             echo 'Creating table for File Meta Data... ';
  888.             $DB->query"CREATE TABLE T_files (
  889.                                          file_ID        int(11) unsigned  not null AUTO_INCREMENT,
  890.                                          file_root_type enum('absolute','user','group','collection') not null default 'absolute',
  891.                                          file_root_ID   int(11) unsigned  not null default 0,
  892.                                          file_path      varchar(255)      not null default '',
  893.                                          file_title     varchar(255),
  894.                                          file_alt       varchar(255),
  895.                                          file_desc      text,
  896.                                          primary key (file_ID),
  897.                                          unique file (file_root_type, file_root_ID, file_path)
  898.                                     )" );
  899.             echo "OK.<br />\n";
  900.  
  901.  
  902.             echo 'Creating table for base domains... ';
  903.             $DB->query"CREATE TABLE T_basedomains (
  904.                                         dom_ID     INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  905.                                         dom_name   VARCHAR(250) NOT NULL DEFAULT '',
  906.                                         dom_status ENUM('unknown','whitelist','blacklist') NOT NULL DEFAULT 'unknown',
  907.                                         dom_type   ENUM('unknown','normal','searcheng','aggregator') NOT NULL DEFAULT 'unknown',
  908.                                         PRIMARY KEY (dom_ID),
  909.                                         UNIQUE dom_name (dom_name)
  910.                                     )" );    // fp> the unique key was only named in version 1.9. Crap. Put the name back here to save as many souls as possible. bulk has not upgraded from 0.9 yet :/
  911.             echo "OK.<br />\n";
  912.  
  913.         set_upgrade_checkpoint'8820' );
  914.     }
  915.  
  916.  
  917.     if$old_db_version 8840 )
  918.     {
  919.  
  920.             echo 'Creating table for user agents... ';
  921.             $DB->query"CREATE TABLE T_useragents (
  922.                                         agnt_ID        INT UNSIGNED NOT NULL AUTO_INCREMENT,
  923.                                         agnt_signature VARCHAR(250) NOT NULL,
  924.                                         agnt_type      ENUM('rss','robot','browser','unknown') DEFAULT 'unknown' NOT NULL,
  925.                                         PRIMARY KEY (agnt_ID) )" );
  926.             echo "OK.<br />\n";
  927.  
  928.  
  929.             echo 'Creating table for Hit-Logs... ';
  930.             $query "CREATE TABLE T_hitlog (
  931.                                     hit_ID             INT(11) NOT NULL AUTO_INCREMENT,
  932.                                     hit_sess_ID        INT UNSIGNED,
  933.                                     hit_datetime       DATETIME NOT NULL,
  934.                                     hit_uri            VARCHAR(250) DEFAULT NULL,
  935.                                     hit_referer_type   ENUM('search','blacklist','referer','direct','spam') NOT NULL,
  936.                                     hit_referer        VARCHAR(250) DEFAULT NULL,
  937.                                     hit_referer_dom_ID INT UNSIGNED DEFAULT NULL,
  938.                                     hit_blog_ID        int(11) UNSIGNED NULL DEFAULT NULL,
  939.                                     hit_remote_addr    VARCHAR(40) DEFAULT NULL,
  940.                                     PRIMARY KEY (hit_ID),
  941.                                     INDEX hit_datetime ( hit_datetime ),
  942.                                     INDEX hit_blog_ID (hit_blog_ID)
  943.                                 )";
  944.             $DB->query$query );
  945.             echo "OK.<br />\n";
  946.  
  947.  
  948.             echo 'Creating table for subscriptions... ';
  949.             $DB->query"CREATE TABLE T_subscriptions (
  950.                                          sub_coll_ID     int(11) unsigned    not null,
  951.                                          sub_user_ID     int(11) unsigned    not null,
  952.                                          sub_items       tinyint(1)          not null,
  953.                                          sub_comments    tinyint(1)          not null,
  954.                                          primary key (sub_coll_ID, sub_user_ID)
  955.                                         )" );
  956.             echo "OK.<br />\n";
  957.  
  958.  
  959.             echo 'Creating table for blog-group permissions... ';
  960.             $DB->query"CREATE TABLE T_coll_group_perms (
  961.                                             bloggroup_blog_ID int(11) unsigned NOT NULL default 0,
  962.                                             bloggroup_group_ID int(11) unsigned NOT NULL default 0,
  963.                                             bloggroup_ismember tinyint NOT NULL default 0,
  964.                                             bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft') NOT NULL default '',
  965.                                             bloggroup_perm_delpost tinyint NOT NULL default 0,
  966.                                             bloggroup_perm_comments tinyint NOT NULL default 0,
  967.                                             bloggroup_perm_cats tinyint NOT NULL default 0,
  968.                                             bloggroup_perm_properties tinyint NOT NULL default 0,
  969.                                             bloggroup_perm_media_upload tinyint NOT NULL default 0,
  970.                                             bloggroup_perm_media_browse tinyint NOT NULL default 0,
  971.                                             bloggroup_perm_media_change tinyint NOT NULL default 0,
  972.                                             PRIMARY KEY bloggroup_pk (bloggroup_blog_ID,bloggroup_group_ID) )" );
  973.             echo "OK.<br />\n";
  974.  
  975.  
  976.         echo 'Upgrading blogs table... ';
  977.         $query "ALTER TABLE T_blogs
  978.                             MODIFY COLUMN blog_ID int(11) unsigned NOT NULL auto_increment,
  979.                             MODIFY COLUMN blog_links_blog_ID INT(11) NULL DEFAULT NULL,
  980.                             CHANGE COLUMN blog_stub blog_urlname VARCHAR(255) NOT NULL DEFAULT 'urlname',
  981.                             ADD COLUMN blog_allowcomments VARCHAR(20) NOT NULL default 'post_by_post' AFTER blog_keywords,
  982.                             ADD COLUMN blog_allowblogcss TINYINT(1) NOT NULL default 1 AFTER blog_allowpingbacks,
  983.                             ADD COLUMN blog_allowusercss TINYINT(1) NOT NULL default 1 AFTER blog_allowblogcss,
  984.                             ADD COLUMN blog_stub VARCHAR(255) NOT NULL DEFAULT 'stub' AFTER blog_staticfilename,
  985.                             ADD COLUMN blog_commentsexpire INT(4) NOT NULL DEFAULT 0 AFTER blog_links_blog_ID,
  986.                             ADD COLUMN blog_media_location ENUM( 'default', 'subdir', 'custom', 'none' ) DEFAULT 'default' NOT NULL AFTER blog_commentsexpire,
  987.                             ADD COLUMN blog_media_subdir VARCHAR( 255 ) NOT NULL AFTER blog_media_location,
  988.                             ADD COLUMN blog_media_fullpath VARCHAR( 255 ) NOT NULL AFTER blog_media_subdir,
  989.                             ADD COLUMN blog_media_url VARCHAR(255) NOT NULL AFTER blog_media_fullpath,
  990.                             DROP INDEX blog_stub,
  991.                             ADD UNIQUE blog_urlname ( blog_urlname )";
  992.         $DB->query$query );
  993.         echo "OK.<br />\n";
  994.  
  995.         set_upgrade_checkpoint'8840' );
  996.     }
  997.  
  998.  
  999.     if$old_db_version 8850 )
  1000.     {
  1001.  
  1002.         echo 'Updating relative URLs... ';
  1003.         // We need to move the slashes to the end:
  1004.         $query "UPDATE T_blogs
  1005.                                  SET blog_siteurl = CONCAT( SUBSTRING(blog_siteurl,2) , '/' )
  1006.                              WHERE blog_siteurl LIKE '/%'";
  1007.         $DB->query$query );
  1008.         echo "OK.<br />\n";
  1009.  
  1010.         echo 'Copying urlnames to stub names... ';
  1011.         $query 'UPDATE T_blogs
  1012.                             SET blog_stub = blog_urlname';
  1013.         $DB->query$query );
  1014.         echo "OK.<br />\n";
  1015.  
  1016.         set_upgrade_checkpoint'8850' );
  1017.     }
  1018.  
  1019.  
  1020.     if$old_db_version 8855 )
  1021.     {
  1022.  
  1023.         echo 'Upgrading posts table... ';
  1024.         $query "ALTER TABLE {$tableprefix}posts
  1025.                             DROP COLUMN post_karma,
  1026.                             DROP COLUMN post_autobr,
  1027.                             DROP INDEX post_author,
  1028.                             DROP INDEX post_issue_date,
  1029.                             DROP INDEX post_category,
  1030.                             CHANGE COLUMN ID post_ID int(11) unsigned NOT NULL auto_increment,
  1031.                             CHANGE COLUMN post_author    post_creator_user_ID int(11) unsigned NOT NULL,
  1032.                             CHANGE COLUMN post_issue_date    post_datestart datetime NOT NULL,
  1033.                             CHANGE COLUMN post_mod_date    post_datemodified datetime NOT NULL,
  1034.                             CHANGE COLUMN post_category post_main_cat_ID int(11) unsigned NOT NULL,
  1035.                             ADD post_parent_ID                int(11) unsigned NULL AFTER post_ID,
  1036.                             ADD post_lastedit_user_ID    int(11) unsigned NULL AFTER post_creator_user_ID,
  1037.                             ADD post_assigned_user_ID    int(11) unsigned NULL AFTER post_lastedit_user_ID,
  1038.                             ADD post_datedeadline         datetime NULL AFTER post_datestart,
  1039.                             ADD post_datecreated            datetime NULL AFTER post_datedeadline,
  1040.                             ADD post_pst_ID                        int(11) unsigned NULL AFTER post_status,
  1041.                             ADD post_ptyp_ID                    int(11) unsigned NULL AFTER post_pst_ID,
  1042.                             ADD post_views                        int(11) unsigned NOT NULL DEFAULT 0 AFTER post_flags,
  1043.                             ADD post_commentsexpire        datetime DEFAULT NULL AFTER post_comments,
  1044.                             ADD post_priority                    int(11) unsigned null,
  1045.                             ADD INDEX post_creator_user_ID( post_creator_user_ID ),
  1046.                             ADD INDEX post_parent_ID( post_parent_ID ),
  1047.                             ADD INDEX post_assigned_user_ID( post_assigned_user_ID ),
  1048.                             ADD INDEX post_datestart( post_datestart ),
  1049.                             ADD INDEX post_main_cat_ID( post_main_cat_ID ),
  1050.                             ADD INDEX post_ptyp_ID( post_ptyp_ID ),
  1051.                             ADD INDEX post_pst_ID( post_pst_ID ) ";
  1052.         $DB->query$query );
  1053.         echo "OK.<br />\n";
  1054.  
  1055.         set_upgrade_checkpoint'8855' );
  1056.     }
  1057.  
  1058.  
  1059.     if$old_db_version 8860 )
  1060.     {
  1061.         echo 'Updating post data... ';
  1062.         $query "UPDATE {$tableprefix}posts
  1063.                             SET post_lastedit_user_ID = post_creator_user_ID,
  1064.                                     post_datecreated = post_datestart";
  1065.         $DB->query$query );
  1066.         echo "OK.<br />\n";
  1067.  
  1068.  
  1069.         task_begin'Upgrading users table... ' );
  1070.         $DB->query'UPDATE T_users
  1071.                                       SET dateYMDhour = \'2000-01-01 00:00:00\'
  1072.                                     WHERE dateYMDhour = \'0000-00-00 00:00:00\'' );
  1073.         $DB->query'ALTER TABLE T_users
  1074.                             MODIFY COLUMN dateYMDhour DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
  1075.                             CHANGE COLUMN ID user_ID int(11) unsigned NOT NULL auto_increment,
  1076.                             MODIFY COLUMN user_icq int(11) unsigned DEFAULT 0 NOT NULL,
  1077.                             ADD COLUMN user_showonline tinyint(1) NOT NULL default 1 AFTER user_notify' );
  1078.         task_end();
  1079.  
  1080.  
  1081.         set_upgrade_checkpoint'8860' );
  1082.     }
  1083.  
  1084.  
  1085.     if$old_db_version 8900 )
  1086.     {
  1087.  
  1088.         echo 'Setting new defaults... ';
  1089.         $query 'INSERT INTO T_settings (set_name, set_value)
  1090.                             VALUES
  1091.                                 ( "reloadpage_timeout", "300" ),
  1092.                                 ( "upload_enabled", "'.(isset($use_fileupload? (int)$use_fileupload '1').'" ),
  1093.                                 ( "upload_allowedext", "'.(isset($fileupload_allowedtypes$fileupload_allowedtypes 'jpg gif png').'" ),
  1094.                                 ( "upload_maxkb", "'.(isset($fileupload_maxk? (int)$fileupload_maxk '96').'" )
  1095.                             ';
  1096.         $DB->query$query );
  1097.         // Replace "paged" mode with "posts" // note: moved to blogsettings in 2.0
  1098.         $DB->query'UPDATE T_settings
  1099.                                         SET set_value = "posts"
  1100.                                     WHERE set_name = "what_to_show"
  1101.                                       AND set_value = "paged"' );
  1102.         echo "OK.<br />\n";
  1103.  
  1104.  
  1105.         if!isset$tableblogusers_isuptodate ) )
  1106.         {    // We have created the blogusers table before and it's already clean!
  1107.             echo 'Altering table for Blog-User permissions... ';
  1108.             $DB->query'ALTER TABLE T_coll_user_perms
  1109.                                         MODIFY COLUMN bloguser_blog_ID int(11) unsigned NOT NULL default 0,
  1110.                                         MODIFY COLUMN bloguser_user_ID int(11) unsigned NOT NULL default 0,
  1111.                                         ADD COLUMN bloguser_perm_media_upload tinyint NOT NULL default 0,
  1112.                                         ADD COLUMN bloguser_perm_media_browse tinyint NOT NULL default 0,
  1113.                                         ADD COLUMN bloguser_perm_media_change tinyint NOT NULL default 0' );
  1114.             echo "OK.<br />\n";
  1115.         }
  1116.  
  1117.  
  1118.         task_begin'Altering comments table...' );
  1119.         $DB->query'UPDATE T_comments
  1120.                                       SET comment_date = \'2000-01-01 00:00:00\'
  1121.                                     WHERE comment_date = \'0000-00-00 00:00:00\'' );
  1122.         $DB->query'ALTER TABLE T_comments
  1123.                                     MODIFY COLUMN comment_date DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
  1124.                                     MODIFY COLUMN comment_post_ID        int(11) unsigned NOT NULL default 0' );
  1125.         task_end();
  1126.  
  1127.         set_upgrade_checkpoint'8900' );
  1128.     }
  1129.  
  1130.     if$old_db_version 9000 )
  1131.     {
  1132.         echo 'Altering Posts to Categories table... ';
  1133.         $DB->query"ALTER TABLE T_postcats
  1134.                                     MODIFY COLUMN postcat_post_ID int(11) unsigned NOT NULL,
  1135.                                     MODIFY COLUMN postcat_cat_ID int(11) unsigned NOT NULL" );
  1136.         echo "OK.<br />\n";
  1137.  
  1138.  
  1139.         echo 'Altering Categories table... ';
  1140.         $DB->query"ALTER TABLE T_categories
  1141.                                     MODIFY COLUMN cat_ID int(11) unsigned NOT NULL auto_increment,
  1142.                                     MODIFY COLUMN cat_parent_ID int(11) unsigned NULL,
  1143.                                     MODIFY COLUMN cat_blog_ID int(11) unsigned NOT NULL default 2" );
  1144.         echo "OK.<br />\n";
  1145.  
  1146.  
  1147.         echo 'Altering Locales table... ';
  1148.         $DB->query'ALTER TABLE T_locales
  1149.                                     ADD loc_startofweek TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER loc_timefmt' );
  1150.         echo "OK.<br />\n";
  1151.  
  1152.  
  1153.         if!isset$tablegroups_isuptodate ) )
  1154.         {    // We have created the groups table before and it's already clean!
  1155.             echo 'Altering Groups table... ';
  1156.             $DB->query"ALTER TABLE T_groups
  1157.                                         ADD COLUMN grp_perm_admin enum('none','hidden','visible') NOT NULL default 'visible' AFTER grp_name,
  1158.                                         ADD COLUMN grp_perm_files enum('none','view','add','edit') NOT NULL default 'none'" );
  1159.             echo "OK.<br />\n";
  1160.         }
  1161.  
  1162.  
  1163.         echo 'Creating table for Post Links... ';
  1164.         $DB->query"CREATE TABLE T_links (
  1165.                                     link_ID               int(11) unsigned  not null AUTO_INCREMENT,
  1166.                                     link_datecreated      datetime          not null,
  1167.                                     link_datemodified     datetime          not null,
  1168.                                     link_creator_user_ID  int(11) unsigned  not null,
  1169.                                     link_lastedit_user_ID int(11) unsigned  not null,
  1170.                                     link_item_ID          int(11) unsigned  NOT NULL,
  1171.                                     link_dest_item_ID     int(11) unsigned  NULL,
  1172.                                     link_file_ID          int(11) unsigned  NULL,
  1173.                                     link_ltype_ID         int(11) unsigned  NOT NULL default 1,
  1174.                                     link_external_url     VARCHAR(255)      NULL,
  1175.                                     link_title            TEXT              NULL,
  1176.                                     PRIMARY KEY (link_ID),
  1177.                                     INDEX link_item_ID( link_item_ID ),
  1178.                                     INDEX link_dest_item_ID (link_dest_item_ID),
  1179.                                     INDEX link_file_ID (link_file_ID)
  1180.                                 )" );
  1181.         echo "OK.<br />\n";
  1182.  
  1183.  
  1184.         echo 'Creating default Post Types... ';
  1185.         $DB->query"
  1186.             INSERT INTO {$tableprefix}posttypes ( ptyp_ID, ptyp_name )
  1187.             VALUES ( 1, 'Post' ),
  1188.                    ( 2, 'Link' ));
  1189.         echo "OK.<br />\n";
  1190.  
  1191.  
  1192.         set_upgrade_checkpoint'9000' );
  1193.     }
  1194.  
  1195.  
  1196.     if$old_db_version 9100 )
  1197.     {    // 1.8 ALPHA
  1198.  
  1199.         echo 'Creating table for plugin events... ';
  1200.         $DB->query'
  1201.             CREATE TABLE T_pluginevents(
  1202.                     pevt_plug_ID INT(11) UNSIGNED NOT NULL,
  1203.                     pevt_event VARCHAR(40) NOT NULL,
  1204.                     pevt_enabled TINYINT NOT NULL DEFAULT 1,
  1205.                     PRIMARY KEY( pevt_plug_ID, pevt_event )
  1206.                 )' );
  1207.         echo "OK.<br />\n";
  1208.  
  1209.  
  1210.         echo 'Altering Links table... ';
  1211.         $DB->query'ALTER TABLE T_links
  1212.                      CHANGE link_item_ID link_itm_ID INT( 11 ) UNSIGNED NOT NULL,
  1213.                      CHANGE link_dest_item_ID link_dest_itm_ID INT( 11 ) UNSIGNED NULL' );
  1214.         echo "OK.<br />\n";
  1215.  
  1216.  
  1217.         if$old_db_version >= 9000 )
  1218.         // sess_agnt_ID used in Phoenix-Alpha
  1219.             echo 'Altering sessions table... ';
  1220.             $query "
  1221.                     ALTER TABLE T_sessions
  1222.                      DROP COLUMN sess_agnt_ID";
  1223.             $DB->query$query );
  1224.             echo "OK.<br />\n";
  1225.         }
  1226.  
  1227.         echo 'Creating table for file types... ';
  1228.         $DB->query'
  1229.                 CREATE TABLE T_filetypes (
  1230.                     ftyp_ID int(11) unsigned NOT NULL auto_increment,
  1231.                     ftyp_extensions varchar(30) NOT NULL,
  1232.                     ftyp_name varchar(30) NOT NULL,
  1233.                     ftyp_mimetype varchar(50) NOT NULL,
  1234.                     ftyp_icon varchar(20) default NULL,
  1235.                     ftyp_viewtype varchar(10) NOT NULL,
  1236.                     ftyp_allowed tinyint(1) NOT NULL default 0,
  1237.                     PRIMARY KEY (ftyp_ID)
  1238.                 )' );
  1239.         echo "OK.<br />\n";
  1240.  
  1241.         echo 'Creating default file types... ';
  1242.     // TODO: dh> shouldn't they get localized to the app's default locale?
  1243.         $DB->query"INSERT INTO T_filetypes
  1244.                 (ftyp_ID, ftyp_extensions, ftyp_name, ftyp_mimetype, ftyp_icon, ftyp_viewtype, ftyp_allowed)
  1245.             VALUES
  1246.                 (1, 'gif', 'GIF image', 'image/gif', 'image2.png', 'image', 1),
  1247.                 (2, 'png', 'PNG image', 'image/png', 'image2.png', 'image', 1),
  1248.                 (3, 'jpg jpeg', 'JPEG image', 'image/jpeg', 'image2.png', 'image', 1),
  1249.                 (4, 'txt', 'Text file', 'text/plain', 'document.png', 'text', 1),
  1250.                 (5, 'htm html', 'HTML file', 'text/html', 'html.png', 'browser', 0),
  1251.                 (6, 'pdf', 'PDF file', 'application/pdf', 'pdf.png', 'browser', 1),
  1252.                 (7, 'doc', 'Microsoft Word file', 'application/msword', 'doc.gif', 'external', 1),
  1253.                 (8, 'xls', 'Microsoft Excel file', 'application/vnd.ms-excel', 'xls.gif', 'external', 1),
  1254.                 (9, 'ppt', 'Powerpoint', 'application/vnd.ms-powerpoint', 'ppt.gif', 'external', 1),
  1255.                 (10, 'pps', 'Slideshow', 'pps', 'pps.gif', 'external', 1),
  1256.                 (11, 'zip', 'ZIP archive', 'application/zip', 'zip.gif', 'external', 1),
  1257.                 (12, 'php php3 php4 php5 php6', 'PHP script', 'application/x-httpd-php', 'php.gif', 'text', 0),
  1258.                 (13, 'css', 'Style sheet', 'text/css', '', 'text', 1)
  1259.             " );
  1260.         echo "OK.<br />\n";
  1261.  
  1262.         echo 'Giving Administrator Group edit perms on files... ';
  1263.         $DB->query'UPDATE T_groups
  1264.                      SET grp_perm_files = "edit"
  1265.                      WHERE grp_ID = 1' );
  1266.          // Later versions give 'all' on install, but we won't upgrade to that for security.
  1267.         echo "OK.<br />\n";
  1268.  
  1269.         echo 'Giving Administrator Group full perms on media for all blogs... ';
  1270.         $DB->query'UPDATE T_coll_group_perms
  1271.                      SET bloggroup_perm_media_upload = 1,
  1272.                          bloggroup_perm_media_browse = 1,
  1273.                          bloggroup_perm_media_change = 1
  1274.                      WHERE bloggroup_group_ID = 1' );
  1275.         echo "OK.<br />\n";
  1276.  
  1277.  
  1278.         if$old_db_version >= 9000 )
  1279.         // Uninstall all ALPHA (potentially incompatible) plugins
  1280.             echo 'Uninstalling all existing plugins... ';
  1281.             $DB->query'DELETE FROM T_plugins WHERE 1=1' );
  1282.             echo "OK.<br />\n";
  1283.         }
  1284.  
  1285.         // NOTE: basic plugins get installed separatly for upgrade and install..
  1286.  
  1287.  
  1288.         set_upgrade_checkpoint'9100' );
  1289.     }
  1290.  
  1291.  
  1292.     if$old_db_version 9190 // Note: changed from 9200, to include the block below, if DB is not yet on 1.8
  1293.     {    // 1.8 ALPHA (block #2)
  1294.         echo 'Altering Posts table... ';
  1295.         $DB->query"ALTER TABLE {$tableprefix}posts
  1296.                      CHANGE post_comments post_comment_status ENUM('disabled', 'open', 'closed') NOT NULL DEFAULT 'open');
  1297.         echo "OK.<br />\n";
  1298.  
  1299.  
  1300.         set_upgrade_checkpoint'9190' );
  1301.     }
  1302.  
  1303.  
  1304.     if$old_db_version 9192 )
  1305.     // 1.8 ALPHA (block #3) - The payload that db_delta() handled before
  1306.  
  1307.         // This is a fix, which broke upgrade to 1.8 (from 1.6) in MySQL strict mode (inserted after 1.8 got released!):
  1308.         if$DB->get_row'SHOW COLUMNS FROM T_hitlog LIKE "hit_referer_type"' ) )
  1309.         // a niiiiiiiice extra check :p
  1310.             task_begin'Deleting all "spam" hitlog entries... ' );
  1311.             $DB->query'
  1312.                     DELETE FROM T_hitlog
  1313.                      WHERE hit_referer_type = "spam"' );
  1314.             task_end();
  1315.         }
  1316.  
  1317.         task_begin'Upgrading users table... ' );
  1318.         $DB->query'ALTER TABLE T_users
  1319.                                         CHANGE COLUMN user_firstname user_firstname varchar(50) NULL,
  1320.                                         CHANGE COLUMN user_lastname user_lastname varchar(50) NULL,
  1321.                                         CHANGE COLUMN user_nickname user_nickname varchar(50) NULL,
  1322.                                         CHANGE COLUMN user_icq user_icq int(11) unsigned NULL,
  1323.                                         CHANGE COLUMN user_email user_email varchar(255) NOT NULL,
  1324.                                         CHANGE COLUMN user_url user_url varchar(255) NULL,
  1325.                                         CHANGE COLUMN user_ip user_ip varchar(15) NULL,
  1326.                                         CHANGE COLUMN user_domain user_domain varchar(200) NULL,
  1327.                                         CHANGE COLUMN user_browser user_browser varchar(200) NULL,
  1328.                                         CHANGE COLUMN user_aim user_aim varchar(50) NULL,
  1329.                                         CHANGE COLUMN user_msn user_msn varchar(100) NULL,
  1330.                                         CHANGE COLUMN user_yim user_yim varchar(50) NULL,
  1331.                                         ADD COLUMN user_allow_msgform TINYINT NOT NULL DEFAULT \'1\' AFTER user_idmode,
  1332.                                         ADD COLUMN user_validated TINYINT(1) NOT NULL DEFAULT 0 AFTER user_grp_ID' );
  1333.         task_end();
  1334.  
  1335.         task_begin'Creating blog settings...' );
  1336.         $DB->query'CREATE TABLE T_coll_settings (
  1337.                                                             cset_coll_ID INT(11) UNSIGNED NOT NULL,
  1338.                                                             cset_name    VARCHAR( 30 ) NOT NULL,
  1339.                                                             cset_value   VARCHAR( 255 ) NULL,
  1340.                                                             PRIMARY KEY ( cset_coll_ID, cset_name )
  1341.                                             )' );
  1342.         task_end();
  1343.         set_upgrade_checkpoint'9192' );
  1344.     }
  1345.  
  1346.  
  1347.     if$old_db_version 9195 )
  1348.     {
  1349.         task_begin'Upgrading posts table... ' );
  1350.         $DB->query'ALTER TABLE '.$tableprefix.'posts
  1351.                                         CHANGE COLUMN post_content post_content         text NULL,
  1352.                                         CHANGE COLUMN post_url post_url                      VARCHAR(255) NULL DEFAULT NULL,
  1353.                                         CHANGE COLUMN post_renderers post_renderers     TEXT NOT NULL' );
  1354.         task_end();
  1355.  
  1356.         task_begin'Upgrading comments table... ' );
  1357.         $DB->query'ALTER TABLE T_comments
  1358.                                         CHANGE COLUMN comment_author_email comment_author_email varchar(255) NULL,
  1359.                                         CHANGE COLUMN comment_author_url comment_author_url varchar(255) NULL,
  1360.                                         ADD COLUMN comment_spam_karma TINYINT NULL AFTER comment_karma,
  1361.                                         ADD COLUMN comment_allow_msgform TINYINT NOT NULL DEFAULT 0 AFTER comment_spam_karma' );
  1362.         task_end();
  1363.  
  1364.         set_upgrade_checkpoint'9195' );
  1365.     }
  1366.  
  1367.  
  1368.     if$old_db_version 9200 )
  1369.     {
  1370.         task_begin'Upgrading hitlog table... ' );
  1371.         $DB->query'ALTER TABLE T_hitlog
  1372.                                         CHANGE COLUMN hit_referer_type hit_referer_type   ENUM(\'search\',\'blacklist\',\'referer\',\'direct\') NOT NULL,
  1373.                                         ADD COLUMN hit_agnt_ID        INT UNSIGNED NULL AFTER hit_remote_addr' );
  1374.         task_end();
  1375.  
  1376.         task_begin'Upgrading post links table... ' );
  1377.         $DB->query'ALTER TABLE T_links
  1378.                                         ADD INDEX link_itm_ID( link_itm_ID ),
  1379.                                         ADD INDEX link_dest_itm_ID (link_dest_itm_ID)' );
  1380.         task_end();
  1381.  
  1382.         task_begin'Upgrading plugins table... ' );
  1383.         $DB->query'ALTER TABLE T_plugins
  1384.                                         CHANGE COLUMN plug_priority plug_priority        TINYINT NOT NULL default 50,
  1385.                                         ADD COLUMN plug_code            VARCHAR(32) NULL AFTER plug_classname,
  1386.                                         ADD COLUMN plug_apply_rendering ENUM( \'stealth\', \'always\', \'opt-out\', \'opt-in\', \'lazy\', \'never\' ) NOT NULL DEFAULT \'never\' AFTER plug_code,
  1387.                                         ADD COLUMN plug_version         VARCHAR(42) NOT NULL default \'0\' AFTER plug_apply_rendering,
  1388.                                         ADD COLUMN plug_status          ENUM( \'enabled\', \'disabled\', \'needs_config\', \'broken\' ) NOT NULL AFTER plug_version,
  1389.                                         ADD COLUMN plug_spam_weight     TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER plug_status,
  1390.                                         ADD UNIQUE plug_code( plug_code ),
  1391.                                         ADD INDEX plug_status( plug_status )' );
  1392.         task_end();
  1393.  
  1394.         task_begin'Creating plugin settings table... ' );
  1395.         $DB->query'CREATE TABLE T_pluginsettings (
  1396.                                                             pset_plug_ID INT(11) UNSIGNED NOT NULL,
  1397.                                                             pset_name VARCHAR( 30 ) NOT NULL,
  1398.                                                             pset_value TEXT NULL,
  1399.                                                             PRIMARY KEY ( pset_plug_ID, pset_name )
  1400.                                             )' );
  1401.         task_end();
  1402.  
  1403.         task_begin'Creating plugin user settings table... ' );
  1404.         $DB->query'CREATE TABLE T_pluginusersettings (
  1405.                                                             puset_plug_ID INT(11) UNSIGNED NOT NULL,
  1406.                                                             puset_user_ID INT(11) UNSIGNED NOT NULL,
  1407.                                                             puset_name VARCHAR( 30 ) NOT NULL,
  1408.                                                             puset_value TEXT NULL,
  1409.                                                             PRIMARY KEY ( puset_plug_ID, puset_user_ID, puset_name )
  1410.                                             )' );
  1411.         task_end();
  1412.  
  1413.         task_begin'Creating scheduled tasks table... ' );
  1414.         $DB->query'CREATE TABLE T_cron__task(
  1415.                                                  ctsk_ID              int(10) unsigned      not null AUTO_INCREMENT,
  1416.                                                  ctsk_start_datetime  datetime              not null,
  1417.                                                  ctsk_repeat_after    int(10) unsigned,
  1418.                                                  ctsk_name            varchar(50)           not null,
  1419.                                                  ctsk_controller      varchar(50)           not null,
  1420.                                                  ctsk_params          text,
  1421.                                                  primary key (ctsk_ID)
  1422.                                             )' );
  1423.         task_end();
  1424.  
  1425.         task_begin'Creating cron log table... ' );
  1426.         $DB->query'CREATE TABLE T_cron__log(
  1427.                                                              clog_ctsk_ID              int(10) unsigned   not null,
  1428.                                                              clog_realstart_datetime   datetime           not null,
  1429.                                                              clog_realstop_datetime    datetime,
  1430.                                                              clog_status               enum(\'started\',\'finished\',\'error\',\'timeout\') not null default \'started\',
  1431.                                                              clog_messages             text,
  1432.                                                              primary key (clog_ctsk_ID)
  1433.                                             )' );
  1434.         task_end();
  1435.  
  1436.         task_begin'Upgrading blogs table... ' );
  1437.         // blog_allowpingbacks is "DEFAULT 1" in the 0.9.0.11 dump.. - changed in 0.9.2?!
  1438.         $DB->query'ALTER TABLE T_blogs
  1439.                                         ALTER COLUMN blog_allowpingbacks SET DEFAULT 0,
  1440.                                     CHANGE COLUMN blog_media_subdir blog_media_subdir VARCHAR( 255 ) NULL,
  1441.                                         CHANGE COLUMN blog_media_fullpath blog_media_fullpath VARCHAR( 255 ) NULL,
  1442.                                         CHANGE COLUMN blog_media_url blog_media_url VARCHAR( 255 ) NULL' );
  1443.         task_end();
  1444.  
  1445.  
  1446.         set_upgrade_checkpoint'9200' )// at 1.8 "Summer Beta" release
  1447.     }
  1448.  
  1449.  
  1450.     // ____________________________ 1.9: ____________________________
  1451.  
  1452.     if$old_db_version 9290 )
  1453.     {
  1454.         echo 'Post-fix hit_referer_type == NULL... ';
  1455.         // If you've upgraded from 1.6 to 1.8 and it did not break because of strict mode, there are now NULL values for what "spam" was:
  1456.         $DB->query'
  1457.                     DELETE FROM T_hitlog
  1458.                      WHERE hit_referer_type IS NULL' );
  1459.         echo "OK.<br />\n";
  1460.  
  1461.         echo 'Marking administrator accounts as validated... ';
  1462.         $DB->query'
  1463.                 UPDATE T_users
  1464.                    SET user_validated = 1
  1465.                  WHERE user_grp_ID = 1' );
  1466.         echo "OK.<br />\n";
  1467.  
  1468.         echo 'Converting auto_prune_stats setting... ';
  1469.         $old_auto_prune_stats $DB->get_var'
  1470.                 SELECT set_value
  1471.                   FROM T_settings
  1472.                  WHERE set_name = "auto_prune_stats"' );
  1473.         ifis_null($old_auto_prune_stats&& $old_auto_prune_stats )
  1474.         // This means it has been disabled before, so set auto_prune_stats_mode to "off"!
  1475.             $DB->query'
  1476.                     REPLACE INTO T_settings ( set_name, set_value )
  1477.                      VALUES ( "auto_prune_stats_mode", "off" )' );
  1478.         }
  1479.         echo "OK.<br />\n";
  1480.  
  1481.         echo 'Converting time_difference from hours to seconds... ';
  1482.         $DB->query'UPDATE T_settings SET set_value = set_value*3600 WHERE set_name = "time_difference"' );
  1483.         echo "OK.<br />\n";
  1484.  
  1485.  
  1486.         echo 'Updating hitlog capabilities... ';
  1487.         $DB->query'
  1488.                 ALTER TABLE T_useragents ADD INDEX agnt_type ( agnt_type )' );
  1489.         $DB->query'
  1490.                 ALTER TABLE T_hitlog
  1491.                   CHANGE COLUMN hit_referer_type hit_referer_type ENUM(\'search\',\'blacklist\',\'referer\',\'direct\',\'self\',\'admin\') NOT NULL' );
  1492.         echo "OK.<br />\n";
  1493.  
  1494.         echo 'Updating plugin capabilities... ';
  1495.         $DB->query'
  1496.                 ALTER TABLE T_plugins
  1497.                     MODIFY COLUMN plug_status ENUM( \'enabled\', \'disabled\', \'needs_config\', \'broken\' ) NOT NULL' );
  1498.         echo "OK.<br />\n";
  1499.  
  1500.         set_upgrade_checkpoint'9290' );
  1501.     }
  1502.  
  1503.  
  1504.     if$old_db_version 9300 )
  1505.     {
  1506.         // This can be so long, it needs its own checkpoint protected block in case of failure
  1507.         echo 'Updating hitlog indexes... ';
  1508.         $DB->query'
  1509.                 ALTER TABLE T_hitlog
  1510.                   ADD INDEX hit_agnt_ID        ( hit_agnt_ID ),
  1511.                   ADD INDEX hit_uri            ( hit_uri ),
  1512.                   ADD INDEX hit_referer_dom_ID ( hit_referer_dom_ID )
  1513.                 ' );
  1514.         echo "OK.<br />\n";
  1515.  
  1516.         set_upgrade_checkpoint'9300' );
  1517.     }
  1518.  
  1519.  
  1520.     if$old_db_version 9310 )
  1521.     {
  1522.         echo 'Updating basedomains... ';
  1523.         $DB->query'
  1524.                 UPDATE T_basedomains
  1525.                    SET dom_status = "unknown"' );        // someone has filled this up with junk blacklists before
  1526.         $DB->query'
  1527.                 ALTER TABLE T_basedomains  ADD INDEX dom_type (dom_type)' );
  1528.         echo "OK.<br />\n";
  1529.  
  1530.         set_upgrade_checkpoint'9310' );
  1531.     }
  1532.  
  1533.  
  1534.     if$old_db_version 9315 )
  1535.     {
  1536.         echo 'Altering locales table... ';
  1537.         $DB->query"ALTER TABLE T_locales CHANGE COLUMN loc_datefmt loc_datefmt varchar(20) NOT NULL default 'y-m-d'" );
  1538.         $DB->query"ALTER TABLE T_locales CHANGE COLUMN loc_timefmt loc_timefmt varchar(20) NOT NULL default 'H:i:s'" );
  1539.         echo "OK.<br />\n";
  1540.  
  1541.         echo 'Creating item prerendering cache table... ';
  1542.         $DB->query"
  1543.                 CREATE TABLE {$tableprefix}item__prerendering(
  1544.                     itpr_itm_ID                   INT(11) UNSIGNED NOT NULL,
  1545.                     itpr_format                   ENUM('htmlbody', 'entityencoded', 'xml', 'text') NOT NULL,
  1546.                     itpr_renderers                TEXT NOT NULL,
  1547.                     itpr_content_prerendered      TEXT NULL,
  1548.                     itpr_datemodified             TIMESTAMP NOT NULL,
  1549.                     PRIMARY KEY (itpr_itm_ID, itpr_format)
  1550.                 ));
  1551.         echo "OK.<br />\n";
  1552.  
  1553.         echo 'Altering plugins table... ';
  1554.         $DB->query"ALTER TABLE T_plugins ADD COLUMN plug_name            VARCHAR(255) NULL default NULL AFTER plug_version" );
  1555.         $DB->query"ALTER TABLE T_plugins ADD COLUMN plug_shortdesc       VARCHAR(255) NULL default NULL AFTER plug_name" );
  1556.         echo "OK.<br />\n";
  1557.  
  1558.         set_upgrade_checkpoint'9315' );
  1559.     }
  1560.  
  1561.  
  1562.     if$old_db_version 9320 )
  1563.     // Dropping hit_datetime because it's very slow on INSERT (dh)
  1564.         // This can be so long, it needs its own checkpoint protected block in case of failure
  1565.         ifdb_index_exists'T_hitlog''hit_datetime' ) )
  1566.         // only drop, if it still exists (may have been removed manually)
  1567.             echo 'Updating hitlog indexes... ';
  1568.             $DB->query'
  1569.                     ALTER TABLE T_hitlog
  1570.                         DROP INDEX hit_datetime
  1571.                     ' );
  1572.             echo "OK.<br />\n";
  1573.         }
  1574.  
  1575.         set_upgrade_checkpoint'9320' );
  1576.     }
  1577.  
  1578.  
  1579.     if$old_db_version 9326 )
  1580.     {
  1581.         echo 'Removing obsolete settings... ';
  1582.         $DB->query'DELETE FROM T_settings WHERE set_name = "upload_allowedext"' );
  1583.         echo "OK.<br />\n";
  1584.  
  1585.         echo 'Updating blogs... ';
  1586.         db_drop_col'T_blogs''blog_allowpingbacks' );
  1587.  
  1588.         // Remove and transform obsolete fields blog_pingb2evonet, blog_pingtechnorati, blog_pingweblogs, blog_pingblodotgs
  1589.         ifdb_cols_exist'T_blogs'array('blog_pingb2evonet''blog_pingtechnorati''blog_pingweblogs''blog_pingblodotgs') ) )
  1590.         {
  1591.             foreach$DB->get_results'
  1592.                     SELECT blog_ID, blog_pingb2evonet, blog_pingtechnorati, blog_pingweblogs, blog_pingblodotgs
  1593.                         FROM T_blogs' as $row )
  1594.             {
  1595.                 $ping_plugins $DB->get_var'SELECT cset_value FROM T_coll_settings WHERE cset_coll_ID = '.$row->blog_ID.' AND cset_name = "ping_plugins"' );
  1596.                 $ping_plugins explode(','$ping_plugins);
  1597.                 if$row->blog_pingb2evonet )
  1598.                 {
  1599.                     $ping_plugins['ping_b2evonet';
  1600.                 }
  1601.                 if$row->blog_pingtechnorati || $row->blog_pingweblogs || $row->blog_pingblodotgs )
  1602.                 // if either one of the previous pingers was enabled, add ping-o-matic:
  1603.                     $ping_plugins['ping_pingomatic';
  1604.                 }
  1605.  
  1606.                 // Insert transformed/generated ping plugins collection setting:
  1607.                 $ping_plugins array_unique($ping_plugins);
  1608.                 $DB->query'REPLACE INTO T_coll_settings
  1609.                         ( cset_coll_ID, cset_name, cset_value )
  1610.                         VALUES ( '.$row->blog_ID.', "ping_plugins", "'.implode','$ping_plugins ).'" )' );
  1611.             }
  1612.             $DB->query'ALTER TABLE T_blogs
  1613.                     DROP COLUMN blog_pingb2evonet,
  1614.                     DROP COLUMN blog_pingtechnorati,
  1615.                     DROP COLUMN blog_pingweblogs,
  1616.                     DROP COLUMN blog_pingblodotgs' );
  1617.         }
  1618.         echo "OK.<br />\n";
  1619.  
  1620.  
  1621.         set_upgrade_checkpoint'9326' );
  1622.     }
  1623.  
  1624.  
  1625.     if$old_db_version 9328 )
  1626.     {
  1627.         echo 'Updating posts... ';
  1628.         db_add_col"{$tableprefix}posts"'post_notifications_status',  'ENUM("noreq","todo","started","finished") NOT NULL DEFAULT "noreq" AFTER post_flags' );
  1629.         db_add_col"{$tableprefix}posts"'post_notifications_ctsk_ID''INT(10) unsigned NULL DEFAULT NULL AFTER post_notifications_status' );
  1630.         echo "OK.<br />\n";
  1631.         set_upgrade_checkpoint'9328' );
  1632.     }
  1633.  
  1634.  
  1635.     if$old_db_version 9330 )
  1636.     {
  1637.         ifdb_col_exists"{$tableprefix}posts"'post_flags') )
  1638.         {
  1639.             echo 'Updating post notifications... ';
  1640.             $DB->query"
  1641.                 UPDATE {$tableprefix}posts
  1642.                      SET post_notifications_status = 'finished'
  1643.                  WHERE post_flags LIKE '%pingsdone%');
  1644.             db_drop_col"{$tableprefix}posts"'post_flags' );
  1645.             echo "OK.<br />\n";
  1646.         }
  1647.         set_upgrade_checkpoint'9330' );
  1648.     }
  1649.  
  1650.  
  1651.     if$old_db_version 9340 )
  1652.     {
  1653.         echo 'Removing duplicate post link indexes... ';
  1654.         ifdb_index_exists'T_links''link_item_ID' ) )
  1655.         // only drop, if it still exists (may have been removed manually)
  1656.             $DB->query'
  1657.                     ALTER TABLE T_links
  1658.                         DROP INDEX link_item_ID
  1659.                     ' );
  1660.         }
  1661.         ifdb_index_exists'T_links''link_dest_item_ID' ) )
  1662.         // only drop, if it still exists (may have been removed manually)
  1663.             $DB->query'
  1664.                     ALTER TABLE T_links
  1665.                         DROP INDEX link_dest_item_ID
  1666.                     ' );
  1667.         }
  1668.         echo "OK.<br />\n";
  1669.  
  1670.         set_upgrade_checkpoint'9340' );
  1671.     }
  1672.  
  1673.     // ____________________________ 1.10: ____________________________
  1674.  
  1675.     if$old_db_version 9345 )
  1676.     {
  1677.         echo 'Updating post table... ';
  1678.         $DB->query"ALTER TABLE {$tableprefix}posts CHANGE COLUMN post_content post_content MEDIUMTEXT NULL);
  1679.         echo "OK.<br />\n";
  1680.         set_upgrade_checkpoint'9345' );
  1681.     }
  1682.  
  1683.     if$old_db_version 9346 )
  1684.     {
  1685.         echo 'Updating prerendering table... ';
  1686.         $DB->query"ALTER TABLE {$tableprefix}item__prerendering CHANGE COLUMN itpr_content_prerendered itpr_content_prerendered MEDIUMTEXT NULL);
  1687.         echo "OK.<br />\n";
  1688.         set_upgrade_checkpoint'9346' );
  1689.     }
  1690.  
  1691.     if$old_db_version 9348 )
  1692.     {
  1693.         echo 'Updating sessions table... ';
  1694.         $DB->query'ALTER TABLE T_sessions CHANGE COLUMN sess_data sess_data MEDIUMBLOB DEFAULT NULL' );
  1695.         echo "OK.<br />\n";
  1696.         set_upgrade_checkpoint'9348' );
  1697.     }
  1698.  
  1699.     if$old_db_version 9350 )
  1700.     {
  1701.         echo 'Updating hitlog table... ';
  1702.         $DB->query'ALTER TABLE T_hitlog CHANGE COLUMN hit_referer_type hit_referer_type   ENUM(\'search\',\'blacklist\',\'spam\',\'referer\',\'direct\',\'self\',\'admin\') NOT NULL' );
  1703.         echo "OK.<br />\n";
  1704.  
  1705.         set_upgrade_checkpoint'9350' );
  1706.     }
  1707.  
  1708.  
  1709.     // TODO: "If a user has permission to edit a blog, he should be able to put files in the media folder for that blog." - see http://forums.b2evolution.net/viewtopic.php?p=36417#36417
  1710.     /*
  1711.     // blueyed>> I've came up with the following, but it's too generic IMHO
  1712.     if( $old_db_version < 9300 )
  1713.     {
  1714.         echo 'Setting automatic media perms on blogs (members can upload)... ';
  1715.         $users = $DB->query( '
  1716.                 UPDATE T_users
  1717.                    SET bloguser_perm_media_upload = 1
  1718.                  WHERE bloguser_ismember = 1' );
  1719.         echo "OK.<br />\n";
  1720.     }
  1721.     */
  1722.  
  1723.  
  1724.     // ____________________________ 2.0: ____________________________
  1725.  
  1726.     if$old_db_version 9406 )
  1727.     {
  1728.         echo 'Updating chapter url names... ';
  1729.         $DB->query'
  1730.             ALTER TABLE T_categories
  1731.                 ADD COLUMN cat_urlname VARCHAR(255) NOT NULL' );
  1732.  
  1733.         // Create cat_urlname from cat_name:
  1734.         // TODO: Also use it for cafelog upgrade.
  1735.         load_funcs('locales/_charset.funcs.php');
  1736.         foreach$DB->get_results('SELECT cat_ID, cat_name FROM T_categories'as $cat )
  1737.         {
  1738.             $cat_name trim($cat->cat_name);
  1739.             ifstrlen($cat_name) )
  1740.             {
  1741.                 $cat_urlname urltitle_validate(''$cat_name$cat->cat_IDfalse'cat_urlname''cat_ID''T_categories');
  1742.             }
  1743.             else
  1744.             {
  1745.                 $cat_urlname 'c'.$cat->cat_ID;
  1746.             }
  1747.  
  1748.             $DB->query'
  1749.                 UPDATE T_categories
  1750.                      SET cat_urlname = '.$DB->quote($cat_urlname).'
  1751.                  WHERE cat_ID = '.$cat->cat_ID );
  1752.         }
  1753.  
  1754.         $DB->query'
  1755.             ALTER TABLE T_categories
  1756.                 ADD UNIQUE cat_urlname ( cat_urlname )' );
  1757.         echo "OK.<br />\n";
  1758.  
  1759.         echo 'Updating Settings... ';
  1760.         $DB->query'
  1761.       UPDATE T_settings
  1762.          SET set_value = "disabled"
  1763.        WHERE set_name = "links_extrapath"
  1764.          AND set_value = 0' );
  1765.         $DB->query'
  1766.       UPDATE T_settings
  1767.          SET set_value = "ymd"
  1768.        WHERE set_name = "links_extrapath"
  1769.          AND set_value <> 0' );
  1770.         echo "OK.<br />\n";
  1771.  
  1772.         set_upgrade_checkpoint'9406' );
  1773.     }
  1774.  
  1775.  
  1776.     if$old_db_version 9407 )
  1777.     {
  1778.         echo 'Moving general settings to blog settings... ';
  1779.         $DB->query'REPLACE INTO T_coll_settings( cset_coll_ID, cset_name, cset_value )
  1780.                      SELECT blog_ID, set_name, set_value
  1781.                                      FROM T_blogs, T_settings
  1782.                                     WHERE set_name = "posts_per_page"
  1783.                                        OR set_name = "what_to_show"
  1784.                                        OR set_name = "archive_mode"' );
  1785.         $DB->query'DELETE FROM T_settings
  1786.                                     WHERE set_name = "posts_per_page"
  1787.                                        OR set_name = "what_to_show"
  1788.                                        OR set_name = "archive_mode"' );
  1789.         echo "OK.<br />\n";
  1790.  
  1791.         echo 'Upgrading blogs table... ';
  1792.         $query "ALTER TABLE T_blogs
  1793.                             DROP COLUMN blog_force_skin";
  1794.         $DB->query$query );
  1795.         echo "OK.<br />\n";
  1796.  
  1797.         echo 'Upgrading groups table... ';
  1798.         $query "ALTER TABLE T_groups
  1799.                             CHANGE COLUMN grp_perm_files grp_perm_files enum('none','view','add','edit','all') NOT NULL default 'none'";
  1800.         $DB->query$query );
  1801.         echo "OK.<br />\n";
  1802.  
  1803.         echo 'Upgrading files table... ';
  1804.         $query "ALTER TABLE T_files
  1805.                             CHANGE COLUMN file_root_type file_root_type enum('absolute','user','group','collection','skins') not null default 'absolute'";
  1806.         $DB->query$query );
  1807.         echo "OK.<br />\n";
  1808.  
  1809.         echo 'Updating file types... ';
  1810.         // Only change this if it's close enough to a default install (non customized)
  1811.         $DB->query"UPDATE T_filetypes
  1812.                                         SET ftyp_viewtype = 'text'
  1813.                                     WHERE ftyp_ID = 12
  1814.                                         AND ftyp_extensions = 'php php3 php4 php5 php6'
  1815.                                         AND ftyp_mimetype ='application/x-httpd-php'
  1816.                                         AND ftyp_icon = 'php.gif'" );
  1817.         echo "OK.<br />\n";
  1818.  
  1819.         echo 'Remove obsolete user settings... ';
  1820.         $DB->query'DELETE FROM T_usersettings
  1821.                                     WHERE uset_name = "plugins_disp_avail"' );
  1822.         echo "OK.<br />\n";
  1823.  
  1824.         set_upgrade_checkpoint'9407' );
  1825.     }
  1826.  
  1827.  
  1828.     if$old_db_version 9408 )
  1829.     {
  1830.         echo 'Creating skins table... ';
  1831.         $DB->query'CREATE TABLE T_skins__skin (
  1832.               skin_ID      int(10) unsigned      NOT NULL auto_increment,
  1833.               skin_name    varchar(32)           NOT NULL,
  1834.               skin_type    enum(\'normal\',\'feed\') NOT NULL default \'normal\',
  1835.               skin_folder  varchar(32)           NOT NULL,
  1836.               PRIMARY KEY skin_ID (skin_ID),
  1837.               UNIQUE skin_folder( skin_folder ),
  1838.               KEY skin_name( skin_name )
  1839.             )' );
  1840.         echo "OK.<br />\n";
  1841.  
  1842.         echo 'Creating skin containers table... ';
  1843.         $DB->query'CREATE TABLE T_skins__container (
  1844.               sco_skin_ID   int(10) unsigned      NOT NULL,
  1845.               sco_name      varchar(40)           NOT NULL,
  1846.               PRIMARY KEY (sco_skin_ID, sco_name)
  1847.             )' );
  1848.         echo "OK.<br />\n";
  1849.  
  1850.         install_basic_skins();
  1851.  
  1852.         echo 'Creating widgets table... ';
  1853.         $DB->query'CREATE TABLE T_widget (
  1854.                          wi_ID                    INT(10) UNSIGNED auto_increment,
  1855.                         wi_coll_ID    INT(11) UNSIGNED NOT NULL,
  1856.                         wi_sco_name   VARCHAR( 40 ) NOT NULL,
  1857.                         wi_order            INT(10) UNSIGNED NOT NULL,
  1858.                         wi_type       ENUM( \'core\', \'plugin\' ) NOT NULL DEFAULT \'core\',
  1859.                         wi_code       VARCHAR(32) NOT NULL,
  1860.                         wi_params     TEXT NULL,
  1861.                         PRIMARY KEY ( wi_ID ),
  1862.                         UNIQUE wi_order( wi_coll_ID, wi_sco_name, wi_order )
  1863.           )' );
  1864.         echo "OK.<br />\n";
  1865.  
  1866.         echo 'Updating blogs table... ';
  1867.         $DB->query'ALTER TABLE T_blogs
  1868.                                  ALTER COLUMN blog_allowtrackbacks SET DEFAULT 0,
  1869.                                     DROP COLUMN blog_default_skin,
  1870.                                      ADD COLUMN blog_owner_user_ID   int(11) unsigned NOT NULL default 1 AFTER blog_name,
  1871.                                      ADD COLUMN blog_skin_ID INT(10) UNSIGNED NOT NULL DEFAULT 1 AFTER blog_allowusercss' );
  1872.         echo "OK.<br />\n";
  1873.  
  1874.  
  1875.         install_basic_widgets();
  1876.  
  1877.         set_upgrade_checkpoint'9408' );
  1878.     }
  1879.  
  1880.  
  1881.     if$old_db_version 9409 )
  1882.     {
  1883.         // Upgrade the blog access types:
  1884.         echo 'Updating blogs access types... ';
  1885.         $DB->query'UPDATE T_blogs
  1886.                                         SET blog_access_type = "absolute"
  1887.                                     WHERE blog_siteurl LIKE "http://%"
  1888.                                        OR blog_siteurl LIKE "https://%"' );
  1889.  
  1890.         $DB->query'UPDATE T_blogs
  1891.                                         SET blog_access_type = "relative",
  1892.                                                 blog_siteurl = CONCAT( blog_siteurl, blog_stub )
  1893.                                     WHERE blog_access_type = "stub"' );
  1894.  
  1895.         db_drop_col'T_blogs''blog_stub' );
  1896.  
  1897.         echo "OK.<br />\n";
  1898.  
  1899.  
  1900.          echo 'Updating columns... ';
  1901.         $DB->query"ALTER TABLE T_groups CHANGE COLUMN grp_perm_stats grp_perm_stats enum('none','user','view','edit') NOT NULL default 'none'" );
  1902.  
  1903.         $DB->query"ALTER TABLE T_coll_user_perms CHANGE COLUMN bloguser_perm_poststatuses bloguser_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default ''" );
  1904.  
  1905.         $DB->query"ALTER TABLE T_coll_group_perms CHANGE COLUMN bloggroup_perm_poststatuses bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default ''" );
  1906.  
  1907.         $DB->query"ALTER TABLE {$tableprefix}posts CHANGE COLUMN post_status post_status enum('published','deprecated','protected','private','draft','redirected') NOT NULL default 'published');
  1908.         echo "OK.<br />\n";
  1909.  
  1910.         set_upgrade_checkpoint'9409' );
  1911.     }
  1912.  
  1913.  
  1914.     if$old_db_version 9410 )
  1915.     {
  1916.          echo 'Updating columns... ';
  1917.         $DB->query"ALTER TABLE T_comments CHANGE COLUMN comment_status comment_status ENUM('published','deprecated','protected','private','draft','redirected') DEFAULT 'published' NOT NULL" );
  1918.  
  1919.         $DB->query"ALTER TABLE T_sessions CHANGE COLUMN sess_data sess_data MEDIUMBLOB DEFAULT NULL" );
  1920.  
  1921.         $DB->query"ALTER TABLE T_hitlog CHANGE COLUMN hit_referer_type hit_referer_type ENUM('search','blacklist','spam','referer','direct','self','admin') NOT NULL" );
  1922.  
  1923.         echo "OK.<br />\n";
  1924.  
  1925.         set_upgrade_checkpoint'9410' );
  1926.     }
  1927.  
  1928.  
  1929.     if$old_db_version 9411 )
  1930.     {
  1931.         echo 'Adding default Post Types... ';
  1932.         $DB->query"
  1933.             REPLACE INTO {$tableprefix}posttypes ( ptyp_ID, ptyp_name )
  1934.             VALUES ( 1000, 'Page' ),
  1935.                          ( 2000, 'Reserved' ),
  1936.                          ( 3000, 'Reserved' ),
  1937.                          ( 4000, 'Reserved' ),
  1938.                          ( 5000, 'Reserved' ) );
  1939.         echo "OK.<br />\n";
  1940.         set_upgrade_checkpoint'9411' );
  1941.     }
  1942.  
  1943.  
  1944.     if$old_db_version 9412 )
  1945.     {
  1946.         echo 'Adding field for post excerpts... ';
  1947.         $DB->query"ALTER TABLE {$tableprefix}posts ADD COLUMN post_excerpt  text NULL AFTER post_content);
  1948.         echo "OK.<br />\n";
  1949.         set_upgrade_checkpoint'9412' );
  1950.     }
  1951.  
  1952.     if$old_db_version 9414 )
  1953.     {
  1954.         echo "Renaming tables...";
  1955.         $DB->query"RENAME TABLE {$tableprefix}item__prerendering TO T_items__prerendering);
  1956.         $DB->query"RENAME TABLE {$tableprefix}poststatuses TO T_items__status);
  1957.         $DB->query"RENAME TABLE {$tableprefix}posttypes TO T_items__type);
  1958.         $DB->query"RENAME TABLE {$tableprefix}posts TO T_items__item);
  1959.         echo "OK.<br />\n";
  1960.  
  1961.         echo "Creating Tag tables...";
  1962.         $DB->query"CREATE TABLE T_items__tag (
  1963.               tag_ID   int(11) unsigned not null AUTO_INCREMENT,
  1964.               tag_name varchar(50)      not null,
  1965.               primary key (tag_ID),
  1966.               UNIQUE tag_name( tag_name )
  1967.             )" );
  1968.  
  1969.         $DB->query"CREATE TABLE T_items__itemtag (
  1970.               itag_itm_ID int(11) unsigned NOT NULL,
  1971.               itag_tag_ID int(11) unsigned NOT NULL,
  1972.               PRIMARY KEY (itag_itm_ID, itag_tag_ID),
  1973.               UNIQUE tagitem ( itag_tag_ID, itag_itm_ID )
  1974.             )" );
  1975.         echo "OK.<br />\n";
  1976.  
  1977.         set_upgrade_checkpoint'9414' );
  1978.     }
  1979.  
  1980.  
  1981.     if$old_db_version 9416 )
  1982.     {
  1983.         echo "Updating blogs table...";
  1984.         $DB->query"ALTER TABLE T_blogs
  1985.                                     ADD COLUMN blog_advanced_perms  TINYINT(1) NOT NULL default 0 AFTER blog_owner_user_ID,
  1986.                                     DROP COLUMN blog_staticfilename" );
  1987.         $DB->query"UPDATE T_blogs
  1988.                                       SET blog_advanced_perms = 1" );
  1989.         echo "OK.<br />\n";
  1990.  
  1991.         echo "Additionnal blog permissions...";
  1992.         $DB->query"ALTER TABLE T_coll_user_perms
  1993.                                     ADD COLUMN bloguser_perm_admin tinyint NOT NULL default 0 AFTER bloguser_perm_properties,
  1994.                                     ADD COLUMN bloguser_perm_edit  ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no' AFTER bloguser_perm_poststatuses" );
  1995.  
  1996.         $DB->query"ALTER TABLE T_coll_group_perms
  1997.                                     ADD COLUMN bloggroup_perm_admin tinyint NOT NULL default 0 AFTER bloggroup_perm_properties,
  1998.                                     ADD COLUMN bloggroup_perm_edit  ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no' AFTER bloggroup_perm_poststatuses" );
  1999.  
  2000.         // Preserve full admin perms:
  2001.         $DB->query"UPDATE T_coll_user_perms
  2002.                                         SET bloguser_perm_admin = 1
  2003.                                     WHERE bloguser_perm_properties <> 0" );
  2004.         $DB->query"UPDATE T_coll_group_perms
  2005.                                         SET bloggroup_perm_admin = 1
  2006.                                     WHERE bloggroup_perm_properties <> 0" );
  2007.  
  2008.         // Preserve full edit perms:
  2009.         $DB->query"UPDATE T_coll_user_perms
  2010.                                         SET bloguser_perm_edit = 'all'" );
  2011.         $DB->query"UPDATE T_coll_group_perms
  2012.                                         SET bloggroup_perm_edit = 'all'" );
  2013.  
  2014.         echo "OK.<br />\n";
  2015.  
  2016.         set_upgrade_checkpoint'9416' );
  2017.     }
  2018.  
  2019.  
  2020.     if$old_db_version 9500 )
  2021.     {
  2022.         task_begin'Normalizing columns...' );
  2023.         $DB->query'ALTER TABLE T_blogs
  2024.                                         ALTER COLUMN blog_shortname SET DEFAULT \'\',
  2025.                                         ALTER COLUMN blog_tagline SET DEFAULT \'\',
  2026.                                         CHANGE COLUMN blog_description blog_description     varchar(250) NULL default \'\',
  2027.                                         ALTER COLUMN blog_siteurl SET DEFAULT \'\'' );
  2028.         task_end();
  2029.  
  2030.         task_begin'Normalizing dates...' );
  2031.         $DB->query'UPDATE T_users
  2032.                                         SET dateYMDhour = \'2000-01-01 00:00:00\'
  2033.                                     WHERE dateYMDhour = \'0000-00-00 00:00:00\'' );
  2034.         $DB->query'ALTER TABLE T_users
  2035.                                     MODIFY COLUMN dateYMDhour DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\'' );
  2036.         $DB->query'UPDATE T_comments
  2037.                                         SET comment_date = \'2000-01-01 00:00:00\'
  2038.                                     WHERE comment_date = \'0000-00-00 00:00:00\'' );
  2039.         $DB->query'ALTER TABLE T_comments
  2040.                                     MODIFY COLUMN comment_date DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\'' );
  2041.         task_end();
  2042.  
  2043.         task_begin'Normalizing cron jobs...' );
  2044.         $DB->query'UPDATE T_cron__task
  2045.                                         SET ctsk_controller = REPLACE(ctsk_controller, "cron/_", "cron/jobs/_" )
  2046.                                     WHERE ctsk_controller LIKE "cron/_%"' );
  2047.         task_end();
  2048.  
  2049.         task_begin'Extending comments table...' );
  2050.         $DB->query'ALTER TABLE T_comments
  2051.                                     ADD COLUMN comment_rating     TINYINT(1) NULL DEFAULT NULL AFTER comment_content,
  2052.                                     ADD COLUMN comment_featured   TINYINT(1) NOT NULL DEFAULT 0 AFTER comment_rating,
  2053.                                     ADD COLUMN comment_nofollow   TINYINT(1) NOT NULL DEFAULT 1 AFTER comment_featured;');
  2054.         task_end();
  2055.  
  2056.         set_upgrade_checkpoint'9500' );
  2057.     }
  2058.  
  2059.  
  2060.     if$old_db_version 9600 )
  2061.     {    // 2.2.0
  2062.         task_begin'Creating global cache table...' );
  2063.         $DB->query'CREATE TABLE T_global__cache (
  2064.                                   cach_name VARCHAR( 30 ) NOT NULL ,
  2065.                                   cach_cache MEDIUMBLOB NULL ,
  2066.                                   PRIMARY KEY ( cach_name )
  2067.                                 )' );
  2068.         task_end();
  2069.  
  2070.         task_begin'Altering posts table...' );
  2071.         $DB->query'ALTER TABLE T_items__item
  2072.                                         MODIFY COLUMN post_datestart DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
  2073.                                         MODIFY COLUMN post_datemodified DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
  2074.                                         ADD COLUMN post_order    float NULL AFTER post_priority,
  2075.                                         ADD COLUMN post_featured tinyint(1) NOT NULL DEFAULT 0 AFTER post_order,
  2076.                                         ADD INDEX post_order( post_order )' );
  2077.         task_end();
  2078.  
  2079.         set_upgrade_checkpoint'9600' );
  2080.     }
  2081.  
  2082.  
  2083.     if$old_db_version 9700 )
  2084.     {    // 2.3.2
  2085.       echo 'Creating PodCast Post Type... ';
  2086.         $DB->query"
  2087.             REPLACE INTO T_items__type ( ptyp_ID, ptyp_name )
  2088.             VALUES ( 2000, 'Podcast' )" );
  2089.         echo "OK.<br />\n";
  2090.  
  2091.         // 2.4.0
  2092.       echo 'Adding additional group permissions... ';
  2093.         $DB->query"
  2094.           ALTER TABLE T_groups
  2095.                     ADD COLUMN grp_perm_bypass_antispam         TINYINT(1)  NOT NULL DEFAULT 0        AFTER grp_perm_blogs,
  2096.                     ADD COLUMN grp_perm_xhtmlvalidation         VARCHAR(10) NOT NULL default 'always' AFTER grp_perm_bypass_antispam,
  2097.                     ADD COLUMN grp_perm_xhtmlvalidation_xmlrpc  VARCHAR(10) NOT NULL default 'always' AFTER grp_perm_xhtmlvalidation,
  2098.                     ADD COLUMN grp_perm_xhtml_css_tweaks        TINYINT(1)  NOT NULL DEFAULT 0        AFTER grp_perm_xhtmlvalidation_xmlrpc,
  2099.               ADD COLUMN grp_perm_xhtml_iframes           TINYINT(1)  NOT NULL DEFAULT 0        AFTER grp_perm_xhtml_css_tweaks,
  2100.               ADD COLUMN grp_perm_xhtml_javascript        TINYINT(1)  NOT NULL DEFAULT 0        AFTER grp_perm_xhtml_iframes,
  2101.                     ADD COLUMN grp_perm_xhtml_objects           TINYINT(1)  NOT NULL DEFAULT 0        AFTER grp_perm_xhtml_javascript " );
  2102.         echo "OK.<br />\n";
  2103.  
  2104.         set_upgrade_checkpoint'9700' );
  2105.     }
  2106.  
  2107.  
  2108.     if$old_db_version 9800 )
  2109.     {    // 2.5.0
  2110.         echo 'Upgrading blogs table... ';
  2111.         db_drop_col'T_blogs''blog_commentsexpire' );
  2112.         echo "OK.<br />\n";
  2113.  
  2114.         echo 'Upgrading items table... ';
  2115.         $DB->query"ALTER TABLE T_items__item
  2116.             CHANGE COLUMN post_urltitle post_urltitle VARCHAR(210) NULL DEFAULT NULL,
  2117.             CHANGE COLUMN post_order    post_order DOUBLE NULL,
  2118.             ADD COLUMN post_titletag  VARCHAR(255) NULL DEFAULT NULL AFTER post_urltitle,
  2119.             ADD COLUMN post_double1   DOUBLE NULL COMMENT 'Custom double value 1' AFTER post_priority,
  2120.             ADD COLUMN post_double2   DOUBLE NULL COMMENT 'Custom double value 2' AFTER post_double1,
  2121.             ADD COLUMN post_double3   DOUBLE NULL COMMENT 'Custom double value 3' AFTER post_double2,
  2122.             ADD COLUMN post_double4   DOUBLE NULL COMMENT 'Custom double value 4' AFTER post_double3,
  2123.             ADD COLUMN post_double5   DOUBLE NULL COMMENT 'Custom double value 5' AFTER post_double4,
  2124.             ADD COLUMN post_varchar1  VARCHAR(255) NULL COMMENT 'Custom varchar value 1' AFTER post_double5,
  2125.             ADD COLUMN post_varchar2  VARCHAR(255) NULL COMMENT 'Custom varchar value 2' AFTER post_varchar1,
  2126.             ADD COLUMN post_varchar3  VARCHAR(255) NULL COMMENT 'Custom varchar value 3' AFTER post_varchar2" );
  2127.         echo "OK.<br />\n";
  2128.  
  2129.          echo 'Creating keyphrase table... ';
  2130.         $query "CREATE TABLE T_track__keyphrase (
  2131.             keyp_ID      INT UNSIGNED NOT NULL AUTO_INCREMENT,
  2132.             keyp_phrase  VARCHAR( 255 ) NOT NULL,
  2133.             PRIMARY KEY        ( keyp_ID ),
  2134.             UNIQUE keyp_phrase ( keyp_phrase )
  2135.           )";
  2136.         $DB->query$query );
  2137.         echo "OK.<br />\n";
  2138.  
  2139.          echo 'Upgrading hitlog table... ';
  2140.         $query "ALTER TABLE T_hitlog
  2141.              CHANGE COLUMN hit_ID hit_ID              INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  2142.              CHANGE COLUMN hit_datetime hit_datetime  DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00',
  2143.              ADD COLUMN hit_keyphrase_keyp_ID         INT UNSIGNED DEFAULT NULL AFTER hit_referer_dom_ID,
  2144.              ADD INDEX hit_remote_addr ( hit_remote_addr ),
  2145.              ADD INDEX hit_sess_ID        ( hit_sess_ID )";
  2146.         $DB->query$query );
  2147.         echo "OK.<br />\n";
  2148.  
  2149.         echo 'Upgrading sessions table... ';
  2150.         $DB->query"ALTER TABLE T_sessions
  2151.             ALTER COLUMN sess_lastseen SET DEFAULT '2000-01-01 00:00:00',
  2152.             ADD COLUMN sess_hitcount  INT(10) UNSIGNED NOT NULL DEFAULT 1 AFTER sess_key,
  2153.             ADD KEY sess_user_ID (sess_user_ID)" );
  2154.         echo "OK.<br />\n";
  2155.  
  2156.         echo 'Creating goal tracking table... ';
  2157.     $DB->query"CREATE TABLE T_track__goal(
  2158.                       goal_ID int(10) unsigned NOT NULL auto_increment,
  2159.                       goal_name varchar(50) default NULL,
  2160.                       goal_key varchar(32) default NULL,
  2161.                       goal_redir_url varchar(255) default NULL,
  2162.                       goal_default_value double default NULL,
  2163.                       PRIMARY KEY (goal_ID),
  2164.                       UNIQUE KEY goal_key (goal_key)
  2165.           )" );
  2166.  
  2167.     $DB->query"CREATE TABLE T_track__goalhit (
  2168.                       ghit_ID int(10) unsigned NOT NULL auto_increment,
  2169.                       ghit_goal_ID    int(10) unsigned NOT NULL,
  2170.                       ghit_hit_ID     int(10) unsigned NOT NULL,
  2171.                       ghit_params     TEXT default NULL,
  2172.                       PRIMARY KEY  (ghit_ID),
  2173.                       KEY ghit_goal_ID (ghit_goal_ID),
  2174.                       KEY ghit_hit_ID (ghit_hit_ID)
  2175.          )" );
  2176.         echo "OK.<br />\n";
  2177.  
  2178.         set_upgrade_checkpoint'9800' );
  2179.     }
  2180.  
  2181.  
  2182.     if$old_db_version 9900 )
  2183.     {    // 3.0 part 1
  2184.         task_begin'Updating keyphrases in hitlog table... ' );
  2185.         flush();
  2186.         load_class'sessions/model/_hit.class.php''Hit' );
  2187.         $sql 'SELECT SQL_NO_CACHE hit_ID, hit_referer
  2188.                     FROM T_hitlog
  2189.                     WHERE hit_referer_type = "search"
  2190.                    AND hit_keyphrase_keyp_ID IS NULL'// this line just in case we crashed in the middle, so we restart where we stopped
  2191.         $rows $DB->get_results$sqlOBJECT'get all search hits' );
  2192.         foreach$rows as $row )
  2193.         {
  2194.             $keyphrase Hit::extract_keyphrase_from_referer$row->hit_referer );
  2195.             ifempty$keyphrase ) )
  2196.             {
  2197.                 continue;
  2198.             }
  2199.  
  2200.             $DB->begin();
  2201.  
  2202.             $sql 'SELECT keyp_ID
  2203.                       FROM T_track__keyphrase
  2204.                      WHERE keyp_phrase = '.$DB->quote($keyphrase);
  2205.             $keyp_ID $DB->get_var$sql00'Get keyphrase ID' );
  2206.  
  2207.             ifempty$keyp_ID ) )
  2208.             {
  2209.                 $sql 'INSERT INTO T_track__keyphrase( keyp_phrase )
  2210.                         VALUES ('.$DB->quote($keyphrase).')';
  2211.                 $DB->query$sql'Add new keyphrase' );
  2212.                 $keyp_ID $DB->insert_id;
  2213.             }
  2214.  
  2215.             $DB->query'UPDATE T_hitlog
  2216.                             SET hit_keyphrase_keyp_ID = '.$keyp_ID.'
  2217.                           WHERE hit_ID = '.$row->hit_ID'Update hit' );
  2218.  
  2219.             $DB->commit();
  2220.             echo ". \n";
  2221.         }
  2222.         task_end();
  2223.  
  2224.         task_begin'Upgrading widgets table... ' );
  2225.         $DB->query"ALTER TABLE T_widget
  2226.             CHANGE COLUMN wi_order wi_order INT(10) NOT NULL" );
  2227.         task_end();
  2228.  
  2229.         task_begin'Upgrading Files table... ' );
  2230.         $DB->query"ALTER TABLE T_files
  2231.                                 CHANGE COLUMN file_root_type file_root_type enum('absolute','user','collection','shared','skins') not null default 'absolute'" );
  2232.         task_end();
  2233.  
  2234.         set_upgrade_checkpoint'9900' );
  2235.     }
  2236.  
  2237.     if$old_db_version 9910 )
  2238.     {    // 3.0 part 2
  2239.  
  2240.         task_begin'Upgrading Blogs table... ' );
  2241.         $DB->query"ALTER TABLE T_blogs CHANGE COLUMN blog_name blog_name varchar(255) NOT NULL default ''" );
  2242.         task_end();
  2243.  
  2244.         task_begin'Adding new Post Types...' );
  2245.         $DB->query"
  2246.             REPLACE INTO T_items__type( ptyp_ID, ptyp_name )
  2247.             VALUES ( 1500, 'Intro-Main' ),
  2248.                          ( 1520, 'Intro-Cat' ),
  2249.                          ( 1530, 'Intro-Tag' ),
  2250.                          ( 1570, 'Intro-Sub' ),
  2251.                          ( 1600, 'Intro-All' ) " );
  2252.         task_end();
  2253.  
  2254.         task_begin'Updating User table' );
  2255.         $DB->query"ALTER TABLE T_users
  2256.                                     ADD COLUMN user_avatar_file_ID int(10) unsigned default NULL AFTER user_validated" );
  2257.         task_end();
  2258.  
  2259.         task_begin'Creating table for User field definitions' );
  2260.         $DB->query"CREATE TABLE T_users__fielddefs (
  2261.                 ufdf_ID int(10) unsigned NOT NULL,
  2262.                 ufdf_type char(8) NOT NULL,
  2263.                 ufdf_name varchar(255) collate latin1_general_ci NOT NULL,
  2264.                 PRIMARY KEY  (ufdf_ID)
  2265.             )" );
  2266.         task_end();
  2267.  
  2268.         task_begin'Creating default field definitions...' );
  2269.         $DB->query"
  2270.         INSERT INTO T_users__fielddefs (ufdf_ID, ufdf_type, ufdf_name)
  2271.              VALUES ( 10000, 'email',    'MSN/Live IM'),
  2272.                             ( 10100, 'word',     'Yahoo IM'),
  2273.                             ( 10200, 'word',     'AOL AIM'),
  2274.                             ( 10300, 'number',   'ICQ ID'),
  2275.                             ( 40000, 'phone',    'Skype'),
  2276.                             ( 50000, 'phone',    'Main phone'),
  2277.                             ( 50100, 'phone',    'Cell phone'),
  2278.                             ( 50200, 'phone',    'Office phone'),
  2279.                             ( 50300, 'phone',    'Home phone'),
  2280.                             ( 60000, 'phone',    'Office FAX'),
  2281.                             ( 60100, 'phone',    'Home FAX'),
  2282.                             (100000, 'url',      'Website'),
  2283.                             (100100, 'url',      'Blog'),
  2284.                             (110000, 'url',      'Linkedin'),
  2285.                             (120000, 'url',      'Twitter'),
  2286.                             (130100, 'url',      'Facebook'),
  2287.                             (130200, 'url',      'Myspace'),
  2288.                             (140000, 'url',      'Flickr'),
  2289.                             (150000, 'url',      'YouTube'),
  2290.                             (160000, 'url',      'Digg'),
  2291.                             (160100, 'url',      'StumbleUpon'),
  2292.                             (200000, 'text',     'Role'),
  2293.                             (200100, 'text',     'Company/Org.'),
  2294.                             (200200, 'text',     'Division'),
  2295.                             (211000, 'text',     'VAT ID'),
  2296.                             (300000, 'text',     'Main address'),
  2297.                             (300300, 'text',     'Home address');" );
  2298.         task_end();
  2299.  
  2300.         task_begin'Creating table for User fields...' );
  2301.         $DB->query"CREATE TABLE T_users__fields (
  2302.                 uf_ID      int(10) unsigned NOT NULL auto_increment,
  2303.               uf_user_ID int(10) unsigned NOT NULL,
  2304.               uf_ufdf_ID int(10) unsigned NOT NULL,
  2305.               uf_varchar varchar(255) NOT NULL,
  2306.               PRIMARY KEY (uf_ID)
  2307.             )" );
  2308.         task_end();
  2309.  
  2310.         set_upgrade_checkpoint'9910' );
  2311.     }
  2312.  
  2313.     if$old_db_version 9920 )
  2314.     {    // 3.1
  2315.         task_begin'Upgrading Posts table... ' );
  2316.         // This is for old posts that may have a post type of NULL which should never happen. ptyp 1 is for regular posts
  2317.         $DB->query"UPDATE T_items__item
  2318.                                         SET post_ptyp_ID = 1
  2319.                                     WHERE post_ptyp_ID IS NULL" );
  2320.         $DB->query"ALTER TABLE T_items__item
  2321.                             CHANGE COLUMN post_ptyp_ID post_ptyp_ID int(10) unsigned NOT NULL DEFAULT 1" );
  2322.         task_end();
  2323.  
  2324.         task_begin'Upgrading Categories table... ' );
  2325.         $DB->query"ALTER TABLE T_categories
  2326.             CHANGE COLUMN cat_name cat_name varchar(255) NOT NULL,
  2327.             CHANGE COLUMN cat_description cat_description varchar(255) NULL DEFAULT NULL" );
  2328.         db_add_col'T_categories''cat_order''int(11) NULL DEFAULT NULL AFTER cat_description' );
  2329.         db_add_index'T_categories''cat_order''cat_order' );
  2330.  
  2331.         $DB->query"UPDATE T_categories
  2332.                     SET cat_order = cat_ID" );
  2333.         task_end();
  2334.  
  2335.         task_begin'Upgrading widgets table... ' );
  2336.         db_add_col'T_widget''wi_enabled''tinyint(1) NOT NULL DEFAULT 1 AFTER wi_order' );
  2337.         task_end();
  2338.     }
  2339.     if$old_db_version 9930 )
  2340.     {    // 3.1 continued
  2341.         task_begin'Updating item types...' );
  2342.         $DB->query"
  2343.             REPLACE INTO T_items__type ( ptyp_ID, ptyp_name )
  2344.             VALUES ( 3000, 'Sidebar link' )" );
  2345.         echo "OK.<br />\n";
  2346.         task_end();
  2347.  
  2348.         task_begin'Updating items table...' );
  2349.         $DB->query"ALTER TABLE T_items__item ENGINE=innodb" );    // fp> hum... this originally was a test :)
  2350.         task_end();
  2351.  
  2352.         task_begin'Creating versions table...' );
  2353.         $DB->query"CREATE TABLE T_items__version (
  2354.                 iver_itm_ID        INT UNSIGNED NOT NULL ,
  2355.                 iver_edit_user_ID  INT UNSIGNED NOT NULL ,
  2356.                 iver_edit_datetime DATETIME NOT NULL ,
  2357.                 iver_status        ENUM('published','deprecated','protected','private','draft','redirected') NULL ,
  2358.                 iver_title         TEXT NULL ,
  2359.                 iver_content       MEDIUMTEXT NULL ,
  2360.                 INDEX iver_itm_ID ( iver_itm_ID )
  2361.                 ) ENGINE = innodb" );
  2362.         task_end();
  2363.  
  2364.         task_begin'Updating group permissions...' );
  2365.         $DB->query"UPDATE T_groups
  2366.                                         SET grp_perm_xhtml_css_tweaks = 1
  2367.                                     WHERE grp_ID <= 3" );
  2368.         task_end();
  2369.  
  2370.         set_upgrade_checkpoint'9930' );
  2371.     }
  2372.  
  2373.     if$old_db_version 9940 )
  2374.     {    // 3.2
  2375.         task_begin'Updating hitlog table...' );
  2376.         $DB->query"ALTER TABLE T_hitlog ADD COLUMN hit_serprank INT UNSIGNED DEFAULT NULL AFTER hit_keyphrase_keyp_ID" );
  2377.         task_end();
  2378.  
  2379.         task_begin'Updating versions table...' );
  2380.         $DB->query"ALTER TABLE T_items__version
  2381.                                 CHANGE COLUMN iver_edit_user_ID iver_edit_user_ID  INT UNSIGNED NULL" );
  2382.         task_end();
  2383.     }
  2384.  
  2385.     if$old_db_version 9950 )
  2386.     {    // 3.3
  2387.         task_begin'Altering Blogs table... ' );
  2388.         $DB->query"ALTER TABLE T_blogs CHANGE COLUMN blog_shortname blog_shortname varchar(255) default ''" );
  2389.         task_end();
  2390.  
  2391.         task_begin'Altering default dates... ' );
  2392.         $DB->query"ALTER TABLE T_links
  2393.       ALTER COLUMN link_datecreated SET DEFAULT '2000-01-01 00:00:00',
  2394.       ALTER COLUMN link_datemodified SET DEFAULT '2000-01-01 00:00:00'" );
  2395.         $DB->query"ALTER TABLE T_cron__task
  2396.       ALTER COLUMN ctsk_start_datetime SET DEFAULT '2000-01-01 00:00:00'" );
  2397.         $DB->query"ALTER TABLE T_cron__log
  2398.       ALTER COLUMN clog_realstart_datetime SET DEFAULT '2000-01-01 00:00:00'" );
  2399.         task_end();
  2400.  
  2401.          task_begin'Altering Items table... ' );
  2402.         $DB->query"ALTER TABLE T_items__item
  2403.             ADD COLUMN post_metadesc VARCHAR(255) NULL DEFAULT NULL AFTER post_titletag,
  2404.             ADD COLUMN post_metakeywords VARCHAR(255) NULL DEFAULT NULL AFTER post_metadesc,
  2405.             ADD COLUMN post_editor_code VARCHAR(32) NULL COMMENT 'Plugin code of the editor used to edit this post' AFTER post_varchar3" );
  2406.         task_end();
  2407.  
  2408.         task_begin'Forcing AutoP posts to html editor...' );
  2409.         $DB->query'UPDATE T_items__item
  2410.                                             SET post_editor_code = "html"
  2411.                                         WHERE post_renderers = "default"
  2412.                                              OR post_renderers LIKE "%b2WPAutP%"' );
  2413.         task_end();
  2414.  
  2415.         set_upgrade_checkpoint'9950' );
  2416.     }
  2417.  
  2418.     if$old_db_version 9960 )
  2419.     {    // 3.3
  2420.  
  2421.         echo "Renaming tables...";
  2422.         $DB->save_error_state();
  2423.         $DB->halt_on_error false;
  2424.         $DB->show_errors false;
  2425.         $DB->query"ALTER TABLE {$tableprefix}users_fields RENAME TO T_users__fields);
  2426.         $DB->restore_error_state();
  2427.         echo "OK.<br />\n";
  2428.  
  2429.         // fp> The following is more tricky to do with CHARACTER SET. During upgrade, we don't know what the admin actually wants.
  2430.         task_begin'Making sure all tables use desired storage ENGINE...' );
  2431.         foreach$schema_queries as $table_name=>$table_def )
  2432.         {
  2433.             if$DB->query'SHOW TABLES LIKE \''.$table_name.'\'' )
  2434.                 && preg_match'/\sENGINE\s*=\s*([a-z]+)/is'$table_def[1]$matches ) )
  2435.             {    // If the table exists and has an ENGINE definition:
  2436.                 echo $table_name.':'.$matches[1].'<br />';
  2437.                 $DB->query"ALTER TABLE $table_name ENGINE = ".$matches[1);
  2438.             }
  2439.         }
  2440.         task_end();
  2441.  
  2442.         set_upgrade_checkpoint'9960' );
  2443.     }
  2444.  
  2445.     if$old_db_version 9970 )
  2446.     {    // 4.0 part 1
  2447.  
  2448.         // For create_default_currencies() and create_default_countries():
  2449.         require_once dirname(__FILE__).'/_functions_create.php';
  2450.  
  2451.         task_begin'Creating table for default currencies... ' );
  2452.         $DB->query"CREATE TABLE T_currency (
  2453.                 curr_ID int(10) unsigned NOT NULL auto_increment,
  2454.                 curr_code char(3) NOT NULL,
  2455.                 curr_shortcut varchar(30) NOT NULL,
  2456.                 curr_name varchar(40) NOT NULL,
  2457.                 PRIMARY KEY curr_ID (curr_ID),
  2458.                 UNIQUE curr_code (curr_code)
  2459.             ) ENGINE = innodb" );
  2460.         task_end();
  2461.  
  2462.         create_default_currencies();
  2463.  
  2464.         task_begin'Creating table for default countries... ' );
  2465.         $DB->query"CREATE TABLE T_country (
  2466.                 ctry_ID int(10) unsigned NOT NULL auto_increment,
  2467.                 ctry_code char(2) NOT NULL,
  2468.                 ctry_name varchar(40) NOT NULL,
  2469.                 ctry_curr_ID int(10) unsigned,
  2470.                 PRIMARY KEY ctry_ID (ctry_ID),
  2471.                 UNIQUE ctry_code (ctry_code)
  2472.             ) ENGINE = innodb" );
  2473.         task_end();
  2474.  
  2475.         create_default_countries();
  2476.  
  2477.         task_begin'Upgrading user permissions table... ' );
  2478.         $DB->query"ALTER TABLE T_coll_user_perms
  2479.             ADD COLUMN bloguser_perm_page        tinyint NOT NULL default 0 AFTER bloguser_perm_media_change,
  2480.             ADD COLUMN bloguser_perm_intro        tinyint NOT NULL default 0 AFTER bloguser_perm_page,
  2481.             ADD COLUMN bloguser_perm_podcast    tinyint NOT NULL default 0 AFTER bloguser_perm_intro,
  2482.             ADD COLUMN bloguser_perm_sidebar    tinyint NOT NULL default 0 AFTER bloguser_perm_podcast" );
  2483.         task_end();
  2484.  
  2485.         task_begin'Upgrading group permissions table... ' );
  2486.         $DB->query"ALTER TABLE T_coll_group_perms
  2487.             ADD COLUMN bloggroup_perm_page        tinyint NOT NULL default 0 AFTER bloggroup_perm_media_change,
  2488.             ADD COLUMN bloggroup_perm_intro        tinyint NOT NULL default 0 AFTER bloggroup_perm_page,
  2489.             ADD COLUMN bloggroup_perm_podcast    tinyint NOT NULL default 0 AFTER bloggroup_perm_intro,
  2490.             ADD COLUMN bloggroup_perm_sidebar    tinyint NOT NULL default 0 AFTER bloggroup_perm_podcast" );
  2491.         task_end();
  2492.  
  2493.         task_begin'Upgrading users table... ' );
  2494.         $DB->query"ALTER TABLE T_users
  2495.             ADD COLUMN user_ctry_ID int(10) unsigned NULL AFTER user_avatar_file_ID" );
  2496.         task_end();
  2497.  
  2498.         // Creating tables for messaging module
  2499.  
  2500.         task_begin'Creating table for message threads... ' );
  2501.         $DB->query"CREATE TABLE T_messaging__thread (
  2502.             thrd_ID int(10) unsigned NOT NULL auto_increment,
  2503.             thrd_title varchar(255) NOT NULL,
  2504.             thrd_datemodified datetime NOT NULL,
  2505.             PRIMARY KEY thrd_ID (thrd_ID)
  2506.         ) ENGINE = innodb" );
  2507.         task_end();
  2508.  
  2509.         task_begin'Creating table for messagee... ' );
  2510.         $DB->query"CREATE TABLE T_messaging__message (
  2511.             msg_ID int(10) unsigned NOT NULL auto_increment,
  2512.             msg_author_user_ID int(10) unsigned NOT NULL,
  2513.             msg_datetime datetime NOT NULL,
  2514.             msg_thread_ID int(10) unsigned NOT NULL,
  2515.             msg_text text NULL,
  2516.             PRIMARY KEY msg_ID (msg_ID)
  2517.         ) ENGINE = innodb" );
  2518.         task_end();
  2519.  
  2520.         task_begin'Creating table for message thread statuses... ' );
  2521.         $DB->query"CREATE TABLE T_messaging__threadstatus (
  2522.             tsta_thread_ID int(10) unsigned NOT NULL,
  2523.             tsta_user_ID int(10) unsigned NOT NULL,
  2524.             tsta_first_unread_msg_ID int(10) unsigned NULL,
  2525.             INDEX(tsta_user_ID)
  2526.         ) ENGINE = innodb" );
  2527.         task_end();
  2528.  
  2529.         task_begin'Creating table for messaging contacts... ' );
  2530.         $DB->query"CREATE TABLE T_messaging__contact (
  2531.             mct_from_user_ID int(10) unsigned NOT NULL,
  2532.             mct_to_user_ID int(10) unsigned NOT NULL,
  2533.             mct_blocked tinyint(1) default 0,
  2534.             mct_last_contact_datetime datetime NOT NULL,
  2535.             PRIMARY KEY mct_PK (mct_from_user_ID, mct_to_user_ID)
  2536.         ) ENGINE = innodb" );
  2537.         task_end();
  2538.  
  2539.         task_begin'Upgrading skins table... ' );
  2540.         $DB->query"ALTER TABLE T_skins__skin
  2541.                         MODIFY skin_type enum('normal','feed','sitemap') NOT NULL default 'normal'" );
  2542.         task_end();
  2543.  
  2544.         task_begin'Setting skin type of sitemap skin to "sitemap"... ' );
  2545.         $DB->query"UPDATE T_skins__skin
  2546.                         SET skin_type = 'sitemap'
  2547.                         WHERE skin_folder = '_sitemap'" );
  2548.         task_end();
  2549.  
  2550.         // Creating table for pluggable permissions
  2551.  
  2552.         task_begin'Creating table for Group Settings... ' );
  2553.         $DB->query"CREATE TABLE T_groups__groupsettings (
  2554.             gset_grp_ID INT(11) UNSIGNED NOT NULL,
  2555.             gset_name VARCHAR(30) NOT NULL,
  2556.             gset_value VARCHAR(255) NULL,
  2557.             PRIMARY KEY (gset_grp_ID, gset_name)
  2558.         ) ENGINE = innodb" );
  2559.         task_end();
  2560.  
  2561.         // Rename T_usersettings table to T_users__usersettings
  2562.  
  2563.         task_begin'Rename T_usersettings table to T_users__usersettings... ' );
  2564.         $DB->query'RENAME TABLE '.$tableprefix.'usersettings TO T_users__usersettings' );
  2565.         task_end();
  2566.  
  2567.         set_upgrade_checkpoint'9970' );
  2568.     }
  2569.  
  2570.  
  2571.     if$old_db_version 9980 )
  2572.     {    // 4.0 part 2
  2573.  
  2574.         task_begin'Upgrading posts... ' );
  2575.         $DB->query'
  2576.             UPDATE T_items__item
  2577.                SET post_datestart = FROM_UNIXTIME( FLOOR(UNIX_TIMESTAMP(post_datestart)/60)*60 )
  2578.              WHERE post_datestart > NOW()' );
  2579.         db_add_col'T_items__item''post_excerpt_autogenerated''TINYINT NULL DEFAULT NULL AFTER post_excerpt' );
  2580.         db_add_col'T_items__item''post_dateset''tinyint(1) NOT NULL DEFAULT 1 AFTER post_assigned_user_ID' );
  2581.         task_end();
  2582.  
  2583.         task_begin'Upgrading countries... ' );
  2584.         db_add_col'T_country''ctry_enabled''tinyint(1) NOT NULL DEFAULT 1 AFTER ctry_curr_ID' );
  2585.         task_end();
  2586.  
  2587.  
  2588.         task_begin'Upgrading links... ' );
  2589.  
  2590.         // Add link_position. Temporary allow NULL, set compatibility default, then do not allow NULL.
  2591.         // TODO: dh> actually, using "teaser" for the first link and "aftermore" for the rest would make more sense (and "aftermore" should get displayed with "no-more" posts anyway).
  2592.         //           Opinions? Could be heavy to transform this though..
  2593.         // fp> no, don't change past posts unexpectedly.
  2594.         db_add_col'T_links''link_position'"varchar(10) NULL AFTER link_title" );
  2595.         $DB->query"UPDATE T_links SET link_position = 'teaser' WHERE link_position IS NULL" );
  2596.         db_add_col'T_links''link_position'"varchar(10) NOT NULL AFTER link_title" )// change to NOT NULL
  2597.  
  2598.         // Add link_order. Temporary allow NULL, use order from ID, then do not allow NULL and add UNIQUE index.
  2599.         db_add_col'T_links''link_order''int(11) unsigned NULL AFTER link_position' );
  2600.         $DB->query"UPDATE T_links SET link_order = link_ID WHERE link_order IS NULL" );
  2601.         db_add_col'T_links''link_order''int(11) unsigned NOT NULL AFTER link_position' )// change to NOT NULL
  2602.         db_add_index'T_links''link_itm_ID_order''link_itm_ID, link_order''UNIQUE' );
  2603.  
  2604.         task_end();
  2605.  
  2606.         task_begin'Upgrading sessions... ' );
  2607.         $DB->query"ALTER TABLE T_sessions CHANGE COLUMN sess_ipaddress sess_ipaddress VARCHAR(39) NOT NULL DEFAULT ''" );
  2608.         task_end();
  2609.  
  2610.         set_upgrade_checkpoint'9980' );
  2611.     }
  2612.  
  2613.     if$old_db_version 9990 )
  2614.     {    // 4.0 part 3
  2615.  
  2616.         task_begin'Upgrading hitlog... ' );
  2617.  
  2618.         db_add_col'T_hitlog''hit_agent_type'"ENUM('rss','robot','browser','unknown') DEFAULT 'unknown' NOT NULL AFTER hit_remote_addr" );
  2619.  
  2620.         ifdb_col_exists('T_hitlog''hit_agnt_ID') )
  2621.         {
  2622.             $DB->query'UPDATE T_hitlog, '.$tableprefix.'useragents
  2623.                             SET hit_agent_type = agnt_type
  2624.                           WHERE hit_agnt_ID = agnt_ID
  2625.                             AND agnt_type <> "unknown"' )// We already have the unknown as default
  2626.             db_drop_col'T_hitlog''hit_agnt_ID' );
  2627.         }
  2628.         $DB->query'DROP TABLE IF EXISTS '.$tableprefix.'useragents' );
  2629.  
  2630.         task_end();
  2631.  
  2632.         // set_upgrade_checkpoint( '9990' );
  2633.     }
  2634.     
  2635.     
  2636.     // Integrate comment_secret
  2637.     task_begin'Extending Comment table... ' );
  2638.     db_add_col'T_comments''comment_secret''varchar(32) NULL default NULL' );
  2639.     task_end();
  2640.     
  2641.  
  2642.     /*
  2643.      * ADD UPGRADES HERE.
  2644.      *
  2645.      * ALL DB CHANGES MUST BE EXPLICITELY CARRIED OUT. DO NOT RELY ON SCHEMA UPDATES!
  2646.      * Schema updates do not survive after several incremental changes.
  2647.      *
  2648.      * NOTE: every change that gets done here, should bump {@link $new_db_version} (by 100).
  2649.      */
  2650.  
  2651.  
  2652.  
  2653.     /* Wait until we're sure and no longer experimental for that one...
  2654.     task_begin( 'Moving user data to fields' );
  2655.     // ICQ
  2656.     $DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
  2657.                              SELECT user_ID, 10300, user_icq
  2658.                                  FROM T_users
  2659.                                 WHERE user_msn IS NOT NULL AND TRIM(user_icq) <> ''" );
  2660.     // URL
  2661.     $DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
  2662.                              SELECT user_ID, 100000, user_url
  2663.                                  FROM T_users
  2664.                                 WHERE user_msn IS NOT NULL AND TRIM(user_url) <> ''" );
  2665.     // AIM
  2666.     $DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
  2667.                              SELECT user_ID, 10200, user_aim
  2668.                                  FROM T_users
  2669.                                 WHERE user_msn IS NOT NULL AND TRIM(user_aim) <> ''" );
  2670.     // MSN/live IM
  2671.     $DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
  2672.                              SELECT user_ID, 10000, user_msn
  2673.                                  FROM T_users
  2674.                                 WHERE user_msn IS NOT NULL AND TRIM(user_msn) <> ''" );
  2675.     // Yahoo IM
  2676.     $DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
  2677.                              SELECT user_ID, 10100, user_yim
  2678.                                  FROM T_users
  2679.                                 WHERE user_msn IS NOT NULL AND TRIM(user_yim) <> ''" );
  2680.     task_end();
  2681.     */
  2682.  
  2683.  
  2684.  
  2685.     // Just in case, make sure the db schema version is upto date at the end.
  2686.     if$old_db_version != $new_db_version )
  2687.     // Update DB schema version to $new_db_version
  2688.         set_upgrade_checkpoint$new_db_version );
  2689.     }
  2690.  
  2691.  
  2692.  
  2693.     // This has to be at the end because plugin install may fail if the DB schema is not current (matching Plugins class).
  2694.     // Only new default plugins will be installed, based on $old_db_version.
  2695.     // dh> NOTE: if this fails (e.g. fatal error in one of the plugins), it will not get repeated
  2696.     install_basic_plugins$old_db_version );
  2697.  
  2698.  
  2699.     /*
  2700.      * -----------------------------------------------
  2701.      * Check to make sure the DB schema is up to date:
  2702.      * -----------------------------------------------
  2703.      */
  2704.     $upgrade_db_deltas array()// This holds changes to make, if any (just all queries)
  2705.  
  2706.     global $debug;
  2707.  
  2708.     foreach$schema_queries as $table => $query_info )
  2709.     {    // For each table in the schema, check diffs...
  2710.         if$debug )
  2711.         {
  2712.             echo '<br />Checking table: '.$table.': ';
  2713.         }
  2714.         $updates db_delta$query_info[1]array('drop_column''drop_index')falsetrue );
  2715.         ifempty($updates) )
  2716.         {
  2717.             if$debug echo 'ok';
  2718.         }
  2719.         else
  2720.         {
  2721.             if$debug echo 'NEEDS UPDATE!';
  2722.             foreach$updates as $table => $queries )
  2723.             {
  2724.                 foreach$queries as $qinfo )
  2725.                 {
  2726.                     foreach$qinfo['queries'as $query )
  2727.                     // subqueries for this query (usually one, but may include required other queries)
  2728.                         $upgrade_db_deltas[$query;
  2729.                     }
  2730.                 }
  2731.             }
  2732.         }
  2733.     }
  2734.  
  2735.     if$debug )
  2736.     {
  2737.         echo '<br />';
  2738.     }
  2739.  
  2740.     ifempty($upgrade_db_deltas) )
  2741.     {    // no upgrades needed:
  2742.         echo '<p>'.T_('The database schema is up to date.').'</p>';
  2743.     }
  2744.     else
  2745.     {    // Upgrades are needed:
  2746.  
  2747.         $confirmed_db_upgrade param('confirmed''integer'0)// force confirmation
  2748.         $upgrade_db_deltas_confirm_md5 param'upgrade_db_deltas_confirm_md5''string''' );
  2749.  
  2750.         if$confirmed_db_upgrade )
  2751.         {
  2752.             ifempty($upgrade_db_deltas_confirm_md5) )
  2753.             // received confirmation from form
  2754.                 if$upgrade_db_deltas_confirm_md5 != md5implode(''$upgrade_db_deltas) ) )
  2755.                 // unlikely to happen
  2756.                     echo '<p class="error">'
  2757.                         .T_('The DB schema has been changed since confirmation.')
  2758.                         .'</p>';
  2759.                 }
  2760.                 else
  2761.                 {
  2762.                     $confirmed_db_upgrade true;
  2763.                 }
  2764.             }
  2765.         }
  2766.  
  2767.         if$confirmed_db_upgrade )
  2768.         {
  2769.             global $action$locale$form_action;
  2770.             load_class'_core/ui/forms/_form.class.php''Form' );
  2771.  
  2772.             if!empty$form_action ) )
  2773.             {
  2774.                 $Form new Form$form_action'''post' );
  2775.             }
  2776.             else
  2777.             {
  2778.                 $Form new FormNULL'''post' );
  2779.             }
  2780.  
  2781.             $Form->begin_form'fform'T_('Upgrade database') );
  2782.  
  2783.             $Form->begin_fieldset();
  2784.             $Form->hidden'upgrade_db_deltas_confirm_md5'md5(implode''$upgrade_db_deltas )) );
  2785.             $Form->hidden'action'$action );
  2786.             $Form->hidden'locale'$locale );
  2787.  
  2788.  
  2789.             echo '<p>'.T_('The version number is correct, but we have detected changes in the database schema. This can happen with CVS versions...').'</p>';
  2790.  
  2791.             echo '<p>'.T_('The following database changes will be carried out. If you are not sure what this means, it will probably be alright.').'</p>';
  2792.  
  2793.             echo '<ul>';
  2794.             foreach$upgrade_db_deltas as $l_delta )
  2795.             {
  2796.                 #echo '<li><code>'.nl2br($l_delta).'</code></li>';
  2797.                 echo '<li><pre>'.str_replace"\t"'  '$l_delta ).'</pre></li>';
  2798.             }
  2799.             echo '</ul>';
  2800.             $Form->submitarray''T_('Upgrade database!')'ActionButton' ) );
  2801.             $Form->end_form();
  2802.  
  2803.             return false;
  2804.         }
  2805.  
  2806.         // Alter DB to match DB schema:
  2807.         install_make_db_schema_currenttrue );
  2808.     }
  2809.  
  2810.     return true;
  2811. }
  2812.  
  2813.  
  2814. /*
  2815.  * $Log: _functions_evoupgrade.php,v $
  2816.  * Revision 1.357  2010/03/04 15:55:17  efy-asimo
  2817.  * integrate comment_secret into the upgrade procedure
  2818.  *
  2819.  * Revision 1.356  2010/02/26 22:15:50  fplanque
  2820.  * whitespace/doc/minor
  2821.  *
  2822.  * Revision 1.355  2010/02/12 18:22:05  efy-yury
  2823.  * add atnispam query obfuscating
  2824.  *
  2825.  * Revision 1.354  2010/02/08 17:55:33  efy-yury
  2826.  * copyright 2009 -> 2010
  2827.  *
  2828.  * Revision 1.353  2010/01/09 18:19:06  blueyed
  2829.  * Upgrade: make upgrade of hitlog more robust in regard to already done changes.
  2830.  *
  2831.  * Revision 1.352  2010/01/03 13:45:37  fplanque
  2832.  * set some crumbs (needs checking)
  2833.  *
  2834.  * Revision 1.351  2009/12/22 08:45:44  fplanque
  2835.  * fix install
  2836.  *
  2837.  * Revision 1.350  2009/12/22 02:55:06  blueyed
  2838.  * doc/todo
  2839.  *
  2840.  * Revision 1.349  2009/12/09 22:57:46  blueyed
  2841.  * todo/note
  2842.  *
  2843.  * Revision 1.348  2009/12/09 17:36:45  blueyed
  2844.  * indent
  2845.  *
  2846.  * Revision 1.347  2009/12/08 22:38:13  fplanque
  2847.  * User agent type is now saved directly into the hits table instead of a costly lookup in user agents table
  2848.  *
  2849.  * Revision 1.346  2009/12/01 21:35:56  blueyed
  2850.  * Merge from whissip: use get_row to not fetch all rows. Use proper category urlnames on upgrade.
  2851.  *
  2852.  * Revision 1.345  2009/11/30 01:22:23  fplanque
  2853.  * fix wrong version status message rigth after upgrade
  2854.  *
  2855.  * Revision 1.344  2009/11/19 10:24:48  efy-maxim
  2856.  * maintenance module - 'Upgrade Database' button support.
  2857.  *
  2858.  * Revision 1.343  2009/10/27 23:06:43  fplanque
  2859.  * doc
  2860.  *
  2861.  * Revision 1.342  2009/10/27 21:57:43  fplanque
  2862.  * minor/doc
  2863.  *
  2864.  * Revision 1.341  2009/10/17 16:31:33  efy-maxim
  2865.  * Renamed: T_groupsettings to T_groups__groupsettings, T_usersettings to T_users__usersettings
  2866.  *
  2867.  * Revision 1.340  2009/10/17 14:49:46  fplanque
  2868.  * doc
  2869.  *
  2870.  * Revision 1.339  2009/10/11 03:31:55  blueyed
  2871.  * Upgrade fixes
  2872.  *
  2873.  * Revision 1.338  2009/10/11 03:00:11  blueyed
  2874.  * Add "position" and "order" properties to attachments.
  2875.  * Position can be "teaser" or "aftermore" for now.
  2876.  * Order defines the sorting of attachments.
  2877.  * Needs testing and refinement. Upgrade might work already, be careful!
  2878.  *
  2879.  * Revision 1.337  2009/10/10 20:17:33  tblue246
  2880.  * Minor debug output layout fix
  2881.  *
  2882.  * Revision 1.336  2009/10/10 16:34:44  blueyed
  2883.  * Fix table alias
  2884.  *
  2885.  * Revision 1.335  2009/10/08 20:05:52  efy-maxim
  2886.  * Modular/Pluggable Permissions
  2887.  *
  2888.  * Revision 1.334  2009/10/07 23:43:25  fplanque
  2889.  * doc
  2890.  *
  2891.  * Revision 1.333  2009/10/04 18:26:48  blueyed
  2892.  * Add missing DB transformations, need to get added to blocks.
  2893.  *
  2894.  * Revision 1.332  2009/09/29 13:32:30  tblue246
  2895.  * OK, no DB changes for 3.3.2, moved to 4.0
  2896.  *
  2897.  * Revision 1.331  2009/09/29 03:47:07  fplanque
  2898.  * doc
  2899.  *
  2900.  * Revision 1.330  2009/09/26 13:41:54  tblue246
  2901.  * If XML feeds are disabled for a blog, still allow accessing "sitemap" skins.
  2902.  *
  2903.  * Revision 1.329  2009/09/25 20:26:26  fplanque
  2904.  * fixes/doc
  2905.  *
  2906.  * Revision 1.328  2009/09/25 14:18:22  tblue246
  2907.  * Reverting accidental commits
  2908.  *
  2909.  * Revision 1.326  2009/09/21 03:31:23  fplanque
  2910.  * made autoupgrade more verbose in debug mode
  2911.  *
  2912.  * Revision 1.325  2009/09/20 19:52:21  blueyed
  2913.  * Make ENGINE match more lax.
  2914.  *
  2915.  * Revision 1.324  2009/09/20 19:47:07  blueyed
  2916.  * Add post_excerpt_autogenerated field.
  2917.  * "text" params get unified newlines now and "excerpt" is a text param.
  2918.  * This is required for detecting if it has been changed really.
  2919.  * If something is wrong about this, please make sure that an unchanged
  2920.  * excerpt won't update the one in DB (when posting the item form).
  2921.  *
  2922.  * Revision 1.323  2009/09/19 13:27:15  blueyed
  2923.  * Fix indent
  2924.  *
  2925.  * Revision 1.322  2009/09/18 16:01:50  fplanque
  2926.  * cleanup
  2927.  *
  2928.  * Revision 1.321  2009/09/18 14:22:11  efy-maxim
  2929.  * 1. 'reply' permission in group form
  2930.  * 2. functionality to store and update contacts
  2931.  * 3. fix in misc functions
  2932.  *
  2933.  * Revision 1.320  2009/09/17 11:34:33  efy-maxim
  2934.  * reply permission in create and upgrade functionality
  2935.  *
  2936.  * Revision 1.319  2009/09/14 18:37:07  fplanque
  2937.  * doc/cleanup/minor
  2938.  *
  2939.  * Revision 1.318  2009/09/14 14:55:19  tblue246
  2940.  * Fix upgrade process
  2941.  *
  2942.  * Revision 1.317  2009/09/14 14:10:14  efy-arrin
  2943.  * Included the ClassName in load_class() call with proper UpperCase
  2944.  *
  2945.  * Revision 1.316  2009/09/13 21:29:22  blueyed
  2946.  * MySQL query cache optimization: remove information about seconds from post_datestart and item_issue_date.
  2947.  *
  2948.  * Revision 1.315  2009/09/13 21:26:50  blueyed
  2949.  * SQL_NO_CACHE for SELECT queries using T_hitlog
  2950.  *
  2951.  * Revision 1.314  2009/09/13 15:56:11  fplanque
  2952.  * minor
  2953.  *
  2954.  * Revision 1.313  2009/09/13 12:25:34  efy-maxim
  2955.  * Messaging permissions have been added to:
  2956.  * 1. Upgrader
  2957.  * 2. Group class
  2958.  * 3. Edit Group form
  2959.  *
  2960.  * Revision 1.312  2009/09/12 18:44:11  efy-maxim
  2961.  * Messaging module improvements
  2962.  *
  2963.  * Revision 1.311  2009/09/10 18:24:07  fplanque
  2964.  * doc
  2965.  *
  2966.  * Revision 1.310  2009/09/10 13:44:57  tblue246
  2967.  * Translation fixes/update
  2968.  *
  2969.  * Revision 1.309  2009/09/10 13:10:37  efy-maxim
  2970.  * int(11) has been changed to int(10) for PKs of T_country, T_currency tables
  2971.  *
  2972.  * Revision 1.308  2009/09/10 12:13:33  efy-maxim
  2973.  * Messaging Module
  2974.  *
  2975.  * Revision 1.307  2009/09/07 23:35:51  fplanque
  2976.  * cleanup
  2977.  *
  2978.  * Revision 1.306  2009/09/07 14:42:35  efy-maxim
  2979.  * Create user_ctry_ID column in T_users table in evoupgrade module
  2980.  *
  2981.  * Revision 1.305  2009/09/05 18:49:29  tblue246
  2982.  * Bad idea was a good idea: Use function call instead of duplicate INSERT statements. Meh.
  2983.  *
  2984.  * Revision 1.302  2009/09/05 12:27:20  tblue246
  2985.  * - Fix upgrade
  2986.  * - Use create_default_currencies() and create_default_countries() instead of duplicated queries.
  2987.  *
  2988.  * Revision 1.301  2009/09/05 11:29:28  efy-maxim
  2989.  * Create default currencies and countries. Upgrade currencies and countries.
  2990.  *
  2991.  * Revision 1.300  2009/08/30 00:30:52  fplanque
  2992.  * increased modularity
  2993.  *
  2994.  * Revision 1.299  2009/07/13 00:14:07  fplanque
  2995.  * fixing default dates
  2996.  *
  2997.  * Revision 1.298  2009/07/12 23:54:10  fplanque
  2998.  * rename table
  2999.  *
  3000.  * Revision 1.297  2009/07/12 23:18:22  fplanque
  3001.  * upgrading tables to innodb
  3002.  *
  3003.  * Revision 1.296  2009/07/11 17:18:03  waltercruz
  3004.  * Fixing missing comma
  3005.  *
  3006.  * Revision 1.295  2009/07/10 20:02:10  fplanque
  3007.  * using innodb by default for most tables now.
  3008.  * enabled transactions by default.
  3009.  *
  3010.  * Revision 1.294  2009/07/07 00:34:42  fplanque
  3011.  * Remember whether or not the TinyMCE editor was last used on a per post and per blog basis.
  3012.  *
  3013.  * Revision 1.293  2009/06/20 17:19:33  leeturner2701
  3014.  * meta desc and meta keywords per blog post
  3015.  *
  3016.  * Revision 1.292  2009/06/01 16:23:32  sam2kb
  3017.  * new_db_version updated to 9950
  3018.  *
  3019.  * Revision 1.291  2009/05/31 17:04:42  sam2kb
  3020.  * blog_shortname field extended to 255 characters
  3021.  * Please change the new_db_version
  3022.  *
  3023.  * Revision 1.290  2009/05/28 12:49:48  fplanque
  3024.  * no message
  3025.  *
  3026.  * Revision 1.289  2009/05/10 00:28:51  fplanque
  3027.  * serp rank logging
  3028.  *
  3029.  * Revision 1.288  2009/03/21 22:55:15  fplanque
  3030.  * Adding TinyMCE -- lowfat version
  3031.  *
  3032.  * Revision 1.287  2009/03/13 00:57:35  fplanque
  3033.  * calling it "sidebar links"
  3034.  *
  3035.  * Revision 1.285  2009/03/08 23:57:47  fplanque
  3036.  * 2009
  3037.  *
  3038.  * Revision 1.284  2009/03/03 20:23:46  blueyed
  3039.  * Move extract_keyphrase_from_referer to Hit class. Otherwise it should get moved to hit.funcs.
  3040.  *
  3041.  * Revision 1.283  2009/02/26 22:33:22  blueyed
  3042.  * Fix messup in last commit.
  3043.  *
  3044.  * Revision 1.282  2009/02/26 22:16:54  blueyed
  3045.  * Use load_class for classes (.class.php), and load_funcs for funcs (.funcs.php)
  3046.  *
  3047.  * Revision 1.281  2009/02/25 22:03:19  blueyed
  3048.  * Upgrade: rename ptyp_ID 3000 to 'Linkroll item'
  3049.  *
  3050.  * Revision 1.280  2009/02/25 20:54:47  blueyed
  3051.  *  - db_add_col: if the column exist already, execute an ALTER statement
  3052.  *  - Add db_add_index, which will drop any existing index, and create the
  3053.  *    new one
  3054.  *  - Use db_add_col/db_add_index for latest changes, to prevent errors on
  3055.  *    HEAD installs
  3056.  *
  3057.  * Revision 1.279  2009/02/25 01:31:16  fplanque
  3058.  * upgrade stuff
  3059.  *
  3060.  * Revision 1.278  2009/02/09 19:20:32  blueyed
  3061.  * Fix E_FATAL during upgrade (bpost_count_words not defined)
  3062.  *
  3063.  * Revision 1.277  2009/02/05 21:33:34  tblue246
  3064.  * Allow the user to enable/disable widgets.
  3065.  * Todo:
  3066.  *     * Fix CSS for the widget state bullet @ JS widget UI.
  3067.  *     * Maybe find a better solution than modifying get_Cache() to get only enabled widgets... :/
  3068.  *     * Buffer JS requests when toggling the state of a widget??
  3069.  *
  3070.  * Revision 1.276  2009/01/28 21:23:22  fplanque
  3071.  * Manual ordering of categories
  3072.  *
  3073.  * Revision 1.275  2009/01/28 00:59:19  blueyed
  3074.  * Fixing doc for a block that gets skipped on installs tracking CVS HEAD, again (probably)
  3075.  *
  3076.  * Revision 1.274  2009/01/27 16:48:31  fplanque
  3077.  * quick fix for NULL ptyp_IDs
  3078.  *
  3079.  * Revision 1.273  2009/01/25 19:09:32  blueyed
  3080.  * phpdoc fixes
  3081.  *
  3082.  * Revision 1.272  2009/01/23 18:32:15  fplanque
  3083.  * versioning
  3084.  *
  3085.  * Revision 1.271  2009/01/21 18:52:15  fplanque
  3086.  * fix
  3087.  *
  3088.  * Revision 1.270  2009/01/21 18:23:26  fplanque
  3089.  * Featured posts and Intro posts
  3090.  *
  3091.  * Revision 1.268  2009/01/13 23:45:59  fplanque
  3092.  * User fields proof of concept
  3093.  *
  3094.  * Revision 1.267  2009/01/13 22:51:29  fplanque
  3095.  * rollback / normalized / MFB
  3096.  *
  3097.  * Revision 1.266  2008/12/28 17:35:51  fplanque
  3098.  * increase blog name max length to 255 chars
  3099.  *
  3100.  * Revision 1.265  2008/10/06 03:36:48  fplanque
  3101.  * Added skype field
  3102.  *
  3103.  * Revision 1.264  2008/10/06 01:55:06  fplanque
  3104.  * User fields proof of concept.
  3105.  * Needs UserFieldDef and UserFieldDefCache + editing of fields.
  3106.  * Does anyone want to take if from there?
  3107.  *
  3108.  * Revision 1.263  2008/09/27 00:05:54  fplanque
  3109.  * minor/version bump
  3110.  *
  3111.  * Revision 1.262  2008/09/24 09:28:36  fplanque
  3112.  * no message
  3113.  *
  3114.  * Revision 1.261  2008/09/23 06:18:39  fplanque
  3115.  * File manager now supports a shared directory (/media/shared/global/)
  3116.  *
  3117.  * Revision 1.260  2008/09/07 07:57:58  fplanque
  3118.  * doc
  3119.  *
  3120.  * Revision 1.259  2008/07/03 09:53:37  yabs
  3121.  * widget UI
  3122.  *
  3123.  * Revision 1.258  2008/05/27 23:36:40  blueyed
  3124.  * Fix indent. Add TODOs about checkpoints.
  3125.  *
  3126.  * Revision 1.257  2008/05/26 19:30:32  fplanque
  3127.  * enhanced analytics
  3128.  *
  3129.  * Revision 1.256  2008/05/10 23:41:04  fplanque
  3130.  * keyphrase logging
  3131.  *
  3132.  * Revision 1.255  2008/04/06 19:19:30  fplanque
  3133.  * Started moving some intelligence to the Modules.
  3134.  * 1) Moved menu structure out of the AdminUI class.
  3135.  * It is part of the app structure, not the UI. Up to this point at least.
  3136.  * Note: individual Admin skins can still override the whole menu.
  3137.  * 2) Moved DB schema to the modules. This will be reused outside
  3138.  * of install for integrity checks and backup.
  3139.  * 3) cleaned up config files
  3140.  *
  3141.  * Revision 1.254  2008/03/23 23:40:42  fplanque
  3142.  * no message
  3143.  *
  3144.  * Revision 1.253  2008/03/22 19:39:28  fplanque
  3145.  * <title> tag support
  3146.  *
  3147.  * Revision 1.252  2008/03/21 16:07:03  fplanque
  3148.  * longer post slugs
  3149.  *
  3150.  * Revision 1.251  2008/03/16 19:40:52  blueyed
  3151.  * Fix renaming of tables, which failed when done in one query (User only has perms on his DB; MySQL 5.0.38-Ubuntu_0ubuntu1.1) (LP: #195612)
  3152.  *
  3153.  * Revision 1.250  2008/03/16 14:19:39  fplanque
  3154.  * no message
  3155.  *
  3156.  * Revision 1.248  2008/03/07 02:00:42  blueyed
  3157.  * doc; indent; use db_drop_col
  3158.  *
  3159.  * Revision 1.247  2008/02/19 11:11:20  fplanque
  3160.  * no message
  3161.  *
  3162.  * Revision 1.246  2008/02/10 00:58:57  fplanque
  3163.  * no message
  3164.  *
  3165.  * Revision 1.245  2008/02/09 20:14:14  fplanque
  3166.  * custom fields management
  3167.  *
  3168.  * Revision 1.244  2008/02/09 17:36:15  fplanque
  3169.  * better handling of order, including approximative comparisons
  3170.  *
  3171.  * Revision 1.243  2008/02/09 02:56:00  fplanque
  3172.  * explicit order by field
  3173.  *
  3174.  * Revision 1.242  2008/02/07 00:35:52  fplanque
  3175.  * cleaned up install
  3176.  *
  3177.  * Revision 1.241  2008/01/23 16:44:27  fplanque
  3178.  * minor
  3179.  *
  3180.  * Revision 1.240  2008/01/22 16:57:08  fplanque
  3181.  * db upgrade stuff
  3182.  *
  3183.  * Revision 1.239  2008/01/21 09:35:38  fplanque
  3184.  * (c) 2008
  3185.  *
  3186.  * Revision 1.238  2008/01/19 10:57:10  fplanque
  3187.  * Splitting XHTML checking by group and interface
  3188.  *
  3189.  * Revision 1.237  2008/01/14 07:33:32  fplanque
  3190.  * Daniel, stop putting the comments in the log! They're more useful in the code!
  3191.  *
  3192.  * Revision 1.236  2008/01/12 19:25:58  blueyed
  3193.  * - Fix install from < 0.8: Make function "cleanup_post_quotes" inline and fix table name
  3194.  * - Only check max_execution_time when > 0 (not disabled)
  3195.  *
  3196.  * Revision 1.235  2008/01/08 03:31:50  fplanque
  3197.  * podcast support
  3198.  *
  3199.  * Revision 1.234  2008/01/05 00:24:35  blueyed
  3200.  * Create same filetypes when upgrading as when installing (DRY anyone?)
  3201.  *
  3202.  * Revision 1.233  2007/11/30 01:46:12  fplanque
  3203.  * db upgrade
  3204.  *
  3205.  * Revision 1.232  2007/11/02 01:53:34  fplanque
  3206.  * comment ratings
  3207.  *
  3208.  * Revision 1.231  2007/10/11 14:02:48  fplanque
  3209.  * simplified
  3210.  *
  3211.  * Revision 1.230  2007/09/19 02:54:16  fplanque
  3212.  * bullet proof upgrade
  3213.  *
  3214.  * Revision 1.229  2007/07/03 23:21:32  blueyed
  3215.  * Fixed includes/requires in/for tests
  3216.  *
  3217.  * Revision 1.228  2007/06/25 11:02:30  fplanque
  3218.  * MODULES (refactored MVC)
  3219.  *
  3220.  * Revision 1.227  2007/06/13 19:06:17  fplanque
  3221.  * debugging
  3222.  *
  3223.  * Revision 1.226  2007/06/03 02:54:18  fplanque
  3224.  * Stuff for permission maniacs (admin part only, actual perms checks to be implemented)
  3225.  * Newbies will not see this complexity since advanced perms are now disabled by default.
  3226.  *
  3227.  * Revision 1.225  2007/05/31 03:02:23  fplanque
  3228.  * Advanced perms now disabled by default (simpler interface).
  3229.  * Except when upgrading.
  3230.  * Enable advanced perms in blog settings -> features
  3231.  *
  3232.  * Revision 1.224  2007/05/29 01:17:20  fplanque
  3233.  * advanced admin blog settings are now restricted by a special permission
  3234.  *
  3235.  * Revision 1.223  2007/05/17 20:44:19  fplanque
  3236.  * fixed upgrade.
  3237.  *
  3238.  * Revision 1.222  2007/05/14 02:47:23  fplanque
  3239.  * (not so) basic Tags framework
  3240.  *
  3241.  * Revision 1.221  2007/05/13 22:04:48  fplanque
  3242.  * basic excerpt support
  3243.  *
  3244.  * Revision 1.220  2007/05/13 20:44:52  fplanque
  3245.  * more pages support
  3246.  *
  3247.  * Revision 1.219  2007/05/02 18:28:19  fplanque
  3248.  * no message
  3249.  *
  3250.  * Revision 1.218  2007/04/27 09:34:45  fplanque
  3251.  * oops
  3252.  *
  3253.  * Revision 1.217  2007/04/27 09:11:37  fplanque
  3254.  * saving "spam" referers again (instead of buggy empty referers)
  3255.  *
  3256.  * Revision 1.216  2007/04/26 00:11:09  fplanque
  3257.  * (c) 2007
  3258.  *
  3259.  * Revision 1.215  2007/04/19 01:51:53  fplanque
  3260.  * upgrade checkpoints
  3261.  *
  3262.  * Revision 1.214  2007/03/26 12:59:18  fplanque
  3263.  * basic pages support
  3264.  *
  3265.  * Revision 1.213  2007/03/25 15:18:57  fplanque
  3266.  * cleanup
  3267.  *
  3268.  * Revision 1.212  2007/03/25 15:07:38  fplanque
  3269.  * multiblog fixes
  3270.  *
  3271.  * Revision 1.211  2007/03/12 14:10:10  waltercruz
  3272.  * Changing the WHERE 1 queries to boolean (WHERE 1=1) queries to satisfy the standarts
  3273.  *
  3274.  * Revision 1.210  2007/02/21 21:33:43  fplanque
  3275.  * allow jpeg extension on new installs/upgrades
  3276.  *
  3277.  * Revision 1.209  2007/02/13 00:38:11  blueyed
  3278.  * Changed DB fields for 1.10.0: sess_data to MEDIUMTEXT (serialize() does not completely convert the binary data to text); post_content and itpr_content_prerendered to MEDIUMTEXT
  3279.  *
  3280.  * Revision 1.208  2007/02/05 00:35:44  fplanque
  3281.  * small adjustments
  3282.  *
  3283.  * Revision 1.207  2007/02/03 19:00:49  fplanque
  3284.  * unbloat
  3285.  *
  3286.  * Revision 1.205  2007/01/23 04:19:50  fplanque
  3287.  * handling of blog owners
  3288.  *
  3289.  * Revision 1.204  2007/01/15 20:54:57  fplanque
  3290.  * minor fix
  3291.  *
  3292.  * Revision 1.203  2007/01/15 03:53:24  fplanque
  3293.  * refactoring / simplified installer
  3294.  *
  3295.  * Revision 1.202  2007/01/12 02:40:26  fplanque
  3296.  * widget default params proof of concept
  3297.  * (param customization to be done)
  3298.  *
  3299.  * Revision 1.201  2007/01/08 23:45:48  fplanque
  3300.  * A little less rough widget manager...
  3301.  * (can handle multiple instances of same widget and remembers order)
  3302.  *
  3303.  * Revision 1.200  2007/01/08 21:53:51  fplanque
  3304.  * typo
  3305.  *
  3306.  * Revision 1.199  2007/01/08 02:11:56  fplanque
  3307.  * Blogs now make use of installed skins
  3308.  * next step: make use of widgets inside of skins
  3309.  *
  3310.  * Revision 1.198  2006/12/20 23:07:24  blueyed
  3311.  * Moved list of available plugins to separate sub-screen/form
  3312.  *
  3313.  * Revision 1.197  2006/12/15 23:31:22  fplanque
  3314.  * reauthorized _ in urltitles.
  3315.  * No breaking of legacy permalinks.
  3316.  * - remains the default placeholder though.
  3317.  *
  3318.  * Revision 1.196  2006/12/07 20:31:29  fplanque
  3319.  * fixed install
  3320.  *
  3321.  * Revision 1.195  2006/12/07 20:03:33  fplanque
  3322.  * Woohoo! File editing... means all skin editing.
  3323.  *
  3324.  * Revision 1.194  2006/12/07 16:06:24  fplanque
  3325.  * prepared new file editing permission
  3326.  *
  3327.  * Revision 1.193  2006/12/04 22:24:51  blueyed
  3328.  * doc
  3329.  *
  3330.  * Revision 1.192  2006/12/04 21:25:18  fplanque
  3331.  * removed user skin switching
  3332.  *
  3333.  * Revision 1.191  2006/12/04 19:41:11  fplanque
  3334.  * Each blog can now have its own "archive mode" settings
  3335.  *
  3336.  * Revision 1.190  2006/12/04 18:16:51  fplanque
  3337.  * Each blog can now have its own "number of page/days to display" settings
  3338.  *
  3339.  * Revision 1.189  2006/11/18 16:34:24  blueyed
  3340.  * Removed todo
  3341.  *
  3342.  * Revision 1.188  2006/11/18 03:58:21  fplanque
  3343.  * removed duplicate indexes on T_links
  3344.  *
  3345.  * Revision 1.187  2006/11/14 23:17:00  fplanque
  3346.  * adding stuff into the 9010 block weeks later was really evil. why do we have blocks for?
  3347.  *
  3348.  * Revision 1.186  2006/11/01 00:24:07  blueyed
  3349.  * Fixed cafelog upgrade
  3350.  *
  3351.  * Revision 1.185  2006/10/14 21:11:48  blueyed
  3352.  * Actually insert the transformed/generated ping plugins setting(s).
  3353.  *
  3354.  * Revision 1.184  2006/10/14 20:53:13  blueyed
  3355.  * Transform blog ping settings to new Plugin structure.
  3356.  *
  3357.  * Revision 1.183  2006/10/11 17:21:09  blueyed
  3358.  * Fixes
  3359.  *
  3360.  * Revision 1.182  2006/10/10 23:00:41  blueyed
  3361.  * Fixed some table names to alias; fixed plugin install procedure; installed ping plugins; moved some upgrade code to 1.9
  3362.  *
  3363.  * Revision 1.181  2006/10/06 21:03:07  blueyed
  3364.  * Removed deprecated/unused "upload_allowedext" Setting, which restricted file extensions during upload though!
  3365.  *
  3366.  * Revision 1.180  2006/10/05 02:58:44  blueyed
  3367.  * Support for skipping index dropping, if it does not exist anymore. Should not bark out then! Also do not add the last checkpoint possibly twice.
  3368.  *
  3369.  * Revision 1.179  2006/10/05 02:42:22  blueyed
  3370.  * Remove index hit_datetime, because its slow on INSERT (e.g. 1s)
  3371.  *
  3372.  * Revision 1.178  2006/10/02 19:07:32  blueyed
  3373.  * Finished upgrade for 1.9-beta
  3374.  *
  3375.  * Revision 1.177  2006/10/01 22:11:43  blueyed
  3376.  * Ping services as plugins.
  3377.  *
  3378.  * Revision 1.176  2006/10/01 00:14:58  blueyed
  3379.  * plug_classpath should not have get merged already
  3380.  */
  3381. ?>

Documentation generated on Sat, 06 Mar 2010 04:11:19 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).