]> git.nbdom.net Git - nb.git/commitdiff
mode nb.rb
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 30 Aug 2016 10:54:22 +0000 (12:54 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 30 Aug 2016 10:54:22 +0000 (12:54 +0200)
etc/dbs/nb.php
etc/dbs/rent.php
lib/php/nb.php

index 4cd914e54701c10763ff1bee7a7b2ba3278e312a..733aa334fd628a679e4d7167ff1e47bf0371fe27 100644 (file)
@@ -11,7 +11,7 @@ $CONF['nb'] = array(
 );
 
 $CONF['nb-sqlite'] = array (
-  'pdo' => 'sqlite:/opt/rent/nb.db',
+  'pdo' => 'sqlite:'.nb::untilde('~nico/ownCloud/var/lib/sqlite/nb.db'),
   '_import' => '_rent',
 );
 
index 519cb42388c18d75026f6534cc07aeb8d2faaae5..b3c09644009bb608a204a4b028386121eacf415d 100644 (file)
@@ -64,17 +64,6 @@ $CONF['_rent'] = array(
 
 return 1;
 
-function untilde($path) {
-  if (!function_exists('posix_getuid')) return $path;
-  return preg_replace_callback('/^(~)(\w+)?/',function($m){
-
-    $uid = fileowner(!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : __FILE__);
-    if (!empty($m[2])) return str_replace($m[2],posix_getpwnam($uid)['dir'],$m[0]);
-
-    return str_replace($m[1],posix_getpwuid(posix_getuid())['dir'],$m[0]);
-  },$path);
-}
-
 function tenant_doc(&$r) { return rent_doc('tenant',$r); }
 function place_doc(&$r) { return rent_doc('place',$r); }
 
@@ -103,7 +92,7 @@ function rent_doc($table,&$r) {
 
     # Absolute path
     or (
-      ( $dir = untilde($r['doc']) ) 
+      ( $dir = nb::untilde($r['doc']) ) 
       and file_exists($dir) and is_dir($dir)
       and ($url='' or 1)
     )
index 21ec681609835def7fdfba17536e98d4e3cf45e6..76703ca2489d785681816636746a50eaa01bc7d0 100644 (file)
@@ -596,5 +596,14 @@ class NB {
 
   }
 
+  public static function untilde($path) {
+    if (!function_exists('posix_getuid')) return $path;
+    return preg_replace_callback('/^(~)(\w+)?/',function($m){
+
+      if (!empty($m[2])) return str_replace($m[1].$m[2],posix_getpwnam($m[2])['dir'],$m[0]);
+
+      return str_replace($m[1],posix_getpwuid(posix_getuid())['dir'],$m[0]);
+    },$path);
+  }
 } # < Class
 ?>