function server_info() { $lang =& DoceboLanguage::createInstance('configuration', 'framework'); $php_conf = ini_get_all(); $intest = '<div>' . '<div class="label_effect">'; $html = '<div class="conf_line_title">' . $lang->def('_SERVERINFO') . '</div>' . config_line($lang->def('_SERVER_ADDR'), $_SERVER['SERVER_ADDR']) . config_line($lang->def('_SERVER_PORT'), $_SERVER['SERVER_PORT']) . config_line($lang->def('_SERVER_NAME'), $_SERVER['SERVER_NAME']) . config_line($lang->def('_SERVER_ADMIN'), $_SERVER['SERVER_ADMIN']) . config_line($lang->def('_SERVER_SOFTWARE'), $_SERVER['SERVER_SOFTWARE']) . '<br />' . '<div class="conf_line_title">' . $lang->def('_SERVER_MYSQL') . '</div>' . config_line($lang->def('_MYSQL_VERS'), mysql_get_server_info()) . '<br />' . '<div class="conf_line_title">' . $lang->def('_PHPINFO') . '</div>' . config_line($lang->def('_PHPVERSION'), phpversion()) . config_line($lang->def('_SAFEMODE'), $php_conf['safe_mode']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_REGISTER_GLOBAL'), $php_conf['register_globals']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_MAGIC_QUOTES_GPC'), $php_conf['magic_quotes_gpc']['local_value'] ? $lang->def('_ON') : $lang->def('_OFF')) . config_line($lang->def('_UPLOAD_MAX_FILESIZE'), $php_conf['upload_max_filesize']['local_value']) . config_line($lang->def('_POST_MAX_SIZE'), $php_conf['post_max_size']['local_value']) . config_line($lang->def('_MAX_EXECUTION_TIME'), $php_conf['max_execution_time']['local_value'] . 's') . config_line($lang->def('_LDAP'), extension_loaded('ldap') ? $lang->def('_ON') : '<span class="font_red">' . $lang->def('_OFF') . ' ' . $lang->def('_USEFULL_ONLY_IF') . '</span>') . config_line($lang->def('_PHP_TIMEZONE'), @date_default_timezone_get()); if (version_compare(phpversion(), "5.0.0") == -1) { echo config_line($lang->def('_DOMXML'), extension_loaded('domxml') ? $lang->def('_ON') : '<span class="font_red">' . $lang->def('_OFF') . ' (' . $lang->def('_NOTSCORM') . ')</span>'); } if (version_compare(phpversion(), "5.2.0", ">")) { echo config_line($lang->def('_ALLOW_URL_INCLUDE'), $php_conf['allow_url_include']['local_value'] ? '<span class="font_red">' . $lang->def('_ON') . '</span>' : $lang->def('_OFF')); } if (Get::cfg('uploadType') == 'ftp') { if (function_exists("ftp_connect")) { require_once _base_ . '/lib/lib.upload.php'; $re_con = sl_open_fileoperations(); echo config_line($lang->def('_UPLOADFTP'), $re_con ? $lang->def('_FTPOK') : '<span class="font_red">' . $lang->def('_FTPERR') . '</span>'); if ($re_con) { sl_close_fileoperations(); } } else { echo config_line($lang->def('_UPLOADFTP'), '<span class="font_red">' . $lang->def('_FTPERR') . '</span>'); } } echo '<div class="nofloat"></div><br />'; return $html; }
/** server infomation **/ public function doIndex() { $db = $this->_mongo->selectDB("admin"); //command line $query = $db->command(array("getCmdLineOpts" => 1)); if (isset($query["argv"])) { $this->commandLine = implode(" ", $query["argv"]); } else { $this->commandLine = ""; } //web server $this->webServers = array(); if (isset($_SERVER["SERVER_SOFTWARE"])) { list($webServer) = explode(" ", $_SERVER["SERVER_SOFTWARE"]); $this->webServers["Web server"] = $webServer; } $this->webServers["<a href=\"http://www.php.net\" target=\"_blank\">PHP version</a>"] = "PHP " . PHP_VERSION; $this->webServers["<a href=\"http://www.php.net/mongo\" target=\"_blank\">PHP extension</a>"] = "<a href=\"http://pecl.php.net/package/mongo\" target=\"_blank\">mongo</a>/" . RMongo::getVersion(); $this->directives = ini_get_all("mongo"); //build info $ret = $db->command(array("buildinfo" => 1)); $this->buildInfos = array(); if ($ret["ok"]) { unset($ret["ok"]); $this->buildInfos = $ret; } //connection $this->connections = array("Host" => $this->_server->mongoHost(), "Port" => $this->_server->mongoPort(), "Username" => "******", "Password" => "******"); $this->display(); }
function get_smt2wp_diagnose_info() { $wp_base_dir = get_wp_base_dir(); $folders = array('server root' => $_SERVER['DOCUMENT_ROOT'], 'wp root' => $wp_base_dir, 'wp content' => $wp_base_dir . '/wp-content', 'wp uploads' => $wp_base_dir . '/wp-content/uploads', 'smt root' => $wp_base_dir . '/wp-content/plugins/' . basename(dirname(__FILE__))); $folders_check_result = array(); foreach ($folders as $key => $folder) { $folder = smt2wp_sanitize_dir_path($folder); // var_dump($folder); $folders_check_result[$key]['path'] = $folder; $folders_check_result[$key]['permissions'] = base_convert(fileperms($folder), 10, 8); // $folders_check_result[$key]['owner'] = posix_getpwuid(fileowner($folder)); $folders_check_result[$key]['owner_id'] = fileowner($folder); // $folders_check_result[$key]['group'] = posix_getgrgid(filegroup($folder)); $folders_check_result[$key]['group_id'] = filegroup($folder); // $folders_check_result[$key]['other_stats'] = stat($folder); $folders_check_result[$key]['is_writable'] = is_writable($folder); $test_folder = smt2wp_sanitize_dir_path($folder . '/test-348214'); $test_file = $test_folder . '/test-file-6542.txt'; $mkdir = mkdir($test_folder); $put_contents = file_put_contents($test_file, 'this is just a test. you can delete this file'); $delete_file = unlink($test_file); $rm_dir = rmdir($test_folder); $folders_check_result[$key]['can_make_dir'] = $mkdir; $folders_check_result[$key]['can_write_file'] = $put_contents === false ? false : true; $folders_check_result[$key]['can_delete_file'] = $delete_file; $folders_check_result[$key]['can_rm_dir'] = $rm_dir; } $all_ini_settings = ini_get_all(); $separator = '<<+>>'; $res = $separator . json_encode($folders_check_result); $res .= $separator . json_encode($all_ini_settings); // var_dump($all_ini_settings); return $res; }
function __construct() { $this->errors = array(); if (!function_exists('apc_cache_info')) { $this->errors[] = "No cache info available. APC does not appear to be running. "; $this->is_valid = false; } else { $this->time = time(); foreach (range(1, 10) as $i) { self::$allowed_values['AGGR'][$i] = $i; } $this->host = getenv('HOSTNAME'); if ($this->host) { $this->host = '(' . $this->host . ')'; } $this->apc_all = ini_get_all('apc'); $this->cache_opcode = apc_cache_info('opcode', 1); $this->cache_user = apc_cache_info('user', 1); $this->sma_information = apc_sma_info(); $this->MYREQUEST = array(); $this->AUTHENTICATED = false; $this->require_login = false; $this->USE_INTERNAL_AUTHENTICATION = true; $this->is_valid = true; } }
/** * Load all PHP ini Data * * @param bool Always true as it can't be fail. */ protected static function initPHPIniData() { if (!empty(static::$phpIniData)) { return true; } static::$phpIniData = ini_get_all(); return true; }
public static function getIniSettingsAsString() { $result = ''; $iniSettings = ini_get_all(null, false); foreach ($iniSettings as $key => $value) { $result .= sprintf('@ini_set(%s, %s);' . "\n", self::exportVariable($key), self::exportVariable($value)); } return $result; }
function getOptions() { $options = array(); foreach (ini_get_all() as $name => $info) { $parts = explode(".", $name); $options[] = array(count($parts) == 1 ? "" : $parts[0], count($parts) == 1 ? $parts[0] : $parts[1], $info['global_value'], $info['local_value']); } return $options; }
function randomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0) { static $lastRandom = ""; $output = ""; $length = abs((int) $length); $secureValue = ""; $rounds = 0; $drop = 0; while (!isset($output[$length - 1])) { //some entropy, but works ^^ $weakEntropy = array(is_array($startEntropy) ? implode($startEntropy) : $startEntropy, serialize(stat(__FILE__)), __DIR__, PHP_OS, microtime(), (string) lcg_value(), (string) PHP_MAXPATHLEN, PHP_SAPI, (string) PHP_INT_MAX . "." . PHP_INT_SIZE, serialize($_SERVER), serialize(get_defined_constants()), get_current_user(), serialize(ini_get_all()), (string) memory_get_usage() . "." . memory_get_peak_usage(), php_uname(), phpversion(), extension_loaded("gmp") ? gmp_strval(gmp_random(4)) : microtime(), zend_version(), (string) getmypid(), (string) getmyuid(), (string) mt_rand(), (string) getmyinode(), (string) getmygid(), (string) rand(), function_exists("zend_thread_id") ? (string) zend_thread_id() : microtime(), var_export(@get_browser(), true), function_exists("getrusage") ? @implode(getrusage()) : microtime(), function_exists("sys_getloadavg") ? @implode(sys_getloadavg()) : microtime(), serialize(get_loaded_extensions()), sys_get_temp_dir(), (string) disk_free_space("."), (string) disk_total_space("."), uniqid(microtime(), true), file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : microtime()); shuffle($weakEntropy); $value = hash("sha512", implode($weakEntropy), true); $lastRandom .= $value; foreach ($weakEntropy as $k => $c) { //mixing entropy values with XOR and hash randomness extractor $value ^= hash("sha256", $c . microtime() . $k, true) . hash("sha256", mt_rand() . microtime() . $k . $c, true); $value ^= hash("sha512", (string) lcg_value() . $c . microtime() . $k, true); } unset($weakEntropy); if ($secure === true) { $strongEntropyValues = array(is_array($startEntropy) ? hash("sha512", $startEntropy[($rounds + $drop) % count($startEntropy)], true) : hash("sha512", $startEntropy, true), file_exists("/dev/urandom") ? fread(fopen("/dev/urandom", "rb"), 64) : str_repeat("", 64), (function_exists("openssl_random_pseudo_bytes") and version_compare(PHP_VERSION, "5.3.4", ">=")) ? openssl_random_pseudo_bytes(64) : str_repeat("", 64), function_exists("mcrypt_create_iv") ? mcrypt_create_iv(64, MCRYPT_DEV_URANDOM) : str_repeat("", 64), $value); $strongEntropy = array_pop($strongEntropyValues); foreach ($strongEntropyValues as $value) { $strongEntropy = $strongEntropy ^ $value; } $value = ""; //Von Neumann randomness extractor, increases entropy $bitcnt = 0; for ($j = 0; $j < 64; ++$j) { $a = ord($strongEntropy[$j]); for ($i = 0; $i < 8; $i += 2) { $b = ($a & 1 << $i) > 0 ? 1 : 0; if ($b != (($a & 1 << $i + 1) > 0 ? 1 : 0)) { $secureValue |= $b << $bitcnt; if ($bitcnt == 7) { $value .= chr($secureValue); $secureValue = 0; $bitcnt = 0; } else { ++$bitcnt; } ++$drop; } else { $drop += 2; } } } } $output .= substr($value, 0, min($length - strlen($output), $length)); unset($value); ++$rounds; } $lastRandom = hash("sha512", $lastRandom, true); return $raw === false ? bin2hex($output) : $output; }
public static function doRuntimeInfoTable($mem) { $s = APCUtils::tableHeader(wfMsg('viewapc-info-runtime')); $r = 1; foreach (ini_get_all('apc') as $k => $v) { $s .= APCUtils::tableRow($r = 1 - $r, htmlspecialchars($k), str_replace(',', ',<br />', htmlspecialchars($v['local_value']))); } $s .= APCUtils::tableFooter(); return $s; }
private final function __construct() { if (session_id()) { session_unset(); session_destroy(); $_SESSION = array(); } //Get all the ini settings to save time later $ini = ini_get_all(null, false); if ($ini['session.save_handler'] != 'files') { //set default sessions save handler ini_set('session.save_handler', 'files'); } if ($ini['session.use_trans_sid'] != '0') { //disable transparent sid support ini_set('session.use_trans_sid', '0'); } if ($ini['session.gc_probability'] != 15) { //Clean up 15% of the time ini_set('session.gc_probability', 15); } if ($ini['session.gc_divisor'] != 100) { ini_set('session.gc_divisor', 100); } $cookie_domain = $GLOBALS['config']->get('config', 'cookie_domain'); if (!empty($cookie_domain) && strstr($GLOBALS['storeURL'], ltrim($cookie_domain, '.'))) { ini_set('session.cookie_domain', $cookie_domain); } if (!$ini['session.cookie_path']) { ini_set('session.cookie_path', $GLOBALS['rootRel']); } ini_set('session.cookie_httponly', true); //If the current session time is longer we will not change anything if ($ini['session.gc_maxlifetime'] < $this->_session_timeout) { ini_set('session.gc_maxlifetime', $this->_session_timeout); } if ($ini['session.cookie_lifetime'] < $this->_session_timeout) { ini_set('session.cookie_lifetime', $this->_session_timeout); } if (!$ini['session.use_cookies']) { //Enforce cookies only ini_set('session.use_cookies', true); } if (!$ini['session.use_only_cookies']) { // make sure session is cookie based only ini_set('session.use_only_cookies', true); } if (!$ini['session.cookie_httponly']) { // make sure sesison cookies are http ONLY! ini_set('session.cookie_httponly', true); } $this->_start(); $this->_validate(); $this->_setTimers(); }
/** * @return array */ public function bootstrap() { $allowedKeys = array_keys(ini_get_all()); $changedSettings = array(); foreach ($this->settings as $key => $value) { if (in_array($key, $allowedKeys)) { ini_set($key, $value); $changedSettings[$key] = $value; } } return $changedSettings; }
/** * {@inheritdoc} */ protected function render() { $config = ini_get_all(); $maxLength = 0; foreach ($config as $name => $value) { $maxLength = max($maxLength, strlen($name)); } foreach ($config as $name => $value) { $name = str_pad($name, $maxLength, " ", STR_PAD_RIGHT); $this->printText("<<3>>{$name} : <<0>>{$value["local_value"]}\n"); } }
/** * Set the messages specific to this test * */ function _setMessages() { parent::_setMessages(); $this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', "force_redirect is enabled, which is the recommended setting"); $ini = ini_get_all(); if (isset($ini['cgi.force_redirect'])) { $this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', "force_redirect is disabled. In most cases, this is a security vulnerability, but it appears this is not needed because you are running " . $this->skipTest()); $this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', "force_redirect is disabled. In most cases, this is a <strong>serious</strong> security vulnerability. Unless you are absolutely sure this is not needed, enable this setting"); } else { $this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', "force_redirect is disabled because php was not compiled with --enable-force-cgi-redirect. In most cases, this is a security vulnerability, but it appears this is not needed because you are running " . $this->skipTest()); $this->setMessageForResult(PHPSECINFO_TEST_RESULT_WARN, 'en', "force_redirect is disabled because php was not compiled with --enable-force-cgi-redirect. In most cases, this is a <strong>serious</strong> security vulnerability. Unless you are absolutely sure this is not needed, recompile php with --enable-force-cgi-redirect and enable cgi.force_redirect"); } }
public static function readDefaults() { $iniSettings = ini_get_all('session', false); $settings = []; foreach ($iniSettings as $key => $value) { $shortKey = str_replace('session.', '', $key); $settings[$shortKey] = $value; } unset($iniSettings); if (empty($settings['save_path'])) { $settings['save_path'] = sys_get_temp_dir(); } self::$_defaults = $settings; }
/** * @public */ function setParam($sessionName = '', $sessionExpire = 0) { $allIniArray = ini_get_all(); if ($sessionName != '') { $this->mSessionName = $sessionName; } else { $this->mSessionName = $allIniArray['session.name']['global_value']; } if (!empty($sessionExpire)) { $this->mSessionLifetime = 60 * $sessionExpire; } else { $this->mSessionLifetime = $allIniArray['session.cookie_lifetime']['global_value']; } }
/** * Get session options * * @param string $option * @return mixed * @throws \InvalidArgumentException */ public function getOptions($option = null) { $options = array(); foreach (ini_get_all('session') as $name => $value) { $options[substr($name, 8)] = $value['local_value']; } if ($option) { if (array_key_exists($option, $options)) { return $options[$option]; } else { throw new \InvalidArgumentException('Unknown option "$option".'); } } return $options; }
/** * Your main program * * Arguments and options have been parsed when this is run * * @param Options $options * @return void */ protected function main(Options $options) { $tf = new TableFormatter($this->colors); $tf->setBorder(' | '); // nice border between colmns // show a header echo $tf->format(array('*', '30%', '30%'), array('ini setting', 'global', 'local')); // a line across the whole width echo str_pad('', $tf->getMaxWidth(), '-') . "\n"; // colored columns $ini = ini_get_all(); foreach ($ini as $val => $opts) { echo $tf->format(array('*', '30%', '30%'), array($val, $opts['global_value'], $opts['local_value']), array(Colors::C_CYAN, Colors::C_RED, Colors::C_GREEN)); } }
public function actionIndex() { $formatter = new CustomFormatter(); $userCacheInfo = apc_cache_info('user'); $fileCacheInfo = apc_cache_info('opcode'); $mem = apc_sma_info(); $iniSettings = array(); foreach (ini_get_all('apc') as $id => $settings) { $iniSettings[] = array('id' => $id, 'local' => $settings['local_value'], 'global' => $settings['global_value'], 'access' => $settings['access']); } $info = array('apc_version' => phpversion('apc'), 'php_version' => phpversion(), 'host' => $_SERVER['SERVER_NAME'] . ' (' . php_uname('n') . ' [' . $_SERVER['SERVER_ADDR'] . '])', 'server_software' => $_SERVER['SERVER_SOFTWARE'], 'shared_memory' => "{$mem['num_seg']} Segment(s) with {$formatter->formatDatasize($mem['seg_size'])}", 'memory_type' => "{$fileCacheInfo['memory_type']} with {$fileCacheInfo['locking_type']}", 'start_time' => $fileCacheInfo['start_time'], 'file_upload_support' => $fileCacheInfo['file_upload_progress']); $delta = $_SERVER['REQUEST_TIME'] - $fileCacheInfo['start_time']; if ($delta === 0) { $delta = 1; } //prevent div by zero $fileCache = array('cached_files' => $fileCacheInfo['num_entries'], 'cached_file_size' => $fileCacheInfo['mem_size'], 'hits' => $fileCacheInfo['num_hits'], 'misses' => $fileCacheInfo['num_misses'], 'request_rate' => ($fileCacheInfo['num_hits'] + $fileCacheInfo['num_misses']) / $delta, 'hit_rate' => $fileCacheInfo['num_hits'] / $delta, 'miss_rate' => $fileCacheInfo['num_misses'] / $delta, 'insert_rate' => $fileCacheInfo['num_inserts'] / $delta, 'cache_full_count' => $fileCacheInfo['expunges']); $delta = $_SERVER['REQUEST_TIME'] - $userCacheInfo['start_time']; if ($delta === 0) { $delta = 1; } //prevent div by zero $userCache = array('cached_entries' => $userCacheInfo['num_entries'], 'cached_entry_size' => $userCacheInfo['mem_size'], 'hits' => $userCacheInfo['num_hits'], 'misses' => $userCacheInfo['num_misses'], 'request_rate' => ($userCacheInfo['num_hits'] + $userCacheInfo['num_misses']) / $delta, 'hit_rate' => $userCacheInfo['num_hits'] / $delta, 'miss_rate' => $userCacheInfo['num_misses'] / $delta, 'insert_rate' => $userCacheInfo['num_inserts'] / $delta, 'cache_full_count' => $userCacheInfo['expunges']); $position = 0; $freesegs = 0; $fragsize = 0; $freetotal = 0; $blocks = array(); foreach ($mem['block_lists'] as $i => $list) { uasort($list, array($this, 'blockSort')); foreach ($list as $block) { if ($position != $block['offset']) { $blocks[] = array('segment' => $i, 'free' => false, 'offset' => $position, 'size' => $block['offset'] - $position, 'percent' => 100 * ($block['offset'] - $position) / $mem['seg_size']); } $blocks[] = array('segment' => $i, 'free' => true, 'offset' => $block['offset'], 'size' => $block['size'], 'percent' => 100 * $block['size'] / $mem['seg_size']); $position = $block['offset'] + $block['size']; if ($block['size'] < 5 * 1024 * 024) { $fragsize += $block['size']; } $freetotal += $block['size']; } $freesegs += count($list); } if ($position < $mem['seg_size']) { $blocks[] = array('segment' => $i, 'free' => false, 'offset' => $position, 'size' => $smaInfo['seg_size'] - $position, 'percent' => 100 * ($mem['seg_size'] - $position) / $mem['seg_size']); } $this->render('index', array('formatter' => $formatter, 'fileCache' => $fileCache, 'fileCacheList' => $fileCacheInfo['cache_list'], 'userCache' => $userCache, 'userCacheList' => $userCacheInfo['cache_list'], 'iniSettings' => $iniSettings, 'info' => $info, 'blocks' => $blocks, 'fragInfo' => array('freesegs' => $freesegs, 'fragsize' => $fragsize, 'freetotal' => $freetotal))); }
function file_get_contents_ext($host) { $inis = ini_get_all(); if ($inis['allow_url_fopen']['global_value']) { $file_contents = file_get_contents($host); } else { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents; }
/** * 安装引导 */ public function index() { $this->show_nav(array('安装向导' => U('/Home/Index/index'))); $allow_fopen = false; $ini = ini_get_all(); if ($ini['allow_url_fopen']['global_value']) { $allow_fopen = TRUE; } $writable = FALSE; if (is_writable('./')) { $writable = TRUE; } //视图赋值 $this->assign(array('dbtest' => U('/Install/Index/dbtest'), 'install_url' => U('/Install/Index/install'), 'allow_fopen' => $allow_fopen, 'writable' => $writable)); $this->show(); }
function _retrieveCurrentValue() { if (preg_match('/Suhosin/', $_SERVER['SERVER_SOFTWARE'])) { $this->current_value = true; } else { $this->current_value = false; $directives = array('suhosin.log.phpscript', 'suhosin.log.phpscript.is_safe', 'suhosin.log.phpscript.name', 'suhosin.log.sapi', 'suhosin.log.script', 'suhosin.log.script.name', 'suhosin.log.syslog', 'suhosin.log.syslog.facility', 'suhosin.log.syslog.priority', 'suhosin.log.use-x-forwareded-for'); $ini_all = ini_get_all(); foreach ($directives as $directive) { if (isset($ini_all[$directive])) { $this->current_value = true; break; } } } }
public static function phpInfos() { $php = array(); $php['version'] = phpversion(); $iniVars = ini_get_all(); $loadedExtensions = get_loaded_extensions(); // $ext = new ReflectionExtension('mysqli'); // $ext->info(); $memoryPeak = memory_get_peak_usage(); $memoryUsage = memory_get_usage(); $iniLoaded = php_ini_loaded_file(); $iniScanned = php_ini_scanned_files(); $symfony = new Symfony(); $symfony->initRequirements(); $symfony->initOptionalRequirements(); $majesteel = new MajesTeel(); $majesteel->initRequirements(); $majesteel->initOptionalRequirements(); Flight::render('templates/phpInfos.tpl', array('php' => $php, 'iniVars' => $iniVars, 'loadedExtensions' => $loadedExtensions, 'memoryPeak' => $memoryPeak, 'memoryUsage' => $memoryUsage, 'iniLoaded' => $iniLoaded, 'iniScanned' => $iniScanned, 'symfony' => $symfony, 'majesteel' => $majesteel)); }
/** * @ajax */ public function POST() { $rows = null; $rows[] = array(array("value" => "DATASOURCE", "colspan" => 3, "style" => array("fontWeight" => "bold"))); $rs = inf()->datasource->getMap(); foreach ($rs as $k => $v) { $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2)); } $rows[] = array(array("value" => "SAP CONFIG", "colspan" => 3, "style" => array("fontWeight" => "bold"))); $rs = inf()->sap->getMap(); foreach ($rs["conf"] as $k => $v) { $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2)); } foreach ($rs["conn"] as $k => $v) { $rows[] = array(array("value" => $k, "align" => "right"), array("value" => $v, "colspan" => 2)); } $rs = ini_get_all(); unset($rs["url_rewriter.tags"]); $rows[] = array(array("value" => "PHP INI", "colspan" => 3, "style" => array("fontWeight" => "bold"))); foreach ($rs as $k => $v) { $rows[] = array(array("value" => $k, "align" => "right"), $v["global_value"], $v["local_value"]); } return array("rows" => $rows); }
/** * Constructor. Checks if the file has been uploaded * * The constructor takes $_FILES['form_field'] array as argument * where form_field is the form field name * * The constructor will check if the file has been uploaded in its temporary location, and * accordingly will set {@link uploaded} (and {@link error} is an error occurred) * * If the file has been uploaded, the constructor will populate all the variables holding the upload * information (none of the processing class variables are used here). * You can have access to information about the file (name, size, MIME type...). * * * Alternatively, you can set the first argument to be a local filename (string) * This allows processing of a local file, as if the file was uploaded * * The optional second argument allows you to set the language for the error messages * * @access private * @param array $file $_FILES['form_field'] * or string $file Local filename * @param string $lang Optional language code */ function upload($file, $lang = 'en_GB') { $this->version = '0.30'; $this->file_src_name = ''; $this->file_src_name_body = ''; $this->file_src_name_ext = ''; $this->file_src_name_ext_ = ''; $this->file_src_mime = ''; $this->file_src_size = ''; $this->file_src_error = ''; $this->file_src_pathname = ''; $this->file_src_temp = ''; $this->file_dst_path = ''; $this->file_dst_name = ''; $this->file_dst_name_body = ''; $this->file_dst_name_ext = ''; $this->file_dst_pathname = ''; $this->image_src_x = null; $this->image_src_y = null; $this->image_src_bits = null; $this->image_src_type = null; $this->image_src_pixels = null; $this->image_dst_x = 0; $this->image_dst_y = 0; $this->uploaded = true; $this->no_upload_check = false; $this->processed = true; $this->error = ''; $this->log = ''; $this->allowed = array(); $this->forbidden = array(); $this->file_is_image = false; $this->init(); $info = null; $mime_from_browser = null; // sets default language $this->translation = array(); $this->translation['file_error'] = 'File error. Please try again.'; $this->translation['local_file_missing'] = 'Local file doesn\'t exist.'; $this->translation['local_file_not_readable'] = 'Local file is not readable.'; $this->translation['uploaded_too_big_ini'] = 'File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini).'; $this->translation['uploaded_too_big_html'] = 'File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form).'; $this->translation['uploaded_partial'] = 'File upload error (the uploaded file was only partially uploaded).'; $this->translation['uploaded_missing'] = 'File upload error (no file was uploaded).'; $this->translation['uploaded_no_tmp_dir'] = 'File upload error (missing a temporary folder).'; $this->translation['uploaded_cant_write'] = 'File upload error (failed to write file to disk).'; $this->translation['uploaded_err_extension'] = 'File upload error (file upload stopped by extension).'; $this->translation['uploaded_unknown'] = 'File upload error (unknown error code).'; $this->translation['try_again'] = 'File upload error. Please try again.'; $this->translation['file_too_big'] = 'File too big.'; $this->translation['no_mime'] = 'MIME type can\'t be detected.'; $this->translation['incorrect_file'] = 'Incorrect type of file.'; $this->translation['image_too_wide'] = 'Image too wide.'; $this->translation['image_too_narrow'] = 'Image too narrow.'; $this->translation['image_too_high'] = 'Image too high.'; $this->translation['image_too_short'] = 'Image too short.'; $this->translation['ratio_too_high'] = 'Image ratio too high (image too wide).'; $this->translation['ratio_too_low'] = 'Image ratio too low (image too high).'; $this->translation['too_many_pixels'] = 'Image has too many pixels.'; $this->translation['not_enough_pixels'] = 'Image has not enough pixels.'; $this->translation['file_not_uploaded'] = 'File not uploaded. Can\'t carry on a process.'; $this->translation['already_exists'] = '%s already exists. Please change the file name.'; $this->translation['temp_file_missing'] = 'No correct temp source file. Can\'t carry on a process.'; $this->translation['source_missing'] = 'No correct uploaded source file. Can\'t carry on a process.'; $this->translation['destination_dir'] = 'Destination directory can\'t be created. Can\'t carry on a process.'; $this->translation['destination_dir_missing'] = 'Destination directory doesn\'t exist. Can\'t carry on a process.'; $this->translation['destination_path_not_dir'] = 'Destination path is not a directory. Can\'t carry on a process.'; $this->translation['destination_dir_write'] = 'Destination directory can\'t be made writeable. Can\'t carry on a process.'; $this->translation['destination_path_write'] = 'Destination path is not a writeable. Can\'t carry on a process.'; $this->translation['temp_file'] = 'Can\'t create the temporary file. Can\'t carry on a process.'; $this->translation['source_not_readable'] = 'Source file is not readable. Can\'t carry on a process.'; $this->translation['no_create_support'] = 'No create from %s support.'; $this->translation['create_error'] = 'Error in creating %s image from source.'; $this->translation['source_invalid'] = 'Can\'t read image source. Not an image?.'; $this->translation['gd_missing'] = 'GD doesn\'t seem to be present.'; $this->translation['watermark_no_create_support'] = 'No create from %s support, can\'t read watermark.'; $this->translation['watermark_create_error'] = 'No %s read support, can\'t create watermark.'; $this->translation['watermark_invalid'] = 'Unknown image format, can\'t read watermark.'; $this->translation['file_create'] = 'No %s create support.'; $this->translation['no_conversion_type'] = 'No conversion type defined.'; $this->translation['copy_failed'] = 'Error copying file on the server. copy() failed.'; $this->translation['reading_failed'] = 'Error reading the file.'; // determines the language $this->lang = $lang; if ($this->lang != 'en_GB' && file_exists(dirname(__FILE__) . '/lang') && file_exists(dirname(__FILE__) . '/lang/class.upload.' . $lang . '.php')) { $translation = null; include dirname(__FILE__) . '/lang/class.upload.' . $lang . '.php'; if (is_array($translation)) { $this->translation = array_merge($this->translation, $translation); } else { $this->lang = 'en_GB'; } } // determines the supported MIME types, and matching image format $this->image_supported = array(); if ($this->gdversion()) { if (imagetypes() & IMG_GIF) { $this->image_supported['image/gif'] = 'gif'; } if (imagetypes() & IMG_JPG) { $this->image_supported['image/jpg'] = 'jpg'; $this->image_supported['image/jpeg'] = 'jpg'; $this->image_supported['image/pjpeg'] = 'jpg'; } if (imagetypes() & IMG_PNG) { $this->image_supported['image/png'] = 'png'; $this->image_supported['image/x-png'] = 'png'; } if (imagetypes() & IMG_WBMP) { $this->image_supported['image/bmp'] = 'bmp'; $this->image_supported['image/x-ms-bmp'] = 'bmp'; $this->image_supported['image/x-windows-bmp'] = 'bmp'; } } // display some system information if (empty($this->log)) { $this->log .= '<b>system information</b><br />'; $inis = ini_get_all(); $open_basedir = array_key_exists('open_basedir', $inis) && array_key_exists('local_value', $inis['open_basedir']) && !empty($inis['open_basedir']['local_value']) ? $inis['open_basedir']['local_value'] : false; $gd = $this->gdversion() ? $this->gdversion(true) : 'GD not present'; $supported = trim((in_array('png', $this->image_supported) ? 'png' : '') . ' ' . (in_array('jpg', $this->image_supported) ? 'jpg' : '') . ' ' . (in_array('gif', $this->image_supported) ? 'gif' : '') . ' ' . (in_array('bmp', $this->image_supported) ? 'bmp' : '')); $this->log .= '- class version : ' . $this->version . '<br />'; $this->log .= '- operating system : ' . PHP_OS . '<br />'; $this->log .= '- PHP version : ' . PHP_VERSION . '<br />'; $this->log .= '- GD version : ' . $gd . '<br />'; $this->log .= '- supported image types : ' . (!empty($supported) ? $supported : 'none') . '<br />'; $this->log .= '- open_basedir : ' . (!empty($open_basedir) ? $open_basedir : 'no restriction') . '<br />'; $this->log .= '- upload_max_filesize : ' . $this->file_max_size_raw . ' (' . $this->file_max_size . ' bytes)<br />'; $this->log .= '- language : ' . $this->lang . '<br />'; } if (!$file) { $this->uploaded = false; $this->error = $this->translate('file_error'); } // check if we sent a local filename rather than a $_FILE element if (!is_array($file)) { if (empty($file)) { $this->uploaded = false; $this->error = $this->translate('file_error'); } else { $this->no_upload_check = TRUE; // this is a local filename, i.e.not uploaded $this->log .= '<b>' . $this->translate("source is a local file") . ' ' . $file . '</b><br />'; if ($this->uploaded && !file_exists($file)) { $this->uploaded = false; $this->error = $this->translate('local_file_missing'); } if ($this->uploaded && !is_readable($file)) { $this->uploaded = false; $this->error = $this->translate('local_file_not_readable'); } if ($this->uploaded) { $this->file_src_pathname = $file; $this->file_src_name = basename($file); $this->log .= '- local file name OK<br />'; preg_match('/\\.([^\\.]*$)/', $this->file_src_name, $extension); if (is_array($extension) && sizeof($extension) > 0) { $this->file_src_name_ext = strtolower($extension[1]); $this->file_src_name_ext_ = strtolower($extension[1]); $this->file_src_name_body = substr($this->file_src_name, 0, strlen($this->file_src_name) - strlen($this->file_src_name_ext) - 1); } else { $this->file_src_name_ext = ''; $this->file_src_name_ext_ = ''; $this->file_src_name_body = $this->file_src_name; } $this->file_src_size = file_exists($file) ? filesize($file) : 0; } $this->file_src_error = 0; } } else { // this is an element from $_FILE, i.e. an uploaded file $this->log .= '<b>source is an uploaded file</b><br />'; if ($this->uploaded) { $this->file_src_error = trim($file['error']); switch ($this->file_src_error) { case UPLOAD_ERR_OK: // all is OK $this->log .= '- upload OK<br />'; break; case UPLOAD_ERR_INI_SIZE: $this->uploaded = false; $this->error = $this->translate('uploaded_too_big_ini'); break; case UPLOAD_ERR_FORM_SIZE: $this->uploaded = false; $this->error = $this->translate('uploaded_too_big_html'); break; case UPLOAD_ERR_PARTIAL: $this->uploaded = false; $this->error = $this->translate('uploaded_partial'); break; case UPLOAD_ERR_NO_FILE: $this->uploaded = false; $this->error = $this->translate('uploaded_missing'); break; case @UPLOAD_ERR_NO_TMP_DIR: $this->uploaded = false; $this->error = $this->translate('uploaded_no_tmp_dir'); break; case @UPLOAD_ERR_CANT_WRITE: $this->uploaded = false; $this->error = $this->translate('uploaded_cant_write'); break; case @UPLOAD_ERR_EXTENSION: $this->uploaded = false; $this->error = $this->translate('uploaded_err_extension'); break; default: $this->uploaded = false; $this->error = $this->translate('uploaded_unknown') . ' (' . $this->file_src_error . ')'; } } if ($this->uploaded) { $this->file_src_pathname = $file['tmp_name']; $this->file_src_name = $file['name']; if ($this->file_src_name == '') { $this->uploaded = false; $this->error = $this->translate('try_again'); } } if ($this->uploaded) { $this->log .= '- file name OK<br />'; preg_match('/\\.([^\\.]*$)/', $this->file_src_name, $extension); if (is_array($extension) && sizeof($extension) > 0) { $this->file_src_name_ext = strtolower($extension[1]); $this->file_src_name_ext_ = strtolower($extension[1]); $this->file_src_name_body = substr($this->file_src_name, 0, strlen($this->file_src_name) - strlen($this->file_src_name_ext) - 1); } else { $this->file_src_name_ext = ''; $this->file_src_name_ext_ = ''; $this->file_src_name_body = $this->file_src_name; } $this->file_src_size = $file['size']; $mime_from_browser = $file['type']; } } if ($this->uploaded) { $this->log .= '<b>determining MIME type</b><br />'; $this->file_src_mime = null; // checks MIME type with Fileinfo PECL extension if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_fileinfo) { $this->log .= '- Checking MIME type with Fileinfo PECL extension<br />'; if (function_exists('finfo_open')) { if ($this->mime_fileinfo !== '') { if ($this->mime_fileinfo === true) { if (getenv('MAGIC') === FALSE) { if (substr(PHP_OS, 0, 3) == 'WIN') { $path = realpath(ini_get('extension_dir') . '/../') . 'extras/magic'; } else { $path = '/usr/share/file/magic'; } $this->log .= ' MAGIC path defaults to ' . $path . '<br />'; } else { $path = getenv('MAGIC'); $this->log .= ' MAGIC path is set to ' . $path . ' from MAGIC variable<br />'; } } else { $path = $this->mime_fileinfo; $this->log .= ' MAGIC path is set to ' . $path . '<br />'; } $f = @finfo_open(FILEINFO_MIME, $path); } else { $this->log .= ' MAGIC path will not be used<br />'; $f = @finfo_open(FILEINFO_MIME); } if (is_resource($f)) { $mime = finfo_file($f, realpath($this->file_src_pathname)); finfo_close($f); $this->file_src_mime = $mime; $this->log .= ' MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } else { $this->log .= ' Fileinfo PECL extension failed (finfo_open)<br />'; } } elseif (@class_exists('finfo')) { $f = new finfo(FILEINFO_MIME); if ($f) { $this->file_src_mime = $f->file(realpath($this->file_src_pathname)); $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by Fileinfo PECL extension<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } else { $this->log .= ' Fileinfo PECL extension failed (finfo)<br />'; } } else { $this->log .= ' Fileinfo PECL extension not available<br />'; } } else { $this->log .= '- Fileinfo PECL extension deactivated<br />'; } } // checks MIME type with shell if unix access is authorized if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_file) { $this->log .= '- Checking MIME type with UNIX file() command<br />'; if (substr(PHP_OS, 0, 3) != 'WIN') { if (strlen($mime = @exec("file -bi " . escapeshellarg($this->file_src_pathname))) != 0) { $this->file_src_mime = trim($mime); $this->log .= ' MIME type detected as ' . $this->file_src_mime . ' by UNIX file() command<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } else { $this->log .= ' UNIX file() command failed<br />'; } } else { $this->log .= ' UNIX file() command not availabled<br />'; } } else { $this->log .= '- UNIX file() command is deactivated<br />'; } } // checks MIME type with mime_magic if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_magic) { $this->log .= '- Checking MIME type with mime.magic file (mime_content_type())<br />'; if (function_exists('mime_content_type')) { $this->file_src_mime = mime_content_type($this->file_src_pathname); $this->log .= ' MIME type detected as ' . $this->file_src_mime . ' by mime_content_type()<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } else { $this->log .= ' mime_content_type() is not available<br />'; } } else { $this->log .= '- mime.magic file (mime_content_type()) is deactivated<br />'; } } // checks MIME type with getimagesize() if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->mime_getimagesize) { $this->log .= '- Checking MIME type with getimagesize()<br />'; $info = getimagesize($this->file_src_pathname); if (is_array($info) && array_key_exists('mime', $info)) { $this->file_src_mime = trim($info['mime']); if (empty($this->file_src_mime)) { $this->log .= ' MIME empty, guessing from type<br />'; $mime = is_array($info) && array_key_exists(2, $info) ? $info[2] : null; // 1 = GIF, 2 = JPG, 3 = PNG $this->file_src_mime = $mime == IMAGETYPE_GIF ? 'image/gif' : ($mime == IMAGETYPE_JPEG ? 'image/jpeg' : ($mime == IMAGETYPE_PNG ? 'image/png' : ($mime == IMAGETYPE_BMP ? 'image/bmp' : null))); } $this->log .= ' MIME type detected as ' . $this->file_src_mime . ' by PHP getimagesize() function<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } else { $this->log .= ' getimagesize() failed<br />'; } } else { $this->log .= '- getimagesize() is deactivated<br />'; } } // default to MIME from browser (or Flash) if (!empty($mime_from_browser) && !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime)) { $this->file_src_mime = $mime_from_browser; $this->log .= '- MIME type detected as ' . $this->file_src_mime . ' by browser<br />'; if (preg_match("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", $this->file_src_mime)) { $this->file_src_mime = preg_replace("/^([\\.-\\w]+)\\/([\\.-\\w]+)(.*)\$/i", '$1/$2', $this->file_src_mime); $this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />'; } else { $this->file_src_mime = null; } } // we need to work some magic if we upload via Flash if ($this->file_src_mime == 'application/octet-stream' || !$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { if ($this->file_src_mime == 'application/octet-stream') { $this->log .= '- Flash may be rewriting MIME as application/octet-stream<br />'; } $this->log .= '- Try to guess MIME type from file extension (' . $this->file_src_name_ext . '): '; switch ($this->file_src_name_ext) { case 'jpg': case 'jpeg': case 'jpe': $this->file_src_mime = 'image/jpeg'; break; case 'gif': $this->file_src_mime = 'image/gif'; break; case 'png': $this->file_src_mime = 'image/png'; break; case 'bmp': $this->file_src_mime = 'image/bmp'; break; case 'flv': $this->file_src_mime = 'video/x-flv'; break; case 'js': $this->file_src_mime = 'application/x-javascript'; break; case 'json': $this->file_src_mime = 'application/json'; break; case 'tiff': $this->file_src_mime = 'image/tiff'; break; case 'css': $this->file_src_mime = 'text/css'; break; case 'xml': $this->file_src_mime = 'application/xml'; break; case 'doc': case 'docx': $this->file_src_mime = 'application/msword'; break; case 'xls': case 'xlt': case 'xlm': case 'xld': case 'xla': case 'xlc': case 'xlw': case 'xll': $this->file_src_mime = 'application/vnd.ms-excel'; break; case 'ppt': case 'pps': $this->file_src_mime = 'application/vnd.ms-powerpoint'; break; case 'rtf': $this->file_src_mime = 'application/rtf'; break; case 'pdf': $this->file_src_mime = 'application/pdf'; break; case 'html': case 'htm': case 'php': $this->file_src_mime = 'text/html'; break; case 'txt': $this->file_src_mime = 'text/plain'; break; case 'mpeg': case 'mpg': case 'mpe': $this->file_src_mime = 'video/mpeg'; break; case 'mp3': $this->file_src_mime = 'audio/mpeg3'; break; case 'wav': $this->file_src_mime = 'audio/wav'; break; case 'aiff': case 'aif': $this->file_src_mime = 'audio/aiff'; break; case 'avi': $this->file_src_mime = 'video/msvideo'; break; case 'wmv': $this->file_src_mime = 'video/x-ms-wmv'; break; case 'mov': $this->file_src_mime = 'video/quicktime'; break; case 'zip': $this->file_src_mime = 'application/zip'; break; case 'tar': $this->file_src_mime = 'application/x-tar'; break; case 'swf': $this->file_src_mime = 'application/x-shockwave-flash'; break; case 'odt': $this->file_src_mime = 'application/vnd.oasis.opendocument.text'; break; case 'ott': $this->file_src_mime = 'application/vnd.oasis.opendocument.text-template'; break; case 'oth': $this->file_src_mime = 'application/vnd.oasis.opendocument.text-web'; break; case 'odm': $this->file_src_mime = 'application/vnd.oasis.opendocument.text-master'; break; case 'odg': $this->file_src_mime = 'application/vnd.oasis.opendocument.graphics'; break; case 'otg': $this->file_src_mime = 'application/vnd.oasis.opendocument.graphics-template'; break; case 'odp': $this->file_src_mime = 'application/vnd.oasis.opendocument.presentation'; break; case 'otp': $this->file_src_mime = 'application/vnd.oasis.opendocument.presentation-template'; break; case 'ods': $this->file_src_mime = 'application/vnd.oasis.opendocument.spreadsheet'; break; case 'ots': $this->file_src_mime = 'application/vnd.oasis.opendocument.spreadsheet-template'; break; case 'odc': $this->file_src_mime = 'application/vnd.oasis.opendocument.chart'; break; case 'odf': $this->file_src_mime = 'application/vnd.oasis.opendocument.formula'; break; case 'odb': $this->file_src_mime = 'application/vnd.oasis.opendocument.database'; break; case 'odi': $this->file_src_mime = 'application/vnd.oasis.opendocument.image'; break; case 'oxt': $this->file_src_mime = 'application/vnd.openofficeorg.extension'; break; case 'docx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; break; case 'docm': $this->file_src_mime = 'application/vnd.ms-word.document.macroEnabled.12'; break; case 'dotx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; break; case 'dotm': $this->file_src_mime = 'application/vnd.ms-word.template.macroEnabled.12'; break; case 'xlsx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; break; case 'xlsm': $this->file_src_mime = 'application/vnd.ms-excel.sheet.macroEnabled.12'; break; case 'xltx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; break; case 'xltm': $this->file_src_mime = 'application/vnd.ms-excel.template.macroEnabled.12'; break; case 'xlsb': $this->file_src_mime = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; break; case 'xlam': $this->file_src_mime = 'application/vnd.ms-excel.addin.macroEnabled.12'; break; case 'pptx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; break; case 'pptm': $this->file_src_mime = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; break; case 'ppsx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; break; case 'ppsm': $this->file_src_mime = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; break; case 'potx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.presentationml.template'; break; case 'potm': $this->file_src_mime = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; break; case 'ppam': $this->file_src_mime = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; break; case 'sldx': $this->file_src_mime = 'application/vnd.openxmlformats-officedocument.presentationml.slide'; break; case 'sldm': $this->file_src_mime = 'application/vnd.ms-powerpoint.slide.macroEnabled.12'; break; case 'thmx': $this->file_src_mime = 'application/vnd.ms-officetheme'; break; case 'onetoc': case 'onetoc2': case 'onetmp': case 'onepkg': $this->file_src_mime = 'application/onenote'; break; } if ($this->file_src_mime == 'application/octet-stream') { $this->log .= 'doesn\'t look like anything known<br />'; } else { $this->log .= 'MIME type set to ' . $this->file_src_mime . '<br />'; } } if (!$this->file_src_mime || !is_string($this->file_src_mime) || empty($this->file_src_mime) || strpos($this->file_src_mime, '/') === FALSE) { $this->log .= '- MIME type couldn\'t be detected! (' . (string) $this->file_src_mime . ')<br />'; } // determine whether the file is an image if ($this->file_src_mime && is_string($this->file_src_mime) && !empty($this->file_src_mime) && array_key_exists($this->file_src_mime, $this->image_supported)) { $this->file_is_image = true; $this->image_src_type = $this->image_supported[$this->file_src_mime]; } // if the file is an image, we gather some useful data if ($this->file_is_image) { if ($h = fopen($this->file_src_pathname, 'r')) { fclose($h); $info = getimagesize($this->file_src_pathname); if (is_array($info)) { $this->image_src_x = $info[0]; $this->image_src_y = $info[1]; $this->image_dst_x = $this->image_src_x; $this->image_dst_y = $this->image_src_y; $this->image_src_pixels = $this->image_src_x * $this->image_src_y; $this->image_src_bits = array_key_exists('bits', $info) ? $info['bits'] : null; } else { $this->file_is_image = false; $this->uploaded = false; $this->log .= '- can\'t retrieve image information, image may have been tampered with<br />'; $this->error = $this->translate('source_invalid'); } } else { $this->log .= '- can\'t read source file directly. open_basedir restriction in place?<br />'; } } $this->log .= '<b>source variables</b><br />'; $this->log .= '- You can use all these before calling process()<br />'; $this->log .= ' file_src_name : ' . $this->file_src_name . '<br />'; $this->log .= ' file_src_name_body : ' . $this->file_src_name_body . '<br />'; $this->log .= ' file_src_name_ext : ' . $this->file_src_name_ext . '<br />'; $this->log .= ' file_src_pathname : ' . $this->file_src_pathname . '<br />'; $this->log .= ' file_src_mime : ' . $this->file_src_mime . '<br />'; $this->log .= ' file_src_size : ' . $this->file_src_size . ' (max= ' . $this->file_max_size . ')<br />'; $this->log .= ' file_src_error : ' . $this->file_src_error . '<br />'; if ($this->file_is_image) { $this->log .= '- source file is an image<br />'; $this->log .= ' image_src_x : ' . $this->image_src_x . '<br />'; $this->log .= ' image_src_y : ' . $this->image_src_y . '<br />'; $this->log .= ' image_src_pixels : ' . $this->image_src_pixels . '<br />'; $this->log .= ' image_src_type : ' . $this->image_src_type . '<br />'; $this->log .= ' image_src_bits : ' . $this->image_src_bits . '<br />'; } } }
/** * getOptions() * * @param string $optionName OPTIONAL * @return array|string */ public static function getOptions($optionName = null) { $options = array(); foreach (ini_get_all('session') as $sysOptionName => $sysOptionValues) { $options[substr($sysOptionName, 8)] = $sysOptionValues['local_value']; } foreach (self::$_localOptions as $localOptionName => $localOptionMemberName) { $options[$localOptionName] = self::${$localOptionMemberName}; } if ($optionName) { if (array_key_exists($optionName, $options)) { return $options[$optionName]; } return null; } return $options; }
function server_info() { if (!@phpinfo()) { echo et('NoPhpinfo') . "..."; } echo "<br><br>"; $a = ini_get_all(); $output = "<table border=1 cellspacing=0 cellpadding=4 align=center>"; $output .= "<tr><th colspan=2>ini_get_all()</td></tr>"; while (list($key, $value) = each($a)) { list($k, $v) = each($a[$key]); $output .= "<tr><td align=right>{$key}</td><td>{$v}</td></tr>"; } $output .= "</table>"; echo $output; echo "<br><br>"; $output = "<table border=1 cellspacing=0 cellpadding=4 align=center>"; $output .= "<tr><th colspan=2>\$_SERVER</td></tr>"; foreach ($_SERVER as $k => $v) { $output .= "<tr><td align=right>{$k}</td><td>{$v}</td></tr>"; } $output .= "</table>"; echo $output; echo "<br><br>"; echo "<table border=1 cellspacing=0 cellpadding=4 align=center>"; $safe_mode = trim(ini_get("safe_mode")); if (strlen($safe_mode) == 0 || $safe_mode == 0) { $safe_mode = false; } else { $safe_mode = true; } $is_windows_server = uppercase(substr(PHP_OS, 0, 3)) === 'WIN'; echo "<tr><td colspan=2>" . php_uname(); echo "<tr><td>safe_mode<td>" . ($safe_mode ? "on" : "off"); if ($is_windows_server) { echo "<tr><td>sisop<td>Windows<br>"; } else { echo "<tr><td>sisop<td>Linux<br>"; } echo "</table><br><br><table border=1 cellspacing=0 cellpadding=4 align=center>"; $display_errors = ini_get("display_errors"); $ignore_user_abort = ignore_user_abort(); $max_execution_time = ini_get("max_execution_time"); $upload_max_filesize = ini_get("upload_max_filesize"); $memory_limit = ini_get("memory_limit"); $output_buffering = ini_get("output_buffering"); $default_socket_timeout = ini_get("default_socket_timeout"); $allow_url_fopen = ini_get("allow_url_fopen"); $magic_quotes_gpc = ini_get("magic_quotes_gpc"); ignore_user_abort(true); ini_set("display_errors", 0); ini_set("max_execution_time", 0); ini_set("upload_max_filesize", "10M"); ini_set("memory_limit", "20M"); ini_set("output_buffering", 0); ini_set("default_socket_timeout", 30); ini_set("allow_url_fopen", 1); ini_set("magic_quotes_gpc", 0); echo "<tr><td> <td>Get<td>Set<td>Get"; echo "<tr><td>display_errors<td>{$display_errors}<td>0<td>" . ini_get("display_errors"); echo "<tr><td>ignore_user_abort<td>" . ($ignore_user_abort ? "on" : "off") . "<td>on<td>" . (ignore_user_abort() ? "on" : "off"); echo "<tr><td>max_execution_time<td>{$max_execution_time}<td>0<td>" . ini_get("max_execution_time"); echo "<tr><td>upload_max_filesize<td>{$upload_max_filesize}<td>10M<td>" . ini_get("upload_max_filesize"); echo "<tr><td>memory_limit<td>{$memory_limit}<td>20M<td>" . ini_get("memory_limit"); echo "<tr><td>output_buffering<td>{$output_buffering}<td>0<td>" . ini_get("output_buffering"); echo "<tr><td>default_socket_timeout<td>{$default_socket_timeout}<td>30<td>" . ini_get("default_socket_timeout"); echo "<tr><td>allow_url_fopen<td>{$allow_url_fopen}<td>1<td>" . ini_get("allow_url_fopen"); echo "<tr><td>magic_quotes_gpc<td>{$magic_quotes_gpc}<td>0<td>" . ini_get("magic_quotes_gpc"); echo "</table><br><br>"; echo "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n window.moveTo((window.screen.width-800)/2,((window.screen.height-600)/2)-20);\r\n window.focus();\r\n //-->\r\n </script>"; echo "</body>\n</html>"; }
} ?> </ul> <div style="clear: both"></div> <div id="i-ext-show"></div> <h3>Php.ini</h3> <table cellpadding='0' cellspacing='0'> <tr> <th>name </th> <th>global val</th> <th>local val</th> <th>access</th> </tr> <?php foreach (ini_get_all() as $k => $v) { ?> <tr> <td><?php echo $k; ?> </td> <td><?php echo VarDump($v['global_value']); ?> </td> <td><?php echo VarDump($v['local_value']); ?> </td> <td><?php
<?php if (!defined('INIT_INSTANCE')) { die('Access restricted'); } if ($member_db[UDB_ACL] != ACL_LEVEL_ADMIN) { msg("error", lang("Access Denied"), lang("You don't have permission")); } echo "<b>CuteNews Debug Information:</b><hr><br />"; echo "Script Version/ID:  {$config_version_name} / {$config_version_id}<br />"; echo "\$config_http_script_dir: {$config_http_script_dir}<br /><BR>"; echo "<hr>"; phpinfo(); echo "<hr><textarea cols=85 rows=24>"; print_r(ini_get_all()); echo "</textarea>"; die;
<?php /** * Tests the support of PHP 5.3.2 or greater. * ><p><b>Support for PHP is missing.<br />PHP Unterstützung nicht gefunden</b></p> <!-- * * @author Marcel Werk * @copyright 2001-2015 WoltLab GmbH * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> */ // @codingStandardsIgnoreFile // check php version // php version $phpVersion = phpversion(); $comparePhpVersion = preg_replace('/^(\\d+\\.\\d+\\.\\d+).*$/', '\\1', $phpVersion); $neededPhpVersion = '5.3.2'; $configArray = @ini_get_all(); if (!(version_compare($comparePhpVersion, $neededPhpVersion) >= 0)) { ?> <p style="color:red;" >Your PHP version '<?php echo $phpVersion; ?> ' is insufficient for installation of this software. PHP version <?php echo $neededPhpVersion; ?> or greater is required.<br /> Ihre PHP Version '<?php echo $phpVersion; ?> ' ist unzureichend für die Installation dieser Software. PHP Version <?php echo $neededPhpVersion; ?>
/** * prints some debug info * * @author Andreas Gohr <*****@*****.**> */ function html_debug() { global $conf; global $lang; global $auth; global $INFO; //remove sensitive data $cnf = $conf; debug_guard($cnf); $nfo = $INFO; debug_guard($nfo); $ses = $_SESSION; debug_guard($ses); print '<html><body>'; print '<p>When reporting bugs please send all the following '; print 'output as a mail to andi@splitbrain.org '; print 'The best way to do this is to save this page in your browser</p>'; print '<b>$INFO:</b><pre>'; print_r($nfo); print '</pre>'; print '<b>$_SERVER:</b><pre>'; print_r($_SERVER); print '</pre>'; print '<b>$conf:</b><pre>'; print_r($cnf); print '</pre>'; print '<b>DOKU_BASE:</b><pre>'; print DOKU_BASE; print '</pre>'; print '<b>abs DOKU_BASE:</b><pre>'; print DOKU_URL; print '</pre>'; print '<b>rel DOKU_BASE:</b><pre>'; print dirname($_SERVER['PHP_SELF']) . '/'; print '</pre>'; print '<b>PHP Version:</b><pre>'; print phpversion(); print '</pre>'; print '<b>locale:</b><pre>'; print setlocale(LC_ALL, 0); print '</pre>'; print '<b>encoding:</b><pre>'; print $lang['encoding']; print '</pre>'; if ($auth) { print '<b>Auth backend capabilities:</b><pre>'; print_r($auth->cando); print '</pre>'; } print '<b>$_SESSION:</b><pre>'; print_r($ses); print '</pre>'; print '<b>Environment:</b><pre>'; print_r($_ENV); print '</pre>'; print '<b>PHP settings:</b><pre>'; $inis = ini_get_all(); print_r($inis); print '</pre>'; print '</body></html>'; }