#
# Get URL
#
+#-e $ROOT_DIR.'/lib/php/db/index.php' && die 'OK';
my $url = ($ENV{$UC_NAME.'_URL'} ? $ENV{$UC_NAME.'_URL'} :
( -e $ROOT_DIR.'/lib/php/db/index.php' ? $ROOT_DIR.'/lib/php/db/index.php' : '/opt/rent/www/index.php' )
);
#
# Search existing DIR_SQLITE
#
-$DIR_SQLITE = '';
+unset($DIR_SQLITE);
foreach ([
- '~nico/ownCloud',
- '~nicoadm/ownCloud',
+ '/home/nico/ownCloud',
+ '/Users/nico/ownCloud',
] as $dir) {
- $dir = nb::untilde($dir);
+ #$dir = nb::untilde($dir);
if (!is_readable($dir)) continue;
$DIR_SQLITE = $dir;
break;
}
-if ($DIR_SQLITE) $DIR_SQLITE .= '/var/lib/sqlite';
+if (!empty($DIR_SQLITE)) $DIR_SQLITE .= '/var/lib/sqlite';
#
# Includes dbq/*php
) $host_already_exists[$db['host']] = $id;
}
-if ($DIR_SQLITE) {
+if (!empty($DIR_SQLITE)) {
foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
if (strpos($file,'_conflict-')) continue;
<?php
$DBQ['nb'] = [
- 'host' => 'admin.izideal.vpn',
+# NB 01.11.16 macmini router issue 'host' => 'admin.izideal.vpn',
+ 'host' => '10.8.0.1',
'type' => 'mysql',
'name' => 'nb',
'_import' => ['_nico'],
);
if ($GLOBALS['web']) {
- $DBQ['_ui']['people'] = $DBQ['_ui']['user'] = [
+ $DBQ['_ui']['tables']['people'] = $DBQ['_ui']['tables']['user'] = [
'extras'=> [
'pic' => '\'<img alt="" src="/scripts/gravatar/?email=\' || contact.email || \'" />\'',
],
$DBQ['wp']['host'] = DB_DIR.'/'.DB_FILE;
}
-$DBQ['wp-sqlite'] = array (
+if (!empty($DIR_SQLITE) and file_exists("$DIR_SQLITE/wp.db")) $DBQ['wp-sqlite'] = [
'host' => "$DIR_SQLITE/wp.db",
'type' => 'sqlite',
'_import' => 'wp',
-);
+];
?>
'name' => 'dbname',
'charset' => 'charset',
] as $k => $v) {
- #self::debug($k);
+ #self::debug([$k,$this->$k]);
if ($v=='charset' and $this->type=='pgsql') continue;
if (empty($this->$k)) continue;
$this->pdo = preg_replace("/\b$v=[^;]*(;|$)/","",$this->pdo);
return $dbs;
}
+ public function table_row_encrypt(&$table,&$row) {
+ if (0
+ or empty($this->encrypt)
+ or empty($this->encrypt['secret'])
+ or empty($this->encrypt['tables'])
+ or empty($this->encrypt['tables'][$table->name])
+ ) return $row;
+
+ foreach ($row as $k => $v) {
+ if (!in_array($k,$this->encrypt['tables'][$table->name])) continue;
+ $row[$k] = $this->encrypt($this->encrypt['secret'],$v);
+ }
+
+ return $row;
+ }
+
+ public function table_row_decrypt(&$table,&$row) {
+ if (0
+ or empty($this->encrypt)
+ or empty($this->encrypt['secret'])
+ or empty($this->encrypt['tables'])
+ or empty($this->encrypt['tables'][$table->name])
+ ) return $row;
+
+ foreach ($row as $k => $v) {
+ if (!in_array($k,$this->encrypt['tables'][$table->name])) continue;
+ $row[$k] = $this->decrypt($this->encrypt['secret'],$v);
+ }
+
+ return $row;
+ }
+
} # < Class
?>
if (strpos($this->type,'date') !== false) return 'date';
}
- public function html_edit($value) {
+ public function html_edit($value,$type=null) {
$size = ($this->size() and is_scalar($this->size())) ? $this->size() : 0;
$tag = ( ($size>$this->textarea_size) or preg_match('/^(text|binary)/i',$this->type) ) ? 'textarea' : 'input';
.' id="'.$this->name.'"'
.( $size ? ' size="'.$size.'"' : '')
#.' value="'.$value.'"'
- .($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'.$this->html_type().'" value="'.$value.'" />')
+ .($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'
+ .($type ? $type : $this->html_type())
+ .'" value="'.$value.'" />')
)
.'</div>'.NB_EOL;
'call' => array(
'begin',
#['out', "Hello World !!!\n"],
+
function($page){
global $Db, $Table;
#$type = $page->mime2ext($page->content_type());
#bye($type);
$page->pdef('format','csv');
}
- if ($page->action()) 1;
- else return $Db->action($Db->p('action'),$Table);
- #else require_once(dirname(__FILE__).'/index.php');
+ if (!$page->action()) return $Db->action($Db->p('action'),$Table);
},
+
function($page){
+ #if (!$page->is('html')) return;
global $Db;
if (!empty($Db)) echo $page->tag('div class="db-infos"',join(' | ',[
$Db->type,
($Db->name ? $Db->name : null),
]));
},
+
'end',
),
]);
echo '<div class="fields">'.NB_EOL;
$count = 0;
if ( $add or ($row = $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))) {
+ $orig = $row;
+
+ $this->db()->table_row_decrypt($this,$row);
$count ++;
foreach ($fields as $name => $field) {
elseif(!isset($row[$name])) $row[$name] = '';
echo $field->html_edit($row[$name]
# NB 18.08.15 (! $add and array_key_exists($name,$row) ) ? $row[$name] : $field->default
+ #,( $orig[$name] === $row[$name] ? '' : 'password' )
);
}
$count++;
$call = null;
+ $this->db()->table_row_decrypt($this,$row);
if ($parse and !empty($this->db()->row_parse)) {
$call = $this->db()->row_parse; $call($row);
}
return false;
}
- foreach ($fields as $name => $field) $field->bindParam($query,$hvalues[$name],":$name");
+ foreach ($fields as $name => $field) {
+ $row = [ $name => $hvalues[$name] ];
+ $this->db()->table_row_encrypt($this,$row);
+ $field->bindParam($query,$row[$name],":$name");
+ }
if (self::p('debug')) {
$this->debug($info,1);
}
foreach ($fields as $name) {
- #debug("$name: ".$hvalues[$name]);
- $field->bindParam($query,$hvalues[$name],":$name");
+ $row = [ $name => $hvalues[$name] ];
+ $this->db()->table_row_encrypt($this,$row);
+ $field->bindParam($query,$row[$name],":$name");
}
foreach ($keys as $name) {
$query = $this->db()->exec($sql);
$info['rowCount'] = $query;
+
return $info['rowCount'];
- $info['rowCount'] = $query->rowCount();
- return $info['rowCount'];
- # Like insert- NB 05.04.16
-# NB 05.04.16 return $this->db()->exec($sql)->fetchColumn();
}
public function out($v,$head=array()) { return $this->db()->out($v,$head); }
} # < Class
-#return;
+return;
if (!count($argv) or (string)$argv[1] != 'test') return;
$value = 'Hello World !';
#$value = file_get_contents('/etc/hosts');
if (preg_match('/ml$/',self::$content_type)) {
self::tag_end();
echo '</body>' . NB_EOL;
- echo '</html>' . NB_EOL;
+ if (preg_match('/html$/',self::$content_type)) echo '</html>' . NB_EOL;
}
}