/** * Gets the network's site and user counts. * * @since MU 1.0 * @uses get_blog_count() * @uses get_user_count() * * @return array Site and user count for the network. */ function get_sitestats() { global $wpdb; $stats['blogs'] = get_blog_count(); $stats['users'] = get_user_count(); return $stats; }
/** * Check WordPress version against the newest version. * * The WordPress version, PHP version, and Locale is sent. Checks against the * WordPress server at api.wordpress.org server. Will only check if WordPress * isn't installing. * * @package WordPress * @since 2.3.0 * @uses $wp_version Used to check against the newest WordPress version. * * @return mixed Returns null if update is unsupported. Returns false if check is too soon. */ function wp_version_check() { if (defined('WP_INSTALLING')) { return; } global $wp_version, $wpdb, $wp_local_package, $wpmu_version, $current_site; $php_version = phpversion(); $current = get_transient('update_core'); if (!is_object($current)) { $current = new stdClass(); $current->updates = array(); $current->version_checked = $wp_version; } $locale = apply_filters('core_version_check_locale', get_locale()); // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); set_transient('update_core', $current); if (method_exists($wpdb, 'db_version')) { $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } else { $mysql_version = 'N/A'; } $local_package = isset($wp_local_package) ? $wp_local_package : ''; $url = "http://api.wordpress.org/core/version-check/1.3-mu/?version={$wp_version}&wpmu_version={$wpmu_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}&blogs=" . get_blog_count() . "&users=" . get_user_count(); $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress MU/' . $wpmu_version . '; ' . apply_filters('currentsite_on_version_check', 'http://' . $current_site->domain . $current_site->path)); $response = wp_remote_get($url, $options); if (is_wp_error($response)) { return false; } if (200 != $response['response']['code']) { return false; } $body = trim($response['body']); $body = str_replace(array("\r\n", "\r"), "\n", $body); $new_options = array(); foreach (explode("\n\n", $body) as $entry) { $returns = explode("\n", $entry); $new_option = new stdClass(); $new_option->response = esc_attr($returns[0]); if (isset($returns[1])) { $new_option->url = esc_url($returns[1]); } if (isset($returns[2])) { $new_option->package = esc_url($returns[2]); } if (isset($returns[3])) { $new_option->current = esc_attr($returns[3]); } if (isset($returns[4])) { $new_option->locale = esc_attr($returns[4]); } $new_options[] = $new_option; } $updates = new stdClass(); $updates->updates = $new_options; $updates->last_checked = time(); $updates->version_checked = $wp_version; set_transient('update_core', $updates); }
/** * Gets the network's site and user counts. * * @since MU 1.0 * @uses get_blog_count() * @uses get_user_count() * * @return array Site and user count for the network. */ function get_sitestats() { global $wpdb; $stats = array( 'blogs' => get_blog_count(), 'users' => get_user_count(), ); return $stats; }
protected function get_views() { global $role; $total_users = get_user_count(); $super_admins = get_super_admins(); $total_admins = count($super_admins); $class = $role != 'super' ? ' class="current"' : ''; $role_links = array(); $role_links['all'] = "<a href='" . network_admin_url('users.php') . "'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>'; $class = $role == 'super' ? ' class="current"' : ''; $role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'{$class}>" . sprintf(_n('Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins), number_format_i18n($total_admins)) . '</a>'; return $role_links; }
function index() { if (c("wxValid")) { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $echoStr = $_GET["echostr"]; $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; die($this->valid($echoStr, $signature, $timestamp, $nonce)); } $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $GLOBALS['fromUsername'] = $postObj->FromUserName; $GLOBALS['toUsername'] = $postObj->ToUserName; $event = $postObj->Event; $eventKey = $postObj->EventKey; $keyword = z(t($postObj->Content)); //订阅事件,发送欢迎词 if ($event == "subscribe") { $text = c("subscribe"); die($this->creat_xml_response($text)); } //自定义菜单的点击事件 if ($event == "CLICK") { switch ($eventKey) { case 'V1001_RANK_LUCKY': $votecount = 10 - get_user_count(g("fromUsername")); $msg = "您还剩余{$votecount}票"; die($this->creat_xml_response($msg)); break; case 'V1001_INREODUCE': $title = ""; $description = ""; $picUrl = ""; $url = ""; die($this->creat_pic_response($title, $description, $picUrl, $url)); break; default: break; } } //进行投票操作 $openId = g("fromUsername"); if ($keyword != "") { $workId = strtoupper($keyword); $text = send_vote($openId, $workId); } }
public function dashboard_signups() { global $gMemberNetwork; $query = new \WP_User_Query(array('blog_id' => 0, 'orderby' => 'registered', 'order' => 'DESC', 'number' => 12, 'fields' => array('ID', 'display_name', 'user_email', 'user_registered', 'user_login'))); if (empty($query->results)) { _ex('No User?!', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN); } else { echo '<table class="widefat gmember-dashboard -table-signup"><thead><tr>'; echo '<th>' . _x('On', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>'; echo '<th>' . _x('Name', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>'; echo '<th>' . _x('E-mail', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN) . '</th>'; echo '</tr></thead>'; $last = FALSE; $alt = TRUE; $template = '<tr%1$s>' . '<td class="-month-day" title="%5$s">%4$s</td>' . '<td class="-edit-link"><a title="%8$s" href="%6$s" target="_blank">%2$s</a></td>' . '<td class="-mail-link"><a title="%7$s" href="%7$s" target="_blank">%3$s</a></td>' . '</tr>'; foreach ($query->results as $user) { $registered = strtotime(get_date_from_gmt($user->user_registered)); vprintf($template, array($alt ? ' class="alternate"' : '', esc_html($user->display_name), esc_html(gPluginTextHelper::truncateString($user->user_email, 32)), esc_html($gMemberNetwork->getDate($registered, 'monthday')), esc_attr(human_time_diff($registered) . ' — ' . $gMemberNetwork->getDate($registered)), get_edit_user_link($user->ID), 'mailto:' . esc_attr($user->user_email), $user->user_login)); $alt = !$alt; if (!$last) { $last = $registered; } } echo '</table>'; echo '<table class="gmember-dashboard -table-summary"></tbody>'; echo '<tr><td>'; printf(_x('Last User Registered %s ago', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), human_time_diff($last)); echo '</td><td>'; if ($spam_users = $gMemberNetwork->get_spam_count()) { printf(_nx('With %s Spam User', 'With %s Spam Users', $spam_users, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($spam_users)); } else { _ex('With No Spam User', 'Signup Admin Widget', GMEMBER_TEXTDOMAIN); } echo '</td></tr><tr><td>'; $super_admins = count(get_super_admins()); printf(_nx('And %s Super Admin', 'And %s Super Admins', $super_admins, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($super_admins)); echo '</td><td>'; $user_count = get_user_count(); printf(_nx('Total of One User', 'Total of %s Users', $user_count, 'Signup Admin Widget', GMEMBER_TEXTDOMAIN), number_format_i18n($user_count)); echo '</td></tr>'; echo '</tbody></table>'; } }
/** * 返回用户列表数据 * * @access public * @param * * @return void */ function user_list() { $result = get_filter(); if ($result === false) { /* 过滤条件 */ $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keywords'] = json_str_iconv($filter['keywords']); } $filter['rank'] = empty($_REQUEST['rank']) ? 0 : intval($_REQUEST['rank']); $filter['pay_points_gt'] = empty($_REQUEST['pay_points_gt']) ? 0 : intval($_REQUEST['pay_points_gt']); $filter['pay_points_lt'] = empty($_REQUEST['pay_points_lt']) ? 0 : intval($_REQUEST['pay_points_lt']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'user_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $ex_where = ' WHERE 1 '; if (isset($_REQUEST['sign'])) { if ($_REQUEST['sign'] == 1) { $ex_where .= " AND parent_id = 0 AND is_fenxiao <> 0 AND is_fenxiao = 1"; } if ($_REQUEST['sign'] == 2) { $ex_where .= " AND parent_id > 0 AND is_fenxiao <> 0 AND is_fenxiao = 1"; } if ($_REQUEST['sign'] == 3) { $ex_where .= " AND is_fenxiao <> 1 "; } } if ($filter['keywords']) { $ex_where .= " AND user_name LIKE '%" . mysql_like_quote($filter['keywords']) . "%'"; } if ($filter['rank']) { $sql = "SELECT min_points, max_points, special_rank FROM " . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_id = '{$filter['rank']}'"; $row = $GLOBALS['db']->getRow($sql); if ($row['special_rank'] > 0) { /* 特殊等级 */ $ex_where .= " AND user_rank = '{$filter['rank']}' "; } else { $ex_where .= " AND rank_points >= " . intval($row['min_points']) . " AND rank_points < " . intval($row['max_points']); } } if ($filter['pay_points_gt']) { $ex_where .= " AND pay_points >= '{$filter['pay_points_gt']}' "; } if ($filter['pay_points_lt']) { $ex_where .= " AND pay_points < '{$filter['pay_points_lt']}' "; } $filter['record_count'] = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('users') . $ex_where); /* 分页大小 */ $filter = page_and_size($filter); $sql = "SELECT user_id, user_name, email, is_validated, validated,status,user_money, frozen_money, rank_points, pay_points, reg_time,is_fenxiao,parent_id " . " FROM " . $GLOBALS['ecs']->table('users') . $ex_where . " ORDER by " . $filter['sort_by'] . ' ' . $filter['sort_order'] . " LIMIT " . $filter['start'] . ',' . $filter['page_size']; $filter['keywords'] = stripslashes($filter['keywords']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $user_list = $GLOBALS['db']->getAll($sql); $count = count($user_list); for ($i = 0; $i < $count; $i++) { $user_list[$i]['reg_time'] = local_date($GLOBALS['_CFG']['date_format'], $user_list[$i]['reg_time']); $user_list[$i]['upper_user_name'] = get_upper_level($user_list[$i]['parent_id']); $one_level_user_count = get_user_count($user_list[$i]['user_id'], 1); $two_level_user_count = get_user_count($user_list[$i]['user_id'], 2); $three_level_user_count = get_user_count($user_list[$i]['user_id'], 3); $user_list[$i]['one_level_user_count'] = $one_level_user_count; $user_list[$i]['two_level_user_count'] = $two_level_user_count; $user_list[$i]['three_level_user_count'] = $three_level_user_count; $user_list[$i]['total_user'] = $one_level_user_count + $two_level_user_count + $three_level_user_count; } $arr = array('user_list' => $user_list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); return $arr; }
/** * Check WordPress version against the newest version. * * The WordPress version, PHP version, and Locale is sent. Checks against the * WordPress server at api.wordpress.org server. Will only check if WordPress * isn't installing. * * @since 2.3.0 * @global string $wp_version Used to check against the newest WordPress version. * @global wpdb $wpdb * @global string $wp_local_package * * @param array $extra_stats Extra statistics to report to the WordPress.org API. * @param bool $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set. */ function wp_version_check($extra_stats = array(), $force_check = false) { if (wp_installing()) { return; } global $wp_version, $wpdb, $wp_local_package; // include an unmodified $wp_version include ABSPATH . WPINC . '/version.php'; $php_version = phpversion(); $current = get_site_transient('update_core'); $translations = wp_get_installed_translations('core'); // Invalidate the transient when $wp_version changes if (is_object($current) && $wp_version != $current->version_checked) { $current = false; } if (!is_object($current)) { $current = new stdClass(); $current->updates = array(); $current->version_checked = $wp_version; } if (!empty($extra_stats)) { $force_check = true; } // Wait 60 seconds between multiple version check requests $timeout = 60; $time_not_changed = isset($current->last_checked) && $timeout > time() - $current->last_checked; if (!$force_check && $time_not_changed) { return; } /** * Filter the locale requested for WordPress core translations. * * @since 2.8.0 * * @param string $locale Current locale. */ $locale = apply_filters('core_version_check_locale', get_locale()); // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); set_site_transient('update_core', $current); if (method_exists($wpdb, 'db_version')) { $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } else { $mysql_version = 'N/A'; } if (is_multisite()) { $user_count = get_user_count(); $num_blogs = get_blog_count(); $wp_install = network_site_url(); $multisite_enabled = 1; } else { $user_count = count_users(); $user_count = $user_count['total_users']; $multisite_enabled = 0; $num_blogs = 1; $wp_install = home_url('/'); } $query = array('version' => $wp_version, 'php' => $php_version, 'locale' => $locale, 'mysql' => $mysql_version, 'local_package' => isset($wp_local_package) ? $wp_local_package : '', 'blogs' => $num_blogs, 'users' => $user_count, 'multisite_enabled' => $multisite_enabled, 'initial_db_version' => get_site_option('initial_db_version')); $post_body = array('translations' => wp_json_encode($translations)); if (is_array($extra_stats)) { $post_body = array_merge($post_body, $extra_stats); } $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query($query, null, '&'); if ($ssl = wp_http_supports(array('ssl'))) { $url = set_url_scheme($url, 'https'); } $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'headers' => array('wp_install' => $wp_install, 'wp_blog' => home_url('/')), 'body' => $post_body); $response = wp_remote_post($url, $options); if ($ssl && is_wp_error($response)) { trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.') . ' ' . __('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); $response = wp_remote_post($http_url, $options); } if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { return; } $body = trim(wp_remote_retrieve_body($response)); $body = json_decode($body, true); if (!is_array($body) || !isset($body['offers'])) { return; } $offers = $body['offers']; foreach ($offers as &$offer) { foreach ($offer as $offer_key => $value) { if ('packages' == $offer_key) { $offer['packages'] = (object) array_intersect_key(array_map('esc_url', $offer['packages']), array_fill_keys(array('full', 'no_content', 'new_bundled', 'partial', 'rollback'), '')); } elseif ('download' == $offer_key) { $offer['download'] = esc_url($value); } else { $offer[$offer_key] = esc_html($value); } } $offer = (object) array_intersect_key($offer, array_fill_keys(array('response', 'download', 'locale', 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files'), '')); } $updates = new stdClass(); $updates->updates = $offers; $updates->last_checked = time(); $updates->version_checked = $wp_version; if (isset($body['translations'])) { $updates->translations = $body['translations']; } set_site_transient('update_core', $updates); if (!empty($body['ttl'])) { $ttl = (int) $body['ttl']; if ($ttl && time() + $ttl < wp_next_scheduled('wp_version_check')) { // Queue an event to re-run the update check in $ttl seconds. wp_schedule_single_event(time() + $ttl, 'wp_version_check'); } } // Trigger a background updates check if running non-interactively, and we weren't called from the update handler. if (defined('DOING_CRON') && DOING_CRON && !doing_action('wp_maybe_auto_update')) { do_action('wp_maybe_auto_update'); } }
function test_get_user_count() { // Refresh the cache wp_update_network_counts(); $start_count = get_user_count(); // Only false for large networks as of 3.7 add_filter( 'enable_live_network_counts', '__return_false' ); $this->factory->user->create( array( 'role' => 'administrator' ) ); $count = get_user_count(); // No change, cache not refreshed $this->assertEquals( $start_count, $count ); wp_update_network_counts(); // Magic happens here $count = get_user_count(); $this->assertEquals( $start_count + 1, $count ); remove_filter( 'enable_live_network_counts', '__return_false' ); }
/** * @since 3.1.0 */ function wp_network_dashboard_right_now() { $actions = array(); if (current_user_can('create_sites')) { $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __('Create a New Site') . '</a>'; } if (current_user_can('create_users')) { $actions['create-user'] = '******' . network_admin_url('user-new.php') . '">' . __('Create a New User') . '</a>'; } $c_users = get_user_count(); $c_blogs = get_blog_count(); $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users)); $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs)); $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text); if ($actions) { echo '<ul class="subsubsub">'; foreach ($actions as $class => $action) { $actions[$class] = "\t<li class='{$class}'>{$action}"; } echo implode(" |</li>\n", $actions) . "</li>\n"; echo '</ul>'; } ?> <br class="clear" /> <p class="youhave"><?php echo $sentence; ?> </p> <?php /** * Fires in the Network Admin 'Right Now' dashboard widget * just before the user and site search form fields. * * @since MU * * @param null $unused */ do_action('wpmuadminresult', ''); ?> <form action="<?php echo network_admin_url('users.php'); ?> " method="get"> <p> <label class="screen-reader-text" for="search-users"><?php _e('Search Users'); ?> </label> <input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/> <?php submit_button(__('Search Users'), 'button', false, false, array('id' => 'submit_users')); ?> </p> </form> <form action="<?php echo network_admin_url('sites.php'); ?> " method="get"> <p> <label class="screen-reader-text" for="search-sites"><?php _e('Search Sites'); ?> </label> <input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/> <?php submit_button(__('Search Sites'), 'button', false, false, array('id' => 'submit_sites')); ?> </p> </form> <?php /** * Fires at the end of the 'Right Now' widget in the Network Admin dashboard. * * @since MU */ do_action('mu_rightnow_end'); /** * Fires at the end of the 'Right Now' widget in the Network Admin dashboard. * * @since MU */ do_action('mu_activity_box_end'); }
/** * 返回分销等级会员列表数据 * * @access public * @param * * @return void */ function user_list($user_id, $level) { $filter = array(); $filter['record_count'] = get_user_count($user_id, $level); /* 分页大小 */ $filter = page_and_size($filter); $up_uid = "'{$user_id}'"; for ($i = 1; $i <= $level; $i++) { $count = 0; if ($up_uid) { $sql = "SELECT user_id FROM " . $GLOBALS['ecs']->table('users') . " WHERE parent_id IN({$up_uid})"; $query = $GLOBALS['db']->query($sql); $up_uid = ''; while ($rt = $GLOBALS['db']->fetch_array($query)) { $up_uid .= $up_uid ? ",'{$rt['user_id']}'" : "'{$rt['user_id']}'"; $count++; } } } if ($count) { $sql = "SELECT user_id, user_name, email, is_validated, user_money, frozen_money, rank_points, pay_points, reg_time " . " FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id IN({$up_uid})"; $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $arr[] = $rows; } } if (!empty($arr)) { return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); } }
/** * Check WordPress version against the newest version. * * The WordPress version, PHP version, and Locale is sent. Checks against the * WordPress server at api.wordpress.org server. Will only check if WordPress * isn't installing. * * @package WordPress * @since 2.3.0 * @uses $wp_version Used to check against the newest WordPress version. * * @return mixed Returns null if update is unsupported. Returns false if check is too soon. */ function wp_version_check() { if (defined('WP_INSTALLING')) { return; } global $wpdb, $wp_local_package; include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version $php_version = phpversion(); $current = get_site_transient('update_core'); if (!is_object($current)) { $current = new stdClass(); $current->updates = array(); $current->version_checked = $wp_version; } $locale = apply_filters('core_version_check_locale', get_locale()); // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); set_site_transient('update_core', $current); if (method_exists($wpdb, 'db_version')) { $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } else { $mysql_version = 'N/A'; } if (is_multisite()) { $user_count = get_user_count(); $num_blogs = get_blog_count(); $wp_install = network_site_url(); $multisite_enabled = 1; } else { $user_count = count_users(); $multisite_enabled = 0; $num_blogs = 1; $wp_install = home_url('/'); } $local_package = isset($wp_local_package) ? $wp_local_package : ''; $url = "http://api.wordpress.org/core/version-check/1.6/?version={$wp_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}&blogs={$num_blogs}&users={$user_count['total_users']}&multisite_enabled={$multisite_enabled}"; $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'headers' => array('wp_install' => $wp_install, 'wp_blog' => home_url('/'))); $response = wp_remote_get($url, $options); if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { return false; } $body = trim(wp_remote_retrieve_body($response)); if (!($body = maybe_unserialize($body))) { return false; } if (!isset($body['offers'])) { return false; } $offers = $body['offers']; foreach ($offers as &$offer) { foreach ($offer as $offer_key => $value) { if ('packages' == $offer_key) { $offer['packages'] = (object) array_intersect_key(array_map('esc_url', $offer['packages']), array_fill_keys(array('full', 'no_content', 'new_bundled', 'partial'), '')); } elseif ('download' == $offer_key) { $offer['download'] = esc_url($value); } else { $offer[$offer_key] = esc_html($value); } } $offer = (object) array_intersect_key($offer, array_fill_keys(array('response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled', 'partial_version'), '')); } $updates = new stdClass(); $updates->updates = $offers; $updates->last_checked = time(); $updates->version_checked = $wp_version; set_site_transient('update_core', $updates); }
static function totalUsers($params = null) { if (!empty($params[0])) { return get_user_count() + (int) $params[0]; } else { return get_user_count(); } }
public function optin_data() { global $wpdb; $comments = wp_count_comments(); $users = count_users(); $settings = get_option('yarpp'); $collect = array_flip(array('threshold', 'limit', 'excerpt_length', 'recent', 'rss_limit', 'rss_excerpt_length', 'past_only', 'show_excerpt', 'rss_show_excerpt', 'template', 'rss_template', 'show_pass_post', 'cross_relate', 'rss_display', 'rss_excerpt_display', 'promote_yarpp', 'rss_promote_yarpp', 'myisam_override', 'weight', 'require_tax', 'auto_display_archive')); $check_changed = array('before_title', 'after_title', 'before_post', 'after_post', 'after_related', 'no_results', 'order', 'rss_before_title', 'rss_after_title', 'rss_before_post', 'rss_after_post', 'rss_after_related', 'rss_no_results', 'rss_order', 'exclude', 'thumbnails_heading', 'thumbnails_default', 'rss_thumbnails_heading', 'rss_thumbnails_default', 'display_code'); $data = array('versions' => array('yarpp' => YARPP_VERSION, 'wp' => get_bloginfo('version'), 'php' => phpversion()), 'yarpp' => array('settings' => array_intersect_key($settings, $collect), 'cache_engine' => YARPP_CACHE_TYPE), 'diagnostics' => array('myisam_posts' => $this->diagnostic_myisam_posts(), 'fulltext_disabled' => $this->diagnostic_fulltext_disabled(), 'fulltext_indices' => $this->diagnostic_fulltext_indices(), 'hidden_metaboxes' => $this->diagnostic_hidden_metaboxes(), 'post_thumbnails' => $this->diagnostic_post_thumbnails(), 'happy' => $this->diagnostic_happy(), 'using_thumbnails' => $this->diagnostic_using_thumbnails(), 'generate_thumbnails' => $this->diagnostic_generate_thumbnails()), 'stats' => array('counts' => array(), 'terms' => array(), 'comments' => array('moderated' => $comments->moderated, 'approved' => $comments->approved, 'total' => $comments->total_comments, 'posts' => $wpdb->get_var("select count(ID) from {$wpdb->posts} where post_type = 'post' and comment_count > 0")), 'users' => $wpdb->get_var("select count(ID) from {$wpdb->users}")), 'locale' => get_bloginfo('language'), 'url' => get_bloginfo('url'), 'plugins' => array('active' => implode('|', get_option('active_plugins', array())), 'sitewide' => implode('|', array_keys(get_site_option('active_sitewide_plugins', array())))), 'pools' => $settings['pools']); $data['yarpp']['settings']['auto_display_post_types'] = implode('|', $settings['auto_display_post_types']); $changed = array(); foreach ($check_changed as $key) { if ($this->default_options[$key] != $settings[$key]) { $changed[] = $key; } } foreach (array('before_related', 'rss_before_related') as $key) { if ($settings[$key] != '<p>' . __('Related posts:', 'yarpp') . '</p><ol>' && $settings[$key] != $this->default_options[$key]) { $changed[] = $key; } } $data['yarpp']['changed_settings'] = implode('|', $changed); if (method_exists($this->cache, 'cache_status')) { $data['yarpp']['cache_status'] = $this->cache->cache_status(); } if (method_exists($this->cache, 'stats')) { $stats = $this->cache->stats(); $flattened = array(); foreach ($stats as $key => $value) { $flattened[] = "{$key}:{$value}"; } $data['yarpp']['stats'] = implode('|', $flattened); } if (method_exists($wpdb, 'db_version')) { $data['versions']['mysql'] = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } $counts = array(); foreach (get_post_types(array('public' => true)) as $post_type) { $counts[$post_type] = wp_count_posts($post_type); } $data['stats']['counts'] = wp_list_pluck($counts, 'publish'); foreach (get_taxonomies(array('public' => true)) as $taxonomy) { $data['stats']['terms'][$taxonomy] = wp_count_terms($taxonomy); } if (is_multisite()) { $data['multisite'] = array('url' => network_site_url(), 'users' => get_user_count(), 'sites' => get_blog_count()); } return $data; }
show_message('您还不是分销商!', '去首页', 'index.php'); exit; } if (!$smarty->is_cached('v_user_huiyuan.dwt', $cache_id)) { assign_template(); $position = assign_ur_here(); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 /* meta information */ $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords'])); $smarty->assign('description', htmlspecialchars($_CFG['shop_desc'])); $smarty->assign('user_info', get_user_info_by_user_id($_SESSION['user_id'])); $smarty->assign('one_level_user_count', get_user_count($_SESSION['user_id'], 1)); //一级会员数量 $smarty->assign('two_level_user_count', get_user_count($_SESSION['user_id'], 2)); //一级会员数量 $smarty->assign('three_level_user_count', get_user_count($_SESSION['user_id'], 3)); //一级会员数量 $smarty->assign('one_user_list', get_distrib_user_info($_SESSION['user_id'], 1)); //一级会员信息 $smarty->assign('two_user_list', get_distrib_user_info($_SESSION['user_id'], 2)); //二级会员信息 $smarty->assign('three_user_list', get_distrib_user_info($_SESSION['user_id'], 3)); //三级会员信息 $smarty->assign('user_id', $_SESSION['user_id']); /* 页面中的动态内容 */ assign_dynamic('v_user_huiyuan'); } $smarty->display('v_user_huiyuan.dwt', $cache_id);
function test_get_user_count() { // Refresh the cache wp_update_network_counts(); $start_count = get_user_count(); $this->factory->user->create(array('role' => 'administrator')); $count = get_user_count(); // No change, cache not refreshed $this->assertEquals($start_count, $count); wp_update_network_counts(); // Magic happens here $count = get_user_count(); $this->assertEquals($start_count + 1, $count); }
public function registration_form() { wp_enqueue_script('validator', get_template_directory_uri() . '/js/validator.min.js', array('jquery', 'bootstrap'), false, true); ?> <div id="registrationModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="registrationModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title red font-roboto">Cadastre-se</h4> </div> <div id="cadastro" class="modal-body"> <div class="row mt-md"> <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-body"> <div id="form-cadastro"> <form data-toggle="validator" role="form"> <?php wp_nonce_field('cadastrar-usuario'); ?> <div class="form-group"> <label for="nomeUser">Nome de <span class="red">usuário</span>:</label> <input type="text" class="form-control" name="username" id="username" placeholder="Nome de usuário" data-error="Nome de usuário inválido ou já está em uso." data-remote="wp-admin/admin-ajax.php?action=username_valid_ajax" required> <span class="help-block">Usuário inválido ou já cadastrado</span> </div> <div class="form-group mt-md"> <label for="nomeApres">Nome de <span class="red">apresentação:</span></label> <input type="text" class="form-control" id="nome" name="nome" placeholder="Nome de apresentação" required> </div> <div class="form-group mt-md"> <label for="email">E-mail</label> <input type="email" class="form-control" id="email" name="email" placeholder="Seu e-mail" data-error="Endereço de e-mail inválido ou já está em uso." data-remote="wp-admin/admin-ajax.php?action=email_exists_ajax" required> <span class="help-block">O e-mail deve conter um formato válido e ainda não estar cadastrado em nosso sistema.</span> </div> <div class="form-group mt-md"> <label for="senha">Sua senha:</label> <input type="password" class="form-control" id="senha" name="senha" data-minlength="8" maxlength="10" required> <span class="help-block">A senha deve conter de 8 à 10 caracteres.</span> </div> <div class="form-group mt-md"> <input type="checkbox" name="termos_uso" name="termos_uso" autocomplete="off" data-error="Você deve ler e concordar com o termo antes de continuar o cadastro." required> Li e aceito os <a href="<?php echo site_url('/termos-de-uso/'); ?> " target="_blank">termos de uso</a>. <div class="help-block"></div> </div> <button type="submit" class="btn btn-danger mt-md">Cadastrar</button> </form> </div> </div> </div> </div> <div class="col-md-6"> <div class="row"> <div class="col-sm-4 col-xs-12"> <img src="<?php echo get_template_directory_uri(); ?> /../pensandoodireito-tema/images/oquee/oquee-001.png" class="img-adptive" alt="Proteção de Dados Pessoais" /> </div> <div class="col-sm-8 col-xs-12"> <h3 class="font-roboto red">Mais de <strong><?php echo get_user_count(); ?> </strong> participantes!</h3> <ul class="list-unstyled text-left h5"> <li class="mt-sm text-success"><i class="fa fa-check "></i> <strong>contribua</strong> com suas ideias e opiniões </li> <li class="mt-sm text-success"><i class="fa fa-check"></i> fique por dentro das <strong>leis em elaboração</strong></li> <li class="mt-sm text-success"><i class="fa fa-check"></i> <strong>participe</strong> do processo legislativo </li> </ul> </div> </div> <div class="row mt-md"> <div class="col-md-12"> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingOne"> <h4 class="panel-title"> <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> Por que devo me cadastrar? </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"> <div class="panel-body"> <p>Porque esta é mais uma oportunidade de diálogo aberta pelo governo para ouvir a sociedade sobre temas importantes.</p> <p>Após realizar o seu cadastro, você poderá comentar os debates públicos abertos no site, concordar ou discordar de outros comentários, criar novas pautas e responder à pautas criadas por outros usuários.</p> <p>Por isso, ao se cadastrar, você será uma parte importante do processo, e sua opinião pode influenciar leis, decretos, portarias, e outras peças normativas sobre assuntos relevantes ao nosso país.</p> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingTwo"> <h4 class="panel-title"> <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> O que são "debates"? </a> </h4> </div> <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo"> <div class="panel-body"> Na plataforma, os "debates" podem ser projetos, anteprojetos de lei, textos de decreto ou portarias que estão abertos à participação social para sua consolidação. Eles se destinam a coletar opiniões diversas e qualificadas sobre os temas em discussão. </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingThree"> <h4 class="panel-title"> <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> Quem promove esta iniciativa? </a> </h4> </div> <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree"> <div class="panel-body"> Esta plataforma é uma iniciativa da Secretaria de Assuntos Legislativos do Ministério da Justiça e do projeto Pensando o Direito. </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <?php }
static function userMessages() { global $pgv_lang, $PGV_IMAGE_DIR, $TEXT_DIRECTION, $PGV_STORE_MESSAGES, $PGV_IMAGES; $usermessages = getUserMessages(PGV_USER_NAME); $content = "<form name=\"messageform\" action=\"\" onsubmit=\"return confirm('{$pgv_lang['confirm_message_delete']}');\">"; if (count($usermessages) == 0) { $content .= "{$pgv_lang['no_messages']}<br />\n"; } else { $content .= ' <script language="JavaScript" type="text/javascript"> <!-- function select_all() { '; foreach ($usermessages as $k => $message) { if (isset($message['id'])) { $k = $message['id']; } $content .= ' var cb = document.getElementById("cb_message' . $k . '"); if (cb) { if (!cb.checked) cb.checked = true; else cb.checked = false; } '; } $content .= ' return false; } //--> </script> '; $content .= '<input type="hidden" name="action" value="deletemessage" />' . '<table class="list_table"><tr>' . "<td class=\"list_label\">{$pgv_lang['delete']}<br />\n<a href=\"javascript:;\" onclick=\"return select_all();\">{$pgv_lang['all']}</a></td>\n" . "<td class=\"list_label\">{$pgv_lang['message_subject']}</td>\n" . "<td class=\"list_label\">{$pgv_lang['date_created']}</td>\n" . "<td class=\"list_label\">{$pgv_lang['message_from']}</td>\n" . "</tr>\n"; foreach ($usermessages as $k => $message) { if (isset($message['id'])) { $k = $message['id']; } $content .= "<tr>\n<td class=\"list_value_wrap\"><input type=\"checkbox\" id=\"cb_message{$k}\" name=\"message_id[]\" value=\"{$k}\" /></td>\n"; $showmsg = preg_replace("/(\\w)\\/(\\w)/", "\$1/<span style=\"font-size:1px;\"> </span>\$2", PrintReady($message['subject'])); $showmsg = preg_replace("/@/", "@<span style=\"font-size:1px;\"> </span>", $showmsg); $content .= "<td class=\"list_value_wrap\"><a href=\"javascript:;\" onclick=\"expand_layer('message{$k}'); return false;\"><b>{$showmsg}</b> <img id=\"message{$k}_img\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['plus']['other']}\" border=\"0\" alt=\"\" title=\"\" /></a></td>\n"; if (!empty($message['created'])) { $t = strtotime($message['created']); } else { $t = time(); } $content .= '<td class="list_value_wrap">' . format_timestamp($t) . "</td>\n" . '<td class="list_value_wrap">'; $user_id = get_user_id($message['from']); if ($user_id) { $content .= PrintReady(getUserFullName($user_id)); if ($TEXT_DIRECTION == 'ltr') { $content .= ' ' . getLRM() . ' - ' . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getLRM(); } else { $content .= ' ' . getRLM() . ' - ' . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getRLM(); } } else { $content .= "<a href=\"mailto:{$user_id}\">" . preg_replace("/@/", "@<span style=\"font-size:1px;\"> </span>", $user_id) . '</a>'; } $content .= "</td>\n" . "</tr>\n" . "<tr>\n<td class=\"list_value_wrap\" colspan=\"5\"><div id=\"message{$k}\" style=\"display: none;\">"; $message['body'] = expand_urls(nl2br(htmlspecialchars($message['body'], ENT_COMPAT, 'UTF-8'))); $content .= PrintReady($message['body']) . "<br />\n<br />\n"; if (preg_match("/RE:/", $message["subject"]) == 0) { $message['subject'] = "RE:{$message['subject']}"; } if ($user_id) { $content .= "<a href=\"javascript:;\" onclick=\"reply('{$user_id}', '{$message['subject']}'); return false;\">{$pgv_lang['reply']}</a> | "; } $content .= "<a href=\"" . encode_url("index.php?action=deletemessage&message_id={$k}") . "\" onclick=\"return confirm('{$pgv_lang['confirm_message_delete']}');\">{$pgv_lang['delete']}</a></div></td>\n</tr>\n"; } $content .= "</table>\n" . "<input type=\"submit\" value=\"{$pgv_lang['delete_selected_messages']}\" /><br />\n<br />\n"; } if (get_user_count() > 1) { $content .= "{$pgv_lang['message']} <select name=\"touser\">"; if (PGV_USER_IS_ADMIN) { $content .= "<option value=\"all\">{$pgv_lang['broadcast_all']}</option>\n" . "<option value=\"never_logged\">{$pgv_lang['broadcast_never_logged_in']}</option>\n" . "<option value=\"last_6mo\">{$pgv_lang['broadcast_not_logged_6mo']}</option>\n"; } foreach (get_all_users() as $user_id => $user_name) { if ($user_id != PGV_USER_ID && get_user_setting($user_id, 'verified_by_admin') == 'yes') { $content .= "<option value=\"{$user_id}\">" . PrintReady(getUserFullName($user_id)) . ' '; if ($TEXT_DIRECTION == 'ltr') { $content .= getLRM() . " - {$user_id}" . getLRM(); } else { $content .= getRLM() . " - {$user_id}" . getRLM(); } $content .= "</option>\n"; } } $content .= "</select>\n<input type=\"button\" value=\"{$pgv_lang['send']}\" onclick=\"message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, 'messaging2', ''); return false;\" />\n"; } $content .= "</form>\n"; return $content; }
if (isset($_POST['remarks'])) { file_write_contents(DATA_PATH . 'admin_remarks.txt', $_POST['remarks']); } $frm = new InputForm('', 'post', __('Submit')); $frm->addbreak(__('Welcome to administration panel')); if (!$root) { foreach ($rights as $right => $right_desc) { $frm->addrow($right, $right_desc, 'top'); } } else { $frm->addrow(__('You have all rights on this site')); } $frm->addbreak(__('Information')); $frm->addrow('httpd', $_SERVER['SERVER_SOFTWARE']); $frm->addrow('php', phpversion()); $frm->addrow('ReloadCMS', RCMS_VERSION_A . '.' . RCMS_VERSION_B . '.' . RCMS_VERSION_C . RCMS_VERSION_SUFFIX); $frm->addbreak(__('Additional information')); $frm->addrow(__('Users profiles') . ' (' . get_user_count() . ')', format_size(get_dir_size(USERS_PATH) + get_dir_size(DATA_PATH . 'avatars/') + get_dir_size(DATA_PATH . 'pm/'))); $frm->addrow(__('Logs'), format_size(get_dir_size(LOGS_PATH))); $frm->addrow(__('Config'), format_size(get_dir_size(CONFIG_PATH))); $frm->addrow(__('Backups'), format_size(get_dir_size(BACKUP_PATH))); if ($system->checkForRight('ARTICLES-EDITOR')) { $frm->addbreak(__('Information from users')); } if ($system->checkForRight('SUPPORT')) { $count = sizeof(guestbook_get_msgs(null, true, false, DF_PATH . 'support.dat')); $frm->addrow($count . ' ' . __('feedback requests in database')); } $frm->addbreak(__('Here you can leave message for other administrators')); $frm->addrow($frm->textarea('remarks', file_get_contents(DATA_PATH . 'admin_remarks.txt'), 60, 10), '', 'middle', 'center'); $frm->show();
/** * Import users etc. from index files * */ function import() { global $INDEX_DIRECTORY, $TBLPREFIX, $pgv_lang, $GEDCOMS, $GEDCOM, $gBitDb; if (file_exists($INDEX_DIRECTORY . "authenticate.php") == false) { $this->impSuccess = false; return; } else { require $INDEX_DIRECTORY . "authenticate.php"; $countold = count($users); $gBitDb->query("DELETE FROM {$TBLPREFIX}users"); foreach ($users as $username => $user) { if ($user["editaccount"] == "1") { $user["editaccount"] = "Y"; } else { $user["editaccount"] = "N"; } //-- make sure fields are set for v4.0 DB if (!isset($user["firstname"])) { if (isset($user["fullname"])) { $parts = explode(' ', trim($user["fullname"])); $user["lastname"] = array_pop($parts); $user["firstname"] = implode(" ", $parts); } else { $user["firstname"] = ''; $user["lastname"] = ''; } } if (!isset($user["comment"])) { $user["comment"] = ''; } if (!isset($user["comment_exp"])) { $user["comment_exp"] = ''; } if (!isset($user["sync_gedcom"])) { $user["sync_gedcom"] = 'N'; } if (!isset($user["relationship_privacy"])) { $user["relationship_privacy"] = 'N'; } if (!isset($user["max_relation_path"])) { $user["max_relation_path"] = '2'; } if (!isset($user["auto_accept"])) { $user["auto_accept"] = 'N'; } if ($user_id = create_user($user['username'], $user['password'])) { set_user_setting($user_id, 'firstname', $user["firstname"]); set_user_setting($user_id, 'lastname', $user["lastname"]); set_user_setting($user_id, 'email', $user["email"]); set_user_setting($user_id, 'theme', $user["theme"]); set_user_setting($user_id, 'language', $user["language"]); set_user_setting($user_id, 'contactmethod', $user["contactmethod"]); set_user_setting($user_id, 'defaulttab', $user["defaulttab"]); set_user_setting($user_id, 'comment', $user["comment"]); set_user_setting($user_id, 'comment_exp', $user["comment_exp"]); set_user_setting($user_id, 'pwrequested', $user["pwrequested"]); set_user_setting($user_id, 'reg_timestamp', $user["reg_timestamp"]); set_user_setting($user_id, 'reg_hashcode', $user["reg_hashcode"]); set_user_setting($user_id, 'loggedin', $user["loggedin"]); set_user_setting($user_id, 'sessiontime', $user["sessiontime"]); set_user_setting($user_id, 'max_relation_path', $user["max_relation_path"]); set_user_setting($user_id, 'sync_gedcom', $user["sync_gedcom"] ? 'Y' : 'N'); set_user_setting($user_id, 'relationship_privacy', $user["relationship_privacy"] ? 'Y' : 'N'); set_user_setting($user_id, 'auto_accept', $user["auto_accept"] ? 'Y' : 'N'); set_user_setting($user_id, 'canadmin', $user["canadmin"] ? 'Y' : 'N'); set_user_setting($user_id, 'visibleonline', $user["visibleonline"] ? 'Y' : 'N'); set_user_setting($user_id, 'editaccount', $user["editaccount"] ? 'Y' : 'N'); set_user_setting($user_id, 'verified', $user["verified"] ? 'yes' : 'no'); set_user_setting($user_id, 'verified_by_admin', $user["verified_by_admin"] ? 'yes' : 'no'); foreach (array('gedcomid', 'rootid', 'canedit') as $var) { if ($user[$var]) { foreach (unserialize(stripslashes($user[$var])) as $gedcom => $id) { set_user_gedcom_setting($user_id, $gedcom, $var, $id); } } } AddToLog("added user -> {$user['username']} <-"); } } if ($countold == get_user_count()) { $this->impSuccess = true; } else { $this->impSuccess = false; } } if (file_exists($INDEX_DIRECTORY . "messages.dat") == false) { $this->msgSuccess = false; } else { $gBitDb->query("DELETE FROM {$TBLPREFIX}messages"); $messages = array(); $fp = fopen($INDEX_DIRECTORY . "messages.dat", "rb"); $mstring = fread($fp, filesize($INDEX_DIRECTORY . "messages.dat")); fclose($fp); $messages = unserialize($mstring); foreach ($messages as $newid => $message) { $gBitDb->query("INSERT INTO {$TBLPREFIX}messages (m_id, m_from, m_to, m_subject, m_body, m_created) VALUES (?, ? ,? ,? ,? ,?)", array($newid, $message["from"], $message["to"], $message["subject"], $message["body"], $message["created"])); } $this->msgSuccess = true; } if (file_exists($INDEX_DIRECTORY . "favorites.dat") == false) { $this->favSuccess = false; print $pgv_lang["um_nofav"] . "<br /><br />"; } else { $gBitDb->query("DELETE FROM {$TBLPREFIX}favorites"); $favorites = array(); $fp = fopen($INDEX_DIRECTORY . "favorites.dat", "rb"); $mstring = fread($fp, filesize($INDEX_DIRECTORY . "favorites.dat")); fclose($fp); $favorites = unserialize($mstring); foreach ($favorites as $newid => $favorite) { $res = addFavorite($favorite); if (!$res || DB::isError($res)) { $this->errorMsg = "<span class=\"error\">Unable to update <i>Favorites</i> table.</span><br />\n"; return; } } $this->favSuccess = true; } if (file_exists($INDEX_DIRECTORY . "news.dat") == false) { $this->newsSuccess = false; } else { $gBitDb->query("DELETE FROM {$TBLPREFIX}news"); $allnews = array(); $fp = fopen($INDEX_DIRECTORY . "news.dat", "rb"); $mstring = fread($fp, filesize($INDEX_DIRECTORY . "news.dat")); fclose($fp); $allnews = unserialize($mstring); foreach ($allnews as $newid => $news) { $res = addNews($news); if (!$res) { $this->errorMsg = "<span class=\"error\">Unable to update <i>News</i> table.</span><br />\n"; return; } } $this->newsSuccess = true; } if (file_exists($INDEX_DIRECTORY . "blocks.dat") == false) { $this->blockSuccess = false; } else { $gBitDb->query("DELETE FROM {$TBLPREFIX}blocks"); $allblocks = array(); $fp = fopen($INDEX_DIRECTORY . "blocks.dat", "rb"); $mstring = fread($fp, filesize($INDEX_DIRECTORY . "blocks.dat")); fclose($fp); $allblocks = unserialize($mstring); foreach ($allblocks as $bid => $blocks) { $username = $blocks["username"]; $gBitDb->query("INSERT INTO {$TBLPREFIX}blocks (b_id, b_username, b_location, b_order, b_name, b_config) VALUES (?, ? ,? , ?, ?, ?)", array($bid, $blocks["username"], $blocks["location"], $blocks["order"], $blocks["name"], serialize($blocks["config"]))); } $this->blockSuccess = true; } }
/** * Whether or not we have a large network. * * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites. * Plugins can alter this criteria using the 'wp_is_large_network' filter. * * @since 3.3.0 * @param string $using 'sites or 'users'. Default is 'sites'. * @return bool True if the network meets the criteria for large. False otherwise. */ function wp_is_large_network($using = 'sites') { if ('users' == $using) { $count = get_user_count(); /** * Filter whether the network is considered large. * * @since 3.3.0 * * @param bool $is_large_network Whether the network has more than 10000 users or sites. * @param string $component The component to count. Accepts 'users', or 'sites'. * @param int $count The count of items for the component. */ return apply_filters('wp_is_large_network', $count > 10000, 'users', $count); } $count = get_blog_count(); /** This filter is documented in wp-includes/ms-functions.php */ return apply_filters('wp_is_large_network', $count > 10000, 'sites', $count); }
function appthemes_update_checks() { global $app_abbr, $app_version, $app_theme, $wp_version, $wpdb, $wp_local_package; $theme_name = trim(strtolower($app_theme)); $php_version = phpversion(); $current = get_site_transient($theme_name . '_update_theme'); if (!is_object($current)) { $current = new stdClass(); $current->updates = array(); $current->version_checked = $app_version; } $locale = apply_filters('core_version_check_locale', get_locale()); // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); set_site_transient($theme_name . '_update_theme', $current); if (method_exists($wpdb, 'db_version')) { $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } else { $mysql_version = 'N/A'; } if (is_multisite()) { $user_count = get_user_count(); $num_blogs = get_blog_count(); $wp_install = network_site_url(); $multisite_enabled = 1; } else { $user_count = count_users(); $multisite_enabled = 0; $num_blogs = 1; $wp_install = home_url('/'); } $local_package = isset($wp_local_package) ? $wp_local_package : ''; $url = "http://api.appthemes.com/vcheck/?theme_name={$theme_name}&theme_version={$app_version}&wp_version={$wp_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}&blogs={$num_blogs}&users={$user_count['total_users']}&multisite_enabled={$multisite_enabled}"; $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => $app_theme . '/' . $app_version . '; ' . home_url('/'), 'headers' => array('wp_install' => $wp_install, 'wp_blog' => home_url('/'))); $response = wp_remote_get($url, $options); if (is_wp_error($response)) { return false; } if (200 != $response['response']['code']) { return false; } $body = trim($response['body']); $body = str_replace(array("\r\n", "\r"), "\n", $body); $returns = array(); foreach (explode("\n\n", $body) as $entry) { $returns = explode("\n", $entry); $new_option = new stdClass(); $new_option->latest_version = esc_attr($returns[0]); } $updates = new stdClass(); //$updates->updates = $new_options; $updates->last_checked = time(); $updates->version_checked = $app_version; $updates->latest_version = $new_option->latest_version; set_site_transient($theme_name . '_update_theme', $updates); }
/** * Wrapper for wp_is_large_network() that supports non-MS. * * @since 1.1.2 */ function invite_anyone_is_large_network() { if (function_exists('wp_is_large_network')) { $is_large_network = wp_is_large_network('users'); $count = get_user_count(); } else { global $wpdb; $count = get_transient('ia_user_count'); if (false === $count) { $count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users} WHERE user_status = '0'"); set_transient('ia_user_count', $count, 60 * 60 * 24); } $is_large_network = $count > 10000; return apply_filters('invite_anyone_is_large_network', $count > 10000, $count); } return apply_filters('invite_anyone_is_large_network', $is_large_network, $count); }
/** * Check WordPress version against the newest version. * * The WordPress version, PHP version, and Locale is sent. Checks against the * WordPress server at api.wordpress.org server. Will only check if WordPress * isn't installing. * * @package WordPress * @since 2.3.0 * @uses $wp_version Used to check against the newest WordPress version. * * @param array $extra_stats Extra statistics to report to the WordPress.org API. * @return mixed Returns null if update is unsupported. Returns false if check is too soon. */ function wp_version_check( $extra_stats = array() ) { if ( defined('WP_INSTALLING') ) return; global $wpdb, $wp_local_package; include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version $php_version = phpversion(); $current = get_site_transient( 'update_core' ); $translations = wp_get_installed_translations( 'core' ); if ( ! is_object($current) ) { $current = new stdClass; $current->updates = array(); $current->version_checked = $wp_version; } // Wait 60 seconds between multiple version check requests $timeout = 60; $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); if ( $time_not_changed && empty( $extra_stats ) ) return false; $locale = get_locale(); /** * Filter the locale requested for WordPress core translations. * * @since 2.8.0 * * @param string $locale Current locale. */ $locale = apply_filters( 'core_version_check_locale', $locale ); // Update last_checked for current to prevent multiple blocking requests if request hangs $current->last_checked = time(); set_site_transient( 'update_core', $current ); if ( method_exists( $wpdb, 'db_version' ) ) $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); else $mysql_version = 'N/A'; if ( is_multisite() ) { $user_count = get_user_count(); $num_blogs = get_blog_count(); $wp_install = network_site_url(); $multisite_enabled = 1; } else { $user_count = count_users(); $user_count = $user_count['total_users']; $multisite_enabled = 0; $num_blogs = 1; $wp_install = home_url( '/' ); } $query = array( 'version' => $wp_version, 'php' => $php_version, 'locale' => $locale, 'mysql' => $mysql_version, 'local_package' => isset( $wp_local_package ) ? $wp_local_package : '', 'blogs' => $num_blogs, 'users' => $user_count, 'multisite_enabled' => $multisite_enabled, ); $post_body = array( 'translations' => json_encode( $translations ), ); if ( $extra_stats ) $post_body = array_merge( $post_body, $extra_stats ); $url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' ); if ( wp_http_supports( array( 'ssl' ) ) ) $url = set_url_scheme( $url, 'https' ); $options = array( 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), 'headers' => array( 'wp_install' => $wp_install, 'wp_blog' => home_url( '/' ) ), 'body' => $post_body, ); $response = wp_remote_post( $url, $options ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) return false; $body = trim( wp_remote_retrieve_body( $response ) ); $body = json_decode( $body, true ); if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) return false; $offers = $body['offers']; foreach ( $offers as &$offer ) { foreach ( $offer as $offer_key => $value ) { if ( 'packages' == $offer_key ) $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ), array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) ); elseif ( 'download' == $offer_key ) $offer['download'] = esc_url( $value ); else $offer[ $offer_key ] = esc_html( $value ); } $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) ); } $updates = new stdClass(); $updates->updates = $offers; $updates->last_checked = time(); $updates->version_checked = $wp_version; if ( isset( $body['translations'] ) ) $updates->translations = $body['translations']; set_site_transient( 'update_core', $updates); }
* * @package WordPress * @subpackage Multisite * @since 3.0.0 */ require_once './admin.php'; if (!is_multisite()) { wp_die(__('Multisite support is not enabled.')); } if (!current_user_can('manage_network')) { wp_die(__('You do not have permission to access this page.')); } $title = __('Network Admin'); $parent_file = 'ms-admin.php'; require_once './admin-header.php'; $c_users = get_user_count(); $c_blogs = get_blog_count(); $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users)); $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs)); $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text); ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php echo esc_html($title); ?> </h2>
public function user_count() { //Only send this gauge on every hundredth request, it doesn't change often $sample = mt_rand() / mt_getrandmax(); if ($sample <= 0.01) { if (is_multisite()) { $user_count = get_user_count(); } else { //$user_count = count_users(); //$user_count = $user_count['total_users']; global $wpdb; $user_count = $wpdb->get_var("SELECT COUNT(ID) as c FROM {$wpdb->users}"); //don't go by role, make it simple } $this->statsd->gauge("wordpress.users.count", $user_count); } }
function wp_network_dashboard_right_now() { $actions = array(); if (current_user_can('create_sites')) { $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __('Create a New Site') . '</a>'; } if (current_user_can('create_users')) { $actions['create-user'] = '******' . network_admin_url('user-new.php') . '">' . __('Create a New User') . '</a>'; } $c_users = get_user_count(); $c_blogs = get_blog_count(); $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users)); $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs)); $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text); if ($actions) { echo '<ul class="subsubsub">'; foreach ($actions as $class => $action) { $actions[$class] = "\t<li class='{$class}'>{$action}"; } echo implode(" |</li>\n", $actions) . "</li>\n"; echo '</ul>'; } ?> <br class="clear" /> <p class="youhave"><?php echo $sentence; ?> </p> <?php do_action('wpmuadminresult', ''); ?> <form name="searchform" action="<?php echo network_admin_url('users.php'); ?> " method="get"> <p> <input type="text" name="s" value="" size="17" /> <?php submit_button(__('Search Users'), 'button', 'submit', false, array('id' => 'submit_users')); ?> </p> </form> <form name="searchform" action="<?php echo network_admin_url('sites.php'); ?> " method="get"> <p> <input type="text" name="s" value="" size="17" /> <?php submit_button(__('Search Sites'), 'button', 'submit', false, array('id' => 'submit_sites')); ?> </p> </form> <?php do_action('mu_rightnow_end'); do_action('mu_activity_box_end'); }
/** * Get plugin update information from server * * @global string $wp_version * @global object $wpdb * @return boolean */ function get_info() { global $wp_version, $wpdb; list($plugin_name, $plugin_version) = $this->get_current_plugin_info(); if (is_multisite()) { $user_count = get_user_count(); $num_blogs = get_blog_count(); $wp_install = network_site_url(); $multisite_enabled = 1; } else { $user_count = count_users(); $multisite_enabled = 0; $num_blogs = 1; $wp_install = home_url('/'); } $locale = apply_filters('core_version_check_locale', get_locale()); if (method_exists($wpdb, 'db_version')) { $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version()); } else { $mysql_version = 'N/A'; } $license = $this->get_license_key(); $params = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'body' => array('name' => $plugin_name, 'slug' => self::slug, 'type' => 'plugin', 'version' => $plugin_version, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'action' => 'theme_check', 'locale' => $locale, 'mysql' => $mysql_version, 'blogs' => $num_blogs, 'users' => $user_count['total_users'], 'multisite_enabled' => $multisite_enabled, 'site_url' => $wp_install, 'license' => isset($license['key']) ? $license['key'] : '', 'license_email' => isset($license['email']) ? $license['email'] : '', 'product_id' => self::product_id)); $response = wp_remote_post(self::base_url . '?action=wedevs_update_check', $params); $update = wp_remote_retrieve_body($response); if (is_wp_error($response) || $response['response']['code'] != 200) { return false; } return json_decode($update); }
/** * Whether or not we have a large network. * * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites. * Plugins can alter this criteria using the 'wp_is_large_network' filter. * * @since 3.3.0 * @param string $using 'sites or 'users'. Default is 'sites'. * @return bool True if the network meets the criteria for large. False otherwise. */ function wp_is_large_network( $using = 'sites' ) { if ( 'users' == $using ) { $count = get_user_count(); return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count ); } $count = get_blog_count(); return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count ); }
function print_user_messages($block = true, $config = "", $side, $index) { global $pgv_lang, $PGV_IMAGE_DIR, $TEXT_DIRECTION, $PGV_STORE_MESSAGES, $PGV_IMAGES; $usermessages = getUserMessages(PGV_USER_NAME); $id = "user_messages"; $title = print_help_link("mygedview_message_help", "qm", "", false, true); $title .= $pgv_lang["my_messages"] . " "; if ($TEXT_DIRECTION == "rtl") { $title .= getRLM(); } $title .= "(" . count($usermessages) . ")"; if ($TEXT_DIRECTION == "rtl") { $title .= getRLM(); } $content = ""; $content .= "<form name=\"messageform\" action=\"\" onsubmit=\"return confirm('" . $pgv_lang["confirm_message_delete"] . "');\">"; if (count($usermessages) == 0) { $content .= $pgv_lang["no_messages"] . "<br />"; } else { $content .= ' <script language="JavaScript" type="text/javascript"> <!-- function select_all() { '; foreach ($usermessages as $key => $message) { if (isset($message["id"])) { $key = $message["id"]; } $content .= ' var cb = document.getElementById("cb_message' . $key . '"); if (cb) { if (!cb.checked) cb.checked = true; else cb.checked = false; } '; } $content .= ' return false; } //--> </script> '; $content .= "<input type=\"hidden\" name=\"action\" value=\"deletemessage\" />"; $content .= "<table class=\"list_table\"><tr>"; $content .= "<td class=\"list_label\">" . $pgv_lang["delete"] . "<br /><a href=\"javascript:;\" onclick=\"return select_all();\">" . $pgv_lang["all"] . "</a></td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["message_subject"] . "</td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["date_created"] . "</td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["message_from"] . "</td>"; $content .= "</tr>"; foreach ($usermessages as $key => $message) { if (isset($message["id"])) { $key = $message["id"]; } $content .= "<tr>"; $content .= "<td class=\"list_value_wrap\"><input type=\"checkbox\" id=\"cb_message{$key}\" name=\"message_id[]\" value=\"{$key}\" /></td>"; $showmsg = preg_replace("/(\\w)\\/(\\w)/", "\$1/<span style=\"font-size:1px;\"> </span>\$2", PrintReady($message["subject"])); $showmsg = str_replace("@", "@<span style=\"font-size:1px;\"> </span>", $showmsg); $content .= "<td class=\"list_value_wrap\"><a href=\"javascript:;\" onclick=\"expand_layer('message{$key}'); return false;\"><img id=\"message{$key}_img\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["plus"]["other"] . "\" border=\"0\" alt=\"" . $pgv_lang["show_details"] . "\" title=\"" . $pgv_lang["show_details"] . "\" /> <b>" . $showmsg . "</b></a></td>"; if (!empty($message["created"])) { $time = strtotime($message["created"]); } else { $time = time(); } $content .= "<td class=\"list_value_wrap\">" . format_timestamp($time) . "</td>"; $content .= "<td class=\"list_value_wrap\">"; $user_id = get_user_id($message["from"]); if ($user_id) { $content .= PrintReady(getUserFullName($user_id)); if ($TEXT_DIRECTION == "ltr") { $content .= " " . getLRM() . " - " . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getLRM(); } else { $content .= " " . getRLM() . " - " . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getRLM(); } } else { $content .= "<a href=\"mailto:" . $message["from"] . "\">" . str_replace("@", "@<span style=\"font-size:1px;\"> </span>", $message["from"]) . "</a>"; } $content .= "</td>"; $content .= "</tr>"; $content .= "<tr><td class=\"list_value_wrap\" colspan=\"5\"><div id=\"message{$key}\" style=\"display: none;\">"; $message["body"] = nl2br(htmlspecialchars($message["body"], ENT_COMPAT, 'UTF-8')); $message["body"] = expand_urls($message["body"]); $content .= PrintReady($message["body"]) . "<br /><br />"; if (strpos($message["subject"], "RE:") === false) { $message["subject"] = "RE:" . $message["subject"]; } if ($user_id) { $content .= "<a href=\"javascript:;\" onclick=\"reply('" . $user_id . "', '" . $message["subject"] . "'); return false;\">" . $pgv_lang["reply"] . "</a> | "; } $content .= "<a href=\"" . encode_url("index.php?action=deletemessage&message_id={$key}") . "\" onclick=\"return confirm('" . $pgv_lang["confirm_message_delete"] . "');\">" . $pgv_lang["delete"] . "</a></div></td></tr>"; } $content .= "</table>"; $content .= "<input type=\"submit\" value=\"" . $pgv_lang["delete_selected_messages"] . "\" /><br /><br />"; } if (get_user_count() > 1) { $content .= $pgv_lang["message"] . " <select name=\"touser\">"; if (PGV_USER_IS_ADMIN) { $content .= "<option value=\"all\">" . $pgv_lang["broadcast_all"] . "</option>"; $content .= "<option value=\"never_logged\">" . $pgv_lang["broadcast_never_logged_in"] . "</option>"; $content .= "<option value=\"last_6mo\">" . $pgv_lang["broadcast_not_logged_6mo"] . "</option>"; } foreach (get_all_users() as $user_id => $user_name) { if ($user_id != PGV_USER_ID && get_user_setting($user_id, 'verified_by_admin') == 'yes' && get_user_setting($user_id, 'contactmethod') != 'none') { $content .= "<option value=\"" . $user_name . "\">" . PrintReady(getUserFullName($user_id)) . " "; if ($TEXT_DIRECTION == "ltr") { $content .= stripLRMRLM(getLRM() . " - " . $user_name . getLRM()); } else { $content .= stripLRMRLM(getRLM() . " - " . $user_name . getRLM()); } $content .= "</option>"; } } $content .= "</select><input type=\"button\" value=\"" . $pgv_lang["send"] . "\" onclick=\"message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, 'messaging2', ''); return false;\" />"; } $content .= "</form>"; global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }