forked from jadz/php-sploits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbfuncs.php
56 lines (47 loc) · 1.09 KB
/
dbfuncs.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
<?php
require_once 'common.php';
require_once 'consts.php';
$con = null;
function connect()
{
global $con;
$con = mysql_connect(DB_HOST, DB_USER, DB_PASS);
if(!$con)
die("Unable to connect to: " . DB_USER . ":" . DB_PASS . "@" . DB_HOST . ". Error: " . mysql_error());
selectDb();
}
function selectDb()
{
global $con;
if($con !== null)
mysql_select_db(DB_DB, $con);
}
function getSelect($query)
{
global $con;
if($con === null)
connect();
if(is_resource($con)) {
$result = mysql_query($query, $con);
if($result !== null && is_resource($result)) {
$rows = array();
while($row = mysql_fetch_row($result)) {
$rows[] = $row;
}
return $rows;
}
}
}
function insertQuery($query, $update = false)
{
global $con;
if($con === null)
connect();
if(is_resource($con)) {
$result = mysql_query($query, $con);
if($result !== true) {
return false;
}
return ($update === false) ? true : mysql_insert_id();
}
}