forked from pshep/ANUBIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.inc.php
90 lines (65 loc) · 1.79 KB
/
config.inc.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
$dbdatabase = "anubis_db";
/* MYSQL specific defines */
$dbusername = "anubis";
$dbpassword = "h3rakles";
$dbhost = "localhost";
/* End MYSQL specific defines */
$version = "2.3";
/* Set desired database interface to 1, others 0 */
$db_mysql = "1";
$db_sqlite = "";
/* Sockets time out, set shorter if you have mutiple rigs specified in anubis
but turned off / disabled and page refreshes take a long time */
$socket_timeout = 3;
/*****************************************************************************/
$auto_inc = "";
$table_props = "";
function anubis_db_connect()
{
global $db_mysql, $db_sqlite, $dbhost, $dbusername, $dbpassword, $dbdatabase;
global $primary_key, $table_props, $show_tables;
if ($db_mysql)
{
try
{
/*** connect to MySQL database ***/
$dbh = new PDO("mysql:host=".$dbhost.";dbname=".$dbdatabase, $dbusername, $dbpassword);
}
catch(PDOException $e)
{
die ('FATAL: Cannot use Anubis_db ! ' . $e->getMessage());
}
$primary_key = "int(3) NOT NULL AUTO_INCREMENT PRIMARY KEY";
$table_props = " ENGINE=MyISAM DEFAULT CHARSET=latin1";
$show_tables = 'SHOW TABLES';
}
else if ($db_sqlite)
{
try
{
/*** connect to SQLite database ***/
$dbh = new PDO("sqlite:".$dbdatabase);
}
catch(PDOException $e)
{
die ('FATAL: Cannot use Anubis_db ! ' . $e->getMessage());
}
$primary_key = "INTEGER PRIMARY KEY";
$show_tables = 'SELECT name FROM sqlite_master WHERE type = "table"';
}
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
return $dbh;
}
function db_error()
{
global $dbh;
if ($dbh->errorCode() !== '00000')
{
$err_array = $dbh->errorInfo();
die('FATAL: DB-Error: ' . $err_array[2]);
return true;
}
return false;
}
?>