Exemplo n.º 1
0
/**
 * 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;
}
Exemplo n.º 2
0
if ($opcode_cache == 'none') {
    disp_system_check('warning', T_('Using an opcode cache allows all your PHP scripts to run faster by caching a "compiled" (opcode) version of the scripts instead of recompiling everything at every page load. Several opcode caches are available. We recommend APC.'));
} else {
    disp_system_check('ok');
}
// pre_dump( get_loaded_extensions() );
$block_item_Widget->disp_template_raw('block_end');
/*
 * GD Library
 * windows: extension=php_gd2.dll
 * unix: ?
 * fp> Note: I'm going to use this for thumbnails for now, but I plan to use it for other things like small stats & status graphics.
 */
$block_item_Widget->title = T_('GD Library (image handling)');
$block_item_Widget->disp_template_replaced('block_start');
$gd_version = system_check_gd_version();
init_system_check(T_('GD Library version'), isset($gd_version) ? $gd_version : T_('Not installed'));
if (!isset($gd_version)) {
    disp_system_check('warning', T_('You will not be able to automatically generate thumbnails for images. Enable the gd2 extension in your php.ini file or ask your hosting provider about it.'));
} else {
    disp_system_check('ok');
    $gd_info = gd_info();
    // JPG:
    // Tblue> Note: "JPG Support" was renamed to "JPEG Support" in PHP 5.3.
    init_system_check('GD JPG Support', !empty($gd_info['JPG Support']) || !empty($gd_info['JPEG Support']) ? T_('Read/Write') : T_('No'));
    if (empty($gd_info['JPG Support']) && empty($gd_info['JPEG Support'])) {
        disp_system_check('warning', T_('You will not be able to automatically generate thumbnails for JPG images.'));
    } else {
        disp_system_check('ok');
    }
    // PNG:
Exemplo n.º 3
0
/**
 * 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;
}