-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatabase.php
36 lines (31 loc) · 898 Bytes
/
database.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
<?php
if (!defined('DATABASE_LINK'))
{
die('<b>{{Cite book}} generator:</b><br/><br/>Possible breach, breaking...');
}
/**
* Connects to the desired toolserver database
* @author River Tarnell
* @author Michał "Hołek" Połtyn
* @param string $database
*/
function dbconnect($database)
{
global $error;
global $HOME;
// fix redundant error-reporting
$errorlevel = ini_set('error_reporting','0');
// connect
$mycnf = parse_ini_file($HOME . '/.my.cnf');
$username = $mycnf['user'];
$password = $mycnf['password'];
unset($mycnf);
$mysqli = @new mysqli( str_replace('_','-',$database) . '.db.toolserver.org', $username, $password, str_replace('-','_',$database) );
if ($mysqli->connect_error) {
$error->report('Unavailable-SQL',$mysqli->connect_error);
}
unset($username, $password);
// restore error-reporting
ini_set('error_reporting',$errorlevel);
return $mysqli;
}