crypt:
type: sqlite
host: /dev/shm/crypt.db
+ default_table: credential
$DBQ['all']['_import'][] = $id;
}
-if (nb::p('db')!='nb') $DBQ['all']['_import'][] = 'nb';
#define('NB_PROD',true);
if (empty($_SERVER['PROD'])) error_reporting(E_ALL | E_STRICT | E_NOTICE);
+// Base lib
require(dirname(__FILE__).'/nb.php');
// Cli
ini_set('log_errors', false);
if (nb::p('txt_errors')) ini_set('html_errors', false);
}
+
// Web
else {
ini_set('display_errors',empty($_SERVER['PROD']));
ini_set('html_errors',empty($_SERVER['PROD']));
}
-// Should be done in php.ini for performance
+// Should be done in php.ini for performance ?
if (!ini_get('UTC')) date_default_timezone_set('UTC');
ini_set('include_path',''
if (isset($Table)) self::bye("Table.init(): GLOBALS['Table'] already exists !");
if (isset($Db)) self::bye("Db.init(): GLOBALS['Db'] already exists !");
+ #
+ # Db
+ #
$Db = new self();
- $Db->pinit();
if (empty($Db)) return false;
+ #
+ # Params
+ $Db->pinit();
+
+ #
+ # Load conf
$db = $Db->conf_search_db($conf);
if ($Db->p('localFile')) {
foreach ($Db->localFile($db['name']) as $k=>$v) {
}
}
+ #
# Connection
$Db->__construct($db);
$Db->connect();
- /*
- Table
- */
+ #
+ # Table
+ #
if (self::p('action') and
!self::p('table') and
!preg_match('/^(table\.\w+|rows|insert|edit|delete|update)$/',self::p('action'))
* Return the value set or existing
*/
public static function pdef($name,$value) {
- if (preg_match('/^\s*$/',self::p($name))) return self::pset($name,is_callable($value) ? $value() : $value);
+ if (preg_match('/^\s*$/',self::p($name))) return self::pset($name,(!is_scalar($value) and is_callable($value)) ? $value() : $value);
return self::p($name);
}
}
public static function headers_no_cache() {
+ if (self::php_cli()) return false;
$ts = gmdate("D, d M Y H:i:s") . " GMT";
header("Expires: $ts");
header("Last-Modified: $ts");
}
public static function headers_cache($seconds_to_cache=3600) {
+ if (self::php_cli()) return false;
if ($seconds_to_cache === 0) return headers_no_cache();
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
}
public function headers() {
+ if (self::php_cli()) return false;
#header('Content-type: ' . self::$content_type);
- self::$content_type = 'text/plain';
header('Content-type: '.self::$content_type . (($c = strtoupper ( self::$charset )) ? "; charset=$c" : ""));
if (isset($this->expires)) self::headers_cache($this->expires);
<?php
if (empty($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
if (empty($_SERVER['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = '';
+function parse_uri() {
+ $path = preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']);
+ $values = explode('/',trim($path,'/'));
+
+ $P = [
+ 'db' => '',
+ 'table' => '',
+ 'action' => '',
+ 'format' => '',
+ ];
+
+ $i=0;
+ $count = count($values);
+ foreach ($P as $p => $default) {
+ if ($i>=$count) break;
+ $P[$p] = $values[$i];
+ $i++;
+ }
+
+}
+#var_dump(parse_uri());
$params = [
- #'db',
+ 'db',
'table',
'action',
'format',
}
Page::pdef('format','human');
-#Page::pdef('action','db.ls');
+Page::pdef('action','db.ls');
require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/db/init.php');
-header('Content-type: text/plain');
+#header('Content-type: text/plain');
$Page = $Db->page();
$Page->headers_no_cache();
$Page->call([