]> git.nbdom.net Git - nb.git/commitdiff
/opt/nb/lib/php/nb.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 31 Oct 2017 01:54:57 +0000 (01:54 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 31 Oct 2017 01:54:57 +0000 (01:54 +0000)
etc/profile.d/dbq.sh
lib/php/db.php
lib/php/db/table.php
lib/php/nb.php

index c3e39c6da60502690fadc20ccb048c52b435d80f..ea38de2a7bb1e99867f47044ba5823584f4ea706 100644 (file)
@@ -1,4 +1,5 @@
 which dbq > /dev/null || return 0
+#[ -z "$DBQ_DB" ] && DBQ_DB=nb-sys
 
 dbq2sqlite() {
   dbq f=txt a=db.dump db.type=sqlite $@
index 3183e01fcc5946d9c2727c594b6aeb75d78ac2f5..22d900c7a0c9a2e65fcfed2404a6382d011ece1b 100644 (file)
@@ -1315,13 +1315,14 @@ class Db extends nb {
     $password = '{SSHA512}' . base64_encode(hash('sha512', $password . $salt). $salt);
     return $password;
   }
+
   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 be60611438c6f3e40d850e5f15f0d5d8a0d738ca..165e55102991b19b56f784c49a426720c5095ef8 100644 (file)
@@ -1261,7 +1261,7 @@ Class Table extends nb {
     $id = preg_replace('/[^\w\._-]/','',$id);
 
     $file = TABLE_TEMPLATE.'/'.$id.'.php';
-    if (!is_readable($file)) return false; #self::bye("Wrong id `$id`");
+    if (!is_readable($file)) return false; #$this->bye("Wrong id `$id`");
 # NB 02.12.16     $o['file'] = $file;
     $this->__file = $file;
     $this->__fields = array_keys($fields);
@@ -2176,10 +2176,10 @@ Class Table extends nb {
 
   private function template_id($id=null) {
     if (empty($id)
-      and !( $id=self::p('table.template.id') )
-      and !( $id=self::p('idtemplate') )
+      and !( $id=$this->p('table.template.id') )
+      and !( $id=$this->p('idtemplate') )
       and !( $id = $this->template_id )
-    ) self::bye('Wrong parameter!');
+    ) $this->bye('Wrong parameter!');
     return $id;
   }
 
@@ -2189,7 +2189,7 @@ Class Table extends nb {
     $id = preg_replace('/[^\w\._-]/','',$id);
 
     $file = TABLE_TEMPLATE.'/'.$id.'.php';
-    if (!is_readable($file)) return false; #self::bye("Wrong id `$id`");
+    if (!is_readable($file)) return false; #$this->bye("Wrong id `$id`");
 
     $opt = [ 'format'=> '' ];
     $this->rows($opt);
@@ -2220,6 +2220,11 @@ Class Table extends nb {
   public function ssha_password($password) {
     return $this->db()->ssha_password($password);
   }
+
+  static public function _bye($msg = '__bye__', $backtrace_deep = 0) {
+    die($msg);
+  }
+
 } # < Class
 __table_define();
 ?>
index be0996c0beb8155fe67e3163dbc85ccbae528c91..0ee772095a66bf7ed0b11cafe26d1f0d36bfa177 100644 (file)
@@ -150,7 +150,7 @@ class NB {
 # NB 30.10.17     return bye($msg,$backtrace_deep+1);
 # NB 30.10.17   }
   # # NB 30.10.17: From function.php 
-  public function bye($msg='__bye__',$backtrace_deep=0) {
+  public static function bye($msg='__bye__',$backtrace_deep=0) {
     #if ($msg) err($msg,'bye',$backtrace_deep === 0 ? 1 : $backtrace_deep);
 
     if ($msg!=='__bye__') {