Пример #1
0
function getsock($addr, $port)
{
    $socket = null;
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if ($socket === false || $socket === null) {
        $error = socket_strerror(socket_last_error());
        $msg = "socket create(TCP) failed";
        echo "ERR: {$msg} '{$error}'\n";
        return null;
    }
    $res = socket_connect($socket, $addr, $port);
    if ($res === false) {
        $error = socket_strerror(socket_last_error());
        $msg = '<center class="alert alert-danger bs-alert-old-docs">CGMiner is not running...If it is not restart after minutes ,please try to reboot.</center>';
        socket_close($socket);
        echo $msg;
        @exec('sudo service cgminer stop ');
        @exec('sudo service cgminer stop ');
        @exec('sudo service cgminer stop ');
        $network = get_network();
        $gateway = $network['gateway_id'];
        @exec('sudo  route add default gw ' . $gateway);
        //sleep(3);
        //@exec('sudo service cgminer start &');
        //showmsg($msg,'?c=home&m=reboot','10000');
        //echo "ERR: $msg '$error'\n";
        //exit;
        return null;
    }
    return $socket;
}
Пример #2
0
 function global_home_url($path = '', $scheme = null)
 {
     if (!is_multinetwork()) {
         return network_home_url($path, $scheme);
     }
     $main_site_id = get_main_network_id();
     $main_site = get_network($main_site_id);
     $orig_scheme = $scheme;
     if (!in_array($scheme, array('http', 'https', 'relative'))) {
         $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
     }
     if ('relative' == $scheme) {
         $url = $main_site->path;
     } else {
         $url = set_url_scheme('http://' . $main_site->domain . $main_site->path, $scheme);
     }
     if ($path && is_string($path)) {
         $url .= ltrim($path, '/');
     }
     /**
      * Filters the global home URL.
      *
      * @since 1.0.0
      *
      * @param string      $url         The complete global home URL including scheme and path.
      * @param string      $path        Path relative to the global home URL. Blank string
      *                                 if no path is specified.
      * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
      *                                 'relative' or null.
      */
     return apply_filters('global_home_url', $url, $path, $orig_scheme);
 }
Пример #3
0
function get_network_status()
{
    //创建
    $tmp = array();
    //获取网络信息
    $content1 = get_network();
    sleep(1);
    $content2 = get_network();
    //开始生成数据
    foreach ($content1 as $key => $row) {
        $len = strpos($row, ' ');
        $device_name = substr($row, 0, $len);
        //获取信息-接口名称
        $tmp[$key]['device_name'] = $device_name;
        //获取信息-网络速度
        preg_match_all('|RX bytes:(.*) \\(.*\\)  TX bytes:(.*) \\(.*\\)|', $content1[$key], $matches1);
        preg_match_all('|RX bytes:(.*) \\(.*\\)  TX bytes:(.*) \\(.*\\)|', $content2[$key], $matches2);
        $rx1 = (int) $matches1[1][0];
        $rx2 = (int) $matches2[1][0];
        $tx1 = (int) $matches1[2][0];
        $tx2 = (int) $matches2[2][0];
        $tmp[$key]['rx_speed'] = $rx2 - $rx1;
        $tmp[$key]['tx_speed'] = $tx2 - $tx1;
        //获取信息-总流量
        $tmp[$key]['rx_total'] = $rx2;
        $tmp[$key]['tx_total'] = $tx2;
        //获取信息-IPv4地址
        preg_match_all('|inet addr:(\\S+)|', $content1[$key], $matches3);
        $tmp[$key]['ipv4'] = isset($matches3[1][0]) ? $matches3[1][0] : null;
    }
    return $tmp;
}
function work($scope, $username, $repository, $developer)
{
	// Get some basic data
	$network		= get_network($username, $repository);
	$collaborators	= get_collaborators($username, $repository);

	if ($network === false || $collaborators === false)
	{
		echo "Error: failed to retrieve network or collaborators\n";
		return 1;
	}

	switch ($scope)
	{
		case 'collaborators':
			$remotes = array_intersect_key($network, $collaborators);
		break;

		case 'organisation':
			$remotes = array_intersect_key($network, get_organisation_members($username));
		break;

		case 'contributors':
			$remotes = array_intersect_key($network, get_contributors($username, $repository));
		break;

		case 'network':
			$remotes = $network;
		break;

		default:
			show_usage();
	}

	if (file_exists('.git'))
	{
		add_remote($username, $repository, isset($collaborators[$developer]));
	}
	else
	{
		clone_repository($username, $repository, isset($collaborators[$developer]));
	}

	// Add private security repository for developers
	if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer]))
	{
		run("git remote add $username-security " . get_repository_url($username, "$repository-security", true));
	}

	// Skip blessed repository.
	unset($remotes[$username]);

	foreach ($remotes as $remote)
	{
		add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
	}

	run('git remote update');
}
/**
 * Get the "dashboard blog", the blog where users without a blog edit their profile data.
 * Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
 *
 * @since MU
 * @deprecated 3.1.0 Use get_site()
 * @see get_site()
 *
 * @return WP_Site Current site object.
 */
