+++ /dev/null
-<?php
-#
-# !!! MANDATORY !!!
-#
-$DBQ = [
- 'nb' => [
- 'type' => 'sqlite',
- 'name' => 'Nb',
- 'default_table' => 'mime',
- 'host' => nb::ROOT_DIR.'/share/db/nb.db',
- ],
-
-];
-?>
--- /dev/null
+<?php
+#
+# !!! MANDATORY !!!
+#
+$DBQ['nb'] = [
+ 'type' => 'sqlite',
+ 'name' => 'Nb',
+ 'default_table' => 'mime',
+ 'host' => nb::ROOT_DIR.'/share/db/nb.db',
+];
+?>
--- /dev/null
+<?php
+
+#
+# ALL - Attach all sqlite databases
+#
+#return;
+#die(count($DBQ)."\n");
+$DBQ['all'] = [
+ 'host' => ':memory:',
+ 'type' => 'sqlite',
+ 'name' => 'all',
+ 'pdo' => '',
+ 'default_table' => '',
+# NB 20.01.17 '_import' => ['nb'],
+ 'order' => '10',
+ 'options' => [
+ PDO::ATTR_PERSISTENT => true,
+ ],
+ 'tables' => [],
+ 'types' => [
+ 'sql_pre' => [],
+ ],
+ 'sql_pre' => [
+ #'PRAGMA synchronous = NORMAL',
+ 'PRAGMA busy_timeout = 10000',
+ 'PRAGMA journal_mode = MEMORY',
+ ],
+];
+
+foreach ($DBQ as $id => $db) {
+ if (0
+
+ or empty($db['type'] )
+ or $db['type']!='sqlite'
+
+ or empty($db['host'] )
+ or !is_readable($db['host'])
+ or !strpos($db['host'],'.db')
+
+ ) continue;
+
+ $fname = basename($db['host'],'.db');
+ $fname = preg_replace('/\..*$/','',basename($db['host']));
+
+ $DBQ['all']['attach'][$fname] = $db['host'];
+ $DBQ['all']['_import'] = empty($DBQ['all']['_import']) ? [] : (array)$DBQ['all']['_import'];
+ $DBQ['all']['_import'][] = $id;
+
+}
+if (!isset($DBQ['all']['_import']) or count($DBQ['all']['_import'])<2) unset($DBQ['all']);
--- /dev/null
+<?php
+#
+# Search *.db into DBQ_DIR_SQLITE
+#
+if (empty($_SERVER['DBQ_DIR_SQLITE'])) return;
+$host_already_exists = [];
+
+foreach ([
+ $_SERVER['DBQ_DIR_SQLITE'],
+ '', # / !!!
+] as $DIR_SQLITE) {
+ if (!is_readable($DIR_SQLITE)) continue;
+
+ foreach ($DBQ as $id => $db) {
+ if (1
+ and !empty($db['type']) and $db['type'] == 'sqlite'
+ and !empty($db['host'])
+ ) $host_already_exists[$db['host']] = $id;
+ }
+
+ foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
+
+ if (strpos($file,'_conflict-')) continue;
+
+ if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
+ $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
+ continue;
+ }
+
+ $name = basename($file,'.db');
+ $id = "${name}-sqlite";
+
+ if (!isset($DBQ[$id])) $DBQ[$id] = [
+ 'host' => "$DIR_SQLITE/$file",
+ 'type' => 'sqlite',
+ 'title' => Db::prettyText($name),
+ '_import' => $name
+ ];
+ }
+
+}
+?>
+++ /dev/null
-<?php
-#
-# Create *-sqlite databases
-#
-$host_already_exists = [];
-
-foreach ([
- '/home/nico/ownCloud',
- '/Users/nico/ownCloud',
- '/home/nico/Dropbox',
- '/Users/nico/Dropbox',
- '', # / !!!
-] as $DIR_SQLITE) {
- if (!is_readable($DIR_SQLITE.'/var/lib/sqlite')) continue;
- $DIR_SQLITE .= '/var/lib/sqlite';
-
- foreach ($DBQ as $id => $db) {
- if (1
- and !empty($db['type']) and $db['type'] == 'sqlite'
- and !empty($db['host'])
- ) $host_already_exists[$db['host']] = $id;
- }
-
- foreach (nb::ls_dir($DIR_SQLITE,'\.db$') as $file) {
-
- if (strpos($file,'_conflict-')) continue;
-
- if (isset($host_already_exists["$DIR_SQLITE/$file"])) {
- $DBQ[$host_already_exists["$DIR_SQLITE/$file"]]['sql_pre'][] = 'PRAGMA journal_mode=OFF';
- continue;
- }
-
- $name = basename($file,'.db');
- $id = "${name}-sqlite";
-
- if (!isset($DBQ[$id])) $DBQ[$id] = [
- 'host' => "$DIR_SQLITE/$file",
- 'type' => 'sqlite',
- 'title' => Db::prettyText($name),
- '_import' => $name
- ];
- }
-
-}
-
-unset($DIR_SQLITE,$host_already_exists);
-?>
+++ /dev/null
-<?php
-
-#
-# ALL - Attach all sqlite databases
-#
-#return;
-#die(count($DBQ)."\n");
-$DBQ['all'] = [
- 'host' => ':memory:',
- 'type' => 'sqlite',
- 'name' => 'all',
- 'pdo' => '',
- 'default_table' => '',
-# NB 20.01.17 '_import' => ['nb'],
- 'order' => '10',
- 'options' => [
- PDO::ATTR_PERSISTENT => true,
- ],
- 'tables' => [],
- 'types' => [
- 'sql_pre' => [],
- ],
- 'sql_pre' => [
- #'PRAGMA synchronous = NORMAL',
- 'PRAGMA busy_timeout = 10000',
- 'PRAGMA journal_mode = MEMORY',
- ],
-];
-
-foreach ($DBQ as $id => $db) {
- if (0
-
- or empty($db['type'] )
- or $db['type']!='sqlite'
-
- or empty($db['host'] )
- or !is_readable($db['host'])
- or !strpos($db['host'],'.db')
-
- ) continue;
-
- $fname = basename($db['host'],'.db');
- $fname = preg_replace('/\..*$/','',basename($db['host']));
-
- $DBQ['all']['attach'][$fname] = $db['host'];
- $DBQ['all']['_import'] = empty($DBQ['all']['_import']) ? [] : (array)$DBQ['all']['_import'];
- $DBQ['all']['_import'][] = $id;
-
-}
-if (!isset($DBQ['all']['_import']) or count($DBQ['all']['_import'])<2) unset($DBQ['all']);
require_once(realpath(dirname(__FILE__).'/../config.php'));
require_once(NB_ROOT.'/lib/php/db.php');
if (empty($_SERVER['HOME'])) $_SERVER['HOME'] = '';
+if (empty($DBQ)) $DBQ = [];
$DB_CONFS = array_merge([],
# ::ROOT_DIR