Ejemplo n.º 1
0
function upgrade17_dbchanges4()
{
    global $db, $output, $mybb;
    $output->print_header("Performing Queries");
    echo "<p>Performing necessary upgrade queries..</p>";
    flush();
    if ($db->field_exists('remember', 'users')) {
        $db->drop_column("users", "remember");
    }
    if ($db->type != "pgsql") {
        // PgSQL doesn't support longtext
        $db->modify_column("searchlog", "threads", "longtext NOT NULL");
        $db->modify_column("searchlog", "posts", "longtext NOT NULL");
    }
    if ($db->field_exists("uid", "moderators") && !$db->field_exists("id", "moderators")) {
        switch ($db->type) {
            case "pgsql":
                $db->rename_column("moderators", "uid", "id", "int", true, "'0'");
                break;
            default:
                $db->rename_column("moderators", "uid", "id", "int unsigned NOT NULL default '0'");
        }
    }
    if ($db->table_exists("threadprefixes")) {
        $db->drop_table("threadprefixes");
    }
    if ($db->table_exists("delayedmoderation")) {
        $db->drop_table("delayedmoderation");
    }
    switch ($db->type) {
        case "sqlite":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\trid INTEGER PRIMARY KEY,\n\t\t\t\ttid int NOT NULL default '0',\n\t\t\t\tuid int NOT NULL default '0',\n\t\t\t\trating smallint NOT NULL default '0',\n\t\t\t\tipaddress varchar(30) NOT NULL default ''\n\t\t\t);");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid integer PRIMARY KEY,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint(30) NOT NULL default '0',\n\t\t\t\tuid int(10) NOT NULL default '0',\n\t\t\t\tfid smallint(5) NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint(30) NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL\n\t\t\t);");
            break;
        case "pgsql":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\tpid serial,\n\t\t\t\tprefix varchar(120) NOT NULL default '',\n\t\t\t\tdisplaystyle varchar(200) NOT NULL default '',\n\t\t\t\tforums text NOT NULL,\n\t\t\t\tgroups text NOT NULL,\n\t\t\t\tPRIMARY KEY(pid)\n\t\t\t);");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid serial,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint NOT NULL default '0',\n\t\t\t\tuid int NOT NULL default '0',\n\t\t\t\tfid smallint NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL default '',\n\t\t\t\tPRIMARY KEY (did)\n\t\t\t);");
            break;
        default:
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\tpid int unsigned NOT NULL auto_increment,\n\t\t\t\tprefix varchar(120) NOT NULL default '',\n\t\t\t\tdisplaystyle varchar(200) NOT NULL default '',\n\t\t\t\tforums text NOT NULL,\n\t\t\t\tgroups text NOT NULL,\n\t\t\t\tPRIMARY KEY(pid)\n\t\t\t) ENGINE=MyISAM;");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid int unsigned NOT NULL auto_increment,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint(30) unsigned NOT NULL default '0',\n\t\t\t\tuid int(10) unsigned NOT NULL default '0',\n\t\t\t\tfid smallint(5) unsigned NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint(30) NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL,\n\t\t\t\tPRIMARY KEY (did)\n\t\t\t) ENGINE=MyISAM;");
    }
    $added_tasks = sync_tasks();
    echo "<p>Added {$added_tasks} new tasks.</p>";
    $contents .= "Click next to continue with the upgrade process.</p>";
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">\$(document).ready(function() { var button = \$('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
    $output->print_footer("17_dbchanges5");
}
Ejemplo n.º 2
0
function upgrade30_dbchanges6()
{
    global $cache, $output, $mybb, $db;
    $output->print_header("Updating Database");
    echo "<p>Performing necessary upgrade queries...</p>";
    flush();
    if ($db->table_exists("buddyrequests")) {
        $db->drop_table("buddyrequests");
    }
    $collation = $db->build_create_table_collation();
    switch ($db->type) {
        case "pgsql":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "buddyrequests (\n\t\t\t\t id serial,\n\t\t\t\t uid int NOT NULL,\n\t\t\t\t touid int NOT NULL,\n\t\t\t\t date int NOT NULL,\n\t\t\t\t PRIMARY KEY (id)\n\t\t\t);");
            break;
        case "sqlite":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "buddyrequests (\n\t\t\t\t id INTEGER PRIMARY KEY,\n\t\t\t\t uid bigint unsigned NOT NULL,\n\t\t\t\t touid bigint unsigned NOT NULL,\n\t\t\t\t date int unsigned NOT NULL\n\t\t\t);");
            break;
        default:
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "buddyrequests (\n\t\t\t\t id int(10) UNSIGNED NOT NULL auto_increment,\n\t\t\t\t uid bigint(30) UNSIGNED NOT NULL,\n\t\t\t\t touid bigint(30) UNSIGNED NOT NULL,\n\t\t\t\t date int(11) UNSIGNED NOT NULL,\n\t\t\t\t KEY (uid),\n\t\t\t\t KEY (touid),\n\t\t\t\t PRIMARY KEY (id)\n\t\t\t) ENGINE=MyISAM{$collation};");
            break;
    }
    if ($db->field_exists('msn', 'users')) {
        $db->drop_column("users", "msn");
    }
    if ($db->field_exists('postbit', 'profilefields')) {
        $db->drop_column("profilefields", "postbit");
    }
    if ($db->field_exists('skype', 'users')) {
        $db->drop_column("users", "skype");
    }
    if ($db->field_exists('google', 'users')) {
        $db->drop_column("users", "google");
    }
    if ($db->field_exists('cplanguage', 'adminoptions')) {
        $db->drop_column("adminoptions", "cplanguage");
    }
    if ($db->field_exists('showimages', 'users')) {
        $db->drop_column("users", "showimages");
    }
    if ($db->field_exists('showvideos', 'users')) {
        $db->drop_column("users", "showvideos");
    }
    if ($db->field_exists('caninvitemembers', 'groupleaders')) {
        $db->drop_column("groupleaders", "caninvitemembers");
    }
    if ($db->field_exists('invite', 'joinrequests')) {
        $db->drop_column("joinrequests", "invite");
    }
    if ($db->field_exists('registration', 'profilefields')) {
        $db->drop_column("profilefields", "registration");
    }
    if ($db->field_exists('validated', 'awaitingactivation')) {
        $db->drop_column("awaitingactivation", "validated");
    }
    if ($db->field_exists('sourceeditor', 'users')) {
        $db->drop_column("users", "sourceeditor");
    }
    if ($db->field_exists('buddyrequestspm', 'users')) {
        $db->drop_column("users", "buddyrequestspm");
    }
    if ($db->field_exists('buddyrequestsauto', 'users')) {
        $db->drop_column("users", "buddyrequestsauto");
    }
    if ($db->field_exists('ipaddress', 'privatemessages')) {
        $db->drop_column("privatemessages", "ipaddress");
    }
    if ($db->field_exists('maxoptions', 'polls')) {
        $db->drop_column("polls", "maxoptions");
    }
    switch ($db->type) {
        case "pgsql":
            $db->add_column("profilefields", "postbit", "smallint NOT NULL default '0' AFTER profile");
            $db->add_column("users", "skype", "varchar(75) NOT NULL default '' AFTER yahoo");
            $db->add_column("users", "google", "varchar(75) NOT NULL default '' AFTER skype");
            $db->add_column("adminoptions", "cplanguage", "varchar(50) NOT NULL default '' AFTER cpstyle");
            $db->add_column("users", "showimages", "smallint NOT NULL default '1' AFTER threadmode");
            $db->add_column("users", "showvideos", "smallint NOT NULL default '1' AFTER showimages");
            $db->add_column("users", "buddyrequestspm", "smallint NOT NULL default '1' AFTER pmnotify");
            $db->add_column("users", "buddyrequestsauto", "smallint NOT NULL default '0' AFTER buddyrequestspm");
            $db->add_column("groupleaders", "caninvitemembers", "smallint NOT NULL default '0'");
            $db->add_column("joinrequests", "invite", "smallint NOT NULL default '0'");
            $db->add_column("profilefields", "registration", "smallint NOT NULL default '0' AFTER required");
            $db->add_column("awaitingactivation", "validated", "smallint NOT NULL default '0' AFTER type");
            $db->add_column("users", "sourceeditor", "smallint NOT NULL default '0'");
            break;
        default:
            $db->add_column("profilefields", "postbit", "tinyint(1) NOT NULL default '0' AFTER profile");
            $db->add_column("users", "skype", "varchar(75) NOT NULL default '' AFTER yahoo");
            $db->add_column("users", "google", "varchar(75) NOT NULL default '' AFTER skype");
            $db->add_column("adminoptions", "cplanguage", "varchar(50) NOT NULL default '' AFTER cpstyle");
            $db->add_column("users", "showimages", "tinyint(1) NOT NULL default '1' AFTER threadmode");
            $db->add_column("users", "showvideos", "tinyint(1) NOT NULL default '1' AFTER showimages");
            $db->add_column("users", "buddyrequestspm", "tinyint(1) NOT NULL default '1' AFTER pmnotify");
            $db->add_column("users", "buddyrequestsauto", "tinyint(1) NOT NULL default '0' AFTER buddyrequestspm");
            $db->add_column("groupleaders", "caninvitemembers", "tinyint(1) NOT NULL default '0'");
            $db->add_column("joinrequests", "invite", "tinyint(1) NOT NULL default '0'");
            $db->add_column("profilefields", "registration", "tinyint(1) NOT NULL default '0' AFTER required");
            $db->add_column("awaitingactivation", "validated", "tinyint(1) NOT NULL default '0' AFTER type");
            $db->add_column("users", "sourceeditor", "tinyint(1) NOT NULL default '0'");
            break;
    }
    switch ($db->type) {
        case "pgsql":
            $db->add_column("privatemessages", "ipaddress", "bytea NOT NULL default ''");
            $db->add_column("polls", "maxoptions", "smallint NOT NULL default '0'");
            break;
        case "sqlite":
            $db->add_column("privatemessages", "ipaddress", "blob(16) NOT NULL default ''");
            $db->add_column("polls", "maxoptions", "smallint NOT NULL default '0'");
            break;
        default:
            $db->add_column("privatemessages", "ipaddress", "varbinary(16) NOT NULL default ''");
            $db->add_column("polls", "maxoptions", "smallint unsigned NOT NULL default '0'");
            break;
    }
    $groups = range(1, 39);
    $sql = implode(',', $groups);
    $db->update_query("templategroups", array('isdefault' => 1), "gid IN ({$sql})");
    if ($db->table_exists('reportedposts')) {
        $db->update_query("reportedposts", array('type' => 'post'));
    }
    $db->insert_query("questions", array('question' => 'What does 2 + 2 equal?', 'answer' => '4\\nFour', 'active' => '1'));
    $query = $db->simple_select("attachtypes", "COUNT(*) as numexists", "extension='psd'");
    if ($db->fetch_field($query, "numexists") == 0) {
        $db->insert_query("attachtypes", array('name' => "Adobe Photoshop File", 'mimetype' => 'application/x-photoshop', 'extension' => "psd", 'maxsize' => '1024', 'icon' => 'images/attachtypes/psd.png'));
    }
    // SQLite... As we modify tables below we need to close all cursors before...
    if ($db->type == "sqlite") {
        $query->closeCursor();
    }
    $query = $db->simple_select("templategroups", "COUNT(*) as numexists", "prefix='video'");
    if ($db->fetch_field($query, "numexists") == 0) {
        $db->insert_query("templategroups", array('prefix' => 'video', 'title' => '<lang:group_video>', 'isdefault' => '1'));
    }
    // SQLite... As we modify tables below we need to close all cursors before...
    if ($db->type == "sqlite") {
        $query->closeCursor();
    }
    $query = $db->simple_select("templategroups", "COUNT(*) as numexists", "prefix='php'");
    if ($db->fetch_field($query, "numexists") != 0) {
        $db->update_query("templategroups", array('prefix' => 'announcement', 'title' => '<lang:group_announcement>'), "prefix='php'");
    }
    // SQLite... As we modify tables below we need to close all cursors before...
    if ($db->type == "sqlite") {
        $query->closeCursor();
    }
    $query = $db->simple_select("templategroups", "COUNT(*) as numexists", "prefix='redirect'");
    if ($db->fetch_field($query, "numexists") != 0) {
        $db->update_query("templategroups", array('prefix' => 'posticons', 'title' => '<lang:group_posticons>'), "prefix='redirect'");
    }
    // SQLite... As we modify tables below we need to close all cursors before...
    if ($db->type == "sqlite") {
        $query->closeCursor();
    }
    // Sync usergroups with canbereported; no moderators or banned groups
    echo "<p>Updating usergroup permissions...</p>";
    $groups = array();
    $usergroups = $cache->read('usergroups');
    foreach ($usergroups as $group) {
        if ($group['canmodcp'] || $group['isbannedgroup']) {
            continue;
        }
        $groups[] = "'{$group['gid']}'";
    }
    if (!empty($groups)) {
        $usergroups = implode(',', $groups);
        $db->update_query('usergroups', array('canbereported' => 1), "gid IN ({$usergroups})");
    }
    $db->update_query('usergroups', array('canviewboardclosed' => 1), 'cancp = 1');
    if ($db->table_exists('reportedposts')) {
        if ($db->field_exists("pid", "reportedposts") && !$db->field_exists("id", "reportedposts")) {
            switch ($db->type) {
                case "pgsql":
                    $db->rename_column("reportedposts", "pid", "id", "int", true, "'0'");
                    break;
                default:
                    $db->rename_column("reportedposts", "pid", "id", "int unsigned NOT NULL default '0'");
            }
        }
        if ($db->field_exists("tid", "reportedposts") && !$db->field_exists("id2", "reportedposts")) {
            switch ($db->type) {
                case "pgsql":
                    $db->rename_column("reportedposts", "tid", "id2", "int", true, "'0'");
                    break;
                default:
                    $db->rename_column("reportedposts", "tid", "id2", "int unsigned NOT NULL default '0'");
            }
        }
        if ($db->field_exists("fid", "reportedposts") && !$db->field_exists("id3", "reportedposts")) {
            switch ($db->type) {
                case "pgsql":
                    $db->rename_column("reportedposts", "fid", "id3", "int", true, "'0'");
                    break;
                default:
                    $db->rename_column("reportedposts", "fid", "id3", "int unsigned NOT NULL default '0'");
            }
        }
    }
    if ($db->table_exists('reportedposts')) {
        if ($db->table_exists("reportedcontent")) {
            $db->drop_table("reportedcontent");
        }
        $db->rename_table("reportedposts", "reportedcontent");
        $cache->delete('reportedposts');
    }
    $db->update_query("settings", array('optionscode' => 'select\\r\\n0=No CAPTCHA\\r\\n1=MyBB Default CAPTCHA\\r\\n2=reCAPTCHA\\r\\n3=Are You a Human'), "name='captchaimage'");
    $db->update_query("settings", array('optionscode' => 'select\\r\\ninstant=Instant Activation\\r\\nverify=Send Email Verification\\r\\nrandompass=Send Random Password\\r\\nadmin=Administrator Activation\\r\\nboth=Email Verification & Administrator Activation'), "name='regtype'");
    $db->update_query("settings", array('optionscode' => $db->escape_string('php
<select name=\\"upsetting[{$setting[\'name\']}]\\">
<option value=\\"-12\\" ".($setting[\'value\'] == -12?"selected=\\"selected\\"":"").">GMT -12:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -12).")</option>
<option value=\\"-11\\" ".($setting[\'value\'] == -11?"selected=\\"selected\\"":"").">GMT -11:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -11).")</option>
<option value=\\"-10\\" ".($setting[\'value\'] == -10?"selected=\\"selected\\"":"").">GMT -10:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -10).")</option>
<option value=\\"-9.5\\" ".($setting[\'value\'] == -9.5?"selected=\\"selected\\"":"").">GMT -9:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -9.5).")</option>
<option value=\\"-9\\" ".($setting[\'value\'] == -9?"selected=\\"selected\\"":"").">GMT -9:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -9).")</option>
<option value=\\"-8\\" ".($setting[\'value\'] == -8?"selected=\\"selected\\"":"").">GMT -8:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -8).")</option>
<option value=\\"-7\\" ".($setting[\'value\'] == -7?"selected=\\"selected\\"":"").">GMT -7:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -7).")</option>
<option value=\\"-6\\" ".($setting[\'value\'] == -6?"selected=\\"selected\\"":"").">GMT -6:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -6).")</option>
<option value=\\"-5\\" ".($setting[\'value\'] == -5?"selected=\\"selected\\"":"").">GMT -5:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -5).")</option>
<option value=\\"-4.5\\" ".($setting[\'value\'] == -4.5?"selected=\\"selected\\"":"").">GMT -4:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -4.5).")</option>
<option value=\\"-4\\" ".($setting[\'value\'] == -4?"selected=\\"selected\\"":"").">GMT -4:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -4).")</option>
<option value=\\"-3.5\\" ".($setting[\'value\'] == -3.5?"selected=\\"selected\\"":"").">GMT -3:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -3.5).")</option>
<option value=\\"-3\\" ".($setting[\'value\'] == -3?"selected=\\"selected\\"":"").">GMT -3:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -3).")</option>
<option value=\\"-2\\" ".($setting[\'value\'] == -2?"selected=\\"selected\\"":"").">GMT -2:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -2).")</option>
<option value=\\"-1\\" ".($setting[\'value\'] == -1?"selected=\\"selected\\"":"").">GMT -1:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, -1).")</option>
<option value=\\"0\\" ".($setting[\'value\'] == 0?"selected=\\"selected\\"":"").">GMT (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 0).")</option>
<option value=\\"+1\\" ".($setting[\'value\'] == 1?"selected=\\"selected\\"":"").">GMT +1:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 1).")</option>
<option value=\\"+2\\" ".($setting[\'value\'] == 2?"selected=\\"selected\\"":"").">GMT +2:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 2).")</option>
<option value=\\"+3\\" ".($setting[\'value\'] == 3?"selected=\\"selected\\"":"").">GMT +3:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 3).")</option>
<option value=\\"+3.5\\" ".($setting[\'value\'] == 3.5?"selected=\\"selected\\"":"").">GMT +3:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 3.5).")</option>
<option value=\\"+4\\" ".($setting[\'value\'] == 4?"selected=\\"selected\\"":"").">GMT +4:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 4).")</option>
<option value=\\"+4.5\\" ".($setting[\'value\'] == 4.5?"selected=\\"selected\\"":"").">GMT +4:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 4.5).")</option>
<option value=\\"+5\\" ".($setting[\'value\'] == 5?"selected=\\"selected\\"":"").">GMT +5:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 5).")</option>
<option value=\\"+5.5\\" ".($setting[\'value\'] == 5.5?"selected=\\"selected\\"":"").">GMT +5:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 5.5).")</option>
<option value=\\"+5.75\\" ".($setting[\'value\'] == 5.75?"selected=\\"selected\\"":"").">GMT +5:45 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 5.75).")</option>
<option value=\\"+6\\" ".($setting[\'value\'] == 6?"selected=\\"selected\\"":"").">GMT +6:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 6).")</option>
<option value=\\"+6.5\\" ".($setting[\'value\'] == 6.5?"selected=\\"selected\\"":"").">GMT +6:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 6.5).")</option>
<option value=\\"+7\\" ".($setting[\'value\'] == 7?"selected=\\"selected\\"":"").">GMT +7:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 7).")</option>
<option value=\\"+8\\" ".($setting[\'value\'] == 8?"selected=\\"selected\\"":"").">GMT +8:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 8).")</option>
<option value=\\"+9\\" ".($setting[\'value\'] == 9?"selected=\\"selected\\"":"").">GMT +9:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 9).")</option>
<option value=\\"+9.5\\" ".($setting[\'value\'] == 9.5?"selected=\\"selected\\"":"").">GMT +9:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 9.5).")</option>
<option value=\\"+10\\" ".($setting[\'value\'] == 10?"selected=\\"selected\\"":"").">GMT +10:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 10).")</option>
<option value=\\"+10.5\\" ".($setting[\'value\'] == 10.5?"selected=\\"selected\\"":"").">GMT +10:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 10.5).")</option>
<option value=\\"+11\\" ".($setting[\'value\'] == 11?"selected=\\"selected\\"":"").">GMT +11:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 11).")</option>
<option value=\\"+11.5\\" ".($setting[\'value\'] == 11.5?"selected=\\"selected\\"":"").">GMT +11:30 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 11.5).")</option>
<option value=\\"+12\\" ".($setting[\'value\'] == 12?"selected=\\"selected\\"":"").">GMT +12:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 12).")</option>
<option value=\\"+12.75\\" ".($setting[\'value\'] == 12.75?"selected=\\"selected\\"":"").">GMT +12:45 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 12.75).")</option>
<option value=\\"+13\\" ".($setting[\'value\'] == 13?"selected=\\"selected\\"":"").">GMT +13:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 13).")</option>
<option value=\\"+14\\" ".($setting[\'value\'] == 14?"selected=\\"selected\\"":"").">GMT +14:00 Hours (".my_date($mybb->settings[\'timeformat\'], TIME_NOW, 14).")</option>
</select>')), "name='timezoneoffset'");
    // Update tasks
    $added_tasks = sync_tasks();
    // For the version check task, set a random date and hour (so all MyBB installs don't query mybb.com all at the same time)
    $update_array = array('hour' => rand(0, 23), 'weekday' => rand(0, 6));
    $db->update_query("tasks", $update_array, "file = 'versioncheck'");
    echo "<p>Added {$added_tasks} new tasks.</p>";
    $output->print_contents("<p>Click next to continue with the upgrade process.</p>");
    $output->print_footer("30_threadcount");
}
Ejemplo n.º 3
0
function upgrade17_dbchanges4()
{
    global $db, $output, $mybb;
    $output->print_header("Wykonywanie zapytań");
    echo "<p>Trwa wykonywanie wymaganych zapytań do bazy danych...</p>";
    flush();
    if ($db->field_exists('remember', 'users')) {
        $db->drop_column("users", "remember");
    }
    if ($db->type != "pgsql") {
        // PgSQL doesn't support longtext
        $db->modify_column("searchlog", "threads", "longtext NOT NULL");
        $db->modify_column("searchlog", "posts", "longtext NOT NULL");
    }
    if ($db->field_exists("uid", "moderators") && !$db->field_exists("id", "moderators")) {
        switch ($db->type) {
            case "pgsql":
                $db->rename_column("moderators", "uid", "id", "int", true, "'0'");
                break;
            default:
                $db->rename_column("moderators", "uid", "id", "int unsigned NOT NULL default '0'");
        }
    }
    if ($db->table_exists("threadprefixes")) {
        $db->drop_table("threadprefixes");
    }
    if ($db->table_exists("delayedmoderation")) {
        $db->drop_table("delayedmoderation");
    }
    switch ($db->type) {
        case "sqlite":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\trid INTEGER PRIMARY KEY,\n\t\t\t\ttid int NOT NULL default '0',\n\t\t\t\tuid int NOT NULL default '0',\n\t\t\t\trating smallint NOT NULL default '0',\n\t\t\t\tipaddress varchar(30) NOT NULL default ''\n\t\t\t);");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid integer PRIMARY KEY,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint(30) NOT NULL default '0',\n\t\t\t\tuid int(10) NOT NULL default '0',\n\t\t\t\tfid smallint(5) NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint(30) NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL\n\t\t\t);");
            break;
        case "pgsql":
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\tpid serial,\n\t\t\t\tprefix varchar(120) NOT NULL default '',\n\t\t\t\tdisplaystyle varchar(200) NOT NULL default '',\n\t\t\t\tforums text NOT NULL,\n\t\t\t\tgroups text NOT NULL,\n\t\t\t\tPRIMARY KEY(pid)\n\t\t\t);");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid serial,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint NOT NULL default '0',\n\t\t\t\tuid int NOT NULL default '0',\n\t\t\t\tfid smallint NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL default '',\n\t\t\t\tPRIMARY KEY (did)\n\t\t\t);");
            break;
        default:
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "threadprefixes (\n\t\t\t\tpid int unsigned NOT NULL auto_increment,\n\t\t\t\tprefix varchar(120) NOT NULL default '',\n\t\t\t\tdisplaystyle varchar(200) NOT NULL default '',\n\t\t\t\tforums text NOT NULL,\n\t\t\t\tgroups text NOT NULL,\n\t\t\t\tPRIMARY KEY(pid)\n\t\t\t) ENGINE=MyISAM;");
            $db->write_query("CREATE TABLE " . TABLE_PREFIX . "delayedmoderation (\n\t\t\t\tdid int unsigned NOT NULL auto_increment,\n\t\t\t\ttype varchar(30) NOT NULL default '',\n\t\t\t\tdelaydateline bigint(30) unsigned NOT NULL default '0',\n\t\t\t\tuid int(10) unsigned NOT NULL default '0',\n\t\t\t\tfid smallint(5) unsigned NOT NULL default '0',\n\t\t\t\ttids text NOT NULL,\n\t\t\t\tdateline bigint(30) NOT NULL default '0',\n\t\t\t\tinputs text NOT NULL,\n\t\t\t\tPRIMARY KEY (did)\n\t\t\t) ENGINE=MyISAM;");
    }
    $added_tasks = sync_tasks();
    echo "<p>Dodano {$added_tasks} nowych zadań.</p>";
    $contents .= "Naciśnij przycisk Dalej, aby kontynuować proces aktualizacji.</p>";
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = \$\$('.submit_button'); if(button[0]) { button[0].value = 'Automatyczne przekierowanie...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";
    $output->print_footer("17_dbchanges5");
}