function get_dashboard_blog()
{
    _deprecated_function(__FUNCTION__, '3.1.0');
    if ($blog = get_site_option('dashboard_blog')) {
        return get_site($blog);
    }
    return get_site(get_network()->site_id);
}
 public function test_get_id_from_blogname_invalid_slug()
 {
     global $current_site;
     $original_network = $current_site;
     $current_site = get_network(self::$network_ids['wordpress.org/']);
     $result = get_id_from_blogname('bar');
     $current_site = $original_network;
     $this->assertEquals(null, $result);
 }
Пример #7
0
function get_perc()
{
    $info = array();
    $info['net_info'] = get_network();
    $info['cpu_info'] = get_cpu();
    $info['disk_info'] = get_disk();
    $info['mem_info'] = get_mem();
    return $info;
}
/**
 * Retrieves a sites ID given its (subdomain or directory) slug.
 *
 * @since MU
 * @since 4.7.0 Converted to use get_sites().
 *
 * @param string $slug A site's slug.
 * @return int|null The site ID, or null if no site is found for the given slug.
 */
function get_id_from_blogname($slug)
{
    $current_network = get_network();
    $slug = trim($slug, '/');
    if (is_subdomain_install()) {
        $domain = $slug . '.' . preg_replace('|^www\\.|', '', $current_network->domain);
        $path = $current_network->path;
    } else {
        $domain = $current_network->domain;
        $path = $current_network->path . $slug . '/';
    }
    $site_ids = get_sites(array('number' => 1, 'fields' => 'ids', 'domain' => $domain, 'path' => $path));
    if (empty($site_ids)) {
        return null;
    }
    return array_shift($site_ids);
}
 /**
  * Add a Network
  *
  * <domain>
  * : Domain for network
  *
  * <path>
  * : Path for network
  *
  * [--site_name=<site_name>]
  * : Name of new network
  *
  * [--clone_network=<clone_network>]
  * : ID of network to clone
  *
  * [--options_to_clone=<options_to_clone>]
  * : Options to clone to new network
  *
  */
 public function create($args, $assoc_args)
 {
     list($domain, $path) = $args;
     $assoc_args = wp_parse_args($assoc_args, array('site_name' => false, 'clone_network' => false, 'options_to_clone' => false));
     $clone_network = $assoc_args['clone_network'];
     $options_to_clone = false;
     if (!empty($clone_network) && !get_network($clone_network)) {
         WP_CLI::error(sprintf(__("Clone network %s doesn't exist.", 'wp-multi-network'), $clone_network));
         if (!empty($assoc_args['options_to_clone'])) {
             $options_to_clone = explode(",", $assoc_args['options_to_clone']);
         }
     }
     // Add the network
     $network_id = add_network(array('domain' => $domain, 'path' => $path, 'site_name' => $assoc_args['site_name'], 'user_id' => get_current_user_id(), 'clone_network' => $clone_network, 'options_to_clone' => $options_to_clone));
     if (is_wp_error($network_id)) {
         WP_CLI::error($network_id);
     }
     WP_CLI::success(sprintf(__('Created network %d.', 'wp-multi-network'), $network_id));
 }
/**
 * Defines Multisite cookie constants.
 *
 * @since 3.0.0
 */
function ms_cookie_constants()
{
    $current_network = get_network();
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', $current_network->path);
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', $current_network->path);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        if (!is_subdomain_install() || trim(parse_url(get_option('siteurl'), PHP_URL_PATH), '/')) {
            define('ADMIN_COOKIE_PATH', SITECOOKIEPATH);
        } else {
            define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN') && is_subdomain_install()) {
        if (!empty($current_network->cookie_domain)) {
            define('COOKIE_DOMAIN', '.' . $current_network->cookie_domain);
        } else {
            define('COOKIE_DOMAIN', '.' . $current_network->domain);
        }
    }
}
Пример #11
0
/**
 * Retrieves the current network ID.
 *
 * @since 4.6.0
 *
 * @return int The ID of the current network.
 */
