コード例 #1
0
 function get_system_data()
 {
     global $wp_version;
     $phpVersion = phpversion();
     $maxExecutionTime = ini_get('max_execution_time');
     $maxMemoryLimit = ini_get('memory_limit');
     $extensions = implode(', ', get_loaded_extensions());
     $disabledFunctions = ini_get('disable_functions');
     $mysqlVersion = '';
     if (!class_exists('wpdb')) {
         require_once ABSPATH . '/' . WPINC . '/wp-db.php';
     }
     $mysqli = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
     $errors = $mysqli->last_error;
     if (empty($errors)) {
         $mysqlVersion = $mysqli->db_version();
     }
     $upMaxExecutionTime = 0;
     $newMaxExecutionTime = intval($maxExecutionTime) + 60;
     @set_time_limit($newMaxExecutionTime);
     if (ini_get('max_execution_time') == $newMaxExecutionTime) {
         $upMaxExecutionTime = 1;
         $maxExecutionTime = ini_get('max_execution_time');
     }
     $upMemoryLimit = 0;
     $newMemoryLimit = intval($maxMemoryLimit) + 60;
     ini_set('memory_limit', $newMemoryLimit . 'M');
     if (ini_get('memory_limit') == $newMemoryLimit) {
         $upMemoryLimit = 1;
         $maxMemoryLimit = ini_get('memory_limit');
     }
     $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
     $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
     $ex = check_function($extensions, $extensions_search);
     $func = check_function($disabledFunctions, $disabledFunctions_search, true);
     return array('wp_version' => $wp_version, 'php_verion' => phpversion(), 'maxExecutionTime' => $maxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit, 'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions, 'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime, 'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit, 'newMemoryLimit' => $newMaxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit, 'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'));
 }
コード例 #2
0
ファイル: code_quality.php プロジェクト: erico-deh/ocPortal
function check_command($command, $depth, $function_guard = '', $nogo_parameters = NULL)
{
    if (is_null($nogo_parameters)) {
        $nogo_parameters = array();
    }
    global $LOCAL_VARIABLES, $CURRENT_CLASS, $FUNCTION_SIGNATURES;
    foreach ($command as $i => $c) {
        if ($c == array()) {
            continue;
        }
        if (is_integer($c[count($c) - 1])) {
            $c_pos = $c[count($c) - 1];
            $or = false;
        } else {
            $c_pos = $c[count($c) - 2];
            $or = true;
        }
        switch ($c[0]) {
            case 'CALL_METHOD':
                check_method($c, $c_pos, $function_guard);
                break;
            case 'CALL_INDIRECT':
                add_variable_reference($c[1][1], $c_pos);
                break;
            case 'VARIABLE':
                check_variable($c);
                break;
            case 'CALL_DIRECT':
                if (isset($GLOBALS['PEDANTIC'])) {
                    if (isset($GLOBALS['NULL_ERROR_FUNCS'][$c[1]]) || isset($GLOBALS['FALSE_ERROR_FUNCS'][$c[1]])) {
                        log_warning('Crucial return value was not handled', $c_pos);
                    }
                }
                check_call($c, $c_pos, NULL, $function_guard);
                break;
            case 'GLOBAL':
                foreach ($c[1] as $v) {
                    if (isset($LOCAL_VARIABLES[$v[1]]) && !$LOCAL_VARIABLES[$v[1]]['is_global']) {
                        log_warning($v[1] . ' was referenced before this globalisation.', $c_pos);
                    }
                    add_variable_reference($v[1], $c_pos, false);
                    $LOCAL_VARIABLES[$v[1]]['is_global'] = true;
                    $LOCAL_VARIABLES[$v[1]]['unused_value'] = true;
                }
                break;
            case 'RETURN':
                $ret_type = check_expression($c[1], false, false, $function_guard);
                add_variable_reference('__return', $c_pos);
                set_ocportal_type('__return', $ret_type);
                if (!isset($LOCAL_VARIABLES['__return']['mentions'])) {
                    $LOCAL_VARIABLES['__return']['mentions'] = array();
                }
                $LOCAL_VARIABLES['__return']['mentions'][] = $c_pos;
                if (count($command) - 1 > $i) {
                    log_warning('There is unreachable code', $c_pos);
                }
                break;
            case 'SWITCH':
                $switch_type = check_expression($c[1], false, false, $function_guard);
                foreach ($c[2] as $case) {
                    if (!is_null($case[0])) {
                        $passes = ensure_type(array($switch_type), check_expression($case[0], false, false, $function_guard), $c_pos, 'Switch type inconsistency');
                        if ($passes) {
                            infer_expression_type_to_variable_type($switch_type, $case[0]);
                        }
                    }
                    check_command($case[1], $depth + 1, $function_guard, $nogo_parameters);
                }
                break;
            case 'ASSIGNMENT':
                check_assignment($c, $c_pos, $function_guard);
                break;
            case 'IF':
                $t = check_expression($c[1], false, false, $function_guard);
                $passes = ensure_type(array('boolean'), $t, $c_pos, 'Conditionals must be boolean (if) [is ' . $t . ']', true);
                if ($passes) {
                    infer_expression_type_to_variable_type('boolean', $c[1]);
                }
                if ($c[1][0] == 'BOOLEAN_NOT' && $c[1][1][0] == 'CALL_DIRECT' && strpos($c[1][1][1], '_exists') !== false && $c[1][1][2][0][0] == 'LITERAL' && $c[1][1][2][0][1][0] == 'STRING' && ($c[2][0][0] == 'BREAK' || $c[2][0][0] == 'CONTINUE' || $c[2][0][0] == 'RETURN' || $c[2][0][0] == 'CALL_DIRECT' && $c[2][0][1] == 'critical_error')) {
                    $function_guard .= ',' . $c[1][1][2][0][1][1] . ',';
                }
                $temp_function_guard = $function_guard;
                if ($c[1][0] == 'CALL_DIRECT' && strpos($c[1][1], '_exists') !== false && $c[1][2][0][0] == 'LITERAL' && $c[1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][2][0][1][1] . ',';
                }
                if ($c[1][0] == 'BOOLEAN_AND' && $c[1][1][0] == 'BRACKETED' && $c[1][1][1][0] == 'CALL_DIRECT' && strpos($c[1][1][1][1], '_exists') !== false && $c[1][1][1][2][0][0] == 'LITERAL' && $c[1][1][1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][1][1][2][0][1][1] . ',';
                }
                if ($c[1][0] == 'BOOLEAN_AND' && $c[1][2][0] == 'BOOLEAN_AND' && $c[1][2][1][0] == 'BRACKETED' && $c[1][2][1][1][0] == 'CALL_DIRECT' && strpos($c[1][2][1][1][1], '_exists') !== false && $c[1][2][1][1][2][0][0] == 'LITERAL' && $c[1][2][1][1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][2][1][1][2][0][1][1] . ',';
                }
                check_command($c[2], $depth, $temp_function_guard, $nogo_parameters);
                break;
            case 'IF_ELSE':
                $passes = ensure_type(array('boolean'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Conditionals must be boolean (if-else)', true);
                if ($passes) {
                    infer_expression_type_to_variable_type('boolean', $c[1]);
                }
                $temp_function_guard = $function_guard;
                if ($c[1][0] == 'CALL_DIRECT' && strpos($c[1][1], '_exists') !== false && $c[1][2][0][0] == 'LITERAL' && $c[1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][2][0][1][1] . ',';
                }
                if ($c[1][0] == 'BOOLEAN_AND' && $c[1][1][0] == 'BRACKETED' && $c[1][1][1][0] == 'CALL_DIRECT' && strpos($c[1][1][1][1], '_exists') !== false && $c[1][1][1][2][0][0] == 'LITERAL' && $c[1][1][1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][1][1][2][0][1][1] . ',';
                }
                if ($c[1][0] == 'BOOLEAN_AND' && $c[1][2][0] == 'BOOLEAN_AND' && $c[1][2][1][0] == 'BRACKETED' && $c[1][2][1][1][0] == 'CALL_DIRECT' && strpos($c[1][2][1][1][1], '_exists') !== false && $c[1][2][1][1][2][0][0] == 'LITERAL' && $c[1][2][1][1][2][0][1][0] == 'STRING') {
                    $temp_function_guard .= ',' . $c[1][2][1][1][2][0][1][1] . ',';
                }
                check_command($c[2], $depth, $temp_function_guard, $nogo_parameters);
                check_command($c[3], $depth, $function_guard, $nogo_parameters);
                break;
            case 'INNER_FUNCTION':
                $temp = $LOCAL_VARIABLES;
                check_function($c[1]);
                $LOCAL_VARIABLES = $temp;
                break;
            case 'INNER_CLASS':
                $class = $c[1];
                foreach ($class['functions'] as $function) {
                    $temp = $LOCAL_VARIABLES;
                    $LOCAL_VARIABLES['this'] = array('is_global' => false, 'conditioner' => array(), 'conditioned_zero' => false, 'conditioned_false' => false, 'conditioned_null' => false, 'types' => array('object'), 'references' => 0, 'object_type' => $CURRENT_CLASS, 'unused_value' => false, 'first_mention' => 0, 'mixed_tag' => false);
                    check_function($function);
                    $LOCAL_VARIABLES = $temp;
                }
                break;
            case 'TRY':
                check_command($c[1], $depth + 1, $function_guard, $nogo_parameters);
                // Goes first so that we get local variables defined inside loop for use in our loop conditional
                add_variable_reference($c[2][1][0][1], $c_pos, false);
                check_command($c[2][2], $depth + 1, $function_guard);
                // Goes first so that we get local variables defined inside loop for use in our loop conditional
                break;
            case 'FOREACH_map':
                $passes = ensure_type(array('array'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Foreach must take array');
                if ($passes) {
                    infer_expression_type_to_variable_type('array', $c[1]);
                }
                add_variable_reference($c[2][1], $c_pos, false);
                add_variable_reference($c[3][1], $c_pos, false);
                if (in_array($c[2][1], $nogo_parameters)) {
                    log_warning('Re-using a loop variable, ' . $c[2][1], $c_pos);
                }
                if (in_array($c[3][1], $nogo_parameters)) {
                    log_warning('Re-using a loop variable, ' . $c[3][1], $c_pos);
                }
                check_command($c[4], $depth + 1, $function_guard, array_merge($nogo_parameters, array($c[2][1], $c[3][1])));
                break;
            case 'FOREACH_list':
                $passes = ensure_type(array('array'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Foreach must take array');
                if ($passes) {
                    infer_expression_type_to_variable_type('array', $c[1]);
                }
                add_variable_reference($c[2][1], $c_pos, false);
                if (in_array($c[2][1], $nogo_parameters)) {
                    log_warning('Re-using a loop variable, ' . $c[2][1], $c_pos);
                }
                check_command($c[3], $depth + 1, $function_guard, array_merge($nogo_parameters, array($c[2][1])));
                break;
            case 'FOR':
                if (!is_null($c[1])) {
                    check_command(array($c[1]), $depth + 1, $function_guard);
                }
                check_command(array($c[3]), $depth + 1, $function_guard);
                $passes = ensure_type(array('boolean'), check_expression($c[2], false, false, $function_guard), $c_pos, 'Conditionals must be boolean (for)', true);
                if ($passes) {
                    infer_expression_type_to_variable_type('boolean', $c[2]);
                }
                check_command($c[4], $depth + 1, $function_guard, $nogo_parameters);
                break;
            case 'DO':
                check_command($c[2], $depth + 1, $function_guard, $nogo_parameters);
                // Goes first so that we get local variables defined inside loop for use in our loop conditional
                $passes = ensure_type(array('boolean'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Conditionals must be boolean (do)', true);
                if ($passes) {
                    infer_expression_type_to_variable_type('boolean', $c[1]);
                }
                break;
            case 'WHILE':
                $passes = ensure_type(array('boolean'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Conditionals must be boolean (while)', true);
                if ($passes) {
                    infer_expression_type_to_variable_type('boolean', $c[1]);
                }
                check_command($c[2], $depth + 1, $function_guard, $nogo_parameters);
                break;
            case 'CONTINUE':
                if ($c[1][0] == 'SOLO' && $c[1][1][0] == 'LITERAL' && $c[1][1][1][0] == 'INTEGER') {
                    if ($c[1][1][1][1] > $depth) {
                        log_warning('Continue level greater than loop/switch depth', $c_pos);
                    }
                }
                $passes = ensure_type(array('integer'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Loop/switch control must use integers (continue)');
                if ($passes) {
                    infer_expression_type_to_variable_type('integer', $c[1]);
                }
                break;
            case 'BREAK':
                $passes = ensure_type(array('integer'), check_expression($c[1], false, false, $function_guard), $c_pos, 'Loop/switch control must use integers (break)');
                if ($passes) {
                    infer_expression_type_to_variable_type('integer', $c[1]);
                }
                break;
            case 'PRE_DEC':
                ensure_type(array('integer', 'float'), check_variable($c[1]), $c_pos, 'Can only decrement numbers');
                break;
            case 'PRE_INC':
                ensure_type(array('integer', 'float'), check_variable($c[1]), $c_pos, 'Can only increment numbers');
                break;
            case 'DEC':
                ensure_type(array('integer', 'float'), check_variable($c[1]), $c_pos, 'Can only decrement numbers');
                break;
            case 'INC':
                ensure_type(array('integer', 'float'), check_variable($c[1]), $c_pos, 'Can only increment numbers');
                break;
            case 'ECHO':
                foreach ($c[1] as $e) {
                    $passes = ensure_type(array('string'), check_expression($e, false, false, $function_guard), $c_pos, 'Can only echo strings');
                    if ($passes) {
                        infer_expression_type_to_variable_type('string', $e);
                    }
                }
                break;
        }
        if ($or) {
            check_command(array($c[count($c) - 1]), $depth, $function_guard, $nogo_parameters);
        }
    }
}
コード例 #3
0
ファイル: check_parameters.php プロジェクト: garybulin/php7
/** the main recursion function. splits files in functions and calls the other functions */
function recurse($path)
{
    foreach (scandir($path) as $file) {
        if ($file == '.' || $file == '..' || $file == 'CVS') {
            continue;
        }
        $file = "{$path}/{$file}";
        if (is_dir($file)) {
            recurse($file);
            continue;
        }
        // parse only .c and .cpp files
        if (substr_compare($file, '.c', -2) && substr_compare($file, '.cpp', -4)) {
            continue;
        }
        $txt = file_get_contents($file);
        // remove comments (but preserve the number of lines)
        $txt = preg_replace(array('@//.*@S', '@/\\*.*\\*/@SsUe'), array('', 'preg_replace("/[^\\r\\n]+/S", "", \'$0\')'), $txt);
        $split = preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\\s*\\((\\w+(?:,\\s*\\w+)?)\\)/S', $txt, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
        if (count($split) < 2) {
            continue;
        }
        // no functions defined on this file
        array_shift($split);
        // the first part isn't relevant
        // generate the line offsets array
        $j = 0;
        $lines = preg_split("/(\r\n?|\n)/S", $txt, -1, PREG_SPLIT_DELIM_CAPTURE);
        $lines_offset = array();
        for ($i = 0; $i < count($lines); ++$i) {
            $j += strlen($lines[$i]) + strlen(@$lines[++$i]);
            $lines_offset[] = $j;
        }
        $GLOBALS['lines_offset'] = $lines_offset;
        $GLOBALS['current_file'] = $file;
        for ($i = 0; $i < count($split); $i += 2) {
            // if the /* }}} */ comment is found use it to reduce false positives
            // TODO: check the other indexes
            list($f) = preg_split('@/\\*\\s*}}}\\s*\\*/@S', $split[$i + 1][0]);
            check_function(preg_replace('/\\s*,\\s*/S', '::', $split[$i][0]), $f, $split[$i][1]);
        }
    }
}
コード例 #4
0
 function get_system_data()
 {
     global $wp_version;
     $phpVersion = phpversion();
     $maxExecutionTime = ini_get('max_execution_time');
     $maxMemoryLimit = ini_get('memory_limit');
     $extensions = implode(', ', get_loaded_extensions());
     $disabledFunctions = ini_get('disable_functions');
     $mysqlVersion = '';
     $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD);
     if (!mysqli_connect_errno()) {
         $mysqlVersion = $mysqli->server_info;
     }
     $upMaxExecutionTime = 0;
     $newMaxExecutionTime = intval($maxExecutionTime) + 60;
     @set_time_limit($newMaxExecutionTime);
     if (ini_get('max_execution_time') == $newMaxExecutionTime) {
         $upMaxExecutionTime = 1;
         $maxExecutionTime = ini_get('max_execution_time');
     }
     $upMemoryLimit = 0;
     $newMemoryLimit = intval($maxMemoryLimit) + 60;
     ini_set('memory_limit', $newMemoryLimit . 'M');
     if (ini_get('memory_limit') == $newMemoryLimit) {
         $upMemoryLimit = 1;
         $maxMemoryLimit = ini_get('memory_limit');
     }
     $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
     $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
     $ex = check_function($extensions, $extensions_search);
     $func = check_function($disabledFunctions, $disabledFunctions_search, true);
     return array('wp_version' => $wp_version, 'php_verion' => phpversion(), 'maxExecutionTime' => $maxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit, 'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions, 'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime, 'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit, 'newMemoryLimit' => $newMaxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit, 'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'));
 }
コード例 #5
0
ファイル: check.php プロジェクト: nergal/environment
    return array('is' => !$is, 'message' => $is ? 'Функции расширения <a href="http://php.net/mbstring">mbstring</a> перегружают нативные функции PHP' : 'Да');
}, 'Поддержка FreeType в GD' => function () {
    $is = FALSE;
    $message = 'Нет';
    if (function_exists('gd_info')) {
        $gd = gd_info();
        if ($gd['FreeType Support'] != false) {
            $message = 'Да';
            $is = TRUE;
        }
    }
    return array('is' => $is, 'message' => $message);
}), 'Функции' => array('Функция dl' => function () {
    $is = function_exists('dl') and ini_get('enable_dl');
    return array('is' => !$is, 'message' => $is ? 'Разрешена' : 'Запрещена');
}, 'Вызов link' => check_function('link'), 'Вызов symlink' => check_function('symlink'), 'Вызов system' => check_function('system'), 'Вызов shell_exec' => check_function('shell_exec'), 'Вызов passthru' => check_function('passthru'), 'Вызов exec' => check_function('exec'), 'Вызов pcntl_exec' => check_function('pcntl_exec'), 'Вызов popen' => check_function('popen'), 'Вызов proc_close' => check_function('proc_close'), 'Вызов proc_get_status' => check_function('proc_get_status'), 'Вызов proc_nice' => check_function('proc_nice'), 'Вызов proc_open' => check_function('proc_open'), 'Вызов proc_terminate' => check_function('proc_terminate'), 'Вызов eval' => check_function('eval'), 'Вызов php_uname' => check_function('!php_uname'), 'Вызов base64_decode' => check_function('!base64_decode'), 'Вызов fpassthru' => check_function('!fpassthru'), 'Вызов ini_set' => check_function('!ini_set')));
if (PHP_SAPI !== 'cli') {
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Open Media Group PHP Установка</title>
	<style type="text/css">
	body { width: 42em; margin: 0 auto; font-family: sans-serif; background: #fff; font-size: 1em; }
	h1 { letter-spacing: -0.04em; }
	h1 + p { margin: 0 0 2em; color: #333; font-size: 90%; font-style: italic; }
	code { font-family: monaco, monospace; }
	table { border-collapse: collapse; width: 100%; }
		table th,
		table td { padding: 0.4em; text-align: left; vertical-align: top; }