public function __construct($attr=[]) {
if (is_scalar($attr)) $attr = ['name'=>$attr];
- foreach ($attr as $k => $v) { $this->$k = $v; }
- #if (isset($attr['type'])) debug($attr['type']);
- #debug($this->name.'='.$this->type.nb::debug_backtrace_msg());
+ # NB 07.10.24 foreach ($attr as $k => $v) { $this->$k = $v; }
+ foreach ($attr as $k => $v) {
+ if (property_exists($this,$k)) $this->$k = $v;
+ }
}
public function default2str($default=null) {
public function __sleep() {
return(get_class_vars(get_class($this))); # get all
-# NB 09.04.16 return array_keys((array)$this);
- #debug((array)$this); # publics + private in a weird way !
- #debug(get_object_vars($this)); # non static
}
#public function __wakeup() { }
}
public static function php_cli() {
-# NB 05.03.16 define('NB_CLI', PHP_SAPI === 'cli');
static $php_cli;
if ($php_cli===null or $php_cli==='') $php_cli= (
!isset($_SERVER['SERVER_SOFTWARE']) && (php_sapi_name() == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))
public function ldap($table='',$attrs=[]) {
$this->deniedUnless($this->perm >= self::ADMIN);
-# NB 28.01.18 if (!$table) $table = $this->params['table'];
-# NB 28.01.18 if (!$attrs) $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []);
-
require_once(NB_ROOT.'/lib/php/ldap.php');
#debug($GLOBALS['DBQ_LDAP']);
$dn = join(',',$attrs);
}
private function vi_extract_fields() {
- $sep = $this->param_args_sep . $this->param_args_sep;
- #$sep ='@';
+#debug($_REQUEST);
+ #bye($this->params);
+ # NB 07.10.24 why double ??? $sep = $this->param_args_sep . $this->param_args_sep;
+ $sep = $this->param_args_sep;
$fields = [];
if (strpos($this->params['args'],$sep) !== false) {
}
public function vi($add=false) {
- $all = [];
$nosql = $this->db->conf_type('nosql');
$fields = $this->vi_extract_fields();
+ $all = [];
$keys = $this->table->fields_keys($all);
if (!$keys) $keys = $all;
$keys = array_keys($keys);
+ $values = [];
# NB 26.08.24 $values = ($_SERVER['REQUEST_METHOD'] == 'POST') ? $_POST : explode($this->param_args_sep,$this->params['args']);
if (!empty($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] == 'POST') {
$values = $_POST;
+ } elseif (!empty($_GET)) {
} elseif($this->params['args']) {
- $values = explode($this->param_args_sep,$this->params['args']);
- } else {
- $values = $_GET;
+ # NB 07.10.24 $values = explode($this->param_args_sep,$this->params['args']);
+ $args = explode($this->param_args_sep,$this->params['args']);
+ # NB 07.10.24: Handle case: /DB/TABLE/vi/VALUE
+ for ($i=0;$i<count($keys);$i++) {
+ $k = $keys[$i];
+ $values[$k] = $args[$i];
+ }
}
foreach ($values as $k=>$v) {
}
public function error($admin_msg='') {
- header('Content-type: text/plain');
+ $type = $this->is_html ? 'text/html' : 'text/plain';
+ header("Content-type: $type");
$msg = '500 Internal Server Error';
if (empty($_SERVER['SERVER_PROTOCOL'])) $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
$this->page_table_ls($m[1]);
} elseif ($action == 'vi'
- # NB 29.08.24 or $action!=""
+ # NB 29.08.24 or $action!="" # default action will be vi
) {
if ($action != 'vi') $this->params['args'] = $action;
- #bye($this->params);
$this->deniedUnless($this->perm >= self::READ);
$this->page($this,'vi');
#die($_SERVER['REQUEST_URI']."\n");
#die($_SERVER['QUERY_STRING']."\n");
#phpinfo(); exit;
+#debug($this->params['args']);
$DBQ = new DbQ([
'run' => true,
'base' => (($base = Dbq::client_header('Dbq-Base')) ? preg_replace(',/+$,','',$base) : ''),