From: Nicolas Boisselier Date: Mon, 21 Dec 2015 20:38:41 +0000 (+0000) Subject: referer X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a01147eba0750b4242f3994cca237a9f3f0ef0c7;p=nb.git referer --- diff --git a/lib/php/db/table.php b/lib/php/db/table.php index cd58204b..5dad705d 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -292,14 +292,15 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. echo '' .'
' - .'' - .'' - .'' - .'' .( empty($_SERVER['HTTP_REFERER']) ? '' : '') .'' .'' .'
'.PHP_EOL + .'' + .'' + .'' + .'' + .'' .''.PHP_EOL; } @@ -943,6 +944,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. foreach ($fields as $name) { $field->bindParam($query,$hvalues[$name],":$name"); } + foreach ($keys as $name) { $field->bindParam($query,$hvalues[$name],":key_$name"); } @@ -989,14 +991,22 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. } elseif ($action == 'insert') { $this->insert($this->p()); - header('Location: ?table=' . $this->name); + if ($this->p('referer')) { + header('Location: '.urldecode($this->p('referer'))); + } else { + header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : '')); + } #header('Location: '.str_replace('&','&',$this->url_list())); return true; } elseif ($action == 'update') { #$this->bye($this->p()); $this->update($this->p()); - header('Location: ?table=' . $this->name); + if ($this->p('referer')) { + header('Location: '.urldecode($this->p('referer'))); + } else { + header('Location: ?table=' . $this->name . ($this->p('db') ? '&db='.$this->db->name : '')); + } #header('Location: '.str_replace('&','&',$this->url_list())); return true; diff --git a/lib/php/nb.php b/lib/php/nb.php index 91fb341b..e64b49ad 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -5,14 +5,14 @@ class nb { # Sql: elect type,ext from mime_type where ext in ('json','csv','txt','yaml','xml','html','doc','xls'); public static $content_types = array( - 'application/json' => 'json', - 'application/msword' => 'doc', - 'application/vnd.ms-excel' => 'xls', - 'application/xml' => 'xml', - 'text/csv' => 'csv', - 'text/html' => 'html', - 'text/plain' => 'txt', - 'text/yaml' => 'yaml', + 'json' => 'application/json', + 'doc' => 'application/msword', + 'xls' => 'application/vnd.ms-excel', + 'xml' => 'application/xml', + 'csv' => 'text/csv', + 'html' => 'text/html', + 'txt' => 'text/plain', + 'yaml' => 'text/yaml', ); function __destruct() { @@ -69,7 +69,7 @@ class nb { * Does what it says */ static function ext2mime($ext) { - foreach (self::$content_types as $c => $e) { + foreach (self::$content_types as $e => $c) { if ($ext == $e) return $c; } }