-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.php
54 lines (44 loc) · 1.02 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
include_once("./config.php");
function fnGetSelectedProjectPath()
{
$sDir = fnGetSelectedDatabase();
return DATA_PATH."{$sDir}/";
}
function fnPreparePath($sPath)
{
$sDir = fnGetSelectedProjectPath();
return "{$sDir}{$sPath}";
}
function fnGetDatabasePath()
{
$sDir = fnGetSelectedProjectPath();
return "{$sDir}db/dbfile.db";
}
function fnGetDatabasesList()
{
$aProjects = glob(DATA_PATH."*");
return $aProjects;
}
function fnGetDatabasesListForDatalist()
{
$aList = fnGetDatabasesList();
$aList = array_map(function ($aI) { return [ "text" => $aI ]; }, $aList);
return $aList;
}
function fnSelectDatabase($sDatabaseName)
{
$_SESSION["database"] = $sDatabaseName;
}
function fnGetSelectedDatabase()
{
return $_SESSION["database"] ?: "default";
}
function fnConnectDatabase()
{
if (Config::$aOptions["database"]["schema"] == "sqlite") {
$sPath = fnGetDatabasePath();
R::setup("sqlite:{$sPath}");
}
if(!R::testConnection()) die('No DB connection!');
}