Repository navigation
Expand file tree
/
Copy pathBase.php
More file actions
80 lines (73 loc) · 2.24 KB
/
Copy pathBase.php
File metadata and controls
80 lines (73 loc) · 2.24 KB
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
<?php
namespace Meso;
use mysqli_sql_exception;
require("log_handler.php");
class Base
{
public $servername;
public $username;
public $password;
public $dbname;
public $connection;
public $settings;
public function connect()
{
$connection = mysqli_connect($this->servername, $this->username, $this->password, $this->dbname);
if(mysqli_connect_errno())
{
echo "Failed to connect to MySQL: ".mysqli_connect_error();
return false;
}
$this->connection = $connection;
return true;
}
public function query($query, $optional_callback = '', $inputs = '')
{
cp:
try
{
if(preg_match("/[;]/", $query) == 1)
{
$res_query = mysqli_multi_query($this->connection, $query);
}
else
{
$res_query = mysqli_query($this->connection, $query);
}
}
catch(mysqli_sql_exception $e)
{
writeLog(str_replace("-", "", strval(date("Y-m-d")))."-".str_replace(":","", date("H:i:s"))."|"."agent"."|".mysqli_error($this->connection)."- this is an exception not gone"."%");
return false;
}
$errno = mysqli_errno($this->connection);
if(mysqli_error($this->connection))
{
print_r("error3".mysqli_errno($this->connection));
if($this->settings['log_error'])
{
writeLog(str_replace("-", "", strval(date("Y-m-d")))."-".str_replace(":","", date("H:i:s"))."|"."agent"."|".mysqli_error($this->connection)."%");
}
if($this->settings['exception'])
{
return mysqli_error($this->connection);
}
}
if($res_query == false && ($errno == 2006 || $errno == 2013 || $errno == 0 || !mysqli_ping($this->connection)))
{
$this->connect();
goto cp;
}
if(mysqli_error($this->connection) == "asdf" && !empty($optional_callback))
{
if($inputs != '')
{
$optional_callback($inputs);
}
$optional_callback();
goto cp;
} //in progress
return $res_query;
}
}
?>