本文整理汇总了PHP中phpinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP phpinfo函数的具体用法?PHP phpinfo怎么用?PHP phpinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phpinfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
/**
*
*/
function output()
{
global $application;
ob_start();
phpinfo(1);
$content = ob_get_contents();
ob_end_clean();
$flag = true;
while ($flag) {
$pos = _ml_strpos($content, "\n");
$line = _ml_substr($content, 0, $pos);
$content = _ml_substr($content, $pos + 1);
if (_ml_strpos($line, "System")) {
$line = _ml_substr($line, 0, _ml_strrpos($line, "<"));
$line = _ml_substr($line, 0, _ml_strrpos($line, "<"));
$line = _ml_substr($line, _ml_strrpos($line, ">") + 1);
$flag = false;
}
}
$OS = $line;
$request = new Request();
$request->setView('PHPInfo');
$link = $request->getURL();
global $db_link;
$template_contents = array("ProductVersion" => PRODUCT_VERSION_NUMBER, "ProductVersionType" => PRODUCT_VERSION_TYPE, "ProductReleaseDate" => PRODUCT_VERSION_DATE, "CoreVersion" => CORE_VERSION, "ModulesList" => $this->outputModules(), "phpVersion" => PHP_VERSION, "MySQLVersion" => mysqli_get_server_info($db_link), "ServerOS" => $OS, "WebServerVersion" => $_SERVER["SERVER_SOFTWARE"], "PHPInfoLink" => $link);
$this->_Template_Contents = $template_contents;
$application->registerAttributes($this->_Template_Contents);
return modApiFunc('TmplFiller', 'fill', "tools/server_info/", "container.tpl.html", array());
}
示例2: getPHPInfo
public static function getPHPInfo()
{
if (isset(self::$_aPHPInfo)) {
return self::$_aPHPInfo;
}
ob_start();
phpinfo(-1);
$_sOutput = preg_replace(array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' . '<h1>PHP Version (.*?)</h1>(?:\\n+?)</td></tr>#', '#<h1><a href="(?:.*?)\\?=(.*?)">PHP Credits</a></h1>#', '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', "# +#", '#<tr>#', '#</tr>#'), array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', '<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' . "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>', '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), ob_get_clean());
$_aSections = explode('<h2>', strip_tags($_sOutput, '<h2><th><td>'));
unset($_aSections[0]);
$_aOutput = array();
foreach ($_aSections as $_sSection) {
$_iIndex = substr($_sSection, 0, strpos($_sSection, '</h2>'));
preg_match_all('#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', $_sSection, $_aAskApache, PREG_SET_ORDER);
foreach ($_aAskApache as $_aMatches) {
if (!isset($_aMatches[1], $_aMatches[2])) {
array_slice($_aMatches, 2);
continue;
}
$_aOutput[$_iIndex][$_aMatches[1]] = !isset($_aMatches[3]) || $_aMatches[2] == $_aMatches[3] ? $_aMatches[2] : array_slice($_aMatches, 2);
}
}
self::$_aPHPInfo = $_aOutput;
return self::$_aPHPInfo;
}
示例3: ckeditor_parse_php_info
/**
* http://www.php.net/manual/en/function.phpinfo.php
* code at adspeed dot com
* 09-Dec-2005 11:31
* This function parses the phpinfo output to get details about a PHP module.
*/
function ckeditor_parse_php_info()
{
ob_start();
phpinfo(INFO_MODULES);
$s = ob_get_contents();
ob_end_clean();
$s = strip_tags($s, '<h2><th><td>');
$s = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $s);
$s = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $s);
$vTmp = preg_split('/(<h2>[^<]+<\\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
$vModules = array();
for ($i = 1; $i < count($vTmp); $i++) {
if (preg_match('/<h2>([^<]+)<\\/h2>/', $vTmp[$i], $vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode("\n", $vTmp[$i + 1]);
foreach ($vTmp2 as $vOne) {
$vPat = '<info>([^<]+)<\\/info>';
$vPat3 = "/{$vPat}\\s*{$vPat}\\s*{$vPat}/";
$vPat2 = "/{$vPat}\\s*{$vPat}/";
if (preg_match($vPat3, $vOne, $vMat)) {
// 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]), trim($vMat[3]));
} elseif (preg_match($vPat2, $vOne, $vMat)) {
// 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
示例4: getPhpInfo
/**
* Method to get the PHP info
*
* @return string
*/
public function getPhpInfo()
{
if (!is_null($this->phpInfo)) {
return $this->phpInfo;
}
if (function_exists('phpinfo')) {
ob_start();
date_default_timezone_set('UTC');
phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
$phpInfo = ob_get_contents();
ob_end_clean();
preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpInfo, $output);
$output = preg_replace('#<table[^>]*>#', '<table class="table table-striped">', $output[1][0]);
$output = preg_replace('#(\\w),(\\w)#', '\\1, \\2', $output);
$output = preg_replace('#<hr />#', '', $output);
$output = str_replace('<div class="center">', '', $output);
$output = preg_replace('#<tr class="h">(.*)<\\/tr>#', '<thead><tr class="h">$1</tr></thead><tbody>', $output);
$output = str_replace('</table>', '</tbody></table>', $output);
$output = str_replace('</div>', '', $output);
$this->phpInfo = $output;
} elseif (function_exists('phpversion')) {
$this->phpInfo = $this->translator->trans('mautic.sysinfo.phpinfo.phpversion', array('%phpversion%' => phpversion()));
} else {
$this->phpInfo = $this->translator->trans('mautic.sysinfo.phpinfo.missing');
}
return $this->phpInfo;
}
示例5: Image_Graph_gd_version
/**
* Check which version of GD is installed
* @return int 0 if GD isn't installed, 1 if GD 1.x is installed and 2 if GD 2.x is installed
*/
function Image_Graph_gd_version()
{
if (function_exists("gd_info")) {
$info = gd_info();
$version = $info['GD Version'];
} else {
ob_start();
phpinfo(8);
$php_info = ob_get_contents();
ob_end_clean();
if (ereg("<td[^>]*>GD Version *<\/td><td[^>]*>([^<]*)<\/td>", $php_info, $result)) {
$version = $result[1];
}
}
if ($version) {
//define("GD_VERSION", $version);
}
if (ereg("1\.[0-9]{1,2}", $version)) {
return 1;
}
elseif (ereg("2\.[0-9]{1,2}", $version)) {
return 2;
} else {
return 0;
}
}
示例6: compatibilityCheckPHPInfo
protected function compatibilityCheckPHPInfo()
{
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$info = array();
preg_match_all('{<tr><td class="e">(?>(.+?)</td>)<td class="v">(?>(.+?)</td>)</tr>}', $phpinfo, $matches);
foreach ($matches[1] as $key => $label) {
$info[trim(strtolower($label))] = trim(strtolower($matches[2][$key]));
}
preg_match_all('{<tr class="h"><th>(?>(.+?)</th>)<th>(?>(.+?)</th>)</tr>}', $phpinfo, $matches);
foreach ($matches[1] as $key => $label) {
$info[trim(strtolower($label))] = trim(strtolower($matches[2][$key]));
}
if (isset($info['server_software'])) {
if (strpos($info['server_software'], 'apache') === false) {
$this->err("Apache web server server software is required. You are running \"{$info['server_software']}\". Continue at your own risk, ProcessWire is not currently tested with any other server software.");
} else {
$this->li("Server Software: {$info['server_software']}");
}
} else {
$this->err("Unable to determine server software. It may be okay to continue, but note that ProcessWire is only developed for Apache at present.");
}
$tests = array('mysqli support', 'spl support', 'ctype functions', 'gd support', 'iconv support', 'hash support', 'json support', 'pcre (perl compatible regular expressions) support', 'session support');
foreach ($tests as $test) {
if (!isset($info[$test]) || $info[$test] != 'enabled') {
$this->err("Failed test for: {$test}");
} else {
$this->li("{$test}: OK");
}
}
}
示例7: testGD
/**
* Test if the GD library is available
*
* @return array
*/
protected static function testGD()
{
$gd = array();
$output = '';
$gdVersion = null;
$gdInfo = null;
//$GDfuncList = get_extension_funcs('gd');
if (function_exists('gd_info')) {
$gdInfo = gd_info();
$gdVersion = $gdInfo['GD Version'];
} else {
ob_start();
@phpinfo(INFO_MODULES);
$output = ob_get_contents();
ob_end_clean();
$matches[1] = '';
if ($output !== '') {
if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) {
$gdVersion = $matches[2];
} else {
return $gd;
}
}
}
if (function_exists('imagecreatetruecolor') && function_exists('imagecreatefromjpeg')) {
$gdVersion = isset($gdVersion) ? $gdVersion : 2;
$gd['gd2'] = "GD: " . $gdVersion;
} elseif (function_exists('imagecreatefromjpeg')) {
$gdVersion = isset($gdVersion) ? $gdVersion : 1;
$gd['gd1'] = "GD: " . $gdVersion;
}
return $gd;
}
示例8: php_admin_info
function php_admin_info()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// SET PLUGIN PATH REGARDLESS OF CONTAINING DIRECTORY
$plug_path = plugins_url('/', __FILE__);
$phpStyle = <<<PHPSTYLE
\t<style type="text/css">
\t#php-info-wrapper { padding: 20px; }
\t#php-info-wrapper table { padding: 1px; background: #ccc; border: 1px #777 solid; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px; }
\t#php-info-wrapper td, th {padding:3px; background:#efefef; -webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;}
\t#php-info-wrapper tr.h img { display:none; }
\t#php-info-wrapper tr.h td{ background:none; }
\t#php-info-wrapper tr.h { text-align:right; height: 130px; background: url({$plug_path}php-logo.png) no-repeat 30px center; }
\t#php-info-wrapper tr.h h1{ padding-right:50px; }
\t</style>
PHPSTYLE;
echo $phpStyle;
echo '<div id="php-info-wrapper" class="wrap" >';
ob_start();
phpinfo();
$pinfo = ob_get_contents();
ob_end_clean();
$pinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo);
$pinfo = preg_replace('%^.*<title>(.*)</title>.*$%ms', '$1', $pinfo);
echo $pinfo;
echo '</div>';
}
示例9: getICUDataVersion
/**
* @static
*
* @return string
*/
public static function getICUDataVersion()
{
if (defined('INTL_ICU_VERSION')) {
return INTL_ICU_VERSION;
}
ob_start();
phpinfo();
$content = ob_get_contents();
ob_end_clean();
$info = explode("\n", $content);
if ('cli' == php_sapi_name()) {
foreach ($info as $line) {
$results = array();
if (preg_match('/(ICU Data version|ICU version) => (.*)/', $line, $results)) {
return $results[2];
}
}
} else {
foreach ($info as $line) {
$results = array();
if (preg_match('/(ICU Data version).*/', $line, $results)) {
return trim(strtolower(strip_tags($results[0])), 'ICU Data version');
}
if (preg_match('/(ICU version).*/', $line, $results)) {
return trim(strtolower(strip_tags($results[0])), 'icu version');
}
}
}
return;
}
示例10: run
public function run($command)
{
if (in_array($command, $this->getSynonyms())) {
$return = array();
$return[] = new Page($this->getHelp());
ob_start();
phpinfo(1);
$phpModules = ob_get_clean();
$return[] = new Page("<h3 id='PHP General'>PHP General</h3>" . $phpModules);
ob_start();
phpinfo(4);
$phpModules = ob_get_clean();
$return[] = new Page("<h3 id='PHP Configuration'>PHP Configuration</h3>" . $phpModules);
ob_start();
phpinfo(8);
$phpModules = ob_get_clean();
$return[] = new Page("<h3 id='PHP Modules'>PHP Modules</h3>" . $phpModules);
ob_start();
phpinfo(16);
$phpModules = ob_get_clean();
$return[] = new Page("<h3 id='PHP Environment'>PHP Environment</h3>" . $phpModules);
ob_start();
phpinfo(32);
$phpModules = ob_get_clean();
$return[] = new Page("<h3 id='PHP Variables'>PHP Variables</h3>" . $phpModules);
return $return;
}
return array();
}
示例11: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
/*$arr = [5 => 0, 6 => 0, 7 => 0, 8 => 0];
$arr_test = [];
$num = array_search(min($arr),$arr);
var_dump($num);
exit();*/
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
/********************snoopy**********************/
/*$snoopy = new Snoopy();
header('Content-type:text/html;charset=gbk');
$snoopy->fetch('https://www.taobao.com');
print_r($snoopy->results);*/
/********************snoopy*************************/
//随机排序
/*$a = array(1,2,3,4,5);
shuffle($a);
for ($i=0; $i<count($a); ++$i)
echo $a[$i]." ";
shuffle($a);
echo "<br />";
for ($i=0; $i<count($a); ++$i) echo $a[$i]." ";*/
echo phpinfo();
exit;
$this->render('index');
}
示例12: generateSummary
protected function generateSummary()
{
$suhosin_help = <<<FEED
<pre>
http://www.magentocommerce.com/wiki/groups/227/magento-compatible_suhosin_configuration
suggested in [.htaccess]
php_value suhosin.mail.protect 0
php_value suhosin.memory_limit 256M
php_value suhosin.post.max_vars 5000
php_value suhosin.post.max_value_length 500000
php_value suhosin.request.max_vars 5000
php_value suhosin.request.max_value_length 500000
<pre/>
FEED;
// Check if Suhosin is compiled into php and not a extension
// magento says to use these settings if using Suhosin...
//http://www.magentocommerce.com/wiki/groups/227/magento-compatible_suhosin_configuration
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$has_suhosin = false;
if (!extension_loaded('suhosin')) {
$this->addPass($this->__("PHP does not have problematic extension Suhosin."));
} else {
$this->addNotice($this->__("PHP has extension Suhosin."), $this->__("If Magento has issues, try these configuration ontop of the default values: %s", $suhosin_help));
}
if (strpos($phpinfo, "Suhosin Patch") === false) {
$this->addPass($this->__("Suhosin is not compiled directly into the PHP binary."));
} else {
$this->addNotice($this->__("Suhosin is compiled directly into the PHP binary."), $this->__("If Magento has issues, try these configuration ontop of the default values: %s", $suhosin_help));
}
}
示例13: index
function index()
{
$this->template->set('title', $this->language->get('heading_title'));
$view = $this->locator->create('template');
$view->set('button_list', $this->language->get('button_list'));
$view->set('button_insert', $this->language->get('button_insert'));
$view->set('button_update', $this->language->get('button_update'));
$view->set('button_delete', $this->language->get('button_delete'));
$view->set('button_save', $this->language->get('button_save'));
$view->set('button_cancel', $this->language->get('button_cancel'));
$view->set('button_print', $this->language->get('button_print'));
$view->set('heading_title', $this->language->get('heading_title'));
$view->set('heading_description', $this->language->get('heading_description'));
$view->set('text_php', $this->language->get('text_php'));
$view->set('text_db', $this->language->get('text_db'));
$view->set('text_db_server', $this->language->get('text_db_server'));
$view->set('text_db_name', $this->language->get('text_db_name'));
$view->set('php', phpversion());
$view->set('server', $_SERVER['SERVER_SOFTWARE']);
$view->set('db', 'MySQL ' . $this->modelServerInfo->get_server_info());
$view->set('db_server', DB_HOST);
$view->set('db_name', DB_NAME);
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo = str_replace('border: 1px', '', $phpinfo);
preg_match('#<body>(.*?)</body>#is', $phpinfo, $regs);
$view->set('phpinfo', $regs[1]);
$this->template->set('content', $view->fetch('content/server_info.tpl'));
$this->template->set($this->module->fetch());
$this->response->set($this->template->fetch('layout.tpl'));
}
示例14: login
function login($username, $password)
{
global $_SESSION;
// Check for LDAP functions
if (!function_exists('ldap_connect')) {
$ex = 'LDAP support is not enabled in your PHP configuration.';
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
ob_start();
phpinfo(INFO_GENERAL);
$phpinfo = ob_get_contents();
ob_end_clean();
preg_match('/Loaded Configuration File <\\/td><td.*?>(.*?)\\s*</', $phpinfo, $phpinfo);
$ex .= ' You probably just need to uncomment the line ;extension=php_ldap.dll in php.ini' . (count($phpinfo) > 1 ? ' (' . trim($phpinfo[1]) . ')' : '') . ' by removing the ";" and restart your web server.';
} else {
if (strtolower(substr(PHP_OS, 0, 5)) == 'Linux') {
$ex .= ' You probably need to install the php5-ldap (or similar depending on your distribution) package.';
}
}
throw new Exception($ex);
}
$auth = ldap_connect($this->config['host']);
if (!$auth) {
return false;
}
ldap_set_option($auth, LDAP_OPT_PROTOCOL_VERSION, 3);
if (!@ldap_bind($auth, sprintf($this->config['bind_dn'], $username), $password)) {
return false;
}
$_SESSION['valid'] = true;
$_SESSION['user'] = $username;
$_SESSION['admin'] = !$this->config['adminUser'] || $_SESSION['user'] == $this->config['adminUser'];
$_SESSION['authCheckHeartbeat'] = time();
}
示例15: access_details
function access_details()
{
$access_details = array();
$access_details['domain'] = '';
$access_details['ip'] = '';
$access_details['directory'] = '';
$access_details['server_hostname'] = '';
$access_details['server_ip'] = '';
if (function_exists('phpinfo')) {
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$list = strip_tags($phpinfo);
$access_details['domain'] = $this->scrape_phpinfo($list, 'HTTP_HOST');
$access_details['ip'] = $this->scrape_phpinfo($list, 'SERVER_ADDR');
$access_details['directory'] = $this->scrape_phpinfo($list, 'SCRIPT_FILENAME');
$access_details['server_hostname'] = $this->scrape_phpinfo($list, 'System');
$access_details['server_ip'] = @gethostbyname($access_details['server_hostname']);
}
$access_details['domain'] = $access_details['domain'] ? $access_details['domain'] : $_SERVER['HTTP_HOST'];
$access_details['ip'] = $access_details['ip'] ? $access_details['ip'] : $this->server_addr();
$access_details['directory'] = $access_details['directory'] ? $access_details['directory'] : $this->path_translated();
$access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : @gethostbyaddr($access_details['ip']);
$access_details['server_hostname'] = $access_details['server_hostname'] ? $access_details['server_hostname'] : 'Unknown';
$access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : @gethostbyaddr($access_details['ip']);
$access_details['server_ip'] = $access_details['server_ip'] ? $access_details['server_ip'] : 'Unknown';
foreach ($access_details as $key => $value) {
$access_details[$key] = $access_details[$key] ? $access_details[$key] : 'Unknown';
}
if ($this->valid_for_product_tiers) {
$access_details['valid_for_product_tiers'] = $this->valid_for_product_tiers;
}
return $access_details;
}