.getelementsbyidTagName('a')和.getelementsbyidTagName('A')是一样的都是获取a标签的吗?

热门日志推荐
人人最热标签
分享这篇日志的人常去
北京千橡网景科技发展有限公司:
文网文[号··京公网安备号·甲测资字
文化部监督电子邮箱:wlwh@··
文明办网文明上网举报电话: 举报邮箱:&&&&&&&&&&&&
请输入手机号,完成注册
请输入验证码
密码必须由6-20个字符组成
下载人人客户端
品评校花校草,体验校园广场热门日志推荐
人人最热标签
分享这篇日志的人常去
北京千橡网景科技发展有限公司:
文网文[号··京公网安备号·甲测资字
文化部监督电子邮箱:wlwh@··
文明办网文明上网举报电话: 举报邮箱:&&&&&&&&&&&&
请输入手机号,完成注册
请输入验证码
密码必须由6-20个字符组成
下载人人客户端
品评校花校草,体验校园广场热门日志推荐
人人最热标签
分享这篇日志的人常去
北京千橡网景科技发展有限公司:
文网文[号··京公网安备号·甲测资字
文化部监督电子邮箱:wlwh@··
文明办网文明上网举报电话: 举报邮箱:&&&&&&&&&&&&
请输入手机号,完成注册
请输入验证码
密码必须由6-20个字符组成
下载人人客户端
品评校花校草,体验校园广场Keyboard Shortcuts?
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search(current page)
Focus search box
Change language:
Brazilian Portuguese
Chinese (Simplified)
因为每个系统安装得有所不同,phpinfo() 常用于在系统上检查 和
phpinfo() 同时是个很有价值的、包含所有 EGPCS(Environment, GET, POST, Cookie, Server) 数据的调试工具。
One note on the very useful example by "jon at sitewizard dot ca".& The following statements:Statement 1:$phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];Statement 2:$phpinfo[end(array_keys($phpinfo))][] = $match[2];These two lines will produce the error "Strict Standards:& Only variables should be passed by reference in...".& The root of the error is in the incorrect use of the end() function. The code works but thows the said error.To address this try using the following statements:Statement 1 revision:$keys = array_keys($phpinfo);$phpinfo[end($keys)][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];Statement 2 revision:$keys = array_keys($phpinfo);$phpinfo[end($keys)][] = $match[2];This fixes the error. To wrap it all in an example:&?phpfunction quick_dev_insights_phpinfo() {ob_start();phpinfo(11);$phpinfo = array('phpinfo' =& array());& & if(preg_match_all('#(?:&h2&(?:&a name=".*?"&)?(.*?)(?:&/a&)?&/h2&)|(?:&tr(?: class=".*?")?&&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&(?:&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&(?:&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&)?)?&/tr&)#s', ob_get_clean(), $matches, PREG_SET_ORDER)){& & & & foreach($matches as $match){& & & & if(strlen($match[1])){& & & & & & $phpinfo[$match[1]] = array();& & & & }elseif(isset($match[3])){& & & & $keys1 = array_keys($phpinfo);& & & & $phpinfo[end($keys1)][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];& & & & }else{& & & & & & $keys1 = array_keys($phpinfo);& & & & & & $phpinfo[end($keys1)][] = $match[2];& & & & & & & & & & & & & }& & & & & & & & }}& & if(! empty($phpinfo)){& & & & foreach($phpinfo as $name =& $section) {& & & & & & echo "&h3&$name&/h3&\n&table class='wp-list-table widefat fixed pages'&\n";& & & & & & foreach($section as $key =& $val){& & & & & & & & & & if(is_array($val)){& & & & & & & & & & echo "&tr&&td&$key&/td&&td&$val[0]&/td&&td&$val[1]&/td&&/tr&\n";& & & & & & & & & & }elseif(is_string($key)){& & & & & & & & & & echo "&tr&&td&$key&/td&&td&$val&/td&&/tr&\n";& & & & & & & & & & }else{& & & & & & & & & & echo "&tr&&td&$val&/td&&/tr&\n";& & & & & & & & }& & & & & & }& & & & }& & & & & & echo "&/table&\n";& & & & }else{& & echo "&h3&Sorry, the phpinfo() function is not accessable. Perhaps, it is disabled&a href=''&See the documentation.&/a&&/h3&";& & }}?&Frankly, I went thought the trouble of adding this note because the example by "jon at sitewizard dot ca"& is probably the best on the web, and thought it unfortunate that it throws errors. Hope this is useful to someone.
Embedding phpinfo within your page, that already has style information:The phpinfo output is wrapped within a &div class='phpinfodisplay'&, and we privatize all the style selectors that phpinfo() creates.Yes, we cheat on preparing the selector list.&?phpob_start();phpinfo();preg_match ('%&style type="text/css"&(.*?)&/style&.*?(&body&.*&/body&)%s', ob_get_clean(), $matches);echo "&div class='phpinfodisplay'&&style type='text/css'&\n",& & join( "\n",& & & & array_map(& & & & & & create_function(& & & & & & & & '$i',& & & & & & & & 'return ".phpinfodisplay " . preg_replace( "/,/", ",.phpinfodisplay ", $i );'& & & & & & & & ),& & & & & & preg_split( '/\n/', $matches[1] )& & & & & & )& & & & ),& & "&/style&\n",& & $matches[2],& & "\n&/div&\n";?&Perhaps one day the phpinfo() function will be modified to output such a safe string on its own.
big thanx 2 Mardy dot Hutchinson at gmail dot comvery good!some fixes to correct result displaying:1. we need to trim $matches [1], 'cause ther2. not bad to remove &body& tag 'cause styles for it not apply correctly...3. ...and change styles a little (remove "body" selector)we need to change two lines:&?phppreg_match ('%&style type="text/css"&(.*?)&/style&.*?(&body&.*&/body&)%s', ob_get_clean(), $matches);?&to&?phppreg_match ('%&style type="text/css"&(.*?)&/style&.*?&body&(.*?)&/body&%s', ob_get_clean(), $matches);?&and&?phppreg_split( '/\n/', $matches[1] )?&to&?phppreg_split( '/\n/', trim(preg_replace( "/\nbody/", "\n", $matches[1])) )?&That's all! Now we have a really flexible addition to phpinfo();
I needed a way to quickly scroll through the phpinfo which is a large list of information. so here it is. In the top there is a list with sections, the new section loaded extensions will hold the links to the anchors of the loaded modules. the section session variables will show the current loaded sessions. It's using Domdocument for manipulation so you should have that loaded:&?phpob_start();& & $exts = get_loaded_extensions();& & phpinfo();& & $phpinfo = ob_get_contents();& & ob_end_clean();& & $html_str = $phpinfo;& & $html = new DOMDocument();& & $html-&loadHTML($html_str);& & $title = $html-&getElementsByTagName("title")-&item(0);& & $title-&nodeValue = "PHP Version ".phpversion();& & $body = $html-&getElementsByTagName("body")-&item(0);& & & & $body-&setAttribute("style", "background-color:");& & $table = $body = $html-&getElementsByTagName("table")-&item(3)-&nextSibling;& & $head& = $html-&getElementsByTagName("table")-&item(0)-&nextSibling;& & ob_start();& & ?&& & &h2&&a name="session_variables"&Session variables&/a&&/h2&& & &table border="0" cellpadding="2" width="600"&& & &tr class="h"&&th&Variables&/th&&th&Value&/th&&/tr&& & &?php foreach($_SESSION as $key=&$value){ & & & & if(is_bool($value)){& & & & & & $value = ($value)?"true":"false";& & & & }else if(is_array($value)){& & & & & & $value = '&pre&'.print_r($value, true).'&/pre&';& & & & }else if(empty($value) && $value != "0"){& & & & & & $value = "&i&no value&/i&";& & & & }& & ?&& & &tr&& & & & &td class="e"&&?=$key?&&/td&& & & & &td class="v"&&?=$value?&&/td&& & &/tr&& & &?php& & }& & ?&& & &/table&& & & & &h2&&a name="loaded_extensions"&loaded extensions&/a&&/h2&& & &table border="0" cellpadding="2" width="600"&& & &tr class="h"&&th&Extension&/th&&th&Version&/th&&/tr&& & &?php & & & & & & & & natcasesort($exts);& & foreach($exts as $value){& & & & $version = phpversion($value);& & & & ?&& & &tr&& & & & &td class="e" style="width:150"&&a href="#module_&?=$value?&" style="color: background-color:#"&&?=$value?&&/a&&/td&& & & & &td class="v"&&?=(!empty($version))?$version:"&i&Unknown&/i&" ?&&/td&& & &/tr&& & &?php& & }& & ?&& & &/table&&br /&& & &?php& & $txt_str = ob_get_contents();& & ob_end_clean();& & $txt = new DOMDocument();& & $txt-&loadHTML($txt_str);& & $txt_body = $txt-&getElementsByTagName("body")-&item(0);& & foreach($txt_body-&childNodes as $child){& & & & $child = $html-&importNode($child, true);& & & & $table-&parentNode-&insertBefore($child, $table);& & }& & & & $h2 = $html-&getElementsByTagName("h2");& & foreach($h2 as $item){& & & & if($item-&getElementsByTagName("a")-&length == 0){& & & & & & $value = $item-&nodeValue;& & & & & & $item-&nodeValue = "";& & & & & & $a = $html-&createElement("a");& & & & & & $a-&setAttribute("name", strtolower(str_replace(" ", "_", $value)));& & & & & & $a-&nodeValue = $value;& & & & & & $item-&appendChild($a);& & & & }& & & & $a = $item-&getElementsByTagName("a")-&item(0);& & & & & & & & if(!in_array($a-&nodeValue, $exts)){& & & & & & $menu[strtolower(str_replace(" ", "_", $a-&nodeValue))] = $a-&nodeValue;& & & & }& & & & $top_a = $html-&createElement("a");& & & & if(!in_array($a-&nodeValue, $exts)){& & & & & & $txt = $html-&createTextNode("(Go to top)"); & & & & & & $top_a-&appendChild($txt);& & & & & & $top_a-&setAttribute("href", "#");& & & & }else{& & & & & & $txt = $html-&createTextNode("(Go to extensionlist)"); & & & & & & $top_a-&appendChild($txt);& & & & & & $top_a-&setAttribute("href", "#loaded_extensions");& & & & }& & & & $top_a-&setAttribute("style", "background-color: font-size:12 margin-left:5 margin-top:-5 color:");& & & & $item-&appendChild($top_a);& & & & & & }& & ob_start();& & ?&& & &br /&& & &table border="0" cellpadding="2" width="600"&& & &tr class="h"&&th colspan="2"&Sections&/th&&/tr&& & &tr&& & & & &?php& & & & $i = 0;& & & & foreach($menu as $key=&$item){& & & & & & print "&td class='v'&&a href='#$key' style='background-color:# color:'&$item&/a&&/td&";& & & & & & if($i%2){& & & & & & & & print '&/tr&&tr&';& & & & & & }& & & & & & $i++;& & & & }& & & & if($i%2){& & & & & & print '&td class="v"&&/td&';& & & & }& & & & ?&& & &/tr&& & &/table&& & & & &?php& & $txt_str = ob_get_clean();& & $txt = new DOMDocument();& & $txt-&loadHTML($txt_str);& & $txt_body = $txt-&getElementsByTagName("body")-&item(0);& & foreach($txt_body-&childNodes as $child){& & & & $child = $html-&importNode($child, true);& & & & $table-&parentNode-&insertBefore($child, $head);& & }& & print $html-&saveHTML();?&
I wanted a simple *function* to convert the output of phpinfo into an array.& Here's what I came up with thanks to alot of the previous authors tips, and the source file: php-5.2.6/ext/standard/info.cCall this function like phpinfo_array() prints the array, phpinfo_array(1) returns the array for your own processing.== Sample Output ==[PHP Configuration] =& Array (& [PHP Version] =& 5.2.6& [PHP Egg] =& PHPE8-11d2-A769-00AA001ACF42& [System] =& Linux askapache 2.6.22.19-grsec3& [Build Date] =& Nov 11 :07& [Configure Command] =&& ./configure --prefix=/home/grsec/bin/php & [Server API] =& FastCGI& [IPv6 Support] =& enabled [Zend Egg] =& PHPE8-11d2-A769-00AA001ACF42& [PHP Credits Egg] =& PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000 )[mbstring] =& Array (& [mbstring.http_input] =& pass& [mbstring.internal_encoding] =& Array& & (& && [0] =& ISO-8859-1& && [1] =& no value& & )& [mbstring.language] =& neutral&& )[mcrypt] =& Array (& [Version] =& 3.5.7& [Api No] =&
)&?phpfunction phpinfo_array($return=false){ ob_start();
phpinfo(-1);
$pi = 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()); $sections = explode('&h2&', strip_tags($pi, '&h2&&th&&td&')); unset($sections[0]); $pi = array(); foreach($sections as $section){&& $n = substr($section, 0, strpos($section, '&/h2&'));&& preg_match_all(&& '#%S%(?:&td&(.*?)&/td&)?(?:&td&(.*?)&/td&)?(?:&td&(.*?)&/td&)?%E%#',& && $section, $askapache, PREG_SET_ORDER);&& foreach($askapache as $m)& & && $pi[$n][$m[1]]=(!isset($m[3])||$m[2]==$m[3])?$m[2]:array_slice($m,2); } return ($return === false) ? print_r($pi) : $pi;}?&
check out this cool and fantastic colourful phpinfo()!&?phpob_start();phpinfo();$phpinfo = ob_get_contents();ob_end_clean();preg_match_all('/#[0-9a-fA-F]{6}/', $phpinfo, $rawmatches);for ($i = 0; $i & count($rawmatches[0]); $i++)&& $matches[] = $rawmatches[0][$i];$matches = array_unique($matches);$hexvalue = 'abcdef';$j = 0;foreach ($matches as $match){&& $r = '#';&& $searches[$j] = $match;&& for ($i = 0; $i & 6; $i++)& & & $r .= substr($hexvalue, mt_rand(0, 15), 1);&& $replacements[$j++] = $r;&& unset($r);}for ($i = 0; $i & count($searches); $i++)&& $phpinfo = str_replace($searches, $replacements, $phpinfo);echo $phpinfo;?&
Removes sensitive data like AUTH_USER and AUTH_PASSWORD from the phpinfo output:&?phpob_start();phpinfo();$html = ob_get_contents();ob_end_clean();if (isset($_SERVER['AUTH_USER'])) $html = str_replace($_SERVER['AUTH_USER'], '&i&no value&/i&', $html);if (isset($_SERVER['AUTH_PASSWORD'])) $html = str_replace($_SERVER['AUTH_PASSWORD'], '&i&no value&/i&', $html);echo $html;
This is a slight modification to the previous code by "code at adspeed dot com" that extracts the PHP modules as an array. I used it on PHP 4.1.2 and it failed as the &h2& tags also had an align="center". So this update changes the regex for those tags:&?phpfunction parsePHPModules() { 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)) { $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));&& } elseif (preg_match($vPat2,$vOne,$vMat)) { $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);&& }&& }& } } return $vModules;}?&
Hi.Here my version of saving php_info into an array:&?phpfunction phpinfo_array(){& & ob_start();& & phpinfo();& & $info_arr = array();& & $info_lines = explode("\n", strip_tags(ob_get_clean(), "&tr&&td&&h2&"));& & $cat = "General";& & foreach($info_lines as $line)& & {& & & & preg_match("~&h2&(.*)&/h2&~", $line, $title) ? $cat = $title[1] : null;& & & & if(preg_match("~&tr&&td[^&]+&([^&]*)&/td&&td[^&]+&([^&]*)&/td&&/tr&~", $line, $val))& & & & {& & & & & & $info_arr[$cat][$val[1]] = $val[2];& & & & }& & & & elseif(preg_match("~&tr&&td[^&]+&([^&]*)&/td&&td[^&]+&([^&]*)&/td&&td[^&]+&([^&]*)&/td&&/tr&~", $line, $val))& & & & {& & & & & & $info_arr[$cat][$val[1]] = array("local" =& $val[2], "master" =& $val[3]);& & & & }& & }& & return $info_arr;}echo "&pre&".print_r(phpinfo_array(), 1)."&/pre&";?&
&?php$array = phpinfo_array();echo $array["General"]["System "];& echo $array["General"]["System"];& ?&
To extract all of the data from phpinfo into a nested array:&?phpob_start();phpinfo();$phpinfo = array('phpinfo' =& array());if(preg_match_all('#(?:&h2&(?:&a name=".*?"&)?(.*?)(?:&/a&)?&/h2&)|(?:&tr(?: class=".*?")?&&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&(?:&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&(?:&t[hd](?: class=".*?")?&(.*?)\s*&/t[hd]&)?)?&/tr&)#s', ob_get_clean(), $matches, PREG_SET_ORDER))& & foreach($matches as $match)& & & & if(strlen($match[1]))& & & & & & $phpinfo[$match[1]] = array();& & & & elseif(isset($match[3]))& & & & & & $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];& & & & else& & & & & & $phpinfo[end(array_keys($phpinfo))][] = $match[2];?&Some examples of using individual values from the array:&?php& & echo "System: {$phpinfo['phpinfo']['System']}&br /&\n";& & echo "Safe Mode: {$phpinfo['PHP Core']['safe_mode'][0]}&br /&\n";& & echo "License: {$phpinfo['PHP License'][0]}&br /&\n";?&To display everything:&?php& & foreach($phpinfo as $name =& $section) {& & & & echo "&h3&$name&/h3&\n&table&\n";& & & & foreach($section as $key =& $val) {& & & & & & if(is_array($val))& & & & & & & & echo "&tr&&td&$key&/td&&td&$val[0]&/td&&td&$val[1]&/td&&/tr&\n";& & & & & & elseif(is_string($key))& & & & & & & & echo "&tr&&td&$key&/td&&td&$val&/td&&/tr&\n";& & & & & & else& & & & & & & & echo "&tr&&td&$val&/td&&/tr&\n";& & & & }& & & & echo "&/table&\n";& & }?&Note: In order to properly retrieve all of the data, the regular expression matches table headers as well as table data, resulting in 'Local Value' and 'Global Value' showing up as 'Directive' entries.
A simple method to style your own phpinfo() output.&style type="text/css"&#phpinfo {}#phpinfo pre {}#phpinfo a:link {}#phpinfo a:hover {}#phpinfo table {}#phpinfo .center {}#phpinfo .center table {}#phpinfo .center th {}#phpinfo td, th {}#phpinfo h1 {}#phpinfo h2 {}#phpinfo .p {}#phpinfo .e {}#phpinfo .h {}#phpinfo .v {}#phpinfo .vr {}#phpinfo img {}#phpinfo hr {}&/style&&div id="phpinfo"&&?phpob_start () ;phpinfo () ;$pinfo = ob_get_contents () ;ob_end_clean () ;echo ( str_replace ( "module_Zend Optimizer", "module_Zend_Optimizer", preg_replace ( '%^.*&body&(.*)&/body&.*$%ms', '$1', $pinfo ) ) ) ;?&&/div&
One note on the above functions for cleaning up the phpinfo() HTML and throwing it into an array data structure. In order to catch all of the info tidbits the preg_match_all has to be tweaked to deal with 2 and 3 column tables.
I have changed the preg_match_all() here so that the last &td&&/td& is optional
&?php
function parsePHPConfig() {
& & ob_start();
& & phpinfo(-1);
& & $s = ob_get_contents();
& & ob_end_clean();
& & $a = $mtc = array();
& & if (preg_match_all('/&tr&&td class="e"&(.*?)&\/td&&td class="v"&(.*?)&\/td&(:?&td class="v"&(.*?)&\/td&)?&\/tr&/',$s,$mtc,PREG_SET_ORDER))
& & & & foreach($mtc as $v){
& & & & & & if($v[2] == '&i&no value&/i&')
& & & & & & $a[$v[1]] = $v[2];
& & & & }
& & }
& & return $a;
}
?&
This function parses the phpinfo output to get details about a PHP module.
&?php
function parsePHPModules() {
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)) { $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
& & } elseif (preg_match($vPat2,$vOne,$vMat)) { $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
return $vModules;
}
?&
Sample Output:
[gd] =& Array
(
& [GD Support] =& enabled
& [GD Version] =& bundled (2.0.28 compatible)
& [FreeType Support] =& enabled
& [FreeType Linkage] =& with freetype
& [FreeType Version] =& 2.1.9
& [T1Lib Support] =& enabled
& [GIF Read Support] =& enabled
& [GIF Create Support] =& enabled
& [JPG Support] =& enabled
& [PNG Support] =& enabled
& [WBMP Support] =& enabled
& [XBM Support] =& enabled
)
[date] =& Array (
& [date/time support] =& enabled
& [Timezone Database Version] =& 2005.14
& [Timezone Database] =& internal
& [Default timezone] =& America/Los_Angeles
& [Directive] =& Array (
& && [0] =& Local Value
& && [1] =& Master Value
& )
& [date.timezone] =& Array (
& && [0] =& no value
& && [1] =& no value
& )
&?php
function getModuleSetting($pModuleName,$pSetting) {
$vModules = parsePHPModules();
return $vModules[$pModuleName][$pSetting];
}
?&
Example: getModuleSetting('gd','GD Version'); returns "bundled (2.0.28 compatible)"
Building on SimonD's elegant example to hide the logged-in username and password, which otherwise appear in plain text, the following should work for PHP 5.4+:&?php& & ob_start();& & phpinfo();& & $html = ob_get_contents();& & ob_end_clean();& & if ( isset( $_SERVER[ 'PHP_AUTH_USER' ] ) ) $html = str_replace( $_SERVER[ 'PHP_AUTH_USER' ], '[ protected ]' , $html);& & if ( isset( $_SERVER[ 'PHP_AUTH_PW' ] ) ) $html = str_replace( $_SERVER[ 'PHP_AUTH_PW' ], '[ protected ]' , $html);& & echo $html;?&To remove additional items, just add them as above.
here you can notice that these numeric values of phpinfoare similar to certain things in the binary system:-1, coded in 7 digits:111 1111look at this:1+2+4+8+16+32+64=127unsigned,127 is:111 1111so, take a look at this: the way to get all function is to add all of them. zero is nothing.-1 is all.so you can pass option with a negative number.for example:&?php phpinfo(48) ?&is also:&?php phpinfo(-80) ?&48 = 32 + 16-80= 0 - 64 - 8 - 4 - 2 - 1so you can see in negative mode it like that:not nothingnot all (-1) don't forget it !not option 64not option 8not option 4not option 2so, that's good if you don't want option 8, you will do this:not nothing(0)not all(-1)not option 8(-1)you got:&?php phpinfo(-9); ?&hope this will be useful, that's my 1rst post ^^
//FORM DIV&div id="form_bericht"&&/div&//toevoegen aan form:value="& Vul hier uw voor- en achternaam in..." onfocus="this.value=''"//JS code:function showFormError(inText) {& & document.getElementById('form_bericht').style.display = "block";& & if (inText) {& & & & document.getElementById('form_bericht').innerHTML = inT& & } else {& & & & document.getElementById('form_bericht').innerHTML = "Niet alle verplichte velden zijn ingevuld.";& & }& & }& & & & function checkEmail(inValue) {& & var x=inValue& & var atpos=x.indexOf("@");& & var dotpos=x.lastIndexOf(".");& & if (atpos&1 || dotpos&atpos+2 || dotpos+2&=x.length) {& & & & & & & & & & & && & } else {& & & && & }}function check() {& & document.getElementById('form_bericht').style.display = "none"& & & & & & & & var form = document.forms["contactform"];& & & & & & & & if(form["naam"].value == "& Vul hier uw voor- en achternaam in..."){& & & & showFormError()& & & & contactform.naam.focus();& & & && & }& & if(form["naam"].value == ""){& & & & showFormError()& & & & contactform.naam.focus();& & & && & }& & & & if(form["email"].value == "& Vul hier uw e-mailadres in..."){& & & & showFormError()& & & & contactform.email.focus();& & & && & }& & if(form["email"].value == ""){& & & & showFormError()& & & & contactform.email.focus();& & & && & }& & if (!checkEmail(form["email"].value)) {& & & & showFormError("Geen geldig e-mail adres opgegeven.");& & & & contactform.email.focus();& & & & & & & & & && & }& & & & if(form["bericht"].value == "&& Vul hier uw bericht in..."){& & & & showFormError()& & & & contactform.bericht.focus();& & & && & }& & if(form["bericht"].value == ""){& & & & showFormError()& & & & contactform.bericht.focus();& & & && & }& & & & & &}//file upload&?php$uploaddir = '/var/www/uploads/';$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo "&p&";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {& echo "File is valid, and was successfully uploaded.\n";} else {&& echo "Upload failed";}echo "&/p&";echo '&pre&';echo 'Here is some more debugging info:';print_r($_FILES);print "&/pre&";?& //file upload html&form enctype="multipart/form-data" action="upload.php" method="POST"&& & &input type="hidden" name="MAX_FILE_SIZE" value="512000" /&& & Send this file: &input name="userfile" type="file" /&& & &input type="submit" value="Send File" /&&/form&//file upload #2html&& & &body&& & & & &form method="post"&& & & & & & &label for="file"&Filename:&/label&& & & & & & &input type="file" name="file1" id="file1" /& & & & & & & &br /&& & & & & & &input type="submit" name="submit" value="Submit" /&& & & & &/form&& & &/body&&/html&&?phpif(isset($_POST['submit'])) {& & if ($_FILES["file1"]["error"] & 0) {& & & & echo "Error: " . $_FILES["file1"]["error"] . "&br /&";& & } else {& & & & echo "Upload: " . $_FILES["file1"]["name"] . "&br /&";& & & & echo "Type: " . $_FILES["file1"]["type"] . "&br /&";& & & & echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb&br /&";& & & & echo "Stored in: " . $_FILES["file1"]["tmp_name"];& & }}?&//file upload #3?&& & if(isset($_FILES['image'])){& & & & $errors= array();& & & & $file_name = $_FILES['image']['name'];& & & & $file_size =$_FILES['image']['size'];& & & & $file_tmp =$_FILES['image']['tmp_name'];& & & & $file_type=$_FILES['image']['type'];&& & & & & $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));& & & & & & & & $expensions= array("jpeg","jpg","png");& & & && & & & & if(in_array($file_ext,$expensions)=== false){& & & & & & $errors[]="extension not allowed, please choose a JPEG or PNG file.";& & & & }& & & & if($file_size & 2097152){& & & & $errors[]='File size must be excately 2 MB';& & & & }& & & & & & & & & & & & if(empty($errors)==true){& & & & & & move_uploaded_file($file_tmp,"images/".$file_name);& & & & & & echo "Success";& & & & }else{& & & & & & print_r($errors);& & & & }& & }?&&form action="" method="POST" enctype="multipart/form-data"&&input type="file" name="image" /&&input type="submit"/&&/form&
This is necessary to obtain a W3C validation (XHTML1.0 Transitionnal)...phpinfo's output is declared with that DTD :- "System ID" has the wrong url to validate : "DTD/xhtml1-transitional.dtd" rather than ""- Some module names contains space and the function's output use the name in anchors as ID and NAME. these attributes can't be validated like that (unique name only).&?phpob_start ();ob_start ();& & & & & & & & & & & & & & & phpinfo ();& & & & & & & & & & & & & & && $info = trim (ob_get_clean ());& & & & && $info = preg_replace ('/(id|name)(=["\'][^ "\']+) ([^ "\']*["\'])/i', '$1$2_$3', $info);$imp = new DOMImplementation ();$dtd = $imp-&createDocumentType (& & 'html',& & '-//W3C//DTD XHTML 1.0 Transitional//EN',& & '');$doc = $imp-&createDocument (& & '',& & 'html',& & $dtd);$doc-&encoding = 'utf-8';$info_doc = new DOMDocument ('1.0', 'utf-8');@$info_doc-&loadXML ($info);$doc-&documentElement-&appendChild ( $doc-&importNode (& & & & $info_doc-&getElementsByTagName ('head')-&item (0),& & & & true& & & & & & & & & & & && ));$doc-&documentElement-&appendChild ( $doc-&importNode (& & & & $info_doc-&getElementsByTagName ('body')-&item (0),& & & & true& & & & & & & & & & & && ));$style = $doc-&getElementsByTagName ('style')-&item (0);$style-&appendChild (& & $doc-&createTextNode (& & & & '/* SOME NEW CSS RULES TO ADD TO THE FUNCTION OUTPUT */'& & ));$body = $doc-&getElementsByTagName ('body')-&item (0);$element = $doc-&createElement ('p');$element-&appendChild (& & $doc-&createTextNode (& & & & 'SOME NEW CONTENT TO DISPLAY'& & ));$body-&appendChild ($element);$head = $doc-&getElementsByTagName ('head')-&item (0);$meta = $doc-&createElement ('meta');$meta-&setAttribute ('name', 'author');$meta-&setAttribute ('content', 'arimbourg at ariworld dot eu');$head-&appendChild ($meta);$out = ob_get_clean ();$pre = $doc-&createElement ('div'); $pre-&setAttribute ('style', 'white-space:'); $pre-&appendChild ($doc-&createTextNode ($out));$body-&appendChild ($pre);$doc-&formatOutput = true; $doc-&saveXML ();?&All that could be done with only RegExp but I prefer the use of DOM for manipulating documents
//FORM DIV&div id="form_bericht"&&/div&//toevoegen aan form:value="& Vul hier uw voor- en achternaam in..." onfocus="this.value=''"//JS code:function showFormError(inText) {& & document.getElementById('form_bericht').style.display = "block";& & if (inText) {& & & & document.getElementById('form_bericht').innerHTML = inT& & } else {& & & & document.getElementById('form_bericht').innerHTML = "Niet alle verplichte velden zijn ingevuld.";& & }& & }& & & & function checkEmail(inValue) {& & var x=inValue& & var atpos=x.indexOf("@");& & var dotpos=x.lastIndexOf(".");& & if (atpos&1 || dotpos&atpos+2 || dotpos+2&=x.length) {& & & & & & & & & & & && & } else {& & & && & }}function check() {& & document.getElementById('form_bericht').style.display = "none"& & & & & & & & var form = document.forms["contactform"];& & & & & & & & if(form["naam"].value == "& Vul hier uw voor- en achternaam in..."){& & & & showFormError()& & & & contactform.naam.focus();& & & && & }& & if(form["naam"].value == ""){& & & & showFormError()& & & & contactform.naam.focus();& & & && & }& & & & if(form["email"].value == "& Vul hier uw e-mailadres in..."){& & & & showFormError()& & & & contactform.email.focus();& & & && & }& & if(form["email"].value == ""){& & & & showFormError()& & & & contactform.email.focus();& & & && & }& & if (!checkEmail(form["email"].value)) {& & & & showFormError("Geen geldig e-mail adres opgegeven.");& & & & contactform.email.focus();& & & & & & & & & && & }& & & & if(form["bericht"].value == "&& Vul hier uw bericht in..."){& & & & showFormError()& & & & contactform.bericht.focus();& & & && & }& & if(form["bericht"].value == ""){& & & & showFormError()& & & & contactform.bericht.focus();& & & && & }& & & & & &}//file upload&?php$uploaddir = '/var/www/uploads/';$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo "&p&";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {& echo "File is valid, and was successfully uploaded.\n";} else {&& echo "Upload failed";}echo "&/p&";echo '&pre&';echo 'Here is some more debugging info:';print_r($_FILES);print "&/pre&";?& //file upload html&form enctype="multipart/form-data" action="upload.php" method="POST"&& & &input type="hidden" name="MAX_FILE_SIZE" value="512000" /&& & Send this file: &input name="userfile" type="file" /&& & &input type="submit" value="Send File" /&&/form&//file upload #2html&& & &body&& & & & &form method="post"&& & & & & & &label for="file"&Filename:&/label&& & & & & & &input type="file" name="file1" id="file1" /& & & & & & & &br /&& & & & & & &input type="submit" name="submit" value="Submit" /&& & & & &/form&& & &/body&&/html&&?phpif(isset($_POST['submit'])) {& & if ($_FILES["file1"]["error"] & 0) {& & & & echo "Error: " . $_FILES["file1"]["error"] . "&br /&";& & } else {& & & & echo "Upload: " . $_FILES["file1"]["name"] . "&br /&";& & & & echo "Type: " . $_FILES["file1"]["type"] . "&br /&";& & & & echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb&br /&";& & & & echo "Stored in: " . $_FILES["file1"]["tmp_name"];& & }}?&//file upload #3?&& & if(isset($_FILES['image'])){& & & & $errors= array();& & & & $file_name = $_FILES['image']['name'];& & & & $file_size =$_FILES['image']['size'];& & & & $file_tmp =$_FILES['image']['tmp_name'];& & & & $file_type=$_FILES['image']['type'];&& & & & & $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));& & & & & & & & $expensions= array("jpeg","jpg","png");& & & && & & & & if(in_array($file_ext,$expensions)=== false){& & & & & & $errors[]="extension not allowed, please choose a JPEG or PNG file.";& & & & }& & & & if($file_size & 2097152){& & & & $errors[]='File size must be excately 2 MB';& & & & }& & & & & & & & & & & & if(empty($errors)==true){& & & & & & move_uploaded_file($file_tmp,"images/".$file_name);& & & & & & echo "Success";& & & & }else{& & & & & & print_r($errors);& & & & }& & }?&&form action="" method="POST" enctype="multipart/form-data"&&input type="file" name="image" /&&input type="submit"/&&/form&
&?php$connection = mysql_connect('localhost', 'root', '');if (!$connection){& & die("Database Connection Failed" . mysql_error());}$select_db = mysql_select_db('test');if (!$select_db){& & die("Database Selection Failed" . mysql_error());}?&--------------login and cookie------------------------------&?// Controleren op sessie if(isset($_SESSION['userID'])) {& & echo "U mag op deze pagina komen";}else{& & echo " U mag niet op deze pagina komen" ;}?&&?phpif(isset($_POST['submit'])) {& & $email = mysql_real_escape_string($_POST['email']);& & $wachtwoord = sha1(mysql_real_escape_string($_POST['wachtwoord']));& & & & $result = mysql_query('SELECT userID, email FROM gebruikers WHERE gebruikers.email = '.$email.' AND gebruikers.wachtwoord=.'$wachtwoord) or die('Database connectie is gefaalt');&& && if(mysql_num_rows($sesult) & 0) {& & & & $row = mysql_fetch_array($result);& & & & $_SESSION['userID'] = $row['userID'];& & }&& }?&&form action="login.php" method="post"&& & &input type = "text" name="email"/&& & &input type = "password" name = "wachtwoord"/&& & &input type = "submit" name = "submit" value ="inloggen"/&&/form&---------------------registration--------------------------------&?php& & require('connect.php');& & & & if (isset($_POST['email']) && isset($_POST['wachtwoord'])){& && & & & & $email = $_POST['email'];& & & & $wachtwoord = $_POST['wachtwoord'];& & & & & & & & $query = "INSERT INTO `gebruikers` (email, wachtwoord) VALUES ('$email', '$wachtwoord')";& & & & $result = mysql_query($query);& & & & & & & & if($result){& & & & & & $msg = "Registratie gelukt!";& & & & }else{& & & & & & $msg = "Registratie niet gelukt" ;& & & & }& & & & & & & & echo $msg;& & } ?&}

我要回帖

更多关于 getelementsbyid 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信