}
- public function todo_phpinfo_rows($text=null) {
- #phpinfo(INFO_ALL - INFO_LICENSE);
- 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);
- $t = preg_split('/(<h2[^>]*>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
- $r = array(); $count = count($t);
- $p1 = '<info>([^<]+)<\/info>';
- $p2 = '/'.$p1.'\s*'.$p1.'\s*'.$p1.'/';
- $p3 = '/'.$p1.'\s*'.$p1.'/';
- $lines = [];
- for ($i = 1; $i < $count; $i++) {
- if (preg_match('/<h2[^>]*>([^<]+)<\/h2>/', $t[$i], $matchs)) {
- $name = trim($matchs[1]);
- #$vals = explode("\n", $t[$i + 1]);
- $vals = $t[$i + 1];
- $lines [] = "TODO\n$name\t$vals";
- foreach ($vals AS $val) {
- if (preg_match($p2, $val, $matchs)) { // 3cols
- $r[$name][trim($matchs[1])] = array(trim($matchs[2]), trim($matchs[3]));
- } elseif (preg_match($p3, $val, $matchs)) { // 2cols
- $r[$name][trim($matchs[1])] = trim($matchs[2]);
- }
- }
- }
- }
- return $lines;
- return $r;
- }
-
- public function phpinfo_rows() {
- $txt = $this->is_html ? 0 : 1;
-
- $rows = [];
- $row = [];
- $section = '';
- $p = [
- 'section' => $this->p('section',''),
- 'name' => $this->p('name',''),
- 'value' => $this->p('value',''),
- ];
-
- foreach (explode("\n",$this->page->phpinfo()) as $line) {
-
- if (preg_match(',<h2[^>]*>(.*?)</h2>,',$line,$m)) {
- $section = strtoupper(strip_tags(preg_replace('/\W+/','_',$m[1])));
-
- } elseif (preg_match_all(',<td>(.*?)</td>,',$line,$m)) {
- $name = strip_tags($m[1][0]);
- $value = isset($m[1][1]) ? strip_tags($m[1][1]) : '';
-
- if (preg_match('/^\$_([A-Z_]+)\[["\']([^"\']+)["\']\]/',$name,$m)) {
- $_section = $m[1];
- $name = $m[2];
- } else {
- $_section = $section;
- }
-
- #debug($m);
- if ($p['name'] and !$this->str_match($name,$p['name'])) continue;
- if ($p['value'] and !$this->str_match($value,$p['value'])) continue;
- if ($p['section'] and !$this->str_match($_section,$p['section'])) continue;
-
- if (
- $_section == 'PHP_VARIABLES'
- and preg_match('/^(._SERVER\[.)?(.' . $this->hide_keys_exp . ')(.\])?$/', $name)
- ) {
- $value = $this->hide_keys_value;
- }
-
- $rows[] = [
- 'section' => $_section,
- 'name' => $name,
- 'value' => $value,
- ];
-
- } else {
- #debug($sec." ".$line);
- }
-
- }
-
- return $rows;
- #return $this->page($rows);
- }
-
public function rows_table($name,$rows) {
$this->params['table'] = $name;
$this->params['db'] = ' ';
} elseif ($action == 'phpinfo') {
$this->deniedUnless($this->perm >= self::ADMIN);
- ob_start();
- system("php -r 'phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES + INFO_ENVIRONMENT + INFO_VARIABLES);'");
- $phpinfo = ob_get_contents();
- ob_end_clean();
-
- $lines = explode("\n",$phpinfo);
-
- $section = '';
- $sub = '';
- $rows = [];
-
- while (true) {
- $line = next($lines);
- if ($line === false) break;
- if ($line == 'PHP Credits') break; # No more interrested
-
- // Section
- if (strpos($line, '_______') === 1) {
- #bye($line);
- $section = '';
- while (empty($section)) {
- $section = next($lines);
- }
- #bye($section);
- continue;
- }
-
- // Sub
- if (!empty($line) and substr(trim($line), -1) !== ',' and !strpos($line, '=>')) {
- if (strlen($line)<50)
- $sub = $line;
- #bye($sub);
- continue;
- }
-
- // Key => Val
- $keyVal = explode(' => ',$line);
- if (count($keyVal)>1) {
- $key = array_shift($keyVal);
- $val = array_shift($keyVal);
-
- // Add multi lines values coma
- while (substr(trim($line), -1) === ',') {
- $line = next($lines);
- if ($line === false) break;
- $val .= ' '.$line;
- }
-
- // Add multi lines values Array
- if ($val === 'Array') {
- while (trim($line) !== ')') {
- $line = next($lines);
- if ($line === false) break;
- $val .= ' '.trim($line);
- }
- }
-
- #if ($key == 'Additional .ini files parsed') continue;
- #$val = preg_replace('((</?)(?:font)(\s[^>]+>)','${1}span${2}',$val);
- $val = preg_replace('/(<\/?)(?:font)([\s>]|$)/','${1}span${2}',$val);
- $rows[] = [
- 'section' => $section,
- 'sub' => $sub,
- 'key' => $key,
- 'val' => $val,
- ];
- }
-
- }
-
- $this->page($rows);
- #$this->page($this,'phpinfo_rows');
+ $this->page($this->phpinfo());
} elseif ($action == '_POST') { $this->page($_POST);
} elseif ($action == '_GET') { $this->page($_GET);
}
}
+ private function phpinfo() {
+ ob_start();
+ system("php -r 'phpinfo(INFO_GENERAL + INFO_CONFIGURATION + INFO_MODULES + INFO_ENVIRONMENT + INFO_VARIABLES);'");
+ $phpinfo = ob_get_contents();
+ ob_end_clean();
+
+ $lines = explode("\n",$phpinfo);
+
+ $section = '';
+ $sub = '';
+ $rows = [];
+
+ while (true) {
+ $line = next($lines);
+ if ($line === false) break;
+ if ($line == 'PHP Credits') break; # No more interrested
+
+ // Section
+ if (strpos($line, '_______') === 1) {
+ #bye($line);
+ $section = '';
+ while (empty($section)) {
+ $section = next($lines);
+ }
+ #bye($section);
+ continue;
+ }
+
+ // Sub
+ if (!empty($line) and substr(trim($line), -1) !== ',' and !strpos($line, '=>')) {
+ if (strlen($line)<50)
+ $sub = $line;
+ #bye($sub);
+ continue;
+ }
+
+ // Key => Val
+ $keyVal = explode(' => ',$line);
+ if (count($keyVal)>1) {
+ $key = array_shift($keyVal);
+ $val = array_shift($keyVal);
+
+ // Add multi lines values coma
+ while (substr(trim($line), -1) === ',') {
+ $line = next($lines);
+ if ($line === false) break;
+ $val .= ' '.$line;
+ }
+
+ // Add multi lines values Array
+ if ($val === 'Array') {
+ while (trim($line) !== ')') {
+ $line = next($lines);
+ if ($line === false) break;
+ $val .= ' '.trim($line);
+ }
+ }
+
+ #if ($key == 'Additional .ini files parsed') continue;
+ #$val = preg_replace('((</?)(?:font)(\s[^>]+>)','${1}span${2}',$val);
+ $val = preg_replace('/(<\/?)(?:font)([\s>]|$)/','${1}span${2}',$val);
+ $rows[] = [
+ 'section' => $section,
+ 'sub' => $sub,
+ 'key' => $key,
+ 'val' => $val,
+ ];
+ }
+
+ }
+
+ return $rows;
+ } // phpinfo()
+
public function run_db() {
$this->deniedUnless($this->perm >= self::READ);
$this->db(true); # Db Connections