From 501b8a8e58eb17c922a210fa8cec236232240d0b Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 25 Jan 2018 02:51:16 +0000 Subject: [PATCH] www/dbq/dbq.php --- lib/php/ldap.php | 6 ++-- www/dbq/dbq.php | 76 +++++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/lib/php/ldap.php b/lib/php/ldap.php index 632b3f49..491284ff 100644 --- a/lib/php/ldap.php +++ b/lib/php/ldap.php @@ -193,15 +193,15 @@ class Ldap { public function add($dn,$data) { $conn = $this->conn(); - return ldap_add($conn, $dn, $data); # or self::bye("Unable to add entry to ldap server"); + return ldap_add($conn, $dn, $data); } public function update($dn,$data) { - return ldap_mod_add($this->conn(), $dn, $data); # or self::bye("Unable to add entry to ldap server"); + return ldap_mod_add($this->conn(), $dn, $data); } public function delete($dn) { - return ldap_delete($this->conn(), $dn); # or self::bye("Unable to add entry to ldap server"); + return ldap_delete($this->conn(), $dn); } } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index c6faf4c8..8dbf539e 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -176,53 +176,55 @@ class DbQ extends nb { #debug($GLOBALS['DBQ_LDAP']); $ldap = new Ldap($GLOBALS['DBQ_LDAP']); - if ($this->params['table'] == 'add') { - debug($this->params); - $rows = (int)$ldap->add($this->params['action'],$_POST); - bye($_POST); - $this->page($rows); + if ($this->params['table'] == 'add') { + #debug($this->params); + $rows = (int)$ldap->add($this->params['action'],$_POST); + #bye($_POST); + $this->page($rows); - } elseif ($this->params['table'] == 'update') { - $rows = (int)$ldap->update($this->params['action'],$_POST); - $this->page($rows); + } elseif ($this->params['table'] == 'update') { + $rows = (int)$ldap->update($this->params['action'],$_POST); + $this->page($rows); - } elseif ($this->params['table'] == 'rm') { - $rows = (int)$ldap->delete($this->params['action'],$_POST); - $this->page($rows); + } elseif ($this->params['table'] == 'rm') { + $rows = (int)$ldap->delete($this->params['action'],$_POST); + $this->page($rows); - } + } else { - $filter = ($this->params['table'] ? $this->params['table'] : ''); - $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []); + $filter = ($this->params['table'] ? $this->params['table'] : ''); + $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []); - if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) { - $filter = ''; - $attrs = explode(',',$this->params['table']); - } + if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) { + $filter = ''; + $attrs = explode(',',$this->params['table']); + } - $search = [ - 'filter' => $filter, - 'attrs' => $attrs, - ]; + $search = [ + 'filter' => $filter, + 'attrs' => $attrs, + ]; - if (!$search['filter']) { - if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) { - $search['filter'] = $m[1]; - $search['base'] = $m[2]; - } else { - $search['filter'] = 'cn='.Http::user(); + if (!$search['filter']) { + if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) { + $search['filter'] = $m[1]; + $search['base'] = $m[2]; + } else { + $search['filter'] = 'cn='.Http::user(); + } } - } - $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search); + $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search); + + #echo $rows[0]['jpegPhoto']; exit; + #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ]; + if ($this->is_html + or ($this->params['format'] == $this->format_cli) + or ($this->params['format'] == 'csv') + ) $rows = $this->array_fill_assoc($rows); - #echo $rows[0]['jpegPhoto']; exit; - #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ]; - if ($this->is_html - or ($this->params['format'] == $this->format_cli) - or ($this->params['format'] == 'csv') - ) $rows = $this->array_fill_assoc($rows); + $this->page($rows); + } - $this->page($rows); } public function page_table_ls($args=null) { -- 2.47.3