Example #1
0
function xls_check_server_environment()
{
    $phpinfo = parse_php_info();
    //We check all the elements we need for a successful install and pass back the report
    $checked = array();
    $checked['MySQLi'] = isset($phpinfo['mysqli']) ? "pass" : "fail";
    $checked['PHP Session'] = $phpinfo['session']['Session Support'] == "enabled" ? "pass" : "fail";
    $checked['cURL Support'] = isset($phpinfo['curl']) ? "pass" : "fail";
    if ($checked['cURL Support'] == "pass") {
        $checked['cURL SSL Support'] = stripos($phpinfo['curl']['cURL Information'], "OpenSSL") !== false || stripos($phpinfo['curl']['cURL Information'], "NSS") !== false || $phpinfo['curl']['SSL'] == "Yes" ? "pass" : "fail";
    }
    $checked['Multi-Byte String Library'] = $phpinfo['mbstring']['Multibyte Support'] == "enabled" ? "pass" : "fail";
    $checked['GD Library'] = $phpinfo['gd']['GD Support'] == "enabled" ? "pass" : "fail";
    $checked['GD Library GIF'] = $phpinfo['gd']['GIF Create Support'] == "enabled" ? "pass" : "fail";
    if (isset($phpinfo['gd']['JPG Support'])) {
        $checked['GD Library JPG'] = $phpinfo['gd']['JPG Support'] == "enabled" ? "pass" : "fail";
    } else {
        $checked['GD Library JPG'] = "fail";
    }
    if ($checked['GD Library JPG'] == "fail") {
        $checked['GD Library JPG'] = $phpinfo['gd']['JPEG Support'] == "enabled" ? "pass" : "fail";
    }
    $checked['GD Library PNG'] = $phpinfo['gd']['PNG Support'] == "enabled" ? "pass" : "fail";
    $checked['MCrypt Encryption Library'] = isset($phpinfo['mcrypt']) ? "pass" : "fail";
    $checked['session.use_cookies must be turned On'] = $phpinfo['session']['session.use_cookies'] == "On" ? "pass" : "fail";
    $checked['PDO Library'] = isset($phpinfo['PDO']) ? "pass" : "fail";
    $checked['pdo_mysql Library'] = isset($phpinfo['pdo_mysql']) ? "pass" : "fail";
    $checked['Php_xml library'] = isset($phpinfo['xml']) ? "pass" : "fail";
    $checked['Zip Library'] = isset($phpinfo['zip']) ? "pass" : "fail";
    $checked['Soap Library'] = $phpinfo['soap']['Soap Client'] == "enabled" ? "pass" : "fail";
    $checked['OpenSSL'] = $phpinfo['openssl']['OpenSSL support'] == "enabled" ? "pass" : "fail";
    //Check php.ini settings
    //Removed in 5.4.0 so just check if we're running an older version
    if (version_compare(PHP_VERSION, '5.4.0', '<')) {
        $checked['magic_quotes_gpc in Php.ini must be turned Off'] = $phpinfo['Core']['magic_quotes_gpc'] == "Off" ? "pass" : "fail";
        $checked['allow_call_time_pass_reference in Php.ini must be turned On'] = $phpinfo['Core']['allow_call_time_pass_reference'] == "On" ? "pass" : "fail";
        $checked['register_globals in Php.ini must be turned Off'] = $phpinfo['Core']['register_globals'] == "Off" ? "pass" : "fail";
        $checked['short_open_tag in Php.ini must be turned On'] = $phpinfo['Core']['short_open_tag'] == "On" ? "pass" : "fail";
    }
    if (version_compare(PHP_VERSION, '5.3.27', '>=')) {
        $checked['Default timezone'] = $phpinfo['date']['date.timezone'] == "no value" ? "fail" : "pass";
    }
    //Check folder permissions
    if (file_exists('images')) {
        $checked['/images folder must be writeable'] = is_writable('images') ? "pass" : "fail";
    }
    if (file_exists('assets')) {
        $checked['/assets folder must be writeable'] = is_writable('assets') ? "pass" : "fail";
    }
    if (file_exists('runtime')) {
        $checked['/runtime folder must be writeable'] = is_writable('runtime') ? "pass" : "fail";
    }
    if (file_exists('runtime/cache')) {
        $checked['/runtime/cache folder must be writeable'] = is_writable('runtime/cache') ? "pass" : "fail";
    }
    if (file_exists('config')) {
        $checked['/config folder must be writeable'] = is_writable('config') ? "pass" : "fail";
    }
    //If any of our items fail, be helpful and show them where the php.ini is. Otherwise, we hide it since working servers shouldn't advertise this
    if (in_array('fail', $checked)) {
        $checked = array_merge(array('<b>php.ini file is at</b> ' . $phpinfo['phpinfotemp']['Loaded Configuration File'] => "pass"), $checked);
    }
    return $checked;
}
Example #2
0
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id$
 */
