Ejemplo n.º 1
0
function upgrade12_dbchanges4()
{
    global $db, $output, $mybb;
    $output->print_header("Performing Queries");
    echo "<p>Performing necessary upgrade queries..</p>";
    flush();
    $db->drop_table("spiders");
    $db->drop_table("stats");
    $collation = $db->build_create_table_collation();
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "spiders (\n\t\tsid int unsigned NOT NULL auto_increment,\n\t\tname varchar(100) NOT NULL default '',\n\t\ttheme int unsigned NOT NULL default '0',\n\t\tlanguage varchar(20) NOT NULL default '',\n\t\tusergroup int unsigned NOT NULL default '0',\n\t\tuseragent varchar(200) NOT NULL default '',\n\t\tlastvisit bigint(30) NOT NULL default '0',\n\t\tPRIMARY KEY(sid)\n\t) ENGINE=MyISAM{$collation};");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "stats (\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\tnumusers int unsigned NOT NULL default '0',\n\t\tnumthreads int unsigned NOT NULL default '0',\n\t\tnumposts int unsigned NOT NULL default '0',\n\t\tPRIMARY KEY(dateline)\n\t) ENGINE=MyISAM{$collation};");
    $db->insert_query("spiders", array('name' => 'GoogleBot', 'useragent' => 'google'));
    $db->insert_query("spiders", array('name' => 'Lycos', 'useragent' => 'lycos'));
    $db->insert_query("spiders", array('name' => 'Ask Jeeves', 'useragent' => 'ask jeeves'));
    $db->insert_query("spiders", array('name' => 'Hot Bot', 'useragent' => 'slurp@inktomi'));
    $db->insert_query("spiders", array('name' => 'What You Seek', 'useragent' => 'whatuseek'));
    $db->insert_query("spiders", array('name' => 'Archive.org', 'useragent' => 'is_archiver'));
    $db->insert_query("spiders", array('name' => 'Altavista', 'useragent' => 'scooter'));
    $db->insert_query("spiders", array('name' => 'Alexa', 'useragent' => 'ia_archiver'));
    $db->insert_query("spiders", array('name' => 'MSN Search', 'useragent' => 'msnbot'));
    $db->insert_query("spiders", array('name' => 'Yahoo!', 'useragent' => 'yahoo! slurp'));
    // DST correction changes
    $db->update_query("users", array('dst' => 1), "dst=1");
    $db->update_query("users", array('dst' => 0), "dst=0");
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users CHANGE dst dst INT(1) NOT NULL default '0'");
    if ($db->field_exists('dstcorrection', "users")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users DROP dstcorrection;");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users ADD dstcorrection INT(1) NOT NULL default '0' AFTER dst");
    $db->update_query("users", array('dstcorrection' => 2));
    $db->update_query("adminoptions", array('cpstyle' => ''));
    if ($db->field_exists('permsset', "adminoptions") && !$db->field_exists('permissions', "adminoptions")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions CHANGE permsset permissions TEXT NOT NULL ");
    }
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    // Fetch default permissions list
    $default_permissions = array();
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        if ($uid == -4) {
            foreach ($users['permissions'][0]['module'] as $module) {
                foreach ($module['permission'] as $permission) {
                    $default_permissions[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
                }
            }
            break;
        }
    }
    $convert_permissions = array("caneditsettings" => array("module" => "config", "permission" => "settings"), "caneditann" => array("module" => "forum", "permission" => "announcements"), "caneditforums" => array("module" => "forum", "permission" => "management"), "canmodposts" => array("module" => "forum", "permission" => "moderation_queue"), "caneditsmilies" => array("module" => "config", "permission" => "smilies"), "caneditpicons" => array("module" => "config", "permission" => "post_icons"), "caneditthemes" => array("module" => "style", "permission" => "themes"), "canedittemps" => array("module" => "style", "permission" => "templates"), "caneditusers" => array("module" => "user", "permission" => "view"), "caneditpfields" => array("module" => "config", "permission" => "profile_fields"), "caneditmodactions" => array("module" => "config", "permission" => "mod_tools"), "caneditugroups" => array("module" => "user", "permission" => "groups"), "caneditaperms" => array("module" => "user", "permission" => "admin_permissions"), "caneditutitles" => array("module" => "user", "permission" => "titles"), "caneditattach" => array("module" => "forum", "permission" => "attachments"), "canedithelp" => array("module" => "config", "permission" => "help_documents"), "caneditlangs" => array("module" => "config", "permission" => "languages"), "canrunmaint" => array("module" => "tools", "permission" => "recount_rebuild"), "canrundbtools" => array("module" => "tools", "permission" => "backupdb"));
    $new_permissions = $default_permissions;
    $query = $db->simple_select("adminoptions");
    while ($adminoption = $db->fetch_array($query)) {
        foreach ($adminoption as $field => $value) {
            if (strtolower(substr($field, 0, 3)) != "can") {
                continue;
            }
            if (array_key_exists($field, $convert_permissions)) {
                // Note: old adminoptions table is still yes/no - do not change me
                if ($value == "yes") {
                    $value = 1;
                } else {
                    $value = $default_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']];
                }
                $new_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']] = $value;
            }
        }
        $db->update_query("adminoptions", array('permissions' => serialize($new_permissions)), "uid = '{$adminoption['uid']}'");
        $new_permissions = $default_permissions;
    }
    foreach ($convert_permissions as $field => $value) {
        if ($db->field_exists($field, "adminoptions")) {
            $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions DROP {$field}");
        }
    }
    // Set default views
    if ($db->field_exists('defaultviews', "adminoptions")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions DROP defaultviews");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions ADD defaultviews TEXT NOT NULL");
    $db->update_query("adminoptions", array('defaultviews' => serialize(array('user' => 1))));
    require_once MYBB_ROOT . "inc/functions_rebuild.php";
    rebuild_stats();
    $contents = "Done</p>";
    $contents .= "<p>Click next to continue with the upgrade process.</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 = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";
    $output->print_footer("12_dbchanges5");
}
Ejemplo n.º 2
0
 /**
  * Update the stats cache (kept for the sake of being able to rebuild this cache via the cache interface)
  *
  */
 function update_stats()
 {
     global $db;
     require_once MYBB_ROOT . "inc/functions_rebuild.php";
     rebuild_stats();
 }
