]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 11 Oct 2024 10:17:43 +0000 (12:17 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 11 Oct 2024 10:17:43 +0000 (12:17 +0200)
lib/php/page.php
www/dbq/dbq.php

index 3b55d215911c125ad692828d7c20dd676b89d6d4..b5a055982035baaa4177ccec2084b0d93316991e 100644 (file)
@@ -536,10 +536,19 @@ class Page extends nb {
 
   public static function phpinfo($text=null) {
     if ($text===null) $text = self::php_cli();
+
     ob_start();
     phpinfo(INFO_ALL - INFO_LICENSE);
     $phpinfo = ob_get_contents();
     ob_end_clean();
+    # NB 11.10.24 if ($text) {
+       # NB 11.10.24 $datas = [];
+       # NB 11.10.24 $section = 'php';
+       # NB 11.10.24 foreach (explode("\n",$phpinfo) as $line) {
+               # NB 11.10.24 debug($line);
+       # NB 11.10.24 }
+       # NB 11.10.24 return [];
+    # NB 11.10.24 }
 
     # Only tags without attrs
     $phpinfo = preg_replace('/(<\w+)\s+[^>]+/','$1',$phpinfo);
@@ -556,7 +565,6 @@ class Page extends nb {
     # Pretty h2
     $phpinfo =  preg_replace_callback ('@(<h2>(?:<[^>]+>)?)([^<]+)@',function($m){return $m[1].prettyText($m[2]);},$phpinfo);
 
-# NB 21.12.16     if ($text) return $phpinfo;
     if (!preg_match_all('@(<h2.*?</table>)@s',$phpinfo,$m)) return '';
     #bye($m[0]);
     if ($text) return strip_tags(join("\n",$m[0]));
index 1384d1130e64f6edcff9b42391e1eb4077156d6c..9834a0de9252c877bbf327321664e3ff9f8e8367 100644 (file)
@@ -1062,6 +1062,37 @@ 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, '<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;
 
@@ -1286,6 +1317,7 @@ EOF;
 
                } elseif ($action == 'phpinfo') {
                        $this->deniedUnless($this->perm >= self::ADMIN);
+                       #phpinfo();
                        $this->rows_table($action,$this->phpinfo_rows());
                        #$this->page(['phpinfo'=>$this->page->phpinfo(true)]);
                        #$this->page($this->page->phpinfo());