Example #1
1
 /**
  * Installs the blog
  *
  * {@internal Missing Long Description}}
  *
  * @since 2.1.0
  *
  * @param string $blog_title Blog title.
  * @param string $user_name User's username.
  * @param string $user_email User's email.
  * @param bool $public Whether blog is public.
  * @param string $deprecated Optional. Not used.
  * @param string $user_password Optional. User's chosen password. Will default to a random password.
  * @param string $language Optional. Language chosen.
  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
  */
 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '')
 {
     if (!empty($deprecated)) {
         _deprecated_argument(__FUNCTION__, '2.6');
     }
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     populate_options();
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     if ($language) {
         update_option('WPLANG', $language);
     }
     $guessurl = wp_guess_url();
     update_option('siteurl', $guessurl);
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     /*
      * Create default user. If the user already exists, the user tables are
      * being shared among blogs. Just set the role in that case.
      */
     $user_id = username_exists($user_name);
     $user_password = trim($user_password);
     $email_password = false;
     if (!$user_id && empty($user_password)) {
         $user_password = wp_generate_password(12, false);
         $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
         $user_id = wp_create_user($user_name, $user_password, $user_email);
         update_user_option($user_id, 'default_password_nag', true, true);
         $email_password = true;
     } else {
         if (!$user_id) {
             // Password has been provided
             $message = '<em>' . __('Your chosen password.') . '</em>';
             $user_id = wp_create_user($user_name, $user_password, $user_email);
         } else {
             $message = __('User already exists. Password inherited.');
         }
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     wp_install_defaults($user_id);
     flush_rewrite_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
     wp_cache_flush();
     /**
      * Fires after a site is fully installed.
      *
      * @since 3.9.0
      *
      * @param WP_User $user The site owner.
      */
     do_action('wp_install', $user);
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
 }
 /**
  * Resets roles to WordPress defaults.
  *
  * @return void
  */
 function backupToolReset()
 {
     check_admin_referer('capsman-reset-defaults');
     require_once ABSPATH . 'wp-admin/includes/schema.php';
     if (!function_exists('populate_roles')) {
         ak_admin_error(__('Needed function to create default roles not found!', 'capsman-enhanced'));
         return;
     }
     $roles = array_keys(ak_get_roles(true));
     foreach ($roles as $role) {
         remove_role($role);
     }
     populate_roles();
     $this->cm->setAdminCapability();
     $msg = __('Roles and Capabilities reset to WordPress defaults', 'capsman-enhanced');
     if (function_exists('pp_populate_roles')) {
         pp_populate_roles();
     } else {
         // force PP to repopulate roles
         $pp_ver = get_option('pp_c_version', true);
         if ($pp_ver && is_array($pp_ver)) {
             $pp_ver['version'] = preg_match("/dev|alpha|beta|rc/i", $pp_ver['version']) ? '0.1-beta' : 0.1;
         } else {
             $pp_ver = array('version' => '0.1', 'db_version' => '1.0');
         }
         update_option('pp_c_version', $pp_ver);
         delete_option('ppperm_added_role_caps_10beta');
     }
     ak_admin_notify($msg);
 }
Example #3
0
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
    global $wpdb;
    $base = '/';
    $domain = JQUERY_STAGING_PREFIX . 'jquery.com';
    wp_check_mysql_version();
    wp_cache_flush();
    make_db_current_silent();
    populate_options();
    populate_roles();
    $user_id = wp_create_user($user_name, trim($user_password), $user_email);
    $user = new WP_User($user_id);
    $user->set_role('administrator');
    $guess_url = wp_guess_url();
    foreach ($wpdb->tables('ms_global') as $table => $prefixed_table) {
        $wpdb->{$table} = $prefixed_table;
    }
    install_network();
    populate_network(1, $domain, $user_email, 'jQuery Network', $base, false);
    update_site_option('site_admins', array($user->user_login));
    update_site_option('allowedthemes', array());
    $wpdb->insert($wpdb->blogs, array('site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time('mysql')));
    $blog_id = $wpdb->insert_id;
    update_user_meta($user_id, 'source_domain', $domain);
    update_user_meta($user_id, 'primary_blog', $blog_id);
    if (!($upload_path = get_option('upload_path'))) {
        $upload_path = substr(WP_CONTENT_DIR, strlen(ABSPATH)) . '/uploads';
        update_option('upload_path', $upload_path);
    }
    update_option('fileupload_url', get_option('siteurl') . '/' . $upload_path);
    jquery_install_remaining_sites($user);
    wp_new_blog_notification($blog_title, $guess_url, $user_id, $message = __('The password you chose during the install.'));
    wp_cache_flush();
    return array('url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
 function wp_install($blog_title, $user_name, $user_email, $public, $meta = '')
 {
     global $wp_rewrite;
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     populate_options();
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     $schema = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
     $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     update_option('siteurl', $guessurl);
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     // Create default user.  If the user already exists, the user tables are
     // being shared among blogs.  Just set the role in that case.
     $user_id = username_exists($user_name);
     if (!$user_id) {
         $random_password = substr(md5(uniqid(microtime())), 0, 6);
         $user_id = wp_create_user($user_name, $random_password, $user_email);
     } else {
         $random_password = __('User already exists.  Password inherited.');
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     wp_install_defaults($user_id);
     $wp_rewrite->flush_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
     wp_cache_flush();
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
 }
Example #5
0
 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
 {
     global $wp_rewrite;
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     populate_options();
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     $guessurl = wp_guess_url();
     update_option('siteurl', $guessurl);
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     // Create default user.  If the user already exists, the user tables are
     // being shared among blogs.  Just set the role in that case.
     $user_id = username_exists($user_name);
     if (!$user_id) {
         $random_password = wp_generate_password();
         $user_id = wp_create_user($user_name, $random_password, $user_email);
     } else {
         $random_password = __('User already exists.  Password inherited.');
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     wp_install_defaults($user_id);
     $wp_rewrite->flush_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
     wp_cache_flush();
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
 }
Example #6
0
 /**
  * Installs the blog
  *
  * {@internal Missing Long Description}}
  *
  * @since 2.1.0
  *
  * @param string $blog_title Blog title.
  * @param string $user_name User's username.
  * @param string $user_email User's email.
  * @param bool $public Whether blog is public.
  * @param null $deprecated Optional. Not used.
  * @param string $user_password Optional. User's chosen password. Will default to a random password.
  * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
  */
 function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
 {
     if (!empty($deprecated)) {
         _deprecated_argument(__FUNCTION__, '2.6');
     }
     wp_check_mysql_version();
     wp_cache_flush();
     make_db_current_silent();
     if (!is_file(ABSPATH . 'wp-admin/install.sql')) {
         //[ysd]如果有install.sql不设置默认options数据
         populate_options();
     } else {
         validate_active_plugins();
         //[ysd] 禁用 不可用的插件
     }
     populate_roles();
     update_option('blogname', $blog_title);
     update_option('admin_email', $user_email);
     update_option('blog_public', $public);
     $guessurl = isset($_SERVER['HTTP_APPNAME']) ? 'http://' . substr($_SERVER['HTTP_APPNAME'], 5) . '.1kapp.com' : wp_guess_url();
     //[ysd] 固定了guessurl
     update_option('siteurl', $guessurl);
     update_option('home', $guessurl);
     get_option('siteurl');
     // If not a public blog, don't ping.
     if (!$public) {
         update_option('default_pingback_flag', 0);
     }
     // Create default user. If the user already exists, the user tables are
     // being shared among blogs. Just set the role in that case.
     $user_id = username_exists($user_name);
     $user_password = trim($user_password);
     $email_password = false;
     if (!$user_id && empty($user_password)) {
         $user_password = wp_generate_password(12, false);
         $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
         $user_id = wp_create_user($user_name, $user_password, $user_email);
         update_user_option($user_id, 'default_password_nag', true, true);
         $email_password = true;
     } else {
         if (!$user_id) {
             // Password has been provided
             $message = '<em>' . __('Your chosen password.') . '</em>';
             $user_id = wp_create_user($user_name, $user_password, $user_email);
         } else {
             $message = __('User already exists. Password inherited.');
         }
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     if (!file_exists(ABSPATH . 'wp-admin/without_default')) {
         wp_install_defaults($user_id);
     }
     //[ysd],如果打包时设置了默认数据,才会设置默认数据
     flush_rewrite_rules();
     wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
     wp_cache_flush();
     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
 }
Example #7
0
/**
 * This function overrides wp_install() in wp-admin/includes/upgrade.php
 */
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '2.6');
    }
    wp_check_mysql_version();
    wp_cache_flush();
    /* changes */
    require_once PDODIR . 'schema.php';
    make_db_sqlite();
    /* changes */
    populate_options();
    populate_roles();
    update_option('blogname', $blog_title);
    update_option('admin_email', $user_email);
    update_option('blog_public', $public);
    $guessurl = wp_guess_url();
    update_option('siteurl', $guessurl);
    if (!$public) {
        update_option('default_pingback_flag', 0);
    }
    $user_id = username_exists($user_name);
    $user_password = trim($user_password);
    $email_password = false;
    if (!$user_id && empty($user_password)) {
        $user_password = wp_generate_password(12, false);
        $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
        $user_id = wp_create_user($user_name, $user_password, $user_email);
        update_user_option($user_id, 'default_password_nag', true, true);
        $email_password = true;
    } else {
        if (!$user_id) {
            $message = '<em>' . __('Your chosen password.') . '</em>';
            $user_id = wp_create_user($user_name, $user_password, $user_email);
        }
    }
    $user = new WP_User($user_id);
    $user->set_role('administrator');
    wp_install_defaults($user_id);
    flush_rewrite_rules();
    wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
    wp_cache_flush();
    if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) {
        // Your server is Apache. Nothing to do more.
    } else {
        $server_message = sprintf('Your webserver doesn\'t seem to be Apache. So the database directory access restriction by the .htaccess file may not function. We strongly recommend that you should restrict the access to the directory %s in some other way.', FQDBDIR);
        echo '<div style="position: absolute; margin-top: 350px; width: 700px; border: .5px dashed rgb(0, 0, 0);"><p style="margin: 10px;">';
        echo $server_message;
        echo '</p></div>';
    }
    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
/**
 * this function overrides the built in wordpress  variant
 * 
 * @param object $blog_title
 * @param object $user_name
 * @param object $user_email
 * @param object $public
 * @param object $deprecated [optional]
 * @return 
 */
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '')
{
    global $wp_rewrite, $wpdb;
    //wp_check_mysql_version();
    wp_cache_flush();
    /**** changes start here ***/
    switch (DB_TYPE) {
        case 'sqlite':
            require PDODIR . '/driver_sqlite/schema.php';
            installdb();
            break;
        case 'mysql':
            make_db_current_silent();
            break;
    }
    /**** changes end ***/
    $wpdb->suppress_errors();
    populate_options();
    populate_roles();
    update_option('blogname', $blog_title);
    update_option('admin_email', $user_email);
    update_option('blog_public', $public);
    $guessurl = wp_guess_url();
    update_option('siteurl', $guessurl);
    // If not a public blog, don't ping.
    if (!$public) {
        update_option('default_pingback_flag', 0);
    }
    // Create default user.  If the user already exists, the user tables are
    // being shared among blogs.  Just set the role in that case.
    $user_id = username_exists($user_name);
    if (!$user_id) {
        $random_password = wp_generate_password();
        $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.<br><br>���' . $random_password);
        $user_id = wp_create_user($user_name, $random_password, $user_email);
        update_usermeta($user_id, 'default_password_nag', true);
    } else {
        $random_password = '';
        $message = __('User already exists.  Password inherited.');
    }
    $user = new WP_User($user_id);
    $user->set_role('administrator');
    wp_install_defaults($user_id);
    $wp_rewrite->flush_rules();
    wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
    wp_cache_flush();
    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
}
/**
 * This function overrides wp_install() in wp-admin/includes/upgrade.php
 */
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '')
{
    if (!empty($deprecated)) {
        _deprecated_argument(__FUNCTION__, '2.6');
    }
    wp_check_mysql_version();
    wp_cache_flush();
    /* changes */
    require_once PDODIR . 'schema.php';
    make_db_sqlite();
    /* changes */
    populate_options();
    populate_roles();
    update_option('blogname', $blog_title);
    update_option('admin_email', $user_email);
    update_option('blog_public', $public);
    $guessurl = wp_guess_url();
    update_option('siteurl', $guessurl);
    if (!$public) {
        update_option('default_pingback_flag', 0);
    }
    $user_id = username_exists($user_name);
    $user_password = trim($user_password);
    $email_password = false;
    if (!$user_id && empty($user_password)) {
        $user_password = wp_generate_password(12, false);
        $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
        $user_id = wp_create_user($user_name, $user_password, $user_email);
        update_user_option($user_id, 'default_password_nag', true, true);
        $email_password = true;
    } else {
        if (!$user_id) {
            $message = '<em>' . __('Your chosen password.') . '</em>';
            $user_id = wp_create_user($user_name, $user_password, $user_email);
        }
    }
    $user = new WP_User($user_id);
    $user->set_role('administrator');
    wp_install_defaults($user_id);
    flush_rewrite_rules();
    wp_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.'));
    wp_cache_flush();
    if (isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || isset($_SERVER['SERVER_SIGNATURE']) && stripos($_SERVER['SERVER_SIGNATURE'], 'apache') !== false) {
        // Your server is Apache. Nothing to do more.
    }
    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
Example #10
0
    }
    unset($blogs);
    $blogs = $blog_list;
    if (false == is_array($blogs)) {
        return array();
    }
    if ($num == 'all') {
        return array_slice($blogs, $start, count($blogs));
    } else {
        return array_slice($blogs, $start, $num);
    }
}
$block_size = $_GET['block_size'];
$block_num = $_GET['block_num'];
$log_file = $_GET['log_file'];
$f = fopen($log_file, "w");
echo 'Block number: ' . $block_num . '<BR>' . 'Block_size: ' . $block_size . '<BR><BR>';
$m = 'Block number: ' . $block_num . "\n" . 'Block_size: ' . $block_size . "\n\n";
fwrite($f, $m);
$blog_list = get_blog_list_all($block_size * $block_num, $block_size);
foreach ($blog_list as $blog) {
    switch_to_blog($blog['blog_id']);
    populate_roles();
    echo 'Blog ' . $blog['blog_id'] . ': ' . $blog['domain'] . $blog['path'] . '<BR>';
    $m = 'Blog ' . $blog['blog_id'] . ': ' . $blog['domain'] . $blog['path'] . "\n";
    fwrite($f, $m);
}
echo "<BR>Done<BR>";
$m = "\nDone\n";
fwrite($f, $m);
fclose($f);
function install_blog($blog_id, $blog_title = '')
{
    global $wpdb, $table_prefix, $wp_roles;
    $wpdb->suppress_errors();
    // Cast for security
    $blog_id = (int) $blog_id;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    if ($wpdb->get_results("SELECT ID FROM {$wpdb->posts}")) {
        die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
    }
    $wpdb->suppress_errors(false);
    $url = get_blogaddress_by_id($blog_id);
    // Set everything up
    make_db_current_silent();
    populate_options();
    populate_roles();
    $wp_roles->_init();
    // fix url.
    update_option('siteurl', $url);
    update_option('home', $url);
    update_option('fileupload_url', $url . "files");
    update_option('upload_path', "wp-content/blogs.dir/" . $blog_id . "/files");
    update_option('blogname', $blog_title);
    update_option('admin_email', '');
    $wpdb->update($wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email'));
    // Default category
    $wpdb->insert($wpdb->terms, array('term_id' => 1, 'name' => __('Uncategorized'), 'slug' => sanitize_title(__('Uncategorized')), 'term_group' => 0));
    $wpdb->insert($wpdb->term_taxonomy, array('term_id' => 1, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
    // Default link category
    $cat_name = __('Blogroll');
    $cat_slug = sanitize_title($cat_name);
    $blogroll_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
    if ($blogroll_id == null) {
        $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
        $blogroll_id = $wpdb->insert_id;
    }
    $wpdb->insert($wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
    $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 2));
    update_option('default_link_category', $blogroll_id);
    // remove all perms
    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", $table_prefix . 'user_level'));
    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", $table_prefix . 'capabilities'));
    $wpdb->suppress_errors(false);
}
Example #12
0
/**
 * Install an empty blog.
 *
 * Creates the new blog tables and options. If calling this function
 * directly, be sure to use switch_to_blog() first, so that $wpdb
 * points to the new blog.
 *
 * @since MU
 * @uses make_db_current_silent()
 * @uses populate_roles()
 *
 * @param int $blog_id The value returned by insert_blog().
 * @param string $blog_title The title of the new site.
 */
function install_blog($blog_id, $blog_title = '')
{
    global $wpdb, $wp_roles, $current_site;
    // Cast for security
    $blog_id = (int) $blog_id;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $wpdb->suppress_errors();
    if ($wpdb->get_results("DESCRIBE {$wpdb->posts}")) {
        die('<h1>' . __('Already Installed') . '</h1><p>' . __('You appear to have already installed WordPress. To reinstall please clear your old database tables first.') . '</p></body></html>');
    }
    $wpdb->suppress_errors(false);
    $url = get_blogaddress_by_id($blog_id);
    // Set everything up
    make_db_current_silent('blog');
    populate_options();
    populate_roles();
    $wp_roles->_init();
    $url = untrailingslashit($url);
    update_option('siteurl', $url);
    update_option('home', $url);
    if (get_site_option('ms_files_rewriting')) {
        update_option('upload_path', UPLOADBLOGSDIR . "/{$blog_id}/files");
    } else {
        update_option('upload_path', get_blog_option($current_site->blog_id, 'upload_path'));
    }
    update_option('blogname', stripslashes($blog_title));
    update_option('admin_email', '');
    // remove all perms
    $table_prefix = $wpdb->get_blog_prefix();
    delete_metadata('user', 0, $table_prefix . 'user_level', null, true);
    // delete all
    delete_metadata('user', 0, $table_prefix . 'capabilities', null, true);
    // delete all
}
Example #13
0
 function xpress_oninstall_base($module, $mydirname)
 {
     // transations on module install
     global $ret;
     // TODO :-D
     // for Cube 2.1
     if (defined('XOOPS_CUBE_LEGACY')) {
         $root =& XCube_Root::getSingleton();
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'xpress_message_append_oninstall');
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Fail', 'xpress_message_append_oninstall_err');
         $ret = array();
     } else {
         if (!is_array($ret)) {
             $ret = array();
         }
     }
     $db =& Database::getInstance();
     $mid = $module->getVar('mid');
     if (defined('XOOPS_CUBE_LEGACY')) {
         $ret[] = "********************************* Install Log ********************************<br />";
     } else {
         $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Install Log</h4>';
     }
     //xpress
     global $wpdb, $wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query, $wp_embed;
     global $xoops_config;
     define("WP_INSTALLING", true);
     define('WP_FIRST_INSTALL', true);
     // For WPMU2.8
     $site_url = XOOPS_URL . "/modules/" . $mydirname;
     $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
     $path = $mydirpath . '/';
     $site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME;
     // permission and wordpress files check
     require_once $path . 'include/pre_check.php';
     if (!xp_permission_check($mydirname, $mydirpath)) {
         if (!defined('XOOPS_CUBE_LEGACY')) {
             $ret = $GLOBALS["err_log"];
             $ret[] = "<br /><span style=\"color:#ff0000;\">The uninstallation of the module is executed now. </span><br />";
             $ret[] = xoops_module_uninstall($mydirname);
         }
         return false;
     }
     // install WordPress
     if (file_exists($path . 'wp-load.php')) {
         require_once $path . 'wp-load.php';
     } else {
         require_once $path . 'wp-config.php';
     }
     include_once $mydirpath . '/wp-admin/upgrade-functions.php';
     wp_cache_flush();
     make_db_current_silent();
     $ret[] = "The data base of wordpress was made by prefix {$table_prefix}.<br />";
     $option_desc = __('WordPress web address');
     $wpdb->query("INSERT INTO {$wpdb->options} (blog_id, option_name,option_value, autoload) VALUES ('0', 'siteurl','{$site_url}', 'yes')");
     $wpdb->query("INSERT INTO {$wpdb->options} (blog_id, option_name,option_value, autoload) VALUES ('0', 'home','{$site_url}', 'yes')");
     populate_options();
     populate_roles();
     // create XPressME table
     $xp_prefix = preg_replace('/wordpress/', 'wp', $mydirname);
     $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_views';
     $charset_collate = '';
     if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
     }
     $views_queries = "CREATE TABLE {$views_table} (\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_id bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_views bigint(20) unsigned NOT NULL default '0',\n  \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$views_table} table of XPressME was made.<br />";
     $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_d3forum_link';
     $views_queries = "CREATE TABLE {$d3forum_link} (\n  \t\tcomment_ID bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_id int(10) unsigned NOT NULL default '0' ,\n  \t\twp_post_ID bigint(20) unsigned NOT NULL default '0',\n  \t\tforum_id bigint(20) unsigned NOT NULL default '0',\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$d3forum_link} table of XPressME was made.<br />";
     $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_group_role';
     $views_queries = "CREATE TABLE {$group_role} (\n  \t\tgroupid smallint(5) unsigned NOT NULL default '0',\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tname varchar(50)  NOT NULL default '' ,\n  \t\tdescription text  NOT NULL default '',\n  \t\tgroup_type varchar(50)  NOT NULL default '' ,\n\t\trole varchar(20)  NOT NULL default '' ,\n\t\tlogin_all smallint(5) unsigned NOT NULL default '0' ,\n  \t\tKEY groupid (groupid)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$group_role} table of XPressME was made.<br />";
     $notify_reserve = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_notify_reserve';
     $queries = "CREATE TABLE {$notify_reserve} (\n  \t\tnotify_reserve_id bigint(20) NOT NULL AUTO_INCREMENT ,\n  \t\tnotify_reserve_status varchar(20)  NOT NULL default '' ,\n  \t\tcategory text  NOT NULL default '',\n  \t\titem_id bigint(20) unsigned NOT NULL default '0',\n\t\tevent varchar(20) NOT NULL default '',\n\t\textra_tags_arry longtext NOT NULL default '' ,\n\t\tuser_list_arry longtext NOT NULL default '' ,\n  \t\tmodule_id smallint(5) unsigned NOT NULL default '0' ,\n  \t\tomit_user_id varchar(20) NOT NULL default '' ,\n  \t\tKEY notify_reserve_id (notify_reserve_id)\n\t\t)ENGINE=MyISAM";
     dbDelta($queries);
     $ret[] = "{$notify_reserve} table of XPressME was made.<br />";
     $sql = "INSERT INTO {$group_role} (groupid, role) VALUES (1, 'administrator')";
     $wpdb->query($sql);
     // make templates
     include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php';
     $t_mess = xpress_templates_make($mid, $mydirname);
     // Admin User Data write
     // Change uid field
     $wpdb->query("ALTER TABLE {$wpdb->posts} CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
     $user_name = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uname") : 'admin';
     $email = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("email") : '*****@*****.**';
     $pass_md5 = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("pass") : '';
     add_filter('sanitize_user', "sanitize_user_multibyte", 10, 3);
     if (!function_exists('username_exists')) {
         require_once $mydirpath . '/wp-includes/registration-functions.php';
     }
     $user_id = username_exists($user_name);
     if (!$user_id) {
         $random_password = '******';
         $user_id = wp_create_user($user_name, $random_password, $email);
     } else {
         $random_password = __('User already exists.  Password inherited.');
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     'User ' . $user_name . ' of the administrator was made.';
     // over write xoops md5 password
     $sql = "UPDATE {$wpdb->users} SET user_pass ='******' WHERE ID = {$user_id}";
     $wpdb->query($sql);
     $ret[] = 'The password of XOOPS was copied.<br />';
     // Set Default data
     // make WordPress Default data
     if (function_exists('wp_install_defaults')) {
         wp_install_defaults($user_id);
     } else {
         wp_install_old_defaults($user_id);
     }
     $ret[] = 'The first sample post & comment was written.<br />';
     // Rewrite Option for Xpress
     $xoops_config_tbl = XOOPS_DB_PREFIX . '_config';
     $sql = "SELECT conf_value FROM  {$xoops_config_tbl} WHERE `conf_name` = 'default_TZ'";
     $xoops_default_TZ = $wpdb->get_var($sql);
     update_option('gmt_offset', $xoops_default_TZ);
     if (WPLANG == 'ja_EUC') {
         $setup_charset = 'EUC-JP';
     } elseif (WPLANG == 'ja_SJIS') {
         $setup_charset = 'Shift_JIS';
     } else {
         $setup_charset = 'UTF-8';
     }
     update_option("blog_charset", $setup_charset);
     update_option('blogname', $site_name);
     update_option('blogdescription', 'WordPress for XOOPS');
     update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
     update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
     update_option("home", $site_url);
     update_option("siteurl", $site_url);
     update_option("what_to_show", "posts");
     update_option('default_pingback_flag', 0);
     $ret[] = 'The initial data was written in the data base of wordpress.<br />';
     update_option("template", "xpress_default");
     update_option("stylesheet", "xpress_default");
     $ret[] = 'The default theme of wordpress was set to xpress_default.<br />';
     //	update_option('uploads_use_yearmonth_folders', 1);
     update_option('upload_path', 'wp-content/uploads');
     // activate the xpressme plugin
     require_once dirname(__FILE__) . '/xpress_active_plugin.php';
     if (xpress_pulugin_activation('xpressme/xpressme.php')) {
         $ret[] = 'The xpressme plug-in was activated.<br />';
     } else {
         $GLOBALS["err_log"][] = '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />';
         return false;
     }
     $ret = array_merge($ret, $t_mess);
     return true;
 }
Example #14
0
 /**
  * Reset any default role to default capabilities.
  *
  * ## OPTIONS
  *
  * [<role-key>...]
  * : The internal name of one or more roles to reset.
  *
  * [--all]
  * : If set, all default roles will be reset.
  *
  * ## EXAMPLES
  *
  *     # Reset role.
  *     $ wp role reset administrator author contributor
  *     Success: Reset 1/3 roles.
  *
  *     # Reset all default roles.
  *     $ wp role reset --all
  *     Success: All default roles reset.
  */
 public function reset($args, $assoc_args)
 {
     self::persistence_check();
     if (!\WP_CLI\Utils\get_flag_value($assoc_args, 'all') && empty($args)) {
         WP_CLI::error("Role key not provided, or is invalid.");
     }
     if (!function_exists('populate_roles')) {
         require_once ABSPATH . 'wp-admin/includes/schema.php';
     }
     global $wp_roles;
     $all_roles = array_keys($wp_roles->roles);
     $preserve_args = $args;
     // Get our default roles.
     $default_roles = $preserve = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
     $before = array();
     if (\WP_CLI\Utils\get_flag_value($assoc_args, 'all')) {
         foreach ($default_roles as $role) {
             $before[$role] = get_role($role);
             remove_role($role);
             $args[] = $role;
         }
         populate_roles();
         $not_affected_roles = array_diff($all_roles, $default_roles);
         if (!empty($not_affected_roles)) {
             foreach ($not_affected_roles as $not_affected_role) {
                 WP_CLI::log("Custom role '{$not_affected_role}' not affected.");
             }
         }
     } else {
         foreach ($args as $k => $role_key) {
             $key = array_search($role_key, $default_roles);
             if (false !== $key) {
                 unset($preserve[$key]);
                 $before[$role_key] = get_role($role_key);
                 remove_role($role_key);
             } else {
                 unset($args[$k]);
             }
         }
         $not_affected_roles = array_diff($preserve_args, $default_roles);
         if (!empty($not_affected_roles)) {
             foreach ($not_affected_roles as $not_affected_role) {
                 WP_CLI::log("Custom role '{$not_affected_role}' not affected.");
             }
         }
         // No roles were unset, bail.
         if (count($default_roles) == count($preserve)) {
             WP_CLI::error('Must specify a default role to reset.');
         }
         // For the roles we're not resetting.
         foreach ($preserve as $k => $role) {
             /* save roles
              * if get_role is null
              * save role name for re-removal
              */
             $roleobj = get_role($role);
             $preserve[$k] = is_null($roleobj) ? $role : $roleobj;
             remove_role($role);
         }
         // Put back all default roles and capabilities.
         populate_roles();
         // Restore the preserved roles.
         foreach ($preserve as $k => $roleobj) {
             // Re-remove after populating.
             if (is_a($roleobj, 'WP_Role')) {
                 remove_role($roleobj->name);
                 add_role($roleobj->name, ucwords($roleobj->name), $roleobj->capabilities);
             } else {
                 // When not an object, that means the role didn't exist before.
                 remove_role($roleobj);
             }
         }
     }
     $num_reset = 0;
     $args = array_unique($args);
     $num_to_reset = count($args);
     foreach ($args as $role_key) {
         $after[$role_key] = get_role($role_key);
         if ($after[$role_key] != $before[$role_key]) {
             ++$num_reset;
             $restored_cap = array_diff_key($after[$role_key]->capabilities, $before[$role_key]->capabilities);
             $removed_cap = array_diff_key($before[$role_key]->capabilities, $after[$role_key]->capabilities);
             $restored_cap_count = count($restored_cap);
             $removed_cap_count = count($removed_cap);
             $restored_text = 1 === $restored_cap_count ? '%d capability' : '%d capabilities';
             $removed_text = 1 === $removed_cap_count ? '%d capability' : '%d capabilities';
             $message = "Restored " . $restored_text . " to and removed " . $removed_text . " from '%s' role.";
             WP_CLI::log(sprintf($message, $restored_cap_count, $removed_cap_count, $role_key));
         } else {
             WP_CLI::log("No changes necessary for '{$role_key}' role.");
         }
     }
     if ($num_reset) {
         if (1 === count($args)) {
             WP_CLI::success('Role reset.');
         } else {
             WP_CLI::success("{$num_reset} of {$num_to_reset} roles reset.");
         }
     } else {
         if (1 === count($args)) {
             WP_CLI::success('Role didn\'t need resetting.');
         } else {
             WP_CLI::success('No roles needed resetting.');
         }
     }
 }
Example #15
0
 /**
  * return WordPress user roles to its initial state, just like after installation
  * @global WP_Roles $wp_roles
  */
 protected function wp_roles_reinit()
 {
     global $wp_roles;
     $wp_roles->roles = array();
     $wp_roles->role_objects = array();
     $wp_roles->role_names = array();
     $wp_roles->use_db = true;
     require_once ABSPATH . '/wp-admin/includes/schema.php';
     populate_roles();
     $wp_roles->reinit();
     $this->roles = $this->get_user_roles();
 }
Example #16
0
/**
 * reset user roles to WordPress default roles
 */
function ure_reset_user_roles()
{
    global $wp_roles;
    //$active_plugins = ure_deactivate_plugins();  // deactivate all plugins
    $wp_roles->roles = array();
    $wp_roles->role_objects = array();
    $wp_roles->role_names = array();
    $wp_roles->use_db = true;
    require_once ABSPATH . '/wp-admin/includes/schema.php';
    populate_roles();
    $wp_roles->reinit();
    $reload_link = wp_get_referer();
    $reload_link = remove_query_arg('action', $reload_link);
    $reload_link = add_query_arg('action', 'roles_restore_note', $reload_link);
    /*  
    // return recently deactivated plugins to its original state
    	if ( is_array( $active_plugins ) && count( $active_plugins ) > 0 ) {
          activate_plugins( $active_plugins,  $reload_link);
    	}	
    	//ure_validate_user_roles();  // if user has non-existing role lower him to Subscriber role
    */
    ?>
    
	<script type="text/javascript" >
		document.location = '<?php 
    echo $reload_link;
    ?>
';
	</script>  
<?php 
    return '';
}
Example #17
0
function install_blog($blog_id, $blog_title = '')
{
    global $wpdb, $table_prefix, $wp_roles;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $wpdb->suppress_errors();
    $installed = $wpdb->get_results("SELECT * FROM {$wpdb->posts}");
    $wpdb->suppress_errors(false);
    if ($installed) {
        die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
    }
    $url = get_blogaddress_by_id($blog_id);
    // Set everything up
    make_db_current_silent();
    populate_options();
    populate_roles();
    $wp_roles->_init();
    // fix url.
    update_option('siteurl', $url);
    update_option('home', $url);
    update_option('fileupload_url', $url . "files");
    update_option('upload_path', "wp-content/blogs.dir/" . $blog_id . "/files");
    update_option('blogname', $blog_title);
    update_option('admin_email', '');
    $wpdb->query("UPDATE {$wpdb->options} SET option_value = '' WHERE option_name = 'admin_email'");
    // Default category
    $cat_name = $wpdb->escape(__('Uncategorized'));
    $cat_slug = sanitize_title(__('Uncategorized'));
    $wpdb->query("INSERT INTO {$wpdb->terms} (term_id, name, slug, term_group) VALUES ('1', '{$cat_name}', '{$cat_slug}', '0')");
    $wpdb->query("INSERT INTO {$wpdb->term_taxonomy} (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')");
    // Default link category
    $cat_name = $wpdb->escape(__('Blogroll'));
    $cat_slug = sanitize_title(__('Blogroll'));
    $blogroll_id = $wpdb->get_var("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = '{$cat_slug}'");
    if ($blogroll_id == null) {
        $wpdb->query("INSERT INTO " . $wpdb->sitecategories . " (cat_ID, cat_name, category_nicename, last_updated) VALUES (0, '{$cat_name}', '{$cat_slug}', NOW())");
        $blogroll_id = $wpdb->insert_id;
    }
    $wpdb->query("INSERT INTO {$wpdb->terms} (term_id, name, slug, term_group) VALUES ('{$blogroll_id}', '{$cat_name}', '{$cat_slug}', '0')");
    $wpdb->query("INSERT INTO {$wpdb->term_taxonomy} (term_id, taxonomy, description, parent, count) VALUES ('{$blogroll_id}', 'link_category', '', '0', '2')");
    update_option('default_link_category', $blogroll_id);
    // remove all perms
    $wpdb->query("DELETE FROM " . $wpdb->usermeta . " WHERE meta_key = '" . $table_prefix . "user_level'");
    $wpdb->query("DELETE FROM " . $wpdb->usermeta . " WHERE meta_key = '" . $table_prefix . "capabilities'");
    wp_cache_delete('notoptions', 'options');
    wp_cache_delete('alloptions', 'options');
    $wpdb->suppress_errors(false);
}
Example #18
0
/**
 * Install an empty blog.
 *
 * Creates the new blog tables and options. If calling this function
 * directly, be sure to use switch_to_blog() first, so that $wpdb
 * points to the new blog.
 *
 * @since MU
 *
 * @global wpdb     $wpdb
 * @global WP_Roles $wp_roles
 *
 * @param int    $blog_id    The value returned by insert_blog().
 * @param string $blog_title The title of the new site.
 */
function install_blog($blog_id, $blog_title = '')
{
    global $wpdb, $wp_roles, $current_site;
    // Cast for security
    $blog_id = (int) $blog_id;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $suppress = $wpdb->suppress_errors();
    if ($wpdb->get_results("DESCRIBE {$wpdb->posts}")) {
        die('<h1>' . __('Already Installed') . '</h1><p>' . __('You appear to have already installed WordPress. To reinstall please clear your old database tables first.') . '</p></body></html>');
    }
    $wpdb->suppress_errors($suppress);
    $url = get_blogaddress_by_id($blog_id);
    // Set everything up
    make_db_current_silent('blog');
    populate_options();
    populate_roles();
    // populate_roles() clears previous role definitions so we start over.
    $wp_roles = new WP_Roles();
    $siteurl = $home = untrailingslashit($url);
    if (!is_subdomain_install()) {
        if ('https' === parse_url(get_network_option('siteurl'), PHP_URL_SCHEME)) {
            $siteurl = set_url_scheme($siteurl, 'https');
        }
        if ('https' === parse_url(get_home_url($current_site->blog_id), PHP_URL_SCHEME)) {
            $home = set_url_scheme($home, 'https');
        }
    }
    update_option('siteurl', $siteurl);
    update_option('home', $home);
    if (get_site_option('ms_files_rewriting')) {
        update_option('upload_path', UPLOADBLOGSDIR . "/{$blog_id}/files");
    } else {
        update_option('upload_path', get_blog_option(get_current_site()->blog_id, 'upload_path'));
    }
    update_option('blogname', wp_unslash($blog_title));
    update_option('admin_email', '');
    // remove all perms
    $table_prefix = $wpdb->get_blog_prefix();
    delete_metadata('user', 0, $table_prefix . 'user_level', null, true);
    // delete all
    delete_metadata('user', 0, $table_prefix . 'capabilities', null, true);
    // delete all
}
Example #19
0
 /**
  * Reset any default role to default capabilities.
  *
  * ## OPTIONS
  *
  * [<role-key>...]
  * : The internal name of one or more roles to reset.
  *
  * [--all]
  * : If set, all default roles will be reset.
  *
  * ## EXAMPLES
  *
  *     # Reset role
  *     $ wp role reset administrator author contributor
  *     Success: Reset 1/3 roles.
  *
  *     # Reset all default roles
  *     $ wp role reset --all
  *     Success: All default roles reset.
  */
 public function reset($args, $assoc_args)
 {
     self::persistence_check();
     if (!\WP_CLI\Utils\get_flag_value($assoc_args, 'all') && empty($args)) {
         WP_CLI::error("Role key not provided, or is invalid.");
     }
     if (!function_exists('populate_roles')) {
         require_once ABSPATH . 'wp-admin/includes/schema.php';
     }
     // get our default roles
     $default_roles = $preserve = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
     if (\WP_CLI\Utils\get_flag_value($assoc_args, 'all')) {
         foreach ($default_roles as $role) {
             remove_role($role);
         }
         populate_roles();
         WP_CLI::success('All default roles reset.');
         return;
     }
     foreach ($args as $k => $role_key) {
         $key = array_search($role_key, $default_roles);
         if (false !== $key) {
             unset($preserve[$key]);
             $before[$role_key] = get_role($role_key);
             remove_role($role_key);
         } else {
             unset($args[$k]);
         }
     }
     $num_to_reset = count($args);
     // no roles were unset, bail
     if (count($default_roles) == count($preserve)) {
         WP_CLI::error('Must specify a default role to reset.');
     }
     // for the roles we're not resetting
     foreach ($preserve as $k => $role) {
         /* save roles
          * if get_role is null
          * save role name for re-removal
          */
         $roleobj = get_role($role);
         $preserve[$k] = is_null($roleobj) ? $role : $roleobj;
         remove_role($role);
     }
     // put back all default roles and capabilities
     populate_roles();
     // restore the preserved roles
     foreach ($preserve as $k => $roleobj) {
         // re-remove after populating
         if (is_a($roleobj, 'WP_Role')) {
             remove_role($roleobj->name);
             add_role($roleobj->name, ucwords($roleobj->name), $roleobj->capabilities);
         } else {
             // when not an object, that means the role didn't exist before
             remove_role($roleobj);
         }
     }
     $num_reset = 0;
     foreach ($args as $role_key) {
         $after[$role_key] = get_role($role_key);
         if ($after[$role_key] != $before[$role_key]) {
             ++$num_reset;
         }
     }
     WP_CLI::success("Reset {$num_reset}/{$num_to_reset} roles.");
 }
Example #20
0
/**
 * Install an empty blog.
 *
 * Creates the new blog tables and options. If calling this function
 * directly, be sure to use switch_to_blog() first, so that $wpdb
 * points to the new blog.
 *
 * @since MU
 * @uses make_db_current_silent()
 * @uses populate_roles()
 *
 * @param int $blog_id The value returned by insert_blog().
 * @param string $blog_title The title of the new site.
 */
function install_blog($blog_id, $blog_title = '')
{
    global $wpdb, $table_prefix, $wp_roles;
    $wpdb->suppress_errors();
    // Cast for security
    $blog_id = (int) $blog_id;
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    if ($wpdb->get_results("SELECT ID FROM {$wpdb->posts}")) {
        die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
    }
    $wpdb->suppress_errors(false);
    $url = get_blogaddress_by_id($blog_id);
    // Set everything up
    make_db_current_silent();
    populate_options();
    populate_roles();
    $wp_roles->_init();
    // fix url.
    update_option('siteurl', $url);
    update_option('home', $url);
    update_option('fileupload_url', $url . "files");
    update_option('upload_path', UPLOADBLOGSDIR . "/{$blog_id}/files");
    update_option('blogname', stripslashes($blog_title));
    update_option('admin_email', '');
    $wpdb->update($wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email'));
    // remove all perms
    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", $table_prefix . 'user_level'));
    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", $table_prefix . 'capabilities'));
    $wpdb->suppress_errors(false);
}
 /**
  * Resets roles to WordPress defaults.
  *
  * @return void
  */
 private function backupToolReset()
 {
     require_once ABSPATH . 'wp-admin/includes/schema.php';
     if (!function_exists('populate_roles')) {
         ak_admin_error(__('Needed function to create default roles not found!', $this->ID));
         return;
     }
     $roles = array_keys($this->roles);
     foreach ($roles as $role) {
         remove_role($role);
     }
     populate_roles();
     $this->setAdminCapability();
     ak_admin_notify(__('Roles and Capabilities reset to WordPress defaults', $this->ID));
 }