function print_system_stats($category = false) { global $page_vars; $stats = get_system_stats($category); $results = sprintf("\n<div class='statsbox'>\n<a href='%s'><h2>%s</h2> blogs</a>\n<a href='%s'><h2>%s</h2> posts</a>\n<a href='%s'><h2>%s</h2> papers</a>\n</div>\t\n\t", linkto("blogs.php", $page_vars), number_format($stats['blogs']), linkto("posts.php", $page_vars), number_format($stats['posts']), linkto("papers.php", $page_vars), number_format($stats['papers'])); print $results; }
echo '</div>'; echo '<div class="system_check_value_' . $condition . '">'; echo $syscheck_value; echo ' </div>'; if (!empty($message)) { echo '<div class="system_check_message_' . $condition . '">'; echo $message; echo '</div>'; } echo '</div>'; } $facilitate_exploits = '<p>' . T_('When enabled, this feature is known to facilitate hacking exploits in any PHP application.') . "</p>\n<p>" . T_('b2evolution includes additional measures in order not to be affected by this. However, for maximum security, we still recommend disabling this PHP feature.') . "</p>\n"; $change_ini = '<p>' . T_('If possible, change this setting to <code>%s</code> in your php.ini or ask your hosting provider about it.') . '</p>'; echo '<h2 class="page-title">' . T_('System status') . '</h2>'; // Get system stats to display: $system_stats = get_system_stats(); // Note: hopefully, the update swill have been downloaded in the shutdown function of a previous page (including the login screen) // However if we have outdated info, we will load updates here. load_funcs('dashboard/model/_dashboard.funcs.php'); // Let's clear any remaining messages that should already have been displayed before... $Messages->clear(); if (b2evonet_get_updates(true) !== NULL) { // Updates are allowed, display them: // Display info & error messages $Messages->display(); /** * @var AbstractSettings */ global $global_Cache; $version_status_msg = $global_Cache->get('version_status_msg'); if (!empty($version_status_msg)) {
/** * Get updates from b2evolution.net * * @param boolean useful when trying to upgrade to a release that has just been published (in the last 12 hours) * @return NULL|boolean True if there have been updates, false on error, * NULL if the user has turned off updates. */ function b2evonet_get_updates($force_short_delay = false) { global $allow_evo_stats; // Possible values: true, false, 'anonymous' global $DB, $debug, $evonetsrv_host, $evonetsrv_port, $evonetsrv_uri, $servertimenow, $evo_charset; global $Messages, $Settings, $baseurl, $instance_name, $app_name, $app_version, $app_date; global $Debuglog; global $Timer; if (!isset($allow_evo_stats)) { // Set default value: $allow_evo_stats = true; // allow (non-anonymous) stats } if ($allow_evo_stats === false) { // Get outta here: return NULL; } if ($debug == 2) { $update_every = 8; $attempt_every = 3; } elseif ($force_short_delay) { $update_every = 180; // 3 minutes $attempt_every = 60; // 1 minute } else { $update_every = 3600 * 12; // 12 hours $attempt_every = 3600 * 4; // 4 hours } // Note: do not put $baseurl in here since it would cause too frequently updates, when you have the same install with different $baseurls. // Everytime this method gets called on another baseurl, there's a new check for updates! $version_id = $instance_name . ' ' . $app_name . ' ' . $app_version . ' ' . $app_date; // This is the last version we checked against the server: $last_version_checked = $Settings->get('evonet_last_version_checked'); $servertime_last_update = $Settings->get('evonet_last_update'); $servertime_last_attempt = $Settings->get('evonet_last_attempt'); if ($last_version_checked == $version_id) { // Current version has already been checked, don't check too often: if ($servertime_last_update > $servertimenow - $update_every) { // The previous update was less than 12 hours ago, skip this // echo 'recent update'; return false; } if ($servertime_last_attempt > $servertimenow - $attempt_every) { // The previous update attempt was less than 4 hours ago, skip this // This is so all b2evo's don't go crazy if the server ever is down // echo 'recent attempt'; return false; } } $Timer->resume('evonet: check for updates'); $Debuglog->add(sprintf('Getting updates from %s.', $evonetsrv_host), 'evonet'); if ($debug) { $Messages->add(sprintf(T_('Getting updates from %s.'), $evonetsrv_host), 'note'); } $Settings->set('evonet_last_attempt', $servertimenow); $Settings->dbupdate(); // Construct XML-RPC client: load_funcs('xmlrpc/model/_xmlrpc.funcs.php'); $client = new xmlrpc_client($evonetsrv_uri, $evonetsrv_host, $evonetsrv_port); if ($debug > 1) { $client->debug = 1; } // Run system checks: load_funcs('tools/model/_system.funcs.php'); // Get system stats to display: $system_stats = get_system_stats(); // Construct XML-RPC message: $message = new xmlrpcmsg('b2evo.getupdates', array(new xmlrpcval($allow_evo_stats === 'anonymous' ? md5($baseurl) : $baseurl, 'string'), new xmlrpcval($instance_name, 'string'), new xmlrpcval($app_name, 'string'), new xmlrpcval($app_version, 'string'), new xmlrpcval($app_date, 'string'), new xmlrpcval(array('this_update' => new xmlrpcval($servertimenow, 'string'), 'last_update' => new xmlrpcval($servertime_last_update, 'string'), 'mediadir_status' => new xmlrpcval($system_stats['mediadir_status'], 'int'), 'install_removed' => new xmlrpcval($system_stats['install_removed'] == 'ok' ? 1 : 0, 'int'), 'evo_charset' => new xmlrpcval($system_stats['evo_charset'], 'string'), 'evo_blog_count' => new xmlrpcval($system_stats['evo_blog_count'], 'int'), 'cachedir_status' => new xmlrpcval($system_stats['cachedir_status'], 'int'), 'cachedir_size' => new xmlrpcval($system_stats['cachedir_size'], 'int'), 'general_pagecache_enabled' => new xmlrpcval($system_stats['general_pagecache_enabled'] ? 1 : 0, 'int'), 'blog_pagecaches_enabled' => new xmlrpcval($system_stats['blog_pagecaches_enabled'], 'int'), 'db_version' => new xmlrpcval($system_stats['db_version'], 'string'), 'db_utf8' => new xmlrpcval($system_stats['db_utf8'] ? 1 : 0, 'int'), 'php_uid' => new xmlrpcval($system_stats['php_uid'], 'int'), 'php_uname' => new xmlrpcval($system_stats['php_uname'], 'string'), 'php_gid' => new xmlrpcval($system_stats['php_gid'], 'int'), 'php_gname' => new xmlrpcval($system_stats['php_gname'], 'string'), 'php_version' => new xmlrpcval($system_stats['php_version'], 'string'), 'php_reg_globals' => new xmlrpcval($system_stats['php_reg_globals'] ? 1 : 0, 'int'), 'php_allow_url_include' => new xmlrpcval($system_stats['php_allow_url_include'] ? 1 : 0, 'int'), 'php_allow_url_fopen' => new xmlrpcval($system_stats['php_allow_url_fopen'] ? 1 : 0, 'int'), 'php_upload_max' => new xmlrpcval($system_stats['php_upload_max'], 'int'), 'php_post_max' => new xmlrpcval($system_stats['php_post_max'], 'int'), 'php_memory' => new xmlrpcval($system_stats['php_memory'], 'int'), 'php_mbstring' => new xmlrpcval($system_stats['php_mbstring'] ? 1 : 0, 'int'), 'php_xml' => new xmlrpcval($system_stats['php_xml'] ? 1 : 0, 'int'), 'php_imap' => new xmlrpcval($system_stats['php_imap'] ? 1 : 0, 'int'), 'php_opcode_cache' => new xmlrpcval($system_stats['php_opcode_cache'], 'string'), 'gd_version' => new xmlrpcval($system_stats['gd_version'], 'string')), 'struct'))); $result = $client->send($message); if ($ret = xmlrpc_logresult($result, $Messages, false)) { // Response is not an error, let's process it: $response = $result->value(); if ($response->kindOf() == 'struct') { // Decode struct: $response = xmlrpc_decode_recurse($response); /** * @var AbstractSettings */ global $global_Cache; foreach ($response as $key => $data) { $global_Cache->set($key, serialize($data)); } $global_Cache->delete('evonet_updates'); // Cleanup $global_Cache->dbupdate(); $Settings->set('evonet_last_update', $servertimenow); $Settings->set('evonet_last_version_checked', $version_id); $Settings->dbupdate(); $Debuglog->add('Updates saved', 'evonet'); $Timer->pause('evonet: check for updates'); return true; } else { $Debuglog->add('Invalid updates received', 'evonet'); $Messages->add(T_('Invalid updates received'), 'error'); } } $Timer->pause('evonet: check for updates'); return false; }