From 6271a7fd275effdda2e4ece419cf667427482025 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 20 Nov 2024 21:20:56 +0100 Subject: [PATCH] www/dbq/dbq.php --- www/dbq/dbq.php | 234 ++++++++++++++++-------------------------------- 1 file changed, 75 insertions(+), 159 deletions(-) diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 87c9d422..1bd061c3 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -1056,93 +1056,6 @@ EOF; } - 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, '

'); - $s = preg_replace('/]*>([^<]+)<\/th>/', '\1', $s); - $s = preg_replace('/]*>([^<]+)<\/td>/', '\1', $s); - $t = preg_split('/(]*>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE); - $r = array(); $count = count($t); - $p1 = '([^<]+)<\/info>'; - $p2 = '/'.$p1.'\s*'.$p1.'\s*'.$p1.'/'; - $p3 = '/'.$p1.'\s*'.$p1.'/'; - $lines = []; - for ($i = 1; $i < $count; $i++) { - if (preg_match('/]*>([^<]+)<\/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(',]*>(.*?)

,',$line,$m)) { - $section = strtoupper(strip_tags(preg_replace('/\W+/','_',$m[1]))); - - } elseif (preg_match_all(',(.*?),',$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'] = ' '; @@ -1312,78 +1225,7 @@ EOF; } 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('((]+>)','${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); @@ -1405,6 +1247,80 @@ EOF; } } + 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('((]+>)','${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 -- 2.47.3