mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Ensure that it only tries to read the file but doesn't create a new one if it cannot be found.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+13
-4
@@ -17,24 +17,33 @@ $data = array();
|
||||
// Needs package php5-sqlite, e.g.
|
||||
// sudo apt-get install php5-sqlite
|
||||
|
||||
class FTLDB extends SQLite3
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$this->open("/etc/pihole/pihole-FTL.db", SQLITE3_OPEN_READONLY);
|
||||
}
|
||||
}
|
||||
|
||||
function SQLite3_connect($trytoreconnect)
|
||||
{
|
||||
try {
|
||||
// connect to database
|
||||
$db = new SQLite3('/etc/pihole/pihole-FTL.db');
|
||||
return new FTLDB;
|
||||
}
|
||||
catch (Exception $exception) {
|
||||
// sqlite3 throws an exception when it is unable to connect, try to reconnect after 3 seconds
|
||||
if($trytoreconnect)
|
||||
{
|
||||
sleep(3);
|
||||
SQLite3_connect(false);
|
||||
$db = SQLite3_connect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
SQLite3_connect(true);
|
||||
|
||||
if(empty($db))
|
||||
$db = SQLite3_connect(true);
|
||||
|
||||
if(!$db)
|
||||
{
|
||||
die("Error connecting to database");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user