settings prep 0
This commit is contained in:
@@ -20,7 +20,6 @@ date_default_timezone_set($Pia_TimeZone);
|
||||
// DB File Path
|
||||
$DBFILE = '../../../db/pialert.db';
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Connect DB
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -36,9 +35,11 @@ function SQLite3_connect ($trytoreconnect) {
|
||||
{
|
||||
// sqlite3 throws an exception when it is unable to connect
|
||||
// try to reconnect one time after 3 seconds
|
||||
|
||||
if($trytoreconnect)
|
||||
{
|
||||
sleep(3);
|
||||
echo '<script>alert("Error connecting to database, will try in 3s")</script>';
|
||||
sleep(3);
|
||||
return SQLite3_connect(false);
|
||||
}
|
||||
}
|
||||
@@ -48,21 +49,31 @@ function SQLite3_connect ($trytoreconnect) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Open DB
|
||||
//------------------------------------------------------------------------------
|
||||
function OpenDB () {
|
||||
|
||||
function OpenDB (...$DBPath) {
|
||||
global $DBFILE;
|
||||
global $db;
|
||||
|
||||
// use custom path if supplied
|
||||
foreach ($DBPath as $path) {
|
||||
$DBFILE = $path;
|
||||
}
|
||||
|
||||
if(strlen($DBFILE) == 0)
|
||||
{
|
||||
die ('Database no available');
|
||||
echo '<script>alert("Database not available")</script>';
|
||||
die ('<div style="padding-left:150px">Database not available</div>');
|
||||
}
|
||||
|
||||
$db = SQLite3_connect(true);
|
||||
$db->exec('PRAGMA journal_mode = wal;');
|
||||
|
||||
if(!$db)
|
||||
{
|
||||
die ('Error connecting to database');
|
||||
echo '<script>alert("Error connecting to the database")</script>';
|
||||
die ('<div style="padding-left:150px">Error connecting to the database</div>');
|
||||
}
|
||||
|
||||
$db->exec('PRAGMA journal_mode = wal;');
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user