function get_current_network_id()
{
    if (!is_multisite()) {
        return 1;
    }
    $current_network = get_network();
    if (!isset($current_network->id)) {
        return get_main_network_id();
    }
    return absint($current_network->id);
}
 switch ($_GET['action']) {
     case 'deleteblog':
         if (!current_user_can('delete_sites')) {
             wp_die(__('Sorry, you are not allowed to access this page.'), '', array('response' => 403));
         }
         $updated_action = 'not_deleted';
         if ($id != '0' && $id != get_network()->site_id && current_user_can('delete_site', $id)) {
             wpmu_delete_blog($id, true);
             $updated_action = 'delete';
         }
         break;
     case 'allblogs':
         if ((isset($_POST['action']) || isset($_POST['action2'])) && isset($_POST['allblogs'])) {
             $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
             foreach ((array) $_POST['allblogs'] as $key => $val) {
                 if ($val != '0' && $val != get_network()->site_id) {
                     switch ($doaction) {
                         case 'delete':
                             if (!current_user_can('delete_site', $val)) {
                                 wp_die(__('Sorry, you are not allowed to delete the site.'));
                             }
                             $updated_action = 'all_delete';
                             wpmu_delete_blog($val, true);
                             break;
                         case 'spam':
                         case 'notspam':
                             $updated_action = 'spam' === $doaction ? 'all_spam' : 'all_notspam';
                             update_blog_status($val, 'spam', 'spam' === $doaction ? '1' : '0');
                             break;
                     }
                 } else {
         $parent_file = 'users.php';
         require_once ABSPATH . 'wp-admin/admin-header.php';
         echo '<div class="wrap">';
         confirm_delete_users($_POST['allusers']);
         echo '</div>';
         require_once ABSPATH . 'wp-admin/admin-footer.php';
         exit;
     case 'spam':
         $user = get_userdata($user_id);
         if (is_super_admin($user->ID)) {
             wp_die(sprintf(__('Warning! User cannot be modified. The user %s is a network administrator.'), esc_html($user->user_login)));
         }
         $userfunction = 'all_spam';
         $blogs = get_blogs_of_user($user_id, true);
         foreach ((array) $blogs as $details) {
             if ($details->userblog_id != get_network()->site_id) {
                 // main blog not a spam !
                 update_blog_status($details->userblog_id, 'spam', '1');
             }
         }
         update_user_status($user_id, 'spam', '1');
         break;
     case 'notspam':
         $userfunction = 'all_notspam';
         $blogs = get_blogs_of_user($user_id, true);
         foreach ((array) $blogs as $details) {
             update_blog_status($details->userblog_id, 'spam', '0');
         }
         update_user_status($user_id, 'spam', '0');
         break;
 }
Пример #14
0
/**
 * Retrieve an object containing information about the requested network.
 *
 * @since 3.9.0
 *
 * @internal In 4.6.0, converted to use get_network()
 *
 * @param object|int $network The network's database row or ID.
 * @return WP_Network|false Object containing network information if found, false if not.
 */
function wp_get_network($network)
{
    $network = get_network($network);
    if (null === $network) {
        return false;
    }
    return $network;
}
Пример #15
0
		    label: "Used RAM"
                }
            ];
            // pie chart options
            var dohOptions = {
                 segmentShowStroke : false,
                 animateScale : true
            }
            // get pie chart canvas
            var memory= document.getElementById("memory").getContext("2d");
            // draw pie chart
            new Chart(memory).Pie(dohData, dohOptions);
</script>
<script>
<?php 
$net_info = get_network();
$netTX = $net_info['tx'];
$netRX = $net_info['rx'];
$netEr = $net_info['ex'];
$netDr = $net_info['dx'];
?>
var netOptions = {
	animateRotate : true,
	scaleShowLabelBackdrop : true
	}
var netData = [
    {
        value: <?php 
print $netRX;
?>
,
Пример #16
0
 * @global int       $total_update_count
 * @global string    $parent_file
 */
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $update_title, $total_update_count, $parent_file;
// Catch plugins that include admin-header.php before admin.php completes.
if (empty($current_screen)) {
    set_current_screen();
}
get_admin_page_title();
$title = esc_html(strip_tags($title));
if (is_network_admin()) {
    /* translators: Network admin screen title. 1: Network name */
    $admin_title = sprintf(__('Network Admin: %s'), esc_html(get_network()->site_name));
} elseif (is_user_admin()) {
    /* translators: User dashboard screen title. 1: Network name */
    $admin_title = sprintf(__('User Dashboard: %s'), esc_html(get_network()->site_name));
} else {
    $admin_title = get_bloginfo('name');
}
if ($admin_title == $title) {
    /* translators: Admin screen title. 1: Admin screen name */
    $admin_title = sprintf(__('%1$s &#8212; WordPress'), $title);
} else {
    /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */
    $admin_title = sprintf(__('%1$s &lsaquo; %2$s &#8212; WordPress'), $title, $admin_title);
}
/**
 * Filters the title tag content for an admin page.
 *
 * @since 3.1.0
 *
Пример #17
0
function do_register()
{
    $network = get_network();
    switch ($_GET['status']) {
        case 'check':
            $user_or_code = get_user();
            if (!$user_or_code) {
                $user_or_code = get_code();
            }
            if (!$user_or_code) {
                echo 'available';
            } else {
                echo 'taken';
            }
            return;
        case 'new_code':
            $sql = 'INSERT INTO ' . db_table('codes') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defcode') . ')';
            $resource = 'codes';
            break;
        case 'new_user':
            $sql = 'INSERT INTO ' . db_table('users') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defuser') . ')';
            $resource = 'users';
            break;
    }
    db_query($sql, false);
    $id = db_lastid();
    if ($id) {
        $input = $_POST;
        if (!$input) {
            $input = file_get_contents("php://input");
        }
        $lines = preg_split("/\n+/", $input);
        $attrs = array();
        foreach ($lines as $line) {
            $p = preg_split('/[=: ]+/', $line, 2);
            if ($p[0] && $p[1]) {
                $attrs[$p[0]] = $p[1];
            }
        }
        save_attributes($id, $resource, $attrs);
    }
}
print "Writing Netmask cache...\n";
$fd = fopen("mapper-cache.txt", "w");
foreach ($interfaces as $key => $int) {
    if (isset($int['netmask'])) {
        fputs($fd, $key . "\t" . $int['netmask'] . "\n");
        $count++;
    }
}
fclose($fd);
print "Wrote {$count} cache entries.\n";
# SNMP netmask => .1.3.6.1.2.1.4.20.1.3.10.1.1.254
# SNMP interface index => .1.3.6.1.2.1.4.20.1.2.10.1.1.254
$count = 0;
foreach ($interfaces as $key => $int) {
    if (isset($int['netmask'])) {
        $network = get_network($int['ip'], $int['netmask']) . "/" . get_cidr($int['netmask']);
        $interfaces[$key]['network'] = $network;
        $networks[$network][] = $key;
        $count++;
    } else {
        print $int['ip'] . "\n";
    }
}
print "Assembled {$count} different network/netmask pairs\n";
$link_config = "";
$node_config = "";
$nodes_seen = array();
$count = 0;
$linkid = 0;
$lannodeid = 0;
foreach ($networks as $network => $members) {
		<tr class="form-field form-required">
			<th scope="row"><label for="site-address"><?php 
_e('Site Address (URL)');
?>
</label></th>
			<td>
			<?php 
if (is_subdomain_install()) {
    ?>
				<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php 
    echo preg_replace('|^www\\.|', '', get_network()->domain);
    ?>
</span>
			<?php 
} else {
    echo get_network()->domain . get_network()->path;
    ?>
<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc"  autocapitalize="none" autocorrect="off" />
			<?php 
}
echo '<p class="description" id="site-address-desc">' . __('Only lowercase letters (a-z), numbers, and hyphens are allowed.') . '</p>';
?>
			</td>
		</tr>
		<tr class="form-field form-required">
			<th scope="row"><label for="site-title"><?php 
_e('Site Title');
?>
</label></th>
			<td><input name="blog[title]" type="text" class="regular-text" id="site-title" /></td>
		</tr>
Пример #20
0
    /**
     * Creates the initial content for a newly-installed site.
     *
     * Adds the default "Uncategorized" category, the first post (with comment),
     * first page, and default widgets for default theme for the current version.
     *
     * @since 2.1.0
     *
     * @global wpdb       $wpdb
     * @global WP_Rewrite $wp_rewrite
     * @global string     $table_prefix
     *
     * @param int $user_id User ID.
     */
    function wp_install_defaults($user_id)
    {
        global $wpdb, $wp_rewrite, $table_prefix;
        // Default category
        $cat_name = __('Uncategorized');
        /* translators: Default category slug */
        $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
        if (global_terms_enabled()) {
            $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
            if ($cat_id == null) {
                $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
                $cat_id = $wpdb->insert_id;
            }
            update_option('default_category', $cat_id);
        } else {
            $cat_id = 1;
        }
        $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
        $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
        $cat_tt_id = $wpdb->insert_id;
        // First post
        $now = current_time('mysql');
        $now_gmt = current_time('mysql', 1);
        $first_post_guid = get_option('home') . '/?p=1';
        if (is_multisite()) {
            $first_post = get_site_option('first_post');
            if (!$first_post) {
                /* translators: %s: site link */
                $first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
            }
            $first_post = sprintf($first_post, sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_network()->site_name));
            // Back-compat for pre-4.4
            $first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
            $first_post = str_replace('SITE_NAME', get_network()->site_name, $first_post);
        } else {
            $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!');
        }
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
        // Default comment
        $first_comment_author = __('A WordPress Commenter');
        $first_comment_email = '*****@*****.**';
        $first_comment_url = 'https://wordpress.org/';
        $first_comment = __('Hi, this is a comment.
To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.');
        if (is_multisite()) {
            $first_comment_author = get_site_option('first_comment_author', $first_comment_author);
            $first_comment_email = get_site_option('first_comment_email', $first_comment_email);
            $first_comment_url = get_site_option('first_comment_url', network_home_url());
            $first_comment = get_site_option('first_comment', $first_comment);
        }
        $wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => $first_comment_email, 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
        // First Page
        $first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:\n\n<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>\n\n...or something like this:\n\n<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>\n\nAs a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!"), admin_url());
        if (is_multisite()) {
            $first_page = get_site_option('first_page', $first_page);
        }
        $first_post_guid = get_option('home') . '/?page_id=2';
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'comment_status' => 'closed', 'post_title' => __('Sample Page'), 'post_name' => __('sample-page'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
        // Set up default widgets for default theme.
        update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3));
        if (!is_multisite()) {
            update_user_meta($user_id, 'show_welcome_panel', 1);
        } elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
            update_user_meta($user_id, 'show_welcome_panel', 2);
        }
        if (is_multisite()) {
            // Flush rules to pick up the new page.
            $wp_rewrite->init();
            $wp_rewrite->flush_rules();
            $user = new WP_User($user_id);
            $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
            // Remove all perms except for the login user.
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
            // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
            if (!is_super_admin($user_id) && $user_id != 1) {
                $wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix . '1_capabilities'));
            }
        }
    }
