/** * Get upload_max_filesize value in bytes defined in php.ini. * If value is not defined in php.ini, returns default 2M. * * @static * * @return int */ public static function getMaxUploadSize() { $maxSize = trim(ini_get('upload_max_filesize')); if ($maxSize === '') { $maxSize = '2m'; // PHP default value } return str2mem($maxSize); }
function check_php_upload_max_filesize() { $required = 2 * 1024 * 1024; $recommended = 16 * 1024 * 1024; $current = ini_get('upload_max_filesize'); if (str2mem($current) >= $recommended) { $req = 2; } else { if (str2mem($current) >= $required) { $req = 1; } else { $req = 0; } } $result = array('name' => S_PHP_UPLOAD_MAX_FILESIZE, 'current' => $current, 'required' => mem2str($required), 'recommended' => mem2str($recommended), 'result' => $req, 'error' => mem2str($required) . SPACE . S_IS_MINIMAL_FOR_PHP_ULOAD_FILESIZE_SMALL); return $result; }
/** * Checks for minimum PHP upload max filesize. * * @return array */ public function checkPhpUploadMaxFilesize() { $current = ini_get('upload_max_filesize'); return array('name' => _('PHP option upload_max_filesize'), 'current' => $current, 'required' => mem2str(self::MIN_PHP_UPLOAD_MAX_FILESIZE), 'result' => str2mem($current) >= self::MIN_PHP_UPLOAD_MAX_FILESIZE ? self::CHECK_OK : self::CHECK_FATAL, 'error' => _s('Minimum required PHP upload filesize is %s (configuration option "upload_max_filesize").', mem2str(self::MIN_PHP_UPLOAD_MAX_FILESIZE))); }
function stage2() { $final_result = true; $table = new CTable(null, 'requirements'); $table->setAlign('center'); /* Check PHP version */ $table->addRow($this->get_test_result($final_result, 'PHP version: ', phpversion(), version_compare(phpversion(), '4.3.0', '>='), 'Minimal version of PHP is 4.3.0')); $memory_limit = str2mem(ini_get('memory_limit')); $table->addRow($this->get_test_result($final_result, 'PHP Memory limit:', function_exists('memory_get_usage') ? mem2str($memory_limit) : 'unlimited', $memory_limit >= 8 * 1024 * 1024 || !function_exists('memory_get_usage'), '8M is a minimal PHP memory limitation')); $memory_limit = str2mem(ini_get('post_max_size')); $table->addRow($this->get_test_result($final_result, 'PHP post max size:', mem2str($memory_limit), $memory_limit >= 8 * 1024 * 1024, '8M is minimum size of PHP post')); $table->addRow($this->get_test_result($final_result, 'PHP max execution time:', ini_get('max_execution_time') . ' sec', ini_get('max_execution_time') >= 300, '300 sec is a maximal limitation on execution of PHP scripts')); /* Check supporteds databases */ global $ZBX_CONFIG; $table->addRow($this->get_test_result($final_result, 'PHP Databases support: ', new CScript(implode(SBR, $ZBX_CONFIG['allowed_db'])), !isset($ZBX_CONFIG['allowed_db']['no']), 'Required any databases support [MySQL or PostgreSQL or Oracle]')); /* Check BC math */ $bcmath_fnc_exist = function_exists('bcadd') && function_exists('bccomp') && function_exists('bcdiv') && function_exists('bcmod') && function_exists('bcmul') && function_exists('bcpow') && function_exists('bcscale') && function_exists('bcsqrt') && function_exists('bcsub'); $table->addRow($this->get_test_result($final_result, 'PHP BC math support', $bcmath_fnc_exist ? 'yes' : 'no', $bcmath_fnc_exist, 'Required bcmath module [configured PHP with --enable-bcmath]')); /* Check mb-strings $mbstrings_fnc_exist = mbstrings_available(); $table->addRow( $this->get_test_result( $final_result, 'PHP MB String support', $mbstrings_fnc_exist ? 'yes' : 'no', $mbstrings_fnc_exist, 'Required Multibyte String module [configured PHP with --enable-mbstring]')); //*/ /* Check GD existence */ $gd_version = S_NO; if (is_callable('gd_info')) { $gd_info = gd_info(); $gd_version = $gd_info['GD Version']; } $table->addRow($this->get_test_result($final_result, 'GD Version:', $gd_version, $gd_version != S_NO, 'The GD extension isn\'t loaded.')); /* Check supported image formats */ $img_formats = array(); if (isset($gd_info)) { //if($gd_info['JPG Support']) array_push($img_formats, 'JPEG'); if ($gd_info['PNG Support']) { array_push($img_formats, 'PNG'); } } if (count($img_formats) == 0) { $img_formats = array(S_NO); $no_img_formats = true; } $table->addRow($this->get_test_result($final_result, 'Image formats:', $img_formats, !isset($no_img_formats), 'Required images genetarion support [PNG]')); if (version_compare(phpversion(), '5.1.0RC1', '>=')) { $tmezone = ini_get('date.timezone'); $table->addRow($this->get_test_result($final_result, 'PHP Timezone:', empty($tmezone) ? 'n/a' : $tmezone, !empty($tmezone), 'Timezone for PHP is not set. Please set "date.timezone" option in php.ini.')); unset($tmezone); } if (!$final_result) { $this->DISABLE_NEXT_BUTTON = true; $this->addVar('trouble', true); $final_result = array(new CSpan(S_FAIL, 'fail'), BR(), BR(), 'Please correct all issuse and press "Retry" button', BR(), BR(), new CButton('retry', S_RETRY)); } else { $this->DISABLE_NEXT_BUTTON = false; $final_result = new CSpan(S_OK, 'ok'); } return array($table, BR(), $final_result); }