-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
126 lines (70 loc) · 2.5 KB
/
index.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
$debug = false;
include 'alow.php';
include 'conn/conn.php';
if(!allow_this()){
if($debug){
$log = getdate();
$log['message'] = "not authorized ip access ".$_SERVER['REMOTE_ADDR'];
file_put_contents("error.log", print_r($log,true),FILE_APPEND);
}
throw new SoapFault("RQ-0","not allowed");
}
function run_query($type,$q){
global $CON;
global $debug;
if(!isset($CON[$type])){
if($debug){
$log = getdate();
$log['message'] = "There is No Connection For ".$type;
file_put_contents("error.log", print_r($log,true),FILE_APPEND);
}
throw new SoapFault("RQ-1","There is No Connection For ".$type);
}
$con = mysql_connect($CON[$type]['host'], $CON[$type]['user'], $CON[$type]['pass']);
mysql_select_db($CON[$type]['db'],$con);
if($error = mysql_error($con)){
if($debug){
$log = getdate();
$log['message'] = $error;
file_put_contents("error.log", print_r($log,true),FILE_APPEND);
}
throw new SoapFault("RQ-2",$error);
}
$sql = base64_decode($q);
if($debug){
$log = getdate();
$log['message'] = $sql;
file_put_contents("sql.log", print_r($log,true),FILE_APPEND);
}
$res = mysql_query($sql,$con);
if($error = mysql_error($con)){
if($debug){
$log = getdate();
$log['message'] = $error;
file_put_contents("error.log", print_r($log,true),FILE_APPEND);
}
throw new SoapFault("RQ-3",$error);
}
$data = array();
while($row = mysql_fetch_assoc($res)){
$data[] = $row;
}
if($debug){
$log = getdate();
$log['message'] = $data;
file_put_contents("result.log",print_r($log,true),FILE_APPEND);
$log = getdate();
$log['message'] = mysql_error($con);
file_put_contents("error.log", print_r($log, true), FILE_APPEND);
}
mysql_close($con);
return $data;
}
function test(){
return "halo";
}
$server = new SoapServer(null,array('uri' => "http://php_mysql_bridge/"));
$server->addFunction('run_query');
$server->addFunction('test');
$server->handle();