-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.mysql.php
389 lines (389 loc) · 24.1 KB
/
db.mysql.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<?PHP
/*******************************************************************
| Raha TinyAdmin Var 1.5.0
| ------------------------------------------------
| @copyright: (C) 2007-2008 Raha Group, All Rights Reserved
| @license: CC-BY-SA-4.0 <https://creativecommons.org/licenses/by-sa/4.0>
| @author: Mahdi NezaratiZadeh <HTTPS://Raha.Group>
| @since: 2007-09-08 23:07:15 GMT+0330 - 2008-10-20 18:16:23 GMT+0330
********************************************************************/
header('Content-Type: Text/HTML; Charset=UTF-8');
session_start();
set_time_limit(0);
ini_set("error_reporting", 0);
!extension_loaded("zlib") || ob_start("ob_gzhandler");
define("Time", time());
define("PerPage", 30);
define("File", "DB");
get_magic_quotes_gpc() && ($_REQUEST = killmq($_REQUEST)) && ($_COOKIE = killmq($_COOKIE)) && ($_POST = killmq($_POST)) && ($_GET = killmq($_GET));
$Cookie = array("host", "user", "pass", "db", "save");
function killmq($v) {
return is_array($v) ? array_map("killmq", $v) : stripslashes($v);
}
function size($w) {
for ($s=array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"), $i=0; $w/1024>1; $i++)
$w /= 1024;
return round($w, 3)." ".$s[$i];
}
class DataBase {
public $connected = 0, $selected = 0;
private $host, $database, $affected_rows = 0, $error = array(), $handle, $inserted_id = 0, $query, $SQL, $time;
protected $functions = array("CHAR" => array("ASCII", "CHAR", "SOUNDEX", "LCASE", "UCASE", "PASSWORD", "OLD_PASSWORD", "MD5", "SHA1", "ENCRYPT", "LAST_INSERT_ID", "USER", "CONCAT"), "DATE" => array("NOW", "CURDATE", "CURTIME", "FROM_DAYS", "FROM_UNIXTIME", "PERIOD_ADD", "PERIOD_DIFF", "TO_DAYS", "UNIX_TIMESTAMP", "WEEKDAY"), "NUMBER" => array("ASCII", "CHAR", "MD5", "SHA1", "ENCRYPT", "RAND", "LAST_INSERT_ID", "UNIX_TIMESTAMP", "COUNT", "AVG", "SUM"));
public function __construct($h, $u, $p, $n) {
if (empty($_COOKIE[File]["host"]) && empty($_SESSION[File]["host"]))
return;
($this->handle = @mysql_pconnect($h, $u, $p)) ? $this->connected = 1 : $this->bug("Connection Failed!", "Error");
if ($this->connected)
@mysql_select_db($n, $this->handle) ? $this->selected = 1 : $this->bug("Can not select Data base!", "Error");
$this->host = $h;
$this->database = $n;
}
public function query($q, $h=0) {
if (trim($q) == '')
return;
$h or $this->SQL = $q;
$m = microtime();
$Q = @mysql_query($q, $this->handle);
$m = explode(" ", $m);
$M = explode(" ", microtime());
$h or $this->time = ($M[1]+$M[0])-($m[1]+$m[0]);
if (!$h && preg_match("'^\s*(insert|delete|update|replace) 'i", $q)) {
$this->affected_rows = mysql_affected_rows($this->handle);
if (preg_match("'^\s*(insert|replace) 'i", $q))
$this->inserted_id = mysql_insert_id($this->handle);
}
$h || $this->query = $Q;
return $Q || $h ? $Q : $this->bug($q, "SQL");
}
public function num_rows($q=null) {
return @mysql_num_rows(isset($q) ? $q : $this->query);
}
public function fetch_array($q=null) {
return @mysql_fetch_assoc(isset($q) ? $q : $this->query);
}
public function field_name($q=null, $c=0) {
return @mysql_field_name(isset($q) ? $q : $this->query, $c);
}
public function num_fields($q=null) {
return @mysql_num_fields(isset($q) ? $q : $this->query);
}
public function affected_rows() {
return mysql_affected_rows($this->handle);
}
public function result($q=null, $r=0, $f=0) {
return @mysql_result(isset($q) ? $q : $this->query, $r, $f);
}
public function escape($c) {
return function_exists("mysql_real_escape_string") ? mysql_real_escape_string($c, $this->handle) : mysql_escape_string($c);
}
public function backup($n) {
$Q = mysql_query("show tables like '$n%'");
while ($r=mysql_fetch_row($Q)) {
for ($q=mysql_query("select * from `$r[0]`"), $R=mysql_num_rows($q), $i=0, $c=$d=""; $i<$R; $d .= "$c(\n\t$C\n)", $c=", ", $i++)
for ($j=0, $C=""; $j<mysql_num_fields($q); $j++)
$C .= ($j ? ", " : "").(is_numeric($v=mysql_result($q, $i, $j)) ? $v : "'".str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), ($this->escape($v)))."'");
!$R or $d = "\n\n# --------------------------------------------------------\n# Data contents of table `$r[0]`\n#\nINSERT INTO `$r[0]` VALUES $d;\n\n#\n# End of data contents of table `$r[0]`\n# --------------------------------------------------------\n";
$D .= "\n# --------------------------------------------------------\n# Table: `$r[0]`\n# --------------------------------------------------------\n\nDROP TABLE IF EXISTS `$r[0]`;\n".mysql_result(mysql_query("show create table `$r[0]`"), 0, 1).";$d";
}
return "# Raha MySQL database backup\n#\n# Generated: ".date("l j. F Y H:i T")."\n# Hostname: $this->host\n# Database: $this->database\n# --------------------------------------------------------\n$D";
}
public function getUvaCondition($h, $c, $m, $r) {
$primary_key = $unique_key = $uva_nonprimary_condition = '';
for ($i=0; $i<$c; ++$i) {
$field_flags = mysql_field_flags($h, $i);
$meta = $m[$i];
$condition = ($meta->type == "real" ? " CONCAT(`$meta->name`) " : (MYSQL_VERSION >= 40100 && ($meta->type == "string" || $meta->type == "blob") ? " CONVERT(`$meta->name` USING utf8) " : " `$meta->name` ")).(!isset($r[$i]) || is_null($r[$i]) ? "IS NULL AND" : ($meta->numeric && $meta->type != "timestamp" ? "= $r[$i] AND" : ($meta->type == "blob" && stristr($field_flags, "BINARY") && !empty($r[$i]) ? (MYSQL_VERSION < 40002 ? "LIKE 0x".bin2hex($r[$i])." AND" : "= CAST(0x".bin2hex($r[$i])." AS BINARY) AND") : "= '".$this->escape($r[$i])."' AND")));
if ($meta->primary_key > 0)
$primary_key .= $condition;
elseif ($meta->unique_key > 0)
$unique_key .= $condition;
$uva_nonprimary_condition .= $condition;
}
return preg_replace("'\s?AND$'", "", $primary_key ? $primary_key : ($unique_key ? $unique_key : $uva_nonprimary_condition));
}
public function functions($n) {
foreach ($this->functions as $q => $v) {
$c .= "<optgroup label=$q>";
foreach ($v as $v)
$c .= "<option>$v</option>";
$c .= "</optgroup>";
}
return '<select name="function['.$n.']"><option></option>'.$c.'</select>';
}
public function details() {
for ($v=ceil($this->num_rows()/PerPage), $i=1; $i<=$v; $p.="<option ".($_GET["p"] == $i ? " selected" : "")." value=".$i.">$i</option>", $i++);
return "<table class=table><tr><th>Details</th></tr><tr><td>SQL query: ".htmlentities($this->SQL).($this->affected_rows ? "<br />Affected rows: $this->affected_rows" : "").($this->inserted_id ? "<br />Inserted row id: $this->inserted_id" : "")."<br />Total rows: ".$this->num_rows()."<br />Query took: $this->time sec".(strtolower(trim($this->SQL)) != "show tables" && $this->num_rows()>PerPage && !preg_match("'limit\s*\d+(\s*,\s*\d+)?$'i", $this->SQL) ? "<br />Page: <select onchange=".'"return request(\''.preg_replace("'&p=\d+$'", "", $_SERVER["QUERY_STRING"]).'&p=\'+this.options[this.selectedIndex].value)"'.">$p</select>" : "")."</td></tr></table>";
}
public function SQL() {
foreach (array("", "SHOW CREATE TABLE ", "SHOW VARIABLES LIKE '%'", "SHOW STATUS LIKE '%'", "SHOW FULL COLUMNS FROM ", "DESCRIBE ", "EXPLAIN ", "SHOW CREATE DATABASE ", "SHOW TABLE STATUS LIKE ''", "CREATE TABLE ", "SHOW TABLES", "SHOW DATABASES", "SELECT * FROM ", "INSERT INTO ", "TRUNCATE ", "DELETE FROM ", "DROP TABLE ", "DROP DATABASE ", "CREATE DATABASE ", "RENAME TABLE ", "DROP INDEX ", "CREATE INDEX ", "UPDATE ", "SHOW PROCESSLIST", "DROP USER ", "GRANT ", "SHOW FULL PROCESSLIST", "REVOKE ", "SET PASSWORD ", "FLUSH PRIVILEGES", "DROP USER ", "ANALYZE TABLE ", "CHECK TABLE ", "CHECKSUM TABLE ", "OPTIMIZE TABLE ", "REPAIR ", "RESTORE TABLE ", "SHOW GRANTS FOR ", "SHOW OPEN TABLES ", "SHOW PRIVILEGES", "SHOW WARNINGS", "SHOW ERRORS") as $v)
$_ .= '<option value="'.$v.'">'.trim($v)."</option>";
return '<form method=get enctype=multipart/form-data><textarea name=q id=q style="width: 100%" rows=2>'.htmlentities($this->SQL).'</textarea><br /><select onChange="v = document.getElementById(\'q\'); v.value += (v.value != \'\' ? \'\n\' : \'\')+this.options[this.selectedIndex].value">'.$_.'</select><br /><input type="file" name=import /> <input type=reset onclick="document.getElementById(\'q\').innerHTML=\'\'" value=Clear /> <input type=submit value=Submit /> <input type=button onclick="return request()" value=Index /></form>';
}
public function tables() {
for ($c="<p><table class=table><tr><th>Table</th><th>Action</th><th>Record(s)</th><th>Size</th></tr>", $S=0, $R=0, $q=$this->query("show tables"), $n=$this->num_rows(), $i=0; $i<$n; $i++) {
$t = $this->result($q, $i);
$s = $this->fetch_array($this->query("show table status like '$t'"));
$w = $s["Data_length"]+$s["Index_length"];
$r = $this->result($this->query("select count(*) from ".$t));
$S += $w;
$R += $r;
$c .= "<tr bgcolor=#".($i%2 ? "ffffff" : "f8f8f8")."><td>$t".'</td><td><ul class=img><li class='.($r ? "browse" : '"browse disable"').' title=Browse '.($r ? 'onclick="return request(\'q=select * from `'.$t.'`\')")' : 'style="cursor: default"').'></li><li class=explain title=Explain onclick="return request(\'q=explain `'.$t.'`\')"></li><li class=index title=index onclick="return request(\'q=show index from `'.$t.'`\')"></li><li class=export title=Export onclick="return request(\'do=backup&t='.$t.'\')"></li><li class=insert title=Insert onclick="return request(\'do=inserting&t='.$t.'\')"></li><li class=trash title=Truncate onclick="return request(\'q=truncate table `'.$t.'`\', \'Do you really want to truncate table '.$t.' ?\')"></li><li class=drop title=Drop onclick="return request(\'q=drop table `'.$t.'`\', \'Do you really want to drop table '.$t.' ?\')"></li></ul></td><td>'.$r."</td><td>".size($w)."</td></tr>";
}
return $c.'<tr><td style="color: 003366">Total</td><td><ul class=img><li class=backup title=Backup onclick="return request(\'do=backup\')"></li><li class=drop title=Drop onclick="return request(\'q=drop database `'.$_SESSION[File]["db"].'`\', \'Do you really want to drop database '.$_SESSION[File]["db"].' ?\')"></li></ul></td><td>'.$R.'</td><td>'.size($S).'</td></tr></table></p>';
}
public function publish($m) {
if (preg_match("'^select\s+'i", $this->SQL) && !preg_match("'limit\s*\d+(\s*,\s*\d+)?$'i", $this->SQL)) {
$this->SQL .= " limit ".(is_numeric($_GET["p"]) ? ($_GET["p"]*PerPage)-PerPage : 0).", ".PerPage;
$this->query($this->SQL);
}
for ($c="<p><table class=table><tr>".($m ? '<th style="color: 003366">Action</th>' : ""), $q=$this->query, $n=$this->num_fields(), $i=0; $i<$n; $c.="<th>".$this->field_name($q, $i)."</th>", $i++);
for ($C=mysql_num_fields($q), $M=array(), $num_fields=mysql_num_fields($q), $i=0; $i<$num_fields; $M[]=mysql_fetch_field($q, $i), $i++);
if ($m) {
$Q = preg_replace("'(where\s*.*)?'i", "", $_REQUEST["q"]);
preg_match("'select\s*.*?\s*from\s*([`A-z0-9_ ]*)(\s*.*?)?'i", $Q, $t);
$t = trim(str_replace("`", "", $t[1]));
}
for ($c.="</tr><tr>", $N=$this->num_rows(), $i=0; $i<$N, $r=mysql_fetch_row($q); $i++) {
$w = urlencode($this->getUvaCondition($q, $C, $M, $r));
$c .= "</tr><tr bgcolor=#".($i%2 ? "ffffff" : "f8f8f8").">".($m ? '<td><ul class=img><li class=edit title=Edit onclick="return request(\'do=edit&t='.$t."&w=$w".'\')"></li><li class=drop title=Delete onclick="return request(\'do=delete&t='.$t.'&w='.$w.'\', \'Do you really want to delete this item ?\')"></li></ul></td>' : "");
for ($j=0; $j<$n; $c.="<td>".substr(htmlspecialchars($this->result($q, $i, $j)), 0, 300)."</td>", $j++);
}
return "$c</table></p>";
}
public function bug($e, $t) {
$this->error[$t][$e] = mysql_errno($this->handle).": ".mysql_error($this->handle);
}
public function error() {
foreach ($this->error as $T => $E)
foreach ($E as $q => $e)
$r .= "<p>$T [$e]<pre><code>$q</code></pre></p>";
return $r;
}
}
class Request {
public $result;
public function __construct() {
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["do"]) && method_exists($this, $_POST["do"]))
$this->result = $this->$_POST["do"]($_POST);
elseif ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET["do"]) && method_exists($this, $_GET["do"]))
$this->result = $this->$_GET["do"]($_GET);
}
public function login($_=array()) {
global $Cookie;
foreach ($Cookie as $k)
setcookie(File."[$k]", $_SESSION[File][$k] = $_[$k], $_["save"] ? Time+2592000 : 0);
die(header("location: ?"));
}
public function insert($_) {
global $DB;
foreach ($_["field"] as $c => $v) {
$F .= "$C`$c`";
$V.= $C.(empty($_["function"][$c]) ? "'".$DB->escape($v)."'" : $_["function"][$c]."('".$DB->escape($v)."')");
$C = ", ";
}
$DB->query("insert into $_[t] ($F) values ($V);");
}
public function update($_) {
global $DB;
foreach ($_["field"] as $c => $v) {
$q .= "$C`$c`=".(empty($_["function"][$c]) ? "'".$DB->escape($v)."'": $_["function"][$c]."('".$DB->escape($v)."')");
$C = ", ";
}
empty($_["w"]) or $q .= " where $_[w]";
$DB->query("update $_[t] set $q;");
}
public function delete($_) {
global $DB;
$DB->query("delete from $_[t] where $_[w]");
}
public function backup($_) {
global $DB;
$n = (isset($_["t"]) ? "$_[t](TBL)" : $_SESSION[File][db]."(DB)").".sql";
header("Content-Type: text/x-delimtext; name=$n");
header("Content-disposition: attachment; filename=$n");
die($DB->backup(isset($_["t"]) ? $_["t"] : ""));
}
public function inserting($_) {
global $DB;
for ($DB->query("show fields from $_[t]"), $i=0; $r=$DB->fetch_array(); $c.="<tr bgcolor=#".($i%2 ? "ffffff" : "f8f8f8")."><td>$r[Field]</td><td>$r[Type]</td><td>".$DB->functions($r["Field"])."</td><td>".(stristr($r["Type"], "longtext") || stristr($r["Type"], "text") ? '<textarea name="field['.$r["Field"].']" cols=40 rows=5>'.htmlspecialchars($r["Default"]).'</textarea>' : '<input name="field['.$r["Field"].']" value="'.htmlspecialchars($r["Default"]).'" size=40 />')."</td></tr>", $i++);
return "<form method=post action=\"".(preg_match("/^select/i", $_SESSION[File]["q"]) ? "?q=".$_SESSION[File]["q"] : "")."\"><input type=hidden name=do value=insert /><input type=hidden name=t value=".'"'.$_["t"].'"'." /><table class=table><tr><th width=15%>Field</th><th width=15%>Type</th><th width=15%>Function</th><th>Value</th></tr>$c<tr><td colspan=4 align=center><input type=submit value=Insert /></td></tr></table></form>";
}
public function edit($_) {
global $DB;
for ($DB->query("select * from `$_[t]` where $_[w]"); $r=$DB->fetch_array(); $R[]=$r);
for ($q=$DB->query("show fields from $_[t]"), $i=0; $r=$DB->fetch_array(); $c.="<tr bgcolor=#".($i%2 ? "ffffff" : "f8f8f8")."><td>$r[Field]</td><td>$r[Type]</td><td>".$DB->functions($r["Field"])."</td><td>".(stristr($r["Type"], "longtext") || stristr($r["Type"], "text") ? '<textarea name="field['.$r["Field"].']" cols=40 rows=5>'.htmlspecialchars($R[0][$r["Field"]]).'</textarea>' : '<input name="field['.$r["Field"].']" value="'.htmlspecialchars($R[0][$r["Field"]]).'" size=40 />')."</td></tr>", $i++);
return "<form method=post action=\"".(preg_match("/^select/i", $_SESSION[File]["q"]) ? "?q=".$_SESSION[File]["q"] : "")."\"><input type=hidden name=do value=update /><input type=hidden name=t value=".'"'.$_["t"].'"'." /><input type=hidden name=w value=".'"'.htmlspecialchars($_["w"]).'"'." /><table class=table><tr><th width=15%>Field</th><th width=15%>Type</th><th width=15%>Function</th><th>Value</th></tr>$c<tr><td colspan=4 align=center><input type=submit value=Update /></td></tr></table></form>";
}
public function img() {
header('content-type: image/gif');
die(base64_decode('R0lGODlhjwAQAPf9ALS03cnM2wR00ZXI+nBxcouMu6Wmzv7+/qan2Lm5uVFVh93+/6Sko9jW1S4vM7rC2d7e3kZHR3d2pg2ZCqWntoqKi8zx/0hLeUOzQuHh+paWlpeXx3Bwo9HS0/r6+YJ/etna89shI+Li4ujo6LDe/8vL58LBwJSZt66xsnZ4d4iYv8zMzOFdVffdiXFxizXDHjJurMXFzMLq/lhljTU5bIqKpsrL99LT5+nq/n3uUt3d///6l8HB6ix3yPX189Tk+3x8tNG2aqPU//b9/5OXr/zyjETKKNeSkO/v76u75obB976pZVxaW5D8X+/y/5W7+ye+EpmqtFG2LX7fR7vl/Hp9f3qLo7vH4wROsv7pnN7DdebRrm/OOtTV/JeHqsbDnU+Z5ISDvzKlF2dmZ7vLzP/7uEBYp0xrq1GTRuDY///mhf/wbf7VV9/q/GK+MaXK+MjFxM/OtX+i9XKL2f/fMnW38sfs12rjRePz/mekXITBdvPoymPcQDlWlKm1yOHk7enkkaZVa3/MgYboVKfHotzo79fUz4b2V+zdnNXWoEyhNJSy7q/0eY+0+lnXN9Hc9Le3y7nDtU7SLp+Yco/RfMbcxb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iWgBgg4gQvIpEoFGBR+WMSiFgOUhFteQQXZSoQfNDEKGlzgAxoopkBEsYaO7qMCMMBCMw/CAxdZBQh+NAghMPGCS0BhFVUgWD+QcAsLyIAKLlxALVJAABRUTyAauFgFDEGQDjhgKgXRwyVoIQ11iGIariCRQJBAAQmowAVINOhBPzDFK2QgALRMQy27AAAb3BKXdkLBLMxwghUwoAIV0MBPl7CDJUzCAxV4RDPneRBXEAgIEuiHVBOCBkxA4RKh8KEHOlCLKDi2AgQggAYSIAK0DCQFF0MqQT4g04K0gxbXqEIFCnKAEQhUAZFNLQE+QAG8xQxDMClIEmSxVgpmTAwCDNCAD78wiQodgAEpkNxof5KQPKChmwZBwgpQsDIGoGAFHFnnQFDABAZk0iDXNQhEzKE9grBEBAn4AEYpkIAYQGsEliVuP1TgB9cKRAQNcK961WuCzhLEA0gYgX59kN75ViQgADs='));
}
}
if ($_COOKIE[File]["save"]) {
if ($_COOKIE[File]["db"] != $_SESSION[File]["db"])
unset($Cookie["db"]);
foreach ($Cookie as $k)
$_SESSION[File][$k] = $_COOKIE[File][$k];
}
$DB = new DataBase($_SESSION[File]["host"], $_SESSION[File]["user"], $_SESSION[File]["pass"], $_SESSION[File]["db"]);
$DB->query("set names 'UTF8'");
if ($DB->connected && $DB->selected) {
if ($DB->query("select version()") && $DB->num_rows() > 0) {
$r = mysql_fetch_row($q);
$m = explode(".", $r[0]);
}
define("MYSQL_VERSION", isset($r) ? (int)sprintf("%d%02d%02d", $m[0], $m[1], intval($m[2])) : 32332);
unset($r, $m);
}
$RQE = new Request();
$_GET["do"] != "delete" or $_REQUEST["q"] = "select * from ".trim($_GET['t']);
$m = preg_match("'^(update|insert|replace|delete|drop|truncate|alter|create)'i", $_REQUEST["q"]);
$Q = empty($_REQUEST["q"]) || $m;
if ($DB->connected && $DB->selected) {
if (isset($_FILES['import']['tmp_name']))
foreach (preg_split('/;[\r|\n]+/', file_get_contents($_FILES['import']['tmp_name'])) as $q)
$DB->query($q);
#if ($m)
# $DB->query($_REQUEST["q"]);
$c = 1;
if (count($e=explode(";\r\n", $_REQUEST["q"]))) {
foreach ($e as $q)
if ($q != "") {
$DB->query($q);
$_SESSION[File]["q"] = $q;
$c = 0;
}
}
if ($c)
$DB->query($Q ? "show tables" : $_REQUEST["q"]);
}
ob_start();
?>
<html>
<head>
<title>.:|TinyAdmin|:.</title>
<style>
body {
font-family: tahoma; font-size: 8pt; scrollbar-face-color: #dee3e7; scrollbar-light-color: #ffffff; scrollbar-shadow-color: #dee3e7; Sscrollbar-3dlight-color: #d1d7dc; scrollbar-arrow-color: #006699; scrollbar-track-color: #efefef; scrollbar-darkshadow-color: #98aab1
}
code {
display: block; background-color: #f9f9f9; direction: ltr; padding: 5px; margin-top: 2px; margin-bottom: 2px; border: 1px solid #CCCCCC; font-family: verdana; font-size: 10pt
}
legend {
color: #0046D5
}
p {
font-family: tahoma; font-size: 10pt
}
fieldset {
background: #ffffff; color: #000000; border: #D0D0BF 1px solid; font: 11px Tahoma, Verdana, sans-serif; -moz-border-radius: 5px
}
.table {
font-family: tahoma; font-size: 8pt; padding: 5px; width: 100%; border-spacing: 0px 0px; border-collapse: collapse; border-bottom: solid 1px #b6c0c3; border-right: solid 1px #b6c0c3; background-color: #ffffff
}
.table th, .table td {
border-top: solid 1px #b6c0c3; border-left: solid 1px #b6c0c3
}
.table th {
background-color: #d6dbdf
}
.img {
position: relative; margin: 0px; display: inline
}
.img li {
display: inline; float: left; background: url(<?=$_SERVER['PHP_SELF'].'?do=img'?>) no-repeat; width: 16px; height: 16px; cursor: pointer; margin: 3px
}
.img .delete {
background-position: 0 0
}
.img .browse {
background-position: -16px 0
}
.img .explain {
background-position: -32px 0
}
.img .index {
background-position: -48px 0
}
.img .export {
background-position: -64px 0
}
.img .insert {
background-position: -80px 0
}
.img .trash {
background-position: -96px 0
}
.img .drop {
background-position: -112px 0
}
.img .edit {
background-position: -128px 0
}
.disable {
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); opacity: 0.3;
}
</style>
<script>
function request(q, c) {
if (typeof c == "undefined" || confirm(c))
document.location.href = "?"+(typeof q != "undefined" ? q : "");
return false;
}
</script>
</head>
<body>
<p>
<table align=center width=90%>
<tr>
<td width=50%>
<form method=post style="margin: 0px">
<input type=hidden name=do value=login />
<fieldset style="width: 85%">
<legend>Settings</legend>
<table>
<tr>
<td width=20%>Host:</td>
<td width=35%><input type=text name=host value="<?=empty($_SESSION[File]["host"]) ? "localhost" : $_SESSION[File]["host"]?>" /></td>
<td width=15%>Database:</td>
<td width=30%>
<?if ($DB->connected && ($q=$DB->query("show databases", 1))) {?>
<select name=db>
<?for ($n=$DB->num_rows($q), $i=0; $i<$n; $i++) {?>
<option value="<?=$DB->result($q, $i)?>"<?=@$_SESSION[File]["db"] == $DB->result($q, $i) ? " selected" : ""?>><?=$DB->result($q, $i)?></option>
<?}?>
</select>
<?} else {?>
<input type=text name=db value="<?=@$_SESSION[File]["db"]?>" />
<?}?>
</td>
</tr>
<tr>
<td>User name:</td>
<td><input type=text name=user value="<?=@$_SESSION[File]["user"]?>" /></td>
<td colspan=2><input type=checkbox name=save value=true<?=@$_SESSION[File]["save"] ? " checked" : ""?> /><label for=save>Remember in cookies</label></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=password name=pass value="<?=@$_SESSION[File]["pass"]?>" /></td>
<td align=center colspan=2><input type=submit value=Login /></td>
</tr>
</table>
</fieldset>
</form>
</td>
<td width=50% valign=bottom><?=$DB->connected ? $DB->SQL() : ""?></td>
</tr>
<tr>
<td colspan=2><?=empty($RQE->result) ? ($DB->connected && $DB->selected && $DB->error() == "" ? $DB->details() : $DB->error()) : ""?></td>
</tr>
<?if ($DB->connected && $DB->selected) {?>
<tr>
<td colspan=2><?=empty($RQE->result) ? ($Q ? $DB->tables() : $DB->publish(preg_match("'^select'i", $_REQUEST["q"]))) : $RQE->result?></td>
</tr>
<?}?>
</table>
</p>
</body>
</html>
<?="<!--\n|\tThis Program has written By MAHDI NEZARATIZADEH\n|\tWEB : HTTPS://Raha.Group\n-->\n".str_replace("\r", "", ob_get_clean())."\n".'<span style="color: #c0c0c0; font-size: 8pt">Programmed By <a href="//raha.group" style="color: #c0c0c0; font-size: 8pt" target="_blank">Raha.Group</a></span>'."\n<!-- Powered By WWW.Raha.Group -->"?>