mirror of
https://github.com/pi-hole/web.git
synced 2026-03-02 15:44:45 +00:00
33
api_db.php
33
api_db.php
@@ -8,6 +8,7 @@
|
||||
|
||||
$api = true;
|
||||
header('Content-type: application/json');
|
||||
require("scripts/pi-hole/php/database.php");
|
||||
require("scripts/pi-hole/php/password.php");
|
||||
require("scripts/pi-hole/php/auth.php");
|
||||
check_cors();
|
||||
@@ -62,37 +63,7 @@ else
|
||||
// Needs package php5-sqlite, e.g.
|
||||
// sudo apt-get install php5-sqlite
|
||||
|
||||
function SQLite3_connect($trytoreconnect)
|
||||
{
|
||||
global $DBFILE;
|
||||
try
|
||||
{
|
||||
// connect to database
|
||||
return new SQLite3($DBFILE, SQLITE3_OPEN_READONLY);
|
||||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
// sqlite3 throws an exception when it is unable to connect, try to reconnect after 3 seconds
|
||||
if($trytoreconnect)
|
||||
{
|
||||
sleep(3);
|
||||
$db = SQLite3_connect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strlen($DBFILE) > 0)
|
||||
{
|
||||
$db = SQLite3_connect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
die("No database available");
|
||||
}
|
||||
if(!$db)
|
||||
{
|
||||
die("Error connecting to database");
|
||||
}
|
||||
$db = SQLite3_connect($DBFILE);
|
||||
|
||||
if(isset($_GET["network"]) && $auth)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user