function build_server_stats($is_install = 1, $prev_version = '', $current_version = '', $charset = '')
{
    $info = array();
    // Is this an upgrade or an install?
    if ($is_install == 1) {
        $info['is_install'] = 1;
    } else {
        $info['is_install'] = 0;
    }
    // If we are upgrading....
    if ($info['is_install'] == 0) {
        // What was the previous version?
        $info['prev_version'] = $prev_version;
    }
    // What's our current version?
    $info['current_version'] = $current_version;
    // What is our current charset?
    $info['charset'] = $charset;
    // Parse phpinfo into array
    $phpinfo = parse_php_info();
    // PHP Version
    $info['phpversion'] = phpversion();
    // MySQL Version
    $info['mysql'] = 0;
    if (array_key_exists('mysql', $phpinfo)) {
        $info['mysql'] = $phpinfo['mysql']['Client API version'];
    }
    // PostgreSQL Version
    $info['pgsql'] = 0;
    if (array_key_exists('pgsql', $phpinfo)) {
        $info['pgsql'] = $phpinfo['pgsql']['PostgreSQL(libpq) Version'];
    }
    // SQLite Version
    $info['sqlite'] = 0;
    if (array_key_exists('sqlite', $phpinfo)) {
        $info['sqlite'] = $phpinfo['sqlite']['SQLite Library'];
    }
    // Iconv Library Extension Version
    $info['iconvlib'] = 0;
    if (array_key_exists('iconv', $phpinfo)) {
        $info['iconvlib'] = html_entity_decode($phpinfo['iconv']['iconv implementation']) . "|" . $phpinfo['iconv']['iconv library version'];
    }
    // Check GD & Version
    $info['gd'] = 0;
    if (array_key_exists('gd', $phpinfo)) {
        $info['gd'] = $phpinfo['gd']['GD Version'];
    }
    // CGI Mode
    $sapi_type = php_sapi_name();
    $info['cgimode'] = 0;
    if (strpos($sapi_type, 'cgi') !== false) {
        $info['cgimode'] = 1;
    }
    // Server Software
    $info['server_software'] = $_SERVER['SERVER_SOFTWARE'];
    // Allow url fopen php.ini setting
    $info['allow_url_fopen'] = 0;
    if (ini_get('safe_mode') == 0 && ini_get('allow_url_fopen')) {
        $info['allow_url_fopen'] = 1;
    }
    // Check classes, extensions, php info, functions, and php ini settings
    $check = array('classes' => array('dom' => array('bitwise' => 1, 'title' => 'DOMElement'), 'soap' => array('bitwise' => 2, 'title' => 'SoapClient'), 'xmlwriter' => array('bitwise' => 4, 'title' => 'XMLWriter'), 'imagemagick' => array('bitwise' => 8, 'title' => 'Imagick')), 'extensions' => array('zendopt' => array('bitwise' => 1, 'title' => 'Zend Optimizer'), 'xcache' => array('bitwise' => 2, 'title' => 'XCache'), 'eaccelerator' => array('bitwise' => 4, 'title' => 'eAccelerator'), 'ioncube' => array('bitwise' => 8, 'title' => 'ionCube Loader'), 'PDO' => array('bitwise' => 16, 'title' => 'PDO'), 'pdo_mysql' => array('bitwise' => 32, 'title' => 'pdo_mysql'), 'pdo_pgsql' => array('bitwise' => 64, 'title' => 'pdo_pgsql'), 'pdo_sqlite' => array('bitwise' => 128, 'title' => 'pdo_sqlite'), 'pdo_oci' => array('bitwise' => 256, 'title' => 'pdo_oci'), 'pdo_odbc' => array('bitwise' => 512, 'title' => 'pdo_odbc')), 'phpinfo' => array('zlib' => array('bitwise' => 1, 'title' => 'zlib'), 'mbstring' => array('bitwise' => 2, 'title' => 'mbstring'), 'exif' => array('bitwise' => 4, 'title' => 'exif'), 'zlib' => array('bitwise' => 8, 'title' => 'zlib')), 'functions' => array('sockets' => array('bitwise' => 1, 'title' => 'fsockopen'), 'mcrypt' => array('bitwise' => 2, 'title' => 'mcrypt_encrypt'), 'simplexml' => array('bitwise' => 4, 'title' => 'simplexml_load_string'), 'ldap' => array('bitwise' => 8, 'title' => 'ldap_connect'), 'mysqli' => array('bitwise' => 16, 'title' => 'mysqli_connect'), 'imap' => array('bitwise' => 32, 'title' => 'imap_open'), 'ftp' => array('bitwise' => 64, 'title' => 'ftp_login'), 'pspell' => array('bitwise' => 128, 'title' => 'pspell_new'), 'apc' => array('bitwise' => 256, 'title' => 'apc_cache_info'), 'curl' => array('bitwise' => 512, 'title' => 'curl_init'), 'iconv' => array('bitwise' => 1024, 'title' => 'iconv')), 'php_ini' => array('post_max_size' => 'post_max_size', 'upload_max_filesize' => 'upload_max_filesize', 'safe_mode' => 'safe_mode'));
    foreach ($check as $cat_name => $category) {
        foreach ($category as $name => $what) {
            switch ($cat_name) {
                case "classes":
                    if (class_exists($what['title'])) {
                        $info[$cat_name] |= $what['bitwise'];
                    }
                    break;
                case "extensions":
                    if (extension_loaded($what['title'])) {
                        $info[$cat_name] |= $what['bitwise'];
                    }
                    break;
                case "phpinfo":
                    if (array_key_exists($what['title'], $phpinfo)) {
                        $info[$cat_name] |= $what['bitwise'];
                    }
                    break;
                case "functions":
                    if (function_exists($what['title'])) {
                        $info[$cat_name] |= $what['bitwise'];
                    }
                    break;
                case "php_ini":
                    if (ini_get($what) != 0) {
                        $info[$name] = ini_get($what);
                    } else {
                        $info[$name] = 0;
                    }
                    break;
            }
        }
    }
    // Host URL & hostname
    $info['hosturl'] = $info['hostname'] = "unknown/local";
    if ($_SERVER['HTTP_HOST'] == 'localhost') {
        $info['hosturl'] = $info['hostname'] = "localhost";
    }
    // Check the hosting company
    if (strpos($_SERVER['HTTP_HOST'], ".") !== false) {
        $host_url = "http://www.whoishostingthis.com/" . str_replace(array('http://', 'www.'), '', $_SERVER['HTTP_HOST']);
        $hosting = fetch_remote_file($host_url);
        if ($hosting) {
            preg_match('#We believe \\<a href\\="http:\\/\\/www.whoishostingthis.com\\/linkout\\/\\?t\\=[0-9]&url\\=?([^"]*)" (title="([^"]*)" )target\\=\\_blank\\>([^<]*)\\<\\/a\\>#ism', $hosting, $matches);
            $info['hosturl'] = "unknown/no-url";
            if (isset($matches[1]) && strlen(trim($matches[1])) != 0 && strpos($matches[1], '.') !== false) {
                $info['hosturl'] = strtolower($matches[1]);
            } else {
                if (isset($matches[3]) && strlen(trim($matches[3])) != 0 && strpos($matches[3], '.') !== false) {
                    $info['hosturl'] = strtolower($matches[3]);
                }
            }
            if (isset($matches[4]) && strlen(trim($matches[4])) != 0) {
                $info['hostname'] = $matches[4];
            } elseif (isset($matches[3]) && strlen(trim($matches[3])) != 0) {
                $info['hostname'] = $matches[3];
            } elseif (isset($matches[2]) && strlen(trim($matches[2])) != 0) {
                $info['hostname'] = str_replace(array('title=', '"'), '', $matches[2][0]);
            } elseif (strlen(trim($info['hosturl'])) != 0 && $info['hosturl'] != "unknown/no-url") {
                $info['hostname'] = $info['hosturl'];
            } else {
                $info['hostname'] = "unknown/no-name";
            }
        }
    }
    if (isset($_SERVER['HTTP_USER_AGENT'])) {
        $info['useragent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    // We need a unique ID for the host so hash it to keep it private and send it over
    $id = $_SERVER['HTTP_HOST'] . time();
    if (function_exists('sha1')) {
        $info['id'] = sha1($id);
    } else {
        $info['id'] = md5($id);
    }
    $string = "";
    $amp = "";
    foreach ($info as $key => $value) {
        $string .= $amp . $key . "=" . urlencode($value);
        $amp = "&amp;";
    }
    $server_stats_url = 'http://www.mybb.com/stats.php?' . $string;
    $return = array();
    $return['info_sent_success'] = false;
    if (fetch_remote_file($url) !== false) {
        $return['info_sent_success'] = true;
    }
    $return['info_image'] = "<img src='http://www.mybb.com/stats.php?{$string}&amp;img=1' />";
    $return['info_get_string'] = $string;
    return $return;
}