'/Users/nico/ownCloud',
'/home/nico/Dropbox',
'/Users/nico/Dropbox',
+ '', # / !!!
] as $DIR_SQLITE) {
- if (is_readable($DIR_SQLITE)) {
+
+ if (is_readable($DIR_SQLITE.'/var/lib/sqlite')) {
+ $DIR_SQLITE .= '/var/lib/sqlite';
break;
+
} else {
unset($DIR_SQLITE);
+
}
+
}
-if (!empty($DIR_SQLITE)) $DIR_SQLITE .= '/var/lib/sqlite';
-elseif (file_exists('/var/lib/sqlite')) $DIR_SQLITE = '/var/lib/sqlite';
?>
--- /dev/null
+<?php
+#
+# Create *-sqlite databases
+#
+if (empty($DIR_SQLITE)) return;
+
+$host_already_exists = [];
+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' => 'created by dbq.php',
+ 'title' => Db::prettyText($name),
+ '_import' => $name
+ ];
+ #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
+}
+?>
<?php
-#
-# Create *-sqlite databases
-#
-$host_already_exists = [];
-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;
-}
-
-if (!empty($DIR_SQLITE)) {
- 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";
-
- $DBQ[$id] = [
- 'host' => "$DIR_SQLITE/$file",
- 'type' => 'sqlite',
- 'title' => 'created by dbq.php',
- '_import' => $name
- ];
- #if (!empty($DBQ[$name])) $DBQ[$id] = array_merge_recursive($DBQ[$name],$DBQ[$id]);
- }
-}
#
# ALL - Attach all sqlite databases