<?PHP

/* ====================
Seditio - Website engine
Copyright Neocrome & Seditio Team
http://www.neocrome.net
http://www.seditio.org
[BEGIN_SED]
File=upgrade_150_172.php
Version=172
Updated=2012-sep-23
Type=Core.upgrade
Author=Neocrome
Description=Database upgrade
[END_SED]
==================== */

if ( !defined('SED_CODE') || !defined('SED_ADMIN') ) { die('Wrong URL.'); }

// -----------------

$adminmain .= "-----------------------<br />";

$adminmain .= "Adding the 'is_html' column to comments...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."com ADD com_text_ishtml TINYINT(1) DEFAULT '0' AFTER com_text";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Adding the 'is_html' column to forum posts...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."forum_posts ADD fp_text_ishtml TINYINT(1) DEFAULT '0' AFTER fp_text";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Adding the 'is_html' column to pages, ...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."pages ADD page_text_ishtml TINYINT(1) DEFAULT '0' AFTER page_text";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);
         
$adminmain .= "Adding the 'is_html' column to private messages...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."pm ADD pm_text_ishtml TINYINT(1) DEFAULT '0' AFTER pm_text";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);
       
$adminmain .= "Adding the 'is_html' column to user text...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."users ADD user_text_ishtml TINYINT(1) DEFAULT '0' AFTER user_text";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);
  
// ========================================

$adminmain .= "Cleaning the configuration table...<br />";

$sqlqr = "DELETE FROM ".$cfg['sqldbprefix']."config WHERE config_cat='page' AND config_name='allowphp_pages'";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$sqlqr = "DELETE FROM ".$cfg['sqldbprefix']."config WHERE config_cat='pm' AND config_name='keepoldpms'";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);
                                    
$adminmain .= "Removing the plugin Textboxer 2<br />";
$adminmain .= sed_plugin_uninstall('textboxer2');

// ========================================

$adminmain .= "Clearing the trashcan...<br />";
$sql = sed_sql_query("TRUNCATE TABLE ".$cfg['sqldbprefix']."trash");

$adminmain .= "Clearing the internal SQL cache...<br />";
$sql = sed_sql_query("TRUNCATE TABLE ".$cfg['sqldbprefix']."cache");

// ========================================

$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."pages DROP `user_jrnpagescount`";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr, FALSE);

$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."pages DROP `user_jrnupdated`";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr, FALSE);

// ========================================

$adminmain .= "Adding the Pages new config into the core<br />";
$sqlqr = "INSERT INTO ".$cfg['sqldbprefix']."config (config_owner, config_cat, config_order, config_name, config_type, config_value, config_default)
VALUES ('core', 'page', '03', 'showpagesubcatgroup', 3, '0', '')";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Adding the Pages new config into the core<br />";
$sqlqr = "INSERT INTO ".$cfg['sqldbprefix']."config (config_owner, config_cat, config_order, config_name, config_type, config_value, config_default)
VALUES ('core', 'comments', '03', 'showcommentsonpage', 3, '0', '')";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Adding the PFS new config into the core<br />";
$sqlqr = "INSERT INTO ".$cfg['sqldbprefix']."config (config_owner, config_cat, config_order, config_name, config_type, config_value, config_default)
VALUES ('core', 'pfs', '02', 'pfs_filemask', 3, '0', '')";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

/*
$adminmain .= "Adding the 'user_secret' column to users...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."users ADD user_secret varchar(32) NOT NULL DEFAULT '' AFTER user_password";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Adding the 'user_passtype' column to users...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."users ADD user_passtype tinyint(1) NOT NULL DEFAULT '0' AFTER user_secret";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);
*/

$adminmain .= "Adding the 'fs_parentcat' column to forums...<br />";
$sqlqr = "ALTER TABLE ".$cfg['sqldbprefix']."forum_sections ADD fs_parentcat smallint(1) unsigned NOT NULL DEFAULT '0' AFTER fs_category";
$adminmain .= sed_cc($sqlqr)."<br />";
$sql = sed_sql_query($sqlqr);

$adminmain .= "Changing the SQL version number to 172...<br />";
$sql = sed_sql_query("UPDATE ".$cfg['sqldbprefix']."stats SET stat_value=172 WHERE stat_name='version'");
$adminmain .= "-----------------------<br />";

$upg_status = TRUE;

?>