]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorDevops <sys@15gifts.com>
Tue, 4 Apr 2017 10:04:24 +0000 (11:04 +0100)
committerDevops <sys@15gifts.com>
Tue, 4 Apr 2017 10:04:24 +0000 (11:04 +0100)
lib/php/db.php
lib/php/db/table.php
www/dbq/dbq.php

index 95eb9108bd823499eab816806ab99d48d4740dc4..f18e8ce8428be4ed7308e18ab904cb8125df0062 100644 (file)
@@ -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
 
index 203761d5456c7729b4964c4503d97dc8eff44c84..08b1b1c7f5ac36cc30c987cdd2a67d19dcaa4336 100644 (file)
@@ -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();
 ?>
index 3905c9a197044fe091b4d68cfb2785b32876fa0f..06c650f0fee834fe258c02bfe508bd9d7ad1f02f 100644 (file)
@@ -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 <<<EOF
+    if ($password=='') {
+      if ($password=='') $password = $this->params['table'];
+      if ($password=='' and !empty($_POST['password'])) $password = $_POST['password'];
+      if ($this->db->is_html) echo <<<EOF
 <form action="$this->uri" method="post">
 <label>Password</label><input type="text" name="password" value="$password" />
 <input type="submit" />
 </form>
 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--;