From 9ce76d349f346b5e7f68a7bce0b2aad9db3a6751 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 31 Oct 2017 01:54:57 +0000 Subject: [PATCH] /opt/nb/lib/php/nb.php --- etc/profile.d/dbq.sh | 1 + lib/php/db.php | 3 ++- lib/php/db/table.php | 15 ++++++++++----- lib/php/nb.php | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/etc/profile.d/dbq.sh b/etc/profile.d/dbq.sh index c3e39c6d..ea38de2a 100644 --- a/etc/profile.d/dbq.sh +++ b/etc/profile.d/dbq.sh @@ -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 $@ diff --git a/lib/php/db.php b/lib/php/db.php index 3183e01f..22d900c7 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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 ?> diff --git a/lib/php/db/table.php b/lib/php/db/table.php index be606114..165e5510 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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(); ?> diff --git a/lib/php/nb.php b/lib/php/nb.php index be0996c0..0ee77209 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -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__') { -- 2.47.3