/**
 * Setup the new user signup process
 *
 * @since MU
 *
 * @param string          $user_name  The username.
 * @param string          $user_email The user's email.
 * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
 */
function signup_user($user_name = '', $user_email = '', $errors = '')
{
    global $active_signup;
    if (!is_wp_error($errors)) {
        $errors = new WP_Error();
    }
    $signup_for = isset($_POST['signup_for']) ? esc_html($_POST['signup_for']) : 'blog';
    $signup_user_defaults = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
    /**
     * Filters the default user variables used on the user sign-up form.
     *
     * @since 3.0.0
     *
     * @param array $signup_user_defaults {
     *     An array of default user variables.
     *
     *     @type string   $user_name  The user username.
     *     @type string   $user_email The user email address.
     *     @type WP_Error $errors     A WP_Error object with possible errors relevant to the sign-up user.
     * }
     */
    $filtered_results = apply_filters('signup_user_init', $signup_user_defaults);
    $user_name = $filtered_results['user_name'];
    $user_email = $filtered_results['user_email'];
    $errors = $filtered_results['errors'];
    ?>

	<h2><?php 
    /* translators: %s: name of the network */
    printf(__('Get your own %s account in seconds'), get_network()->site_name);
    ?>
</h2>
	<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
		<input type="hidden" name="stage" value="validate-user-signup" />
		<?php 
    /** This action is documented in wp-signup.php */
    do_action('signup_hidden_fields', 'validate-user');
    ?>
		<?php 
    show_user_form($user_name, $user_email, $errors);
    ?>

		<p>
		<?php 
    if ($active_signup == 'blog') {
        ?>
			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
		<?php 
    } elseif ($active_signup == 'user') {
        ?>
			<input id="signupblog" type="hidden" name="signup_for" value="user" />
		<?php 
    } else {
        ?>
			<input id="signupblog" type="radio" name="signup_for" value="blog" <?php 
        checked($signup_for, 'blog');
        ?>
 />
			<label class="checkbox" for="signupblog"><?php 
        _e('Gimme a site!');
        ?>
</label>
			<br />
			<input id="signupuser" type="radio" name="signup_for" value="user" <?php 
        checked($signup_for, 'user');
        ?>
 />
			<label class="checkbox" for="signupuser"><?php 
        _e('Just a username, please.');
        ?>
</label>
		<?php 
    }
    ?>
		</p>

		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php 
    esc_attr_e('Next');
    ?>
" /></p>
	</form>
	<?php 
}
Пример #22
0
/**
 * Add the "Site Name" menu.
 *
 * @since 3.3.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_site_menu($wp_admin_bar)
{
    // Don't show for logged out users.
    if (!is_user_logged_in()) {
        return;
    }
    // Show only when the user is a member of this site, or they're a super admin.
    if (!is_user_member_of_blog() && !current_user_can('manage_network')) {
        return;
    }
    $blogname = get_bloginfo('name');
    if (!$blogname) {
        $blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url());
    }
    if (is_network_admin()) {
        /* translators: %s: site name */
        $blogname = sprintf(__('Network Admin: %s'), esc_html(get_network()->site_name));
    } elseif (is_user_admin()) {
        /* translators: %s: site name */
        $blogname = sprintf(__('User Dashboard: %s'), esc_html(get_network()->site_name));
    }
    $title = wp_html_excerpt($blogname, 40, '&hellip;');
    $wp_admin_bar->add_menu(array('id' => 'site-name', 'title' => $title, 'href' => is_admin() || !current_user_can('read') ? home_url('/') : admin_url()));
    // Create submenu items.
    if (is_admin()) {
        // Add an option to visit the site.
        $wp_admin_bar->add_menu(array('parent' => 'site-name', 'id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url('/')));
        if (is_blog_admin() && is_multisite() && current_user_can('manage_sites')) {
            $wp_admin_bar->add_menu(array('parent' => 'site-name', 'id' => 'edit-site', 'title' => __('Edit Site'), 'href' => network_admin_url('site-info.php?id=' . get_current_blog_id())));
        }
    } else {
        if (current_user_can('read')) {
            // We're on the front end, link to the Dashboard.
            $wp_admin_bar->add_menu(array('parent' => 'site-name', 'id' => 'dashboard', 'title' => __('Dashboard'), 'href' => admin_url()));
            // Add the appearance submenu items.
            wp_admin_bar_appearance_menu($wp_admin_bar);
        }
    }
}
 /**
  * Generates and displays row action links.
  *
  * @since 4.3.0
  * @access protected
  *
  * @param object $blog        Site being acted upon.
  * @param string $column_name Current column name.
  * @param string $primary     Primary column name.
  * @return string Row actions output.
  */
 protected function handle_row_actions($blog, $column_name, $primary)
 {
     if ($primary !== $column_name) {
         return;
     }
     $blogname = untrailingslashit($blog['domain'] . $blog['path']);
     // Preordered.
     $actions = array('edit' => '', 'backend' => '', 'activate' => '', 'deactivate' => '', 'archive' => '', 'unarchive' => '', 'spam' => '', 'unspam' => '', 'delete' => '', 'visit' => '');
     $actions['edit'] = '<a href="' . esc_url(network_admin_url('site-info.php?id=' . $blog['blog_id'])) . '">' . __('Edit') . '</a>';
     $actions['backend'] = "<a href='" . esc_url(get_admin_url($blog['blog_id'])) . "' class='edit'>" . __('Dashboard') . '</a>';
     if (get_network()->site_id != $blog['blog_id']) {
         if ($blog['deleted'] == '1') {
             $actions['activate'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id']), 'activateblog_' . $blog['blog_id'])) . '">' . __('Activate') . '</a>';
         } else {
             $actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id']), 'deactivateblog_' . $blog['blog_id'])) . '">' . __('Deactivate') . '</a>';
         }
         if ($blog['archived'] == '1') {
             $actions['unarchive'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id']), 'unarchiveblog_' . $blog['blog_id'])) . '">' . __('Unarchive') . '</a>';
         } else {
             $actions['archive'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id']), 'archiveblog_' . $blog['blog_id'])) . '">' . _x('Archive', 'verb; site') . '</a>';
         }
         if ($blog['spam'] == '1') {
             $actions['unspam'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id']), 'unspamblog_' . $blog['blog_id'])) . '">' . _x('Not Spam', 'site') . '</a>';
         } else {
             $actions['spam'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id']), 'spamblog_' . $blog['blog_id'])) . '">' . _x('Spam', 'site') . '</a>';
         }
         if (current_user_can('delete_site', $blog['blog_id'])) {
             $actions['delete'] = '<a href="' . esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id']), 'deleteblog_' . $blog['blog_id'])) . '">' . __('Delete') . '</a>';
         }
     }
     $actions['visit'] = "<a href='" . esc_url(get_home_url($blog['blog_id'], '/')) . "' rel='permalink'>" . __('Visit') . '</a>';
     /**
      * Filters the action links displayed for each site in the Sites list table.
      *
      * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
      * default for each site. The site's status determines whether to show the
      * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
      * 'Not Spam' or 'Spam' link for each site.
      *
      * @since 3.1.0
      *
      * @param array  $actions  An array of action links to be displayed.
      * @param int    $blog_id  The site ID.
      * @param string $blogname Site path, formatted depending on whether it is a sub-domain
      *                         or subdirectory multisite install.
      */
     $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname);
     return $this->row_actions($actions);
 }
Пример #24
0
/**
 * Retrieve an object containing information about the requested network.
 *
 * @since 3.9.0
 * @deprecated 4.7.0 Use `get_network()`
 * @see get_network()
 *
 * @internal In 4.6.0, converted to use get_network()
 *
 * @param object|int $network The network's database row or ID.
 * @return WP_Network|false Object containing network information if found, false if not.
 */
function wp_get_network($network)
{
    _deprecated_function(__FUNCTION__, '4.7.0', 'get_network()');
    $network = get_network($network);
    if (null === $network) {
        return false;
    }
    return $network;
}
 /**
  * Gets a list of networks matching the query vars.
  *
  * @since 4.6.0
  * @access public
  *
  * @return int|array The list of networks.
  */
 public function get_networks()
 {
     $this->parse_query();
     /**
      * Fires before networks are retrieved.
      *
      * @since 4.6.0
      *
      * @param WP_Network_Query &$this Current instance of WP_Network_Query, passed by reference.
      */
     do_action_ref_array('pre_get_networks', array(&$this));
     // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
     $key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
     $last_changed = wp_cache_get('last_changed', 'networks');
     if (!$last_changed) {
         $last_changed = microtime();
         wp_cache_set('last_changed', $last_changed, 'networks');
     }
     $cache_key = "get_network_ids:{$key}:{$last_changed}";
     $cache_value = wp_cache_get($cache_key, 'networks');
     if (false === $cache_value) {
         $network_ids = $this->get_network_ids();
         if ($network_ids) {
             $this->set_found_networks();
         }
         $cache_value = array('network_ids' => $network_ids, 'found_networks' => $this->found_networks);
         wp_cache_add($cache_key, $cache_value, 'networks');
     } else {
         $network_ids = $cache_value['network_ids'];
         $this->found_networks = $cache_value['found_networks'];
     }
     if ($this->found_networks && $this->query_vars['number']) {
         $this->max_num_pages = ceil($this->found_networks / $this->query_vars['number']);
     }
     // If querying for a count only, there's nothing more to do.
     if ($this->query_vars['count']) {
         // $network_ids is actually a count in this case.
         return intval($network_ids);
     }
     $network_ids = array_map('intval', $network_ids);
     if ('ids' == $this->query_vars['fields']) {
         $this->networks = $network_ids;
         return $this->networks;
     }
     if ($this->query_vars['update_network_cache']) {
         _prime_network_caches($network_ids);
     }
     // Fetch full network objects from the primed cache.
     $_networks = array();
     foreach ($network_ids as $network_id) {
         if ($_network = get_network($network_id)) {
             $_networks[] = $_network;
         }
     }
     /**
      * Filters the network query results.
      *
      * @since 4.6.0
      *
      * @param array            $results  An array of networks.
      * @param WP_Network_Query &$this    Current instance of WP_Network_Query, passed by reference.
      */
     $_networks = apply_filters_ref_array('the_networks', array($_networks, &$this));
     // Convert to WP_Network instances
     $this->networks = array_map('get_network', $_networks);
     return $this->networks;
 }
Пример #26
0
    die('WordPress Core directory could not be detected.');
}
define('WP_GLOBAL_ADMIN', true);
/** Load WordPress Administration Bootstrap */
require_once _ga_detect_abspath() . '/wp-admin/admin.php';
// This would be it if it was part of Core.
//require_once( dirname( dirname( __FILE__ ) ) . '/admin.php' );
if (!is_multisite()) {
    wp_die(__('Multisite support is not enabled.'));
}
if (!is_multinetwork()) {
    wp_die(__('Multinetwork support is not enabled.', 'global-admin'));
}
$current_network = get_network();
$main_network_id = get_main_network_id();
$main_network = get_network($main_network_id);
$redirect_global_admin_request = 0 !== strcasecmp($current_network->domain, $main_network->domain) || 0 !== strcasecmp($current_network->path, $main_network->path);
/**
 * Filters whether to redirect the request to the Global Admin.
 *
 * @since 1.0.0
 *
 * @param bool $redirect_global_admin_request Whether the request should be redirected.
 */
$redirect_global_admin_request = apply_filters('redirect_global_admin_request', $redirect_global_admin_request);
if ($redirect_global_admin_request) {
    wp_redirect(global_admin_url());
    exit;
}
unset($current_network);
unset($main_network_id);
Пример #27
0
/**
 * Get the main network ID.
 *
 * @since 4.3.0
 *
 * @return int The ID of the main network.
 */
function get_main_network_id()
{
    if (!is_multisite()) {
        return 1;
    }
    $current_network = get_network();
    if (defined('PRIMARY_NETWORK_ID')) {
        $main_network_id = PRIMARY_NETWORK_ID;
    } elseif (isset($current_network->id) && 1 === (int) $current_network->id) {
        // If the current network has an ID of 1, assume it is the main network.
        $main_network_id = 1;
    } else {
        $_networks = get_networks(array('fields' => 'ids', 'number' => 1));
        $main_network_id = array_shift($_networks);
    }
    /**
     * Filters the main network ID.
     *
     * @since 4.3.0
     *
     * @param int $main_network_id The ID of the main network.
     */
    return (int) apply_filters('get_main_network_id', $main_network_id);
}
Пример #28
0
/**
 * Handles sending password retrieval email to user.
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    $errors = new WP_Error();
    if (empty($_POST['user_login'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or email address.'));
    } elseif (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by('email', trim(wp_unslash($_POST['user_login'])));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_user_by('login', $login);
    }
    /**
     * Fires before errors are returned from a password reset request.
     *
     * @since 2.1.0
     * @since 4.4.0 Added the `$errors` parameter.
     *
     * @param WP_Error $errors A WP_Error object containing any errors generated
     *                         by using invalid credentials.
     */
    do_action('lostpassword_post', $errors);
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or email.'));
        return $errors;
    }
    // Redefining user_login ensures we return the right case in the email.
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    $key = get_password_reset_key($user_data);
    if (is_wp_error($key)) {
        return $key;
    }
    $message = __('Someone has requested a password reset for the following account:') . "\r\n\r\n";
    $message .= network_home_url('/') . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
    $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
    $message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login="******">\r\n";
    if (is_multisite()) {
        $blogname = get_network()->site_name;
    } else {
        /*
         * The blogname option is escaped with esc_html on the way into the database
         * in sanitize_option we want to reverse this for the plain text arena of emails.
         */
        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    }
    /* translators: Password reset email subject. 1: Site name */
    $title = sprintf(__('[%s] Password Reset'), $blogname);
    /**
     * Filters the subject of the password reset email.
     *
     * @since 2.8.0
     * @since 4.4.0 Added the `$user_login` and `$user_data` parameters.
     *
     * @param string  $title      Default email title.
     * @param string  $user_login The username for the user.
     * @param WP_User $user_data  WP_User object.
     */
    $title = apply_filters('retrieve_password_title', $title, $user_login, $user_data);
    /**
     * Filters the message body of the password reset mail.
     *
     * @since 2.8.0
     * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
     *
     * @param string  $message    Default mail message.
     * @param string  $key        The activation key.
     * @param string  $user_login The username for the user.
     * @param WP_User $user_data  WP_User object.
     */
    $message = apply_filters('retrieve_password_message', $message, $key, $user_login, $user_data);
    if ($message && !wp_mail($user_email, wp_specialchars_decode($title), $message)) {
        wp_die(__('The email could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.'));
    }
    return true;
}
/**
 * Create WordPress options and set the default values.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @global int  $wp_db_version
 * @global int  $wp_current_db_version
 */
function populate_options()
{
    global $wpdb, $wp_db_version, $wp_current_db_version;
    $guessurl = wp_guess_url();
    /**
     * Fires before creating WordPress options and populating their default values.
     *
     * @since 2.6.0
     */
    do_action('populate_options');
    if (ini_get('safe_mode')) {
        // Safe mode can break mkdir() so use a flat structure by default.
        $uploads_use_yearmonth_folders = 0;
    } else {
        $uploads_use_yearmonth_folders = 1;
    }
    // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
    $stylesheet = $template = WP_DEFAULT_THEME;
    $theme = wp_get_theme(WP_DEFAULT_THEME);
    if (!$theme->exists()) {
        $theme = WP_Theme::get_core_default_theme();
    }
    // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.
    if ($theme) {
        $stylesheet = $theme->get_stylesheet();
        $template = $theme->get_template();
    }
    $timezone_string = '';
    $gmt_offset = 0;
    /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14)
    	   or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php
    	   for all timezone strings supported by PHP.
    	*/
    $offset_or_tz = _x('0', 'default GMT offset or timezone string');
    if (is_numeric($offset_or_tz)) {
        $gmt_offset = $offset_or_tz;
    } elseif ($offset_or_tz && in_array($offset_or_tz, timezone_identifiers_list())) {
        $timezone_string = $offset_or_tz;
    }
    $options = array('siteurl' => $guessurl, 'home' => $guessurl, 'blogname' => __('My Site'), 'blogdescription' => __('Just another WordPress site'), 'users_can_register' => 0, 'admin_email' => '*****@*****.**', 'start_of_week' => _x('1', 'start of week'), 'use_balanceTags' => 0, 'use_smilies' => 1, 'require_name_email' => 1, 'comments_notify' => 1, 'posts_per_rss' => 10, 'rss_use_excerpt' => 0, 'mailserver_url' => 'mail.example.com', 'mailserver_login' => '*****@*****.**', 'mailserver_pass' => 'password', 'mailserver_port' => 110, 'default_category' => 1, 'default_comment_status' => 'open', 'default_ping_status' => 'open', 'default_pingback_flag' => 1, 'posts_per_page' => 10, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'links_updated_date_format' => __('F j, Y g:i a'), 'comment_moderation' => 0, 'moderation_notify' => 1, 'permalink_structure' => '', 'rewrite_rules' => '', 'hack_file' => 0, 'blog_charset' => 'UTF-8', 'moderation_keys' => '', 'active_plugins' => array(), 'category_base' => '', 'ping_sites' => 'http://rpc.pingomatic.com/', 'comment_max_links' => 2, 'gmt_offset' => $gmt_offset, 'default_email_category' => 1, 'recently_edited' => '', 'template' => $template, 'stylesheet' => $stylesheet, 'comment_whitelist' => 1, 'blacklist_keys' => '', 'comment_registration' => 0, 'html_type' => 'text/html', 'use_trackback' => 0, 'default_role' => 'subscriber', 'db_version' => $wp_db_version, 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 'upload_path' => '', 'blog_public' => '1', 'default_link_category' => 2, 'show_on_front' => 'posts', 'tag_base' => '', 'show_avatars' => '1', 'avatar_rating' => 'G', 'upload_url_path' => '', 'thumbnail_size_w' => 150, 'thumbnail_size_h' => 150, 'thumbnail_crop' => 1, 'medium_size_w' => 300, 'medium_size_h' => 300, 'avatar_default' => 'mystery', 'large_size_w' => 1024, 'large_size_h' => 1024, 'image_default_link_type' => 'none', 'image_default_size' => '', 'image_default_align' => '', 'close_comments_for_old_posts' => 0, 'close_comments_days_old' => 14, 'thread_comments' => 1, 'thread_comments_depth' => 5, 'page_comments' => 0, 'comments_per_page' => 50, 'default_comments_page' => 'newest', 'comment_order' => 'asc', 'sticky_posts' => array(), 'widget_categories' => array(), 'widget_text' => array(), 'widget_rss' => array(), 'uninstall_plugins' => array(), 'timezone_string' => $timezone_string, 'page_for_posts' => 0, 'page_on_front' => 0, 'default_post_format' => 0, 'link_manager_enabled' => 0, 'finished_splitting_shared_terms' => 1, 'site_icon' => 0, 'medium_large_size_w' => 768, 'medium_large_size_h' => 0);
    // 3.3
    if (!is_multisite()) {
        $options['initial_db_version'] = !empty($wp_current_db_version) && $wp_current_db_version < $wp_db_version ? $wp_current_db_version : $wp_db_version;
    }
    // 3.0 multisite
    if (is_multisite()) {
        /* translators: site tagline */
        $options['blogdescription'] = sprintf(__('Just another %s site'), get_network()->site_name);
        $options['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/';
    }
    // Set autoload to no for these options
    $fat_options = array('moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins');
    $keys = "'" . implode("', '", array_keys($options)) . "'";
    $existing_options = $wpdb->get_col("SELECT option_name FROM {$wpdb->options} WHERE option_name in ( {$keys} )");
    $insert = '';
    foreach ($options as $option => $value) {
        if (in_array($option, $existing_options)) {
            continue;
        }
        if (in_array($option, $fat_options)) {
            $autoload = 'no';
        } else {
            $autoload = 'yes';
        }
        if (is_array($value)) {
            $value = serialize($value);
        }
        if (!empty($insert)) {
            $insert .= ', ';
        }
        $insert .= $wpdb->prepare("(%s, %s, %s)", $option, $value, $autoload);
    }
    if (!empty($insert)) {
        $wpdb->query("INSERT INTO {$wpdb->options} (option_name, option_value, autoload) VALUES " . $insert);
    }
    // In case it is set, but blank, update "home".
    if (!__get_option('home')) {
        update_option('home', $guessurl);
    }
    // Delete unused options.
    $unusedoptions = array('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit');
    foreach ($unusedoptions as $option) {
        delete_option($option);
    }
    // Delete obsolete magpie stuff.
    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?\$'");
    /*
     * Deletes all expired transients. The multi-table delete syntax is used
     * to delete the transient record from table a, and the corresponding
     * transient_timeout record from table b.
     */
    $time = time();
    $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\tWHERE a.option_name LIKE %s\n\t\tAND a.option_name NOT LIKE %s\n\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\tAND b.option_value < %d";
    $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', $time));
    if (is_main_site() && is_main_network()) {
        $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )\n\t\t\tAND b.option_value < %d";
        $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', $time));
    }
}
Пример #30
0
/**
 * Whitelists any domain in a multisite installation for safe HTTP requests.
 *
 * Attached to the {@see 'http_request_host_is_external'} filter.
 *
 * @since 3.6.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 * @staticvar array $queried
 *
 * @param bool   $is_external
 * @param string $host
 * @return bool
 */
function ms_allowed_http_request_hosts($is_external, $host)
{
    global $wpdb;
    static $queried = array();
    if ($is_external) {
        return $is_external;
    }
    if ($host === get_network()->domain) {
        return true;
    }
    if (isset($queried[$host])) {
        return $queried[$host];
    }
    $queried[$host] = (bool) $wpdb->get_var($wpdb->prepare("SELECT domain FROM {$wpdb->blogs} WHERE domain = %s LIMIT 1", $host));
    return $queried[$host];
}