]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Dec 2017 02:33:24 +0000 (02:33 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 13 Dec 2017 02:33:24 +0000 (02:33 +0000)
lib/php/nb.php
www/dbq/dbq.php

index ca31a60d6e2719f54a743165444a60115d0c6e74..127d65c47487b989fbd6732b78a034b2d5880f05 100644 (file)
@@ -1082,10 +1082,10 @@ class NB {
 
                if (!isset($o['bind_dn'])) $o['bind_dn'] = 'cn=' . $o['user'] . $o['bind_dn_preff'] . $o['base_dn'];
 
-               if (!isset($o['filter'])) $o['filter'] = "(cn=".$o['user'].")";
-               if (!isset($o['attrs'])) $o['attrs'] = [];
+               if (empty($o['filter'])) $o['filter'] = "(cn=".$o['user'].")";
+               if (empty($o['attrs'])) $o['attrs'] = [];
 
-               #return $o;
+               #return [$o];
 
                $connect = ldap_connect($o['host']) or exit(">>Could not connect to LDAP server<<");
                ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
index 3806ece72aa08ada9a2da5147aeeba7ac58cb8b1..16abac39f2c26679ab8c69fed59e5cc64bfee3e3 100644 (file)
@@ -7,10 +7,12 @@ require_once(NB_ROOT.'/lib/php/http.php');
 require_once(NB_ROOT.'/lib/php/mime.php');
 
 function dbqErrHandle($errNo, $errStr, $errFile, $errLine) {
-               $msg = "$errStr in $errFile on line $errLine";
+               $msg = "$errStr in $errFile on line $errLine\n";
                if ($errNo == E_NOTICE || $errNo == E_WARNING) {
                                header("HTTP/1.0 500 Internal Server Error");
-                               throw new ErrorException($msg, $errNo);
+# NB 13.12.17                          Revel args from function which could be passwords !!!
+# NB 13.12.17                          throw new ErrorException($msg, $errNo);
+                               nb::bye("$errNo: $msg");
                } else {
                                echo $msg;
                }
@@ -48,7 +50,8 @@ class DbQ extends nb {
        public $uri;
        public $uri_params;
        private $param_args_sep = ' ';
-       private $param_exp_value = '[\w\._:-]{2,100}';
+# NB 13.12.17  private $param_exp_value = '[\w\._:-]{2,100}';
+       private $param_exp_value = '[^/]{2,100}';
 
        public $params = [
                'format' => '',
@@ -995,10 +998,15 @@ EOF;
                // NOW ONLY FOR ADMIN !
                } elseif ($this->perm < self::ADMIN) {
 
-               } elseif ($action == 'ldap_search') {
-                       $this->page($this->ldap_search([
-                               'bind_dn_preff'=>'ou=auth',
-                       ]));
+               } elseif ($action == 'ldap') {
+                       #debug($this->params);
+                       $rows = $this->ldap_search([
+                               'bind_dn_preff' => 'ou=auth',
+                               'filter' => ($this->params['table'] ? $this->params['table'] : ''),
+                               'attrs' => ($this->params['action'] ? explode(',',$this->params['action']) : []),
+                       ]);
+                       if ($this->is_html) $rows = $this->array_fill_assoc($rows);
+                       $this->page($rows);
 
                } elseif ($action == 'phpinfo') {
                        $this->rows_table($action,$this->phpinfo_rows());