/** * Collect system stats for display on the "About this system" page * * @return array */ function get_system_stats() { global $evo_charset, $DB, $Settings, $cache_path; static $system_stats = array(); if (!empty($system_stats)) { return $system_stats; } // b2evo config choices: $system_stats['mediadir_status'] = system_check_dir('media'); // If error, then the host is potentially borked $system_stats['install_removed'] = system_check_install_removed(); $system_stats['evo_charset'] = $evo_charset; $system_stats['evo_blog_count'] = count(system_get_blog_IDs(false)); // Caching: $system_stats['cachedir_status'] = system_check_dir('cache'); // If error, then the host is potentially borked $system_stats['cachedir_size'] = get_dirsize_recursive($cache_path); $system_stats['general_pagecache_enabled'] = $Settings->get('general_cache_enabled'); $system_stats['blog_pagecaches_enabled'] = count(system_get_blog_IDs(true)); // Database: $system_stats['db_version'] = $DB->get_version(); // MySQL version $system_stats['db_utf8'] = system_check_db_utf8(); // PHP: list($uid, $uname) = system_check_process_user(); $system_stats['php_uid'] = $uid; $system_stats['php_uname'] = $uname; // Potential unsecure hosts will use names like 'nobody', 'www-data' list($gid, $gname) = system_check_process_group(); $system_stats['php_gid'] = $gid; $system_stats['php_gname'] = $gname; // Potential unsecure hosts will use names like 'nobody', 'www-data' $system_stats['php_version'] = PHP_VERSION; $system_stats['php_reg_globals'] = ini_get('register_globals'); $system_stats['php_allow_url_include'] = ini_get('allow_url_include'); $system_stats['php_allow_url_fopen'] = ini_get('allow_url_fopen'); // TODO php_magic quotes $system_stats['php_upload_max'] = system_check_upload_max_filesize(); $system_stats['php_post_max'] = system_check_post_max_size(); $system_stats['php_memory'] = system_check_memory_limit(); // how much room does b2evo have to move? $system_stats['php_mbstring'] = extension_loaded('mbstring'); $system_stats['php_xml'] = extension_loaded('xml'); $system_stats['php_imap'] = extension_loaded('imap'); $system_stats['php_opcode_cache'] = get_active_opcode_cache(); // GD: $system_stats['gd_version'] = system_check_gd_version(); return $system_stats; }
// fp> TODO: explain why this is bad. Better yet: try to detect if we really need it, base don other conf variables. } else { disp_system_check('ok'); } $block_item_Widget->disp_template_raw('block_end'); /** * PHP */ $block_item_Widget->title = 'PHP'; $block_item_Widget->disp_template_replaced('block_start'); // User ID: list($uid, $uname, $running_as) = system_check_process_user(); init_system_check('PHP running as USER:'******'note'); // Group ID: list($gid, $gname, $running_as) = system_check_process_group(); init_system_check('PHP running as GROUP:', $running_as); disp_system_check('note'); // PHP version $phpinfo_url = '?ctrl=tools&action=view_phpinfo&' . url_crumb('tools'); $phpinfo_link = action_icon(T_('View PHP info'), 'info', $phpinfo_url, '', 5, '', array('target' => '_blank', 'onclick' => 'return pop_up_window( \'' . $phpinfo_url . '\', \'phpinfo\', 650 )')); init_system_check('PHP version', $system_stats['php_version'] . ' ' . $phpinfo_link); if (version_compare($system_stats['php_version'], $required_php_version['application'], '<')) { disp_system_check('error', T_('This version is too old. b2evolution will not run correctly. You must ask your host to upgrade PHP before you can run b2evolution.')); } elseif (version_compare($system_stats['php_version'], '5.2', '<')) { disp_system_check('warning', T_('This version is old. b2evolution may run but some features may fail. You should ask your host to upgrade PHP before running b2evolution.') . '<br />' . T_('PHP 5.2 or greater is recommended for maximum security, especially for "httpOnly" cookies support.')); } else { disp_system_check('ok'); } // register_globals? init_system_check('PHP register_globals', $system_stats['php_reg_globals'] ? T_('On') : T_('Off'));
/** * Get updates from b2evolution.net * * @return boolean True if there have been updates. */ function b2evonet_get_updates() { global $DB, $debug, $evonetsrv_host, $evonetsrv_port, $evonetsrv_uri, $servertimenow, $evo_charset; global $Messages, $Settings, $baseurl, $instance_name, $app_name, $app_version, $app_date; $update_every = 3600 * 12; // 12 hours $attempt_every = 3600 * 4; // 4 hours /* DEBUG: * $update_every = 10; $attempt_every = 5; */ $servertime_last_update = $Settings->get('evonet_last_update'); if ($servertime_last_update > $servertimenow - $update_every) { // The previous update was less than 12 hours ago, skip this // echo 'recent update'; return false; } $servertime_last_attempt = $Settings->get('evonet_last_attempt'); 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; } if ($debug) { $Messages->add(T_('Getting updates from ') . $evonetsrv_host, 'notes'); } $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); // $client->debug = $debug; // Run system checks: load_funcs('tools/model/_system.funcs.php'); list($mediadir_status) = system_check_media_dir(); list($uid, $uname) = system_check_process_user(); list($gid, $gname) = system_check_process_group(); // Construct XML-RPC message: $message = new xmlrpcmsg('b2evo.getupdates', array(new xmlrpcval($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'), 'db_version' => new xmlrpcval($DB->get_version(), 'string'), 'db_utf8' => new xmlrpcval(system_check_db_utf8() ? 1 : 0, 'int'), 'evo_charset' => new xmlrpcval($evo_charset, 'string'), 'php_version' => new xmlrpcval(PHP_VERSION, 'string'), 'php_xml' => new xmlrpcval(extension_loaded('xml') ? 1 : 0, 'int'), 'php_mbstring' => new xmlrpcval(extension_loaded('mbstring') ? 1 : 0, 'int'), 'php_memory' => new xmlrpcval(system_check_memory_limit(), 'int'), 'php_upload_max' => new xmlrpcval(system_check_upload_max_filesize(), 'int'), 'php_post_max' => new xmlrpcval(system_check_post_max_size(), 'int'), 'mediadir_status' => new xmlrpcval($mediadir_status, 'string'), 'install_removed' => new xmlrpcval(system_check_install_removed() ? 1 : 0, 'int'), 'php_uid' => new xmlrpcval($uid, 'int'), 'php_uname' => new xmlrpcval($uname, 'string'), 'php_gid' => new xmlrpcval($gid, 'int'), 'php_gname' => new xmlrpcval($gname, 'string'), 'php_reg_globals' => new xmlrpcval(ini_get('register_globals') ? 1 : 0, 'int'), 'gd_version' => new xmlrpcval(system_check_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; if (isset($response['evo_links'])) { // Extract evo links into its own var: $evo_links = $response['evo_links']; unset($response['evo_links']); if (is_array($evo_links)) { // Save creds: $global_Cache->set('evo_links', serialize($evo_links)); } } if (isset($response['creds'])) { // Extract creds into its own var: $creds = $response['creds']; unset($response['creds']); if (is_array($creds)) { // Save creds: $global_Cache->set('creds', serialize($creds)); } } // Save other info: $global_Cache->set('evonet_updates', serialize($response)); $global_Cache->dbupdate(); $Settings->set('evonet_last_update', $servertimenow); $Settings->dbupdate(); return true; } else { $Messages->add(T_('Invalid updates received'), 'error'); } } return false; }