From: Devops Date: Tue, 4 Apr 2017 10:04:24 +0000 (+0100) Subject: www/dbq/dbq.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=f0e6a7c0ee5496991fc4b1cd15401c544ed64cdc;p=nb.git www/dbq/dbq.php --- diff --git a/lib/php/db.php b/lib/php/db.php index 95eb9108..f18e8ce8 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -1268,6 +1268,11 @@ class Db extends nb { } public function table_row_encrypt(&$table,&$row) { + if (!empty($table->update_parse)) { + $fct = $table->update_parse; + $row = $fct($row,$table); + } + if (0 or empty($this->encrypt) or empty($this->encrypt['secret']) @@ -1332,6 +1337,12 @@ class Db extends nb { ],$opt)); } + public function ssha_password($password='') { + if (empty($password)) return $password; + $salt = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',4)),0,4); + $password = '{SSHA}' . base64_encode(sha1( $password.$salt, TRUE ). $salt); + return $password; + } #public function default_table() { return $this->default_table; } } # < Class diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 203761d5..08b1b1c7 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -27,6 +27,7 @@ Class Table extends nb { public $rows = []; # array inserted into temporary table public $row_parse_pre; # Function to call in rows() public $row_parse_post; # Function to call in rows() + public $update_parse; # Function to call in update, replace, insert public $count; public $engine; public $created; @@ -2205,6 +2206,10 @@ Class Table extends nb { #return $ex; } + + public function ssha_password($password='') { + return $this->db->ssha_password($password); + } } # < Class __table_define(); ?> diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 3905c9a1..06c650f0 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -463,18 +463,17 @@ class DbQ extends nb { } public function ssha_password($password='') { - if ($password=='') $password = $this->params['table']; - if ($password=='' and !empty($_POST['password'])) $password = $_POST['password']; - if ($this->db->is_html) echo <<params['table']; + if ($password=='' and !empty($_POST['password'])) $password = $_POST['password']; + if ($this->db->is_html) echo << EOF; - if (!$password) return []; - $salt = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',4)),0,4); - $password = '{SSHA}' . base64_encode(sha1( $password.$salt, TRUE ). $salt); - return [ 'SSHA' => $password ]; + } + return $this->db->ssha_password($password); } public function status() { #$this->perm--;