function check_expression($e, $assignment = false, $equate_false = false, $function_guard = '') { $c_pos = $e[count($e) - 1]; if ($e[0] == 'CREATE_ARRAY') { return 'array'; } if ($e[0] == 'VARIABLE_REFERENCE') { $e = $e[1]; } if ($e[0] == 'SOLO') { $type = check_expression($e[1], false, false, $function_guard); return $type; } if (in_array($e[0], array('DIVIDE', 'REMAINDER', 'DIV_EQUAL')) && $e[2][0] != 'LITERAL') { if ($assignment && @count($e[2][1][2]) == 0) { $GLOBALS['LOCAL_VARIABLES'][$e[2][1][1]]['conditioner'][] = '_divide_'; } elseif (isset($GLOBALS['PEDANTIC'])) { log_warning('Divide by zero un-handled', $c_pos); } } if ($e[0] == 'UNARY_IF') { if ($e[1][0] == 'CALL_DIRECT' && strpos($e[1][1], '_exists') !== false && $e[1][2][0][0] == 'LITERAL' && $e[1][2][0][1][0] == 'STRING') { $function_guard .= ',' . $e[1][2][0][1][1] . ','; } $passes = ensure_type(array('boolean'), check_expression($e[1], false, false, $function_guard), $c_pos, 'Conditionals must be boolean (unary)'); if ($passes) { infer_expression_type_to_variable_type('boolean', $e[1]); } $type_a = check_expression($e[2][0], false, false, $function_guard); $type_b = check_expression($e[2][1], false, false, $function_guard); if ($type_a != 'NULL' && $type_b != 'NULL') { $passes = ensure_type(array($type_a, 'mixed'), $type_b, $c_pos, 'Type symettry error in unary operator'); if ($passes) { infer_expression_type_to_variable_type($type_a, $e[2][1]); } } return $type_a; } if (in_array($e[0], array('BOOLEAN_AND', 'BOOLEAN_OR', 'BOOLEAN_XOR'))) { if ($e[0] == 'BOOLEAN_AND' && $e[1][0] == 'BRACKETED' && $e[1][1][0] == 'CALL_DIRECT' && strpos($e[1][1][1], '_exists') !== false && $e[1][1][2][0][0] == 'LITERAL' && $e[1][1][2][0][1][0] == 'STRING') { $function_guard .= ',' . $e[1][1][2][0][1][1] . ','; } if ($e[0] == 'BOOLEAN_AND' && $e[2][0] == 'BOOLEAN_AND' && $e[2][1][0] == 'BRACKETED' && $e[2][1][1][0] == 'CALL_DIRECT' && strpos($e[2][1][1][1], '_exists') !== false && $e[2][1][1][2][0][0] == 'LITERAL' && $e[2][1][1][2][0][1][0] == 'STRING') { $function_guard .= ',' . $e[2][1][1][2][0][1][1] . ','; } $passes = ensure_type(array('boolean'), check_expression($e[1], false, false, $function_guard), $c_pos - 1, 'Can only use boolean combinators with booleans'); if ($passes) { infer_expression_type_to_variable_type('boolean', $e[1]); } $passes = ensure_type(array('boolean'), check_expression($e[2], false, false, $function_guard), $c_pos, 'Can only use boolean combinators with booleans'); if ($passes) { infer_expression_type_to_variable_type('boolean', $e[2]); } return 'boolean'; } if (in_array($e[0], array('SL', 'SR', 'REMAINDER'))) { $passes = ensure_type(array('integer'), check_expression($e[1], false, false, $function_guard), $c_pos - 1, 'Can only use integer combinators with integers'); if ($passes) { infer_expression_type_to_variable_type('integer', $e[1]); } $passes = ensure_type(array('integer'), check_expression($e[2], false, false, $function_guard), $c_pos, 'Can only use integer combinators with integers'); if ($passes) { infer_expression_type_to_variable_type('integer', $e[2]); } return 'integer'; } if (in_array($e[0], array('CONC'))) { $type_a = check_expression($e[1], false, false, $function_guard); $type_b = check_expression($e[2], false, false, $function_guard); $passes = ensure_type(array('string'), $type_a, $c_pos - 1, 'Can only use string combinators with strings (1) (not ' . $type_a . ')'); if ($passes) { infer_expression_type_to_variable_type('string', $e[1]); } $passes = ensure_type(array('string'), $type_b, $c_pos, 'Can only use string combinators with strings (2) (not ' . $type_b . ')'); if ($passes) { infer_expression_type_to_variable_type('string', $e[2]); } return 'string'; } if (in_array($e[0], array('SUBTRACT', 'MULTIPLY', 'DIVIDE'))) { $type_a = check_expression($e[1], false, false, $function_guard); $t = check_expression($e[2], false, false, $function_guard); ensure_type(array('integer', 'float'), $type_a, $c_pos - 1, 'Can only use arithmetical combinators with numbers (1) (not ' . $type_a . ')'); ensure_type(array('integer', 'float'), $t, $c_pos, 'Can only use arithmetical combinators with numbers (2) (not ' . $t . ')'); return $e[0] == 'DIVIDE' ? 'float' : $type_a; } if (in_array($e[0], array('ADD'))) { $type_a = check_expression($e[1], false, false, $function_guard); $t = check_expression($e[2], false, false, $function_guard); ensure_type(array('integer', 'float', 'array'), $type_a, $c_pos - 1, 'Can only use + combinator with numbers/arrays (1) (not ' . $type_a . ')'); ensure_type(array('integer', 'float', 'array'), $t, $c_pos, 'Can only use + combinator with numbers/arrays (2) (not ' . $t . ')'); return $type_a; } if (in_array($e[0], array('IS_GREATER_OR_EQUAL', 'IS_SMALLER_OR_EQUAL', 'IS_GREATER', 'IS_SMALLER'))) { $type_a = check_expression($e[1], false, false, $function_guard); $type_b = check_expression($e[2], false, false, $function_guard); ensure_type(array('integer', 'float', 'string'), $type_a, $c_pos - 1, 'Can only use arithmetical comparators with numbers or strings'); ensure_type(array('integer', 'float', 'string'), $type_b, $c_pos, 'Can only use arithmetical comparators with numbers or strings'); ensure_type(array($type_a), $type_b, $c_pos, 'Comparators must have type symettric operands (' . $type_a . ' vs ' . $type_b . ')'); return 'boolean'; } if (in_array($e[0], array('IS_EQUAL', 'IS_IDENTICAL', 'IS_NOT_IDENTICAL', 'IS_NOT_EQUAL'))) { $type_a = check_expression($e[1], false, in_array($e[0], array('IS_IDENTICAL', 'IS_NOT_IDENTICAL')) && $e[2][0] == 'LITERAL' && $e[2][1][0] == 'BOOLEAN' && !$e[2][1][1], $function_guard); $type_b = check_expression($e[2], false, false, $function_guard); $x = $e; if ($x[1][0] == 'EMBEDDED_ASSIGNMENT') { $x = $e[1]; } if ($x[1][0] == 'VARIABLE' && @count($x[1][1][2]) == 0 && $e[2][0] == 'LITERAL') { if (in_array($e[0], array('IS_IDENTICAL', 'IS_NOT_IDENTICAL'))) { if ($e[2][1][0] == 'BOOLEAN' && !$e[2][1][1]) { $GLOBALS['LOCAL_VARIABLES'][$x[1][1][1]]['conditioned_false'] = true; } elseif ($e[2][1][0] == 'NULL') { $GLOBALS['LOCAL_VARIABLES'][$x[1][1][1]]['conditioned_null'] = true; } } if ($e[2][1][0] == 'INTEGER' && $e[2][1][1] == 0) { $GLOBALS['LOCAL_VARIABLES'][$x[1][1][1]]['conditioned_zero'] = true; } } if ($e[0] == 'IS_EQUAL' && $e[2][0] == 'LITERAL' && $e[2][1][0] == 'BOOLEAN') { log_warning('It\'s redundant to equate to truths', $c_pos); } if (strpos($e[0], 'IDENTICAL') === false) { if ($type_b == 'NULL') { log_warning('Comparing to NULL is considered bad', $c_pos); } $passes = ensure_type(array($type_a), $type_b, $c_pos, 'Comparators must have type symettric operands (' . $type_a . ' vs ' . $type_b . ')'); if ($passes) { infer_expression_type_to_variable_type($type_a, $e[2]); } } return 'boolean'; } $inner = $e; switch ($inner[0]) { case 'EMBEDDED_ASSIGNMENT': $ret = check_assignment($inner, $c_pos, $function_guard); return $ret; case 'CALL_METHOD': $ret = check_method($inner, $c_pos, $function_guard); if (is_null($ret)) { log_warning('Method that returns no value used in an expression', $c_pos); return 'mixed'; } return $ret; case 'CALL_INDIRECT': add_variable_reference($inner[1][1], $c_pos); return 'mixed'; case 'CALL_DIRECT': $ret = check_call($inner, $c_pos, NULL, $function_guard); if (is_null($ret)) { log_warning('Function (\'' . $inner[1] . '\') that returns no value used in an expression', $c_pos); return 'mixed'; } if ($inner[1] == 'mixed') { return '*MIXED*'; } if ($assignment) { $GLOBALS['MADE_CALL'] = $inner[1]; if (@$e[2][0][0] == 'VARIABLE' && @count($e[2][0][1][2]) == 0 && $e[1] == 'is_null') { $GLOBALS['LOCAL_VARIABLES'][$e[2][0][1][1]]['conditioned_null'] = true; } } else { if (isset($GLOBALS['PEDANTIC'])) { if (isset($GLOBALS['NULL_ERROR_FUNCS'][$inner[1]])) { log_warning('Crucial error value un-handled', $c_pos); } if (isset($GLOBALS['FALSE_ERROR_FUNCS'][$inner[1]]) && !$equate_false) { log_warning('Crucial error value un-handled', $c_pos); } } } return $ret; break; case 'CASTED': check_expression($inner[2], false, false, $function_guard); return strtolower($inner[1]); case 'BRACKETED': return check_expression($inner[1], false, false, $function_guard); case 'BOOLEAN_NOT': $passes = ensure_type(array('boolean'), check_expression($inner[1], false, false, $function_guard), $c_pos, 'Can only \'NOT\' a boolean', true); if ($passes) { infer_expression_type_to_variable_type('boolean', $inner[1]); } return 'boolean'; case 'BW_NOT': $passes = ensure_type(array('integer'), check_expression($inner[1], false, false, $function_guard), $c_pos, 'Can only \'BITWISE-NOT\' an integer', true); if ($passes) { infer_expression_type_to_variable_type('integer', $inner[1]); } return 'integer'; case 'NEGATE': $type = check_expression($inner[1], false, false, $function_guard); ensure_type(array('integer', 'float'), $type, $c_pos, 'Can only negate a number'); return $type; case 'LITERAL': $type = check_literal($inner[1]); return $type; case 'NEW_OBJECT': global $FUNCTION_SIGNATURES; if (!isset($FUNCTION_SIGNATURES[$inner[1]]) && $FUNCTION_SIGNATURES != array() && strpos($function_guard, ',' . $inner[1] . ',') === false) { if (!is_null($inner[1])) { log_warning('Unknown class, ' . $inner[1], $c_pos); } } foreach ($inner[2] as $param) { check_expression($param, false, false, $function_guard); } if (count($inner[2]) != 0) { check_call(array('CALL_METHOD', $inner[1], $inner[2]), $c_pos, $inner[1], $function_guard); } if ($inner[1] == 'ocp_tempcode') { return 'tempcode'; } return 'object-' . $inner[1]; case 'CLONE_OBJECT': // $a=clone $b will make a shallow copy of the object $, so we just // return $b's type return check_expression($inner[1], false, false, ''); case 'CREATE_ARRAY': foreach ($inner[1] as $param) { check_expression($param[0], false, false, $function_guard); if (isset($param[1])) { check_expression($param[1], false, false, $function_guard); } } return 'array'; case 'VARIABLE': return check_variable($inner, true); } return 'mixed'; }
function install_step2() { global $integria_footertext; global $integria_version; echo "\n\t<div align='center'>\n\t<div id='wizard' >\n\t\t<div id='install_box'>"; echo "<h1>Checking software dependencies</h1>"; echo "<table border='0' width='330' cellpadding='5' cellspacing='5'>"; $res = 0; $res += check_variable(phpversion(), "4.3", "PHP version >= 4.3.x", 1); $res += check_extension("mysql", "PHP MySQL extension"); $res += check_extension("gd", "PHP gd extension"); $res += check_extension("session", "PHP session extension"); $res += check_extension("mbstring", "PHP multibyte extension"); $res += check_extension("ldap", "PHP ldap extension"); $res += check_extension("gettext", "PHP gettext extension"); $res += check_extension("imap", "PHP IMAP extension"); $res += check_extension("gettext", "PHP gettext extension"); $res += check_extension("phar", "PHP Phar extension"); //$res += check_include("PEAR.php","PEAR PHP Library"); $res += check_writable("./include", "./include writable by HTTP server"); $res += check_writable("./attachment/tmp", "./attachment/tmp writable by HTTP server"); echo "</table>\n\t\t</div>\n\t\t<div class='box'>\n\t\t\t<img src='images/integria_white.png' alt=''>\n\t\t\t<br><br>\n\t\t\t<font size=1px>" . $integria_version . "</font>\n\t\t</div>\n\t\t<div class='box'>\n\t\t\t<img src='images/step1.png' alt=''>\n\t\t</div>\n\t\t<div id='install_box' style='margin-bottom: 0px;margin-left: 25px; '>"; if ($res > 0) { echo "<p><img src='images/info.png'> You have some uncomplete \n\t\t\t\tdependencies. Please correct it or this installer \n\t\t\t\tcould not finish your installation.\n\t\t\t\t</p>\n\t\t\t\tIgnore it. <a href='install.php?step=3'>Force install Step #3</a>"; } else { echo "<a href='install.php?step=3'><img align='right' src='images/arrow_next.png' alt=''></a>"; } echo "</div></div>"; }