From 56618935641e1f02f355e8dc05e11dca7126182d Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 17 Jan 2018 01:29:14 +0000 Subject: [PATCH] lib/php/nb.php --- lib/php/db/table.php | 12 +-- lib/php/http.php | 187 +++++++++++++++++++++------------------ lib/php/nb.php | 22 +---- lib/php/out/php_hash.php | 15 +++- lib/php/out/sh.php | 2 +- www/dbq/dbq.php | 15 ++-- 6 files changed, 132 insertions(+), 121 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index bf66e64d..0866b7db 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -145,7 +145,7 @@ Class Table extends nb { foreach ($this->rows as $row) { foreach ($row as $k=>$v) { - $field = $this->fields($k); + $field = $this->field($k); $field->bindParam($query,$v,":$k"); } @@ -661,7 +661,7 @@ Class Table extends nb { public function url_sort($name) { - if (!$this->show_url_sort or !($f=$this->fields($name)) or !empty($f->dyn) or $f->is_encrypt()) return self::prettyText($name); + if (!$this->show_url_sort or !($f=$this->field($name)) or !empty($f->dyn) or $f->is_encrypt()) return self::prettyText($name); #debug($f); # See: http://dev.w3.org/html5/html-author/charref @@ -1213,6 +1213,7 @@ Class Table extends nb { $count_fields = 0; foreach ($fields as $f => $field) { + if (!$this->field($f)) continue; $row[$f] = $field->out(isset($row[$f]) ? $row[$f] : ''); $count_fields++; } @@ -1395,7 +1396,7 @@ Class Table extends nb { foreach ($row as $k=>$v) { if (isset($this->extras[$k])) continue; - $f = $this->fields($k); + $f = $this->field($k); $values[] = $f->quote($v); $keys[] = $f->sql_name(); @@ -2216,11 +2217,6 @@ Class Table extends nb { public function unserialize() { $o = unserialize($this->serialize()); - #return $this->out($this->fields('id')); - #return serialize($this->fields()); - #$this = $o; - #return($o->sql_name()); - #debug($o->sql_name()); return var_export($o,true); } diff --git a/lib/php/http.php b/lib/php/http.php index 9b5d5cdf..e1f85b1d 100644 --- a/lib/php/http.php +++ b/lib/php/http.php @@ -1,91 +1,91 @@ SHELL_REPLACE dbq db=$NB_DB t=http_status -cut 1,2 | perl -pe "s/'/\\\\'/; s/^(.*?)\t(.*?)$/ '\$1' => '\$2',/" - '100' => 'Continue', - '101' => 'Switching Protocols', - '102' => 'Processing', - '200' => 'OK', - '201' => 'Created', - '202' => 'Accepted', - '203' => 'Non-Authoritative Information', - '204' => 'No Content', - '205' => 'Reset Content', - '206' => 'Partial Content', - '207' => 'Multi-Status', - '208' => 'Already Reported', - '226' => 'IM Used', - '300' => 'Multiple Choices', - '301' => 'Moved Permanently', - '302' => 'Found', - '303' => 'See Other', - '304' => 'Not Modified', - '305' => 'Use Proxy', - '306' => 'Switch Proxy', - '307' => 'Temporary Redirect', - '308' => 'Permanent Redirect', - '400' => 'Bad Request', - '401' => 'Unauthorized', - '402' => 'Payment Required', - '403' => 'Forbidden', - '404' => 'Not Found', - '405' => 'Method Not Allowed', - '406' => 'Not Acceptable', - '407' => 'Proxy Authentication Required', - '408' => 'Request Time-out', - '409' => 'Conflict', - '410' => 'Gone', - '411' => 'Length Required', - '412' => 'Precondition Failed', - '413' => 'Payload Too Large', - '414' => 'URI Too Long', - '415' => 'Unsupported Media Type', - '416' => 'Range Not Satisfiable', - '417' => 'Expectation Failed', - '418' => 'I\'m a teapot', - '421' => 'Misdirected Request', - '422' => 'Unprocessable Entity', - '423' => 'Locked', - '424' => 'Failed Dependency', - '426' => 'Upgrade Required', - '428' => 'Precondition Required', - '429' => 'Too Many Requests', - '431' => 'Request Header Fields Too Large', - '451' => 'Unavailable For Legal Reasons', - '500' => 'Internal Server Error', - '501' => 'Not Implemented', - '502' => 'Bad Gateway', - '503' => 'Service Unavailable', - '504' => 'Gateway Time-out', - '505' => 'HTTP Version Not Supported', - '506' => 'Variant Also Negotiates', - '507' => 'Insufficient Storage', - '508' => 'Loop Detected', - '510' => 'Not Extended', - '511' => 'Network Authentication Required', - '420' => 'Method Failure', - '450' => 'Blocked by Windows Parental Controls', - '498' => 'Invalid Token', - '509' => 'Bandwidth Limit Exceeded', - '530' => 'Site is frozen', - '599' => 'Network connect timeout error', - '440' => 'Login Time-out', - '449' => 'Retry With', - '444' => 'No Response', - '495' => 'SSL Certificate Error', - '496' => 'SSL Certificate Required', - '497' => 'HTTP Request Sent to HTTPS Port', - '499' => 'Client Closed Request', - '520' => 'Unknown Error', - '521' => 'Web Server Is Down', - '522' => 'Connection Timed Out', - '523' => 'Origin Is Unreachable', - '524' => 'A Timeout Occurred', - '525' => 'SSL Handshake Failed', - '526' => 'Invalid SSL Certificate', - '527' => 'Railgun Error', - '103' => 'Checkpoint', - '419' => 'I', +#>SHELL_REPLACE dbq db=$NB_DB t=http_status rows.fields=id,name orderby=id f=php_hash | sed "s/^/\t/" + "100" => "Continue", + "101" => "Switching Protocols", + "102" => "Processing", + "103" => "Checkpoint", + "200" => "OK", + "201" => "Created", + "202" => "Accepted", + "203" => "Non-Authoritative Information", + "204" => "No Content", + "205" => "Reset Content", + "206" => "Partial Content", + "207" => "Multi-Status", + "208" => "Already Reported", + "226" => "IM Used", + "300" => "Multiple Choices", + "301" => "Moved Permanently", + "302" => "Found", + "303" => "See Other", + "304" => "Not Modified", + "305" => "Use Proxy", + "306" => "Switch Proxy", + "307" => "Temporary Redirect", + "308" => "Permanent Redirect", + "400" => "Bad Request", + "401" => "Unauthorized", + "402" => "Payment Required", + "403" => "Forbidden", + "404" => "Not Found", + "405" => "Method Not Allowed", + "406" => "Not Acceptable", + "407" => "Proxy Authentication Required", + "408" => "Request Time-out", + "409" => "Conflict", + "410" => "Gone", + "411" => "Length Required", + "412" => "Precondition Failed", + "413" => "Payload Too Large", + "414" => "URI Too Long", + "415" => "Unsupported Media Type", + "416" => "Range Not Satisfiable", + "417" => "Expectation Failed", + "418" => "I'm a teapot", + "419" => "I", + "420" => "Method Failure", + "421" => "Misdirected Request", + "422" => "Unprocessable Entity", + "423" => "Locked", + "424" => "Failed Dependency", + "426" => "Upgrade Required", + "428" => "Precondition Required", + "429" => "Too Many Requests", + "431" => "Request Header Fields Too Large", + "440" => "Login Time-out", + "444" => "No Response", + "449" => "Retry With", + "450" => "Blocked by Windows Parental Controls", + "451" => "Unavailable For Legal Reasons", + "495" => "SSL Certificate Error", + "496" => "SSL Certificate Required", + "497" => "HTTP Request Sent to HTTPS Port", + "498" => "Invalid Token", + "499" => "Client Closed Request", + "500" => "Internal Server Error", + "501" => "Not Implemented", + "502" => "Bad Gateway", + "503" => "Service Unavailable", + "504" => "Gateway Time-out", + "505" => "HTTP Version Not Supported", + "506" => "Variant Also Negotiates", + "507" => "Insufficient Storage", + "508" => "Loop Detected", + "509" => "Bandwidth Limit Exceeded", + "510" => "Not Extended", + "511" => "Network Authentication Required", + "520" => "Unknown Error", + "521" => "Web Server Is Down", + "522" => "Connection Timed Out", + "523" => "Origin Is Unreachable", + "524" => "A Timeout Occurred", + "525" => "SSL Handshake Failed", + "526" => "Invalid SSL Certificate", + "527" => "Railgun Error", + "530" => "Site is frozen", + "599" => "Network connect timeout error", # self::p('sep',' => '), 'eol' => ",\n", 'quote' => "'", ]; +return [ +'align' => self::p('sep',' => '), +'eol' => ",\n", +'quote' => "'", +'preff' => self::p('preff',''), +'row' => function (&$o,&$r) { + if ($o['preff']) echo $o['preff']; + $keys = array_keys($r); + for ($i=2;$i diff --git a/lib/php/out/sh.php b/lib/php/out/sh.php index 11f18afa..ff391444 100644 --- a/lib/php/out/sh.php +++ b/lib/php/out/sh.php @@ -1,7 +1,7 @@ self::p('preff',""), + 'preff' => self::p('preff',''), 'kuc' => (int)self::p('kuc',false), 'nl' => (int)self::p('nl',false), 'rec' => self::p('rec',';'), diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index e19e8ecd..f70750e7 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -5,6 +5,7 @@ require_once(realpath(dirname(__FILE__).'/../../lib/php/nb.php')); require_once(NB_ROOT.'/lib/php/config.php'); require_once(NB_ROOT.'/lib/php/http.php'); require_once(NB_ROOT.'/lib/php/mime.php'); +require_once(NB_ROOT.'/lib/php/page.php'); # NB 03.01.18 if (false) set_error_handler( function ($errNo, $errStr, $errFile, $errLine) { # NB 03.01.18 $msg = "$errStr in $errFile on line $errLine\n"; @@ -135,16 +136,16 @@ class DbQ extends nb { parent::__construct($opt); - // // Page - require_once(NB_ROOT.'/lib/php/page.php'); - $this->page = new Page([ 'css' => $this->css, 'sep' => $this->sep_title, # NB 05.01.18 'expires' => $this->expires, ]); + // Http + $this->http = new Http(); + if ($run) $this->run(); } @@ -285,11 +286,11 @@ class DbQ extends nb { $bottom = []; - if ($this->http_user()) { + if ($this->http->user()) { $bottom[] = 'http_user() ? ' style="background:url(\'/ldap/jpegPhoto.jpg?w=20\') right no-repeat;padding-right:22px"' : '') + .($this->http->user() ? ' style="background:url(\'/ldap/jpegPhoto.jpg?w=20\') right no-repeat;padding-right:22px"' : '') .'>Logout: ' - .$this->http_user() + .$this->http->user() .' (can: '.$this->perm2h().')' #.'' .''; @@ -854,7 +855,7 @@ EOF; ]; $user = ''; - if (true or $user = $this->http_user()) { + if (true or $user = $this->http->user()) { if ($user) $rows[] = [ 'name' => 'dbq.user.name', 'value' => $user ]; $rows[] = [ 'name' => 'dbq.user.perm', 'value' => $this->perm2h() ]; } -- 2.47.3