Ejemplo n.º 3
0
        @mysql_query("TRUNCATE TABLE {$mybb_prefix}users");
        while ($account = mysql_fetch_assoc($list)) {
            $username = $account["username"];
            $email = $account["email"];
            $salt = random_str(8);
            $pass = salt_password($account["password"], $salt);
            $key = generate_loginkey();
            $joined = time();
            $id_level = mybb_level_check($account["real_level"]);
            mysql_query("INSERT INTO {$mybb_prefix}users (`username`, `password`, `salt`,`loginkey`,`usergroup`,`email`, `regdate`,`regip`,`lastip`,`hideemail`,`receivepms`) VALUES ('{$username}', '{$pass}', '{$salt}','{$key}',{$id_level}, '{$email}',{$joined},'{$ip_address}','{$ip_address}',1,1)") or die(mysql_error());
            $fid = mysql_insert_id();
            mysql_query("UPDATE {$TABLE_PREFIX}users SET mybb_fid={$fid} where id=" . $account["id"]);
            mysql_query("UPDATE `{$mybb_prefix}settings` SET `value`=1 where `sid`=61");
            mysql_query("UPDATE `{$mybb_prefix}usergroups` SET `namestyle`='<span style=\"color: orangered;\"><strong>{username}</strong></span>' where `gid`=4");
            mysql_query("UPDATE `{$mybb_prefix}usergroups` SET `namestyle`='<span style=\"color: green;\"><strong>{username}</strong></span>' where `gid`=6");
            rebuild_stats();
            //rebuild users stats in forum
            $counter = $count;
            header("location:" . $_SERVER["PHP_SELF"] . "?act=completed&counter={$counter}");
        }
    }
} elseif ($act == "completed") {
    $counter = (int) $_GET["counter"];
    // Lock import file from future use and change to ipb mode
    @mysql_query("UPDATE `{$TABLE_PREFIX}settings` SET `value` ='mybb' WHERE `key`='forum'");
    @mysql_query("UPDATE `{$TABLE_PREFIX}users` SET `random`=12399 WHERE `id`=1");
    echo $l[32] . $l[48] . " <b>" . $counter . "</b> " . $l[44] . $l[49];
}
function mybb_level_check($level)
{
    global $TABLE_PREFIX;