@@ -54,15 +54,13 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $DoneMessage .= $lang['adm_bn_plnt']; |
| 57 | - } |
|
| 58 | - else |
|
| 57 | + } else |
|
| 59 | 58 | { |
| 60 | 59 | $DoneMessage = sprintf($lang['adm_bn_errr'], $name_output); |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | AdminMessage($DoneMessage, $lang['adm_ban_title']); |
| 64 | -} |
|
| 65 | -elseif($mode == 'unbanit' && $action) |
|
| 63 | +} elseif($mode == 'unbanit' && $action) |
|
| 66 | 64 | { |
| 67 | 65 | sys_admin_player_ban_unset($user, $player_banned_row, ($reason = sys_get_param_str('why')) ? $reason : $lang['sys_unbanned']); |
| 68 | 66 | |
@@ -28,8 +28,7 @@ |
||
| 28 | 28 | if($config->game_watchlist) |
| 29 | 29 | { |
| 30 | 30 | $config->game_watchlist_array = explode(';', $config->game_watchlist); |
| 31 | - } |
|
| 32 | - else |
|
| 31 | + } else |
|
| 33 | 32 | { |
| 34 | 33 | unset($config->game_watchlist_array); |
| 35 | 34 | } |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | header("Content-Type: text/html; charset=utf-8"); |
| 15 | 15 | //error_reporting(E_ALL); |
| 16 | 16 | error_reporting(0); |
| 17 | -if (!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
|
| 17 | +if (!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) { |
|
| 18 | + ob_start('ob_gzhandler'); |
|
| 19 | +} |
|
| 18 | 20 | set_error_handler('sxd_error_handler'); |
| 19 | 21 | register_shutdown_function('sxd_shutdown'); |
| 20 | 22 | $SXD = new Sypex_Dumper(); |
@@ -47,8 +49,11 @@ discard block |
||
| 47 | 49 | } |
| 48 | 50 | } |
| 49 | 51 | } |
| 50 | - if(file_exists("lang/lng_{$lng_name}.php")) include("lang/lng_{$lng_name}.php"); |
|
| 51 | - else include("lang/lng_en.php"); |
|
| 52 | + if(file_exists("lang/lng_{$lng_name}.php")) { |
|
| 53 | + include("lang/lng_{$lng_name}.php"); |
|
| 54 | + } else { |
|
| 55 | + include("lang/lng_en.php"); |
|
| 56 | + } |
|
| 52 | 57 | $this->LNG = &$LNG; |
| 53 | 58 | $this->LNG['name'] = $lng_name; |
| 54 | 59 | return true; |
@@ -59,8 +64,11 @@ discard block |
||
| 59 | 64 | } |
| 60 | 65 | include('cfg.php'); |
| 61 | 66 | $this->loadLang($CFG['lang']); |
| 62 | - if (!ini_get('safe_mode') && function_exists('set_time_limit') && strpos(ini_get('disable_functions'), 'set_time_limit') === false) @set_time_limit($CFG['time_web']); |
|
| 63 | - elseif (ini_get('max_execution_time') < $CFG['time_web']) $CFG['time_web'] = ini_get('max_execution_time'); |
|
| 67 | + if (!ini_get('safe_mode') && function_exists('set_time_limit') && strpos(ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 68 | + @set_time_limit($CFG['time_web']); |
|
| 69 | + } elseif (ini_get('max_execution_time') < $CFG['time_web']) { |
|
| 70 | + $CFG['time_web'] = ini_get('max_execution_time'); |
|
| 71 | + } |
|
| 64 | 72 | $this->CFG = &$CFG; |
| 65 | 73 | $this->try = false; |
| 66 | 74 | $this->virtualize = false; |
@@ -93,13 +101,17 @@ discard block |
||
| 93 | 101 | if($auth && !empty($this->CFG['sjob'])){ |
| 94 | 102 | $this->ajax($this->loadJob($this->CFG['sjob'])); |
| 95 | 103 | echo file_get_contents($this->JOB['file_log']); |
| 96 | - if(file_exists($this->JOB['file_log'])) unlink($this->JOB['file_log']); |
|
| 97 | - if(file_exists($this->JOB['file_rtl'])) unlink($this->JOB['file_rtl']); |
|
| 104 | + if(file_exists($this->JOB['file_log'])) { |
|
| 105 | + unlink($this->JOB['file_log']); |
|
| 106 | + } |
|
| 107 | + if(file_exists($this->JOB['file_rtl'])) { |
|
| 108 | + unlink($this->JOB['file_rtl']); |
|
| 109 | + } |
|
| 110 | + } else { |
|
| 111 | + echo 'Auth error'; |
|
| 98 | 112 | } |
| 99 | - else echo 'Auth error'; |
|
| 100 | 113 | exit; |
| 101 | - } |
|
| 102 | - elseif(!empty($this->CFG['auth'])){ // Авторизация |
|
| 114 | + } elseif(!empty($this->CFG['auth'])){ // Авторизация |
|
| 103 | 115 | $auth = false; |
| 104 | 116 | $sfile = 'ses.php'; |
| 105 | 117 | |
@@ -129,18 +141,25 @@ discard block |
||
| 129 | 141 | $auth = $this->connect($host, $port, $user, $pass); |
| 130 | 142 | break; |
| 131 | 143 | default: $file = 'auth_' . $a . '.php'; |
| 132 | - if(!file_exists($file)) continue; |
|
| 144 | + if(!file_exists($file)) { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 133 | 147 | include $file; |
| 134 | 148 | } |
| 135 | - if($auth) break; |
|
| 149 | + if($auth) { |
|
| 150 | + break; |
|
| 151 | + } |
|
| 136 | 152 | } |
| 137 | 153 | if($auth){ |
| 138 | 154 | $key = md5(rand(1,100000) . $user . microtime()); |
| 139 | 155 | $CFG['lang'] = $this->LNG['name']; |
| 140 | 156 | $_COOKIE['sxd'] = $key; |
| 141 | 157 | $this->saveCFG(); |
| 142 | - if(V_PHP > 50200) setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false, true); |
|
| 143 | - else setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false); |
|
| 158 | + if(V_PHP > 50200) { |
|
| 159 | + setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false, true); |
|
| 160 | + } else { |
|
| 161 | + setcookie('sxd', $key, !empty($_POST['save']) ? time() + 31536000 : 0, '', '', false); |
|
| 162 | + } |
|
| 144 | 163 | header("Location: ./"); |
| 145 | 164 | exit; |
| 146 | 165 | } |
@@ -164,9 +183,15 @@ discard block |
||
| 164 | 183 | exit; |
| 165 | 184 | } |
| 166 | 185 | } |
| 167 | - if(empty($_POST['ajax']['act']) || $_POST['ajax']['act'] != 'save_connect') $this->connect(); |
|
| 168 | - if(isset($_POST['ajax'])) $this->ajax($_POST['ajax']); |
|
| 169 | - else $this->main();exit; |
|
| 186 | + if(empty($_POST['ajax']['act']) || $_POST['ajax']['act'] != 'save_connect') { |
|
| 187 | + $this->connect(); |
|
| 188 | + } |
|
| 189 | + if(isset($_POST['ajax'])) { |
|
| 190 | + $this->ajax($_POST['ajax']); |
|
| 191 | + } else { |
|
| 192 | + $this->main(); |
|
| 193 | + } |
|
| 194 | + exit; |
|
| 170 | 195 | } |
| 171 | 196 | function saveToFile($name, $content){ |
| 172 | 197 | $fp = fopen($name, "w"); |
@@ -183,11 +208,13 @@ discard block |
||
| 183 | 208 | $this->CFG['my_pass'] = $pass; |
| 184 | 209 | } |
| 185 | 210 | if(mysql_connect($this->CFG['my_host'] . ($this->CFG['my_host']{0} != ':' ? ":{$this->CFG['my_port']}" : ''), $this->CFG['my_user'], $this->CFG['my_pass'])) { |
| 186 | - if(V_PHP > 50202) mysql_set_charset('utf8') or sxd_my_error(); |
|
| 187 | - else mysql_query('SET NAMES utf8') or sxd_my_error(); |
|
| 211 | + if(V_PHP > 50202) { |
|
| 212 | + mysql_set_charset('utf8') or sxd_my_error(); |
|
| 213 | + } else { |
|
| 214 | + mysql_query('SET NAMES utf8') or sxd_my_error(); |
|
| 215 | + } |
|
| 188 | 216 | define('V_MYSQL', sxd_ver2int(mysql_get_server_info())); |
| 189 | - } |
|
| 190 | - else { |
|
| 217 | + } else { |
|
| 191 | 218 | define('V_MYSQL', 0); |
| 192 | 219 | $this->error = "sxd.actions.tab_connects();alert(" . sxd_esc(mysql_error()) . ");"; |
| 193 | 220 | } |
@@ -240,7 +267,9 @@ discard block |
||
| 240 | 267 | $this->addCombo('db_charset', 0, 9, 'collation', $this->getCollationList()) . |
| 241 | 268 | $this->addCombo('db_charset_col', 0, 15, 'collation:db_charset') |
| 242 | 269 | ; |
| 243 | - if (!V_MYSQL) $this->VAR['combos'] .= $this->error; |
|
| 270 | + if (!V_MYSQL) { |
|
| 271 | + $this->VAR['combos'] .= $this->error; |
|
| 272 | + } |
|
| 244 | 273 | $this->VAR['combos'] .= $this->getSavedJobs() . "sxd.confirms = {$this->CFG['confirm']};sxd.actions.dblist();"; |
| 245 | 274 | $this->LNG['del_date'] = sprintf($this->LNG['del_date'], '<input type="text" id="del_time" class=txt style="width:24px;" maxlength="3">'); |
| 246 | 275 | $this->LNG['del_count'] = sprintf($this->LNG['del_count'], '<input id="del_count" type="text" class=txt style="width:18px;" maxlength="2">'); |
@@ -298,7 +327,9 @@ discard block |
||
| 298 | 327 | case 'delete_file': |
| 299 | 328 | if(preg_match('/^[^\/]+?\.sql(\.(gz|bz2))?$/', $req['name'])) { |
| 300 | 329 | $file = $this->CFG['backup_path'] . $req['name']; |
| 301 | - if(file_exists($file)) unlink($file); |
|
| 330 | + if(file_exists($file)) { |
|
| 331 | + unlink($file); |
|
| 332 | + } |
|
| 302 | 333 | } |
| 303 | 334 | $res = $this->getFileListExtended(); |
| 304 | 335 | break; |
@@ -329,7 +360,9 @@ discard block |
||
| 329 | 360 | } |
| 330 | 361 | function loadJob($job){ |
| 331 | 362 | $file = $this->CFG['backup_path'] . 'sj_' . (is_array($job) ? $job['job'] : $job) . '.job.php'; |
| 332 | - if(!file_exists($file)) return; |
|
| 363 | + if(!file_exists($file)) { |
|
| 364 | + return; |
|
| 365 | + } |
|
| 333 | 366 | include($file); |
| 334 | 367 | $JOB['act'] = $JOB['type']; |
| 335 | 368 | $JOB['type'] = 'run'; |
@@ -339,9 +372,9 @@ discard block |
||
| 339 | 372 | $r = mysql_query('DROP DATABASE `' . sxd_esc($name, false) . '`') or sxd_my_error(); |
| 340 | 373 | if($r){ |
| 341 | 374 | echo "sxd.clearOpt('db');sxd.addOpt(" . sxd_php2json(array('db' => $this->getDBList())) . ");sxd.combos.services_db.select(0,'-');"; |
| 342 | - } |
|
| 343 | - else |
|
| 344 | - echo "alert(" . sxd_esc(mysql_error()) . ");"; |
|
| 375 | + } else { |
|
| 376 | + echo "alert(" . sxd_esc(mysql_error()) . ");"; |
|
| 377 | + } |
|
| 345 | 378 | } |
| 346 | 379 | function cfg2js($cfg){ |
| 347 | 380 | foreach($cfg AS $k => $v){ |
@@ -351,16 +384,19 @@ discard block |
||
| 351 | 384 | } |
| 352 | 385 | function addDb($req){ |
| 353 | 386 | $r = mysql_query('CREATE DATABASE `' . sxd_esc($req['name'], false) . '`' . (V_MYSQL > 40100 ? "CHARACTER SET {$req['charset']} COLLATE {$req['collate']}" : '')); |
| 354 | - if($r) |
|
| 355 | - echo "sxd.addOpt(" . sxd_php2json(array('db' => array($req['name'] => "{$req['name']} (0)"))) . ");"; |
|
| 356 | - else |
|
| 357 | - sxd_my_error(); |
|
| 387 | + if($r) { |
|
| 388 | + echo "sxd.addOpt(" . sxd_php2json(array('db' => array($req['name'] => "{$req['name']} (0)"))) . ");"; |
|
| 389 | + } else { |
|
| 390 | + sxd_my_error(); |
|
| 391 | + } |
|
| 358 | 392 | } |
| 359 | 393 | function saveConnect($req){ |
| 360 | 394 | $this->CFG['my_host'] = $req['host']; |
| 361 | 395 | $this->CFG['my_port'] = (int)$req['port']; |
| 362 | 396 | $this->CFG['my_user'] = $req['user']; |
| 363 | - if(isset($req['pass'])) $this->CFG['my_pass'] = $req['pass']; |
|
| 397 | + if(isset($req['pass'])) { |
|
| 398 | + $this->CFG['my_pass'] = $req['pass']; |
|
| 399 | + } |
|
| 364 | 400 | $this->CFG['my_comp'] = $req['comp'] ? 1 : 0; |
| 365 | 401 | $this->CFG['my_db'] = $req['db']; |
| 366 | 402 | $this->saveCFG(); |
@@ -372,8 +408,7 @@ discard block |
||
| 372 | 408 | 'collation' => $this->getCollationList() |
| 373 | 409 | ); |
| 374 | 410 | echo "sxd.clearOpt('db');sxd.clearOpt('charset');sxd.clearOpt('collation');sxd.addOpt(" . sxd_php2json($tmp) . ");sxd.combos.backup_db.select(0,'-');sxd.combos.restore_db.select(0,'-');sxd.combos.services_db.select(0,'-');sxd.combos.backup_charset.select(0,'-');sxd.combos.services_db.select(0,'-');sxd.combos.db_charset.select(0,'-');"; |
| 375 | - } |
|
| 376 | - else { |
|
| 411 | + } else { |
|
| 377 | 412 | echo $this->error; |
| 378 | 413 | } |
| 379 | 414 | } |
@@ -406,11 +441,17 @@ discard block |
||
| 406 | 441 | $filter = $object = array(); |
| 407 | 442 | $this->createFilters($job['obj'], $filter, $object); |
| 408 | 443 | $r = mysql_query('SHOW TABLE STATUS') or sxd_my_error(); |
| 409 | - if (!$r) return; |
|
| 444 | + if (!$r) { |
|
| 445 | + return; |
|
| 446 | + } |
|
| 410 | 447 | $tables = array(); |
| 411 | 448 | while($item = mysql_fetch_assoc($r)){ |
| 412 | - if(V_MYSQL > 40101 && is_null($item['Engine']) && preg_match('/^VIEW/i', $item['Comment'])) continue; |
|
| 413 | - if(sxd_check($item['Name'], $object['TA'], $filter['TA'])) $tables[] = "`{$item['Name']}`"; |
|
| 449 | + if(V_MYSQL > 40101 && is_null($item['Engine']) && preg_match('/^VIEW/i', $item['Comment'])) { |
|
| 450 | + continue; |
|
| 451 | + } |
|
| 452 | + if(sxd_check($item['Name'], $object['TA'], $filter['TA'])) { |
|
| 453 | + $tables[] = "`{$item['Name']}`"; |
|
| 454 | + } |
|
| 414 | 455 | } |
| 415 | 456 | $sql = $serv[$job['type']] . ' TABLE ' . implode(',', $tables); |
| 416 | 457 | |
@@ -419,7 +460,9 @@ discard block |
||
| 419 | 460 | } |
| 420 | 461 | |
| 421 | 462 | $r = mysql_query($sql) or sxd_my_error(); |
| 422 | - if (!$r) return; |
|
| 463 | + if (!$r) { |
|
| 464 | + return; |
|
| 465 | + } |
|
| 423 | 466 | $res = array(); |
| 424 | 467 | while($item = mysql_fetch_row($r)){ |
| 425 | 468 | $res[] = $item; |
@@ -436,8 +479,7 @@ discard block |
||
| 436 | 479 | foreach($obj[$type] AS $v){ |
| 437 | 480 | if(strpos($v, '*') !== false) { |
| 438 | 481 | $filter[$type][] = str_replace('*', '.*?', $v); |
| 439 | - } |
|
| 440 | - else { |
|
| 482 | + } else { |
|
| 441 | 483 | $object[$type][$v] = true; |
| 442 | 484 | } |
| 443 | 485 | } |
@@ -460,14 +502,15 @@ discard block |
||
| 460 | 502 | $this->closeConnect(); |
| 461 | 503 | include($this->CFG['backup_path'] . $job['job'] . '.job.php'); |
| 462 | 504 | $this->JOB = &$JOB; |
| 463 | - if(file_exists($this->JOB['file_stp'])) unlink($this->JOB['file_stp']); |
|
| 505 | + if(file_exists($this->JOB['file_stp'])) { |
|
| 506 | + unlink($this->JOB['file_stp']); |
|
| 507 | + } |
|
| 464 | 508 | $this->fh_rtl = fopen($this->JOB['file_rtl'], 'r+b'); |
| 465 | 509 | $this->fh_log = fopen($this->JOB['file_log'], 'ab'); |
| 466 | 510 | $t = fgets($this->fh_rtl); |
| 467 | 511 | if(!empty($t)){ |
| 468 | 512 | $this->rtl = explode("\t", $t); |
| 469 | - } |
|
| 470 | - else { |
|
| 513 | + } else { |
|
| 471 | 514 | $this->addLog($this->LNG['not_found_rtl']); |
| 472 | 515 | exit; |
| 473 | 516 | } |
@@ -477,8 +520,11 @@ discard block |
||
| 477 | 520 | $this->rtl[1] = time(); |
| 478 | 521 | $this->rtl[9] = 0; |
| 479 | 522 | fwrite($this->fh_rtl, implode("\t", $this->rtl)); |
| 480 | - if ($this->JOB['act'] == 'backup') $this->runBackupJob(true); |
|
| 481 | - elseif ($this->JOB['act'] == 'restore') $this->runRestoreJob(true); |
|
| 523 | + if ($this->JOB['act'] == 'backup') { |
|
| 524 | + $this->runBackupJob(true); |
|
| 525 | + } elseif ($this->JOB['act'] == 'restore') { |
|
| 526 | + $this->runRestoreJob(true); |
|
| 527 | + } |
|
| 482 | 528 | } |
| 483 | 529 | function addRestoreJob($job) { |
| 484 | 530 | $this->closeConnect(); |
@@ -493,9 +539,10 @@ discard block |
||
| 493 | 539 | $this->tab_rows = array(); |
| 494 | 540 | $todo = array(); |
| 495 | 541 | foreach($objects AS $t => $list){ |
| 496 | - if($t == 'TA' && (!empty($object['TC']) || !empty($filter['TC']))) {} |
|
| 497 | - elseif(empty($object[$t]) && empty($filter[$t])) {continue;} |
|
| 498 | - if (empty($list)) continue; |
|
| 542 | + if($t == 'TA' && (!empty($object['TC']) || !empty($filter['TC']))) {} elseif(empty($object[$t]) && empty($filter[$t])) {continue;} |
|
| 543 | + if (empty($list)) { |
|
| 544 | + continue; |
|
| 545 | + } |
|
| 499 | 546 | |
| 500 | 547 | foreach($list AS $item){ |
| 501 | 548 | switch($t){ |
@@ -503,11 +550,11 @@ discard block |
||
| 503 | 550 | $type = ''; |
| 504 | 551 | if(sxd_check($item[0], $object['TA'], $filter['TA'])){ |
| 505 | 552 | $type = empty($item[1]) ? 'TC' : 'TA'; |
| 506 | - } |
|
| 507 | - elseif(sxd_check($item[0], $object['TC'], $filter['TC'])) { |
|
| 553 | + } elseif(sxd_check($item[0], $object['TC'], $filter['TC'])) { |
|
| 508 | 554 | $type = 'TC'; |
| 555 | + } else { |
|
| 556 | + continue; |
|
| 509 | 557 | } |
| 510 | - else continue; |
|
| 511 | 558 | $todo['TA'][] = array($type, $item[0], $item[1], $item[2]); |
| 512 | 559 | $rows += $type == 'TA' ? $item[1] : 0; |
| 513 | 560 | break; |
@@ -522,15 +569,21 @@ discard block |
||
| 522 | 569 | $this->JOB['file_rtl'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.rtl'; |
| 523 | 570 | $this->JOB['file_log'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.log'; |
| 524 | 571 | $this->JOB['file_stp'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.stp'; |
| 525 | - if(file_exists($this->JOB['file_stp'])) unlink($this->JOB['file_stp']); |
|
| 572 | + if(file_exists($this->JOB['file_stp'])) { |
|
| 573 | + unlink($this->JOB['file_stp']); |
|
| 574 | + } |
|
| 526 | 575 | |
| 527 | 576 | $this->fh_tmp = $this->openFile($this->JOB['file_tmp'], 'r'); |
| 528 | 577 | // Для чужих дампов определяем разделители строк |
| 529 | 578 | if(is_null($this->JOB['obj'])) { |
| 530 | 579 | $s = fread($this->fh_tmp, 2048); |
| 531 | - if(strpos($s, "\r\n")) $this->JOB['eol'] = "\r\n"; |
|
| 532 | - elseif(strpos($s, "\n")) $this->JOB['eol'] = "\n"; |
|
| 533 | - else $this->JOB['eol'] = "\r"; |
|
| 580 | + if(strpos($s, "\r\n")) { |
|
| 581 | + $this->JOB['eol'] = "\r\n"; |
|
| 582 | + } elseif(strpos($s, "\n")) { |
|
| 583 | + $this->JOB['eol'] = "\n"; |
|
| 584 | + } else { |
|
| 585 | + $this->JOB['eol'] = "\r"; |
|
| 586 | + } |
|
| 534 | 587 | $bom = strncmp($s, "\xEF\xBB\xBF", 3) == 0 ? 3 : ((strncmp($s, "\xFE\xFF", 2) == 0 || strncmp($s, "\xFF\xFE", 2) == 0) ? 2 : 0); |
| 535 | 588 | fseek($this->fh_tmp, $bom); |
| 536 | 589 | } |
@@ -548,11 +601,17 @@ discard block |
||
| 548 | 601 | if($continue){ |
| 549 | 602 | $this->fh_tmp = $this->openFile($this->JOB['file_tmp'], 'r'); |
| 550 | 603 | fseek($this->fh_tmp, $this->rtl[3]); |
| 551 | - if(!empty($this->rtl[6])) $this->setNames($this->JOB['correct'] == 1 && !empty($this->JOB['charset']) ? $this->JOB['charset'] : $this->rtl[6]); |
|
| 552 | - if($this->rtl[7] < $this->rtl[10]) $ei = true; |
|
| 604 | + if(!empty($this->rtl[6])) { |
|
| 605 | + $this->setNames($this->JOB['correct'] == 1 && !empty($this->JOB['charset']) ? $this->JOB['charset'] : $this->rtl[6]); |
|
| 606 | + } |
|
| 607 | + if($this->rtl[7] < $this->rtl[10]) { |
|
| 608 | + $ei = true; |
|
| 609 | + } |
|
| 553 | 610 | } |
| 554 | 611 | mysql_select_db($this->JOB['db']); |
| 555 | - if(is_null($this->JOB['obj'])) $this->runRestoreJobForeign($continue); |
|
| 612 | + if(is_null($this->JOB['obj'])) { |
|
| 613 | + $this->runRestoreJobForeign($continue); |
|
| 614 | + } |
|
| 556 | 615 | //mysql_query("SET NAMES 'UTF8'"); |
| 557 | 616 | $types = array('VI' => 'View', 'PR' => 'Procedure', 'FU' => 'Function', 'TR' => 'Trigger', 'EV' => 'Event'); |
| 558 | 617 | $fcache = ''; |
@@ -583,8 +642,12 @@ discard block |
||
| 583 | 642 | if(V_MYSQL > 40014) { |
| 584 | 643 | mysql_query("SET UNIQUE_CHECKS=0"); |
| 585 | 644 | mysql_query("SET FOREIGN_KEY_CHECKS=0"); |
| 586 | - if(V_MYSQL > 40101) mysql_query("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"); |
|
| 587 | - if(V_MYSQL > 40111) mysql_query("SET SQL_NOTES=0"); |
|
| 645 | + if(V_MYSQL > 40101) { |
|
| 646 | + mysql_query("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"); |
|
| 647 | + } |
|
| 648 | + if(V_MYSQL > 40111) { |
|
| 649 | + mysql_query("SET SQL_NOTES=0"); |
|
| 650 | + } |
|
| 588 | 651 | } |
| 589 | 652 | $log_sql = false; |
| 590 | 653 | $fields = ''; |
@@ -648,13 +711,16 @@ discard block |
||
| 648 | 711 | case 'C': |
| 649 | 712 | $ex = 1; |
| 650 | 713 | if (preg_match('/^CREATE TABLE `/', $q)) { |
| 651 | - if($this->JOB['strategy'] != 0 && isset($tab_exists[$this->rtl[5]])) $ex = 0; |
|
| 652 | - else { |
|
| 714 | + if($this->JOB['strategy'] != 0 && isset($tab_exists[$this->rtl[5]])) { |
|
| 715 | + $ex = 0; |
|
| 716 | + } else { |
|
| 653 | 717 | $ex = 1; |
| 654 | 718 | if((!empty($this->JOB['correct']) && !empty($this->JOB['charset']))){ |
| 655 | 719 | $q = preg_replace('/(DEFAULT)?\s*(CHARSET|CHARACTER SET|COLLATE)[=\s]+\w+/i', '', $q) . (V_MYSQL < 40100 ? '' : ' DEFAULT CHARSET=' . $this->JOB['charset']); |
| 656 | 720 | } |
| 657 | - if(!empty($this->JOB['autoinc'])) $q = preg_replace("/AUTO_INCREMENT=\d+/", "AUTO_INCREMENT=1", $q); |
|
| 721 | + if(!empty($this->JOB['autoinc'])) { |
|
| 722 | + $q = preg_replace("/AUTO_INCREMENT=\d+/", "AUTO_INCREMENT=1", $q); |
|
| 723 | + } |
|
| 658 | 724 | } |
| 659 | 725 | // Достаем имена полей таблицы |
| 660 | 726 | $fields = $this->JOB['strategy'] > 0 && preg_match_all('/^\s+(`.+?`) /m', $q, $f, PREG_PATTERN_ORDER) ? '(' . implode(',', $f[1]) . ')' : ''; |
@@ -675,11 +741,9 @@ discard block |
||
| 675 | 741 | if($tc && ($this->JOB['strategy'] == 0 || isset($tab_exists[$m[2]]))) { |
| 676 | 742 | mysql_query("{$tc} `{$m[2]}`") or sxd_my_error(); |
| 677 | 743 | } |
| 678 | - } |
|
| 679 | - elseif($m[1] == 'TD'){ |
|
| 744 | + } elseif($m[1] == 'TD'){ |
|
| 680 | 745 | $ei = 1; |
| 681 | - } |
|
| 682 | - else { |
|
| 746 | + } else { |
|
| 683 | 747 | $this->rtl[4] = $m[1]; |
| 684 | 748 | $this->rtl[5] = $m[2]; |
| 685 | 749 | $this->rtl[7] = 0; |
@@ -704,8 +768,7 @@ discard block |
||
| 704 | 768 | if($insert) { |
| 705 | 769 | $c = 1; |
| 706 | 770 | } |
| 707 | - } |
|
| 708 | - else { |
|
| 771 | + } else { |
|
| 709 | 772 | error_log(date('r') . "\n----------\n{$q}\n", 3, "backup/sql_error.log"); |
| 710 | 773 | sxd_my_error(); |
| 711 | 774 | } |
@@ -731,7 +794,9 @@ discard block |
||
| 731 | 794 | $this->rtl[7] = 0; |
| 732 | 795 | $this->rtl[8] = 0; |
| 733 | 796 | foreach($this->JOB['todo']['TA'] AS $tab){ |
| 734 | - if ($tab[0] == 'TC') continue; |
|
| 797 | + if ($tab[0] == 'TC') { |
|
| 798 | + continue; |
|
| 799 | + } |
|
| 735 | 800 | mysql_query("ALTER TABLE `{$tab[1]}` ENABLE KEYS") or sxd_my_error(); |
| 736 | 801 | $this->rtl[1] = time(); |
| 737 | 802 | $this->rtl[5] = $tab[1]; |
@@ -770,7 +835,9 @@ discard block |
||
| 770 | 835 | $delimiter = ";"; |
| 771 | 836 | while($q = sxd_read_sql($this->fh_tmp, $seek, $ei, $delimiter, $this->JOB['eol'])){ |
| 772 | 837 | $q = ltrim($q); |
| 773 | - if(empty($q)) break; |
|
| 838 | + if(empty($q)) { |
|
| 839 | + break; |
|
| 840 | + } |
|
| 774 | 841 | if($time_old < time()) { |
| 775 | 842 | if(file_exists($this->JOB['file_stp'])){ |
| 776 | 843 | $type = file_get_contents($this->JOB['file_stp']); |
@@ -829,8 +896,7 @@ discard block |
||
| 829 | 896 | //mysql_query("DROP TABLE IF EXISTS `{$tab}`"); |
| 830 | 897 | if((!empty($this->JOB['correct']) && !empty($this->JOB['charset']))){ |
| 831 | 898 | $q = preg_replace('/(DEFAULT)?\s*(CHARSET|CHARACTER SET|COLLATE)[=\s]+\w+/i', '', $q) . (V_MYSQL < 40100 ? '' : ' DEFAULT CHARSET=' . $this->JOB['charset']); |
| 832 | - } |
|
| 833 | - elseif(empty($this->JOB['charset'])){ |
|
| 899 | + } elseif(empty($this->JOB['charset'])){ |
|
| 834 | 900 | if(preg_match("/(CHARACTER SET|CHARSET)[=\s]+(\w+)/i", $q, $charset)){ |
| 835 | 901 | $this->setNames($charset[2]); |
| 836 | 902 | } |
@@ -849,8 +915,9 @@ discard block |
||
| 849 | 915 | $this->JOB['charset'] = $m[1]; |
| 850 | 916 | $this->setNames($this->JOB['charset']); |
| 851 | 917 | $ex = 0; |
| 918 | + } else { |
|
| 919 | + $ex = 1; |
|
| 852 | 920 | } |
| 853 | - else $ex = 1; |
|
| 854 | 921 | break; |
| 855 | 922 | default: |
| 856 | 923 | $insert = ''; |
@@ -868,8 +935,7 @@ discard block |
||
| 868 | 935 | if($insert) { |
| 869 | 936 | $c = 1; |
| 870 | 937 | } |
| 871 | - } |
|
| 872 | - else { |
|
| 938 | + } else { |
|
| 873 | 939 | error_log("-----------------\n{$q}\n", 3, "error.log"); |
| 874 | 940 | sxd_my_error(); |
| 875 | 941 | } |
@@ -914,17 +980,22 @@ discard block |
||
| 914 | 980 | $queries[] = array("PROCEDURE STATUS WHERE db='{$this->JOB['db']}'", 'Name', 'PR'); |
| 915 | 981 | $queries[] = array("FUNCTION STATUS WHERE db='{$this->JOB['db']}'", 'Name', 'FU'); |
| 916 | 982 | $queries[] = array('TRIGGERS', 'Trigger', 'TR'); |
| 917 | - if(V_MYSQL > 50100) $queries[] = array('EVENTS', 'Name', 'EV'); |
|
| 983 | + if(V_MYSQL > 50100) { |
|
| 984 | + $queries[] = array('EVENTS', 'Name', 'EV'); |
|
| 985 | + } |
|
| 918 | 986 | } |
| 919 | 987 | $todo = $header = array(); |
| 920 | 988 | $tabs = $rows = 0; |
| 921 | 989 | $only_create = explode(' ', $this->CFG['only_create']); |
| 922 | 990 | foreach($queries AS $query){ |
| 923 | 991 | $t = $query[2]; |
| 924 | - if($t == 'TA' && (!empty($object['TC']) || !empty($filter['TC']))) {} |
|
| 925 | - elseif(empty($object[$t]) && empty($filter[$t])) continue; |
|
| 992 | + if($t == 'TA' && (!empty($object['TC']) || !empty($filter['TC']))) {} elseif(empty($object[$t]) && empty($filter[$t])) { |
|
| 993 | + continue; |
|
| 994 | + } |
|
| 926 | 995 | $r = mysql_query('SHOW ' . $query[0]) or sxd_my_error(); |
| 927 | - if (!$r) continue; |
|
| 996 | + if (!$r) { |
|
| 997 | + continue; |
|
| 998 | + } |
|
| 928 | 999 | $todo[$t] = array(); |
| 929 | 1000 | $header[$t] = array(); |
| 930 | 1001 | |
@@ -939,16 +1010,15 @@ discard block |
||
| 939 | 1010 | $header['VI']= array(); |
| 940 | 1011 | } |
| 941 | 1012 | continue; |
| 942 | - } |
|
| 943 | - elseif(sxd_check($n, $object['TA'], $filter['TA'])){ |
|
| 1013 | + } elseif(sxd_check($n, $object['TA'], $filter['TA'])){ |
|
| 944 | 1014 | $engine = V_MYSQL > 40101 ? $item['Engine'] : $item['Type']; |
| 945 | 1015 | $t = in_array($engine, $only_create) ? 'TC' : 'TA'; |
| 946 | - } |
|
| 947 | - elseif(sxd_check($n, $object['TC'], $filter['TC'])) { |
|
| 1016 | + } elseif(sxd_check($n, $object['TC'], $filter['TC'])) { |
|
| 948 | 1017 | $t = 'TC'; |
| 949 | 1018 | $item['Rows'] = $item['Data_length'] = ''; |
| 1019 | + } else { |
|
| 1020 | + continue; |
|
| 950 | 1021 | } |
| 951 | - else continue; |
|
| 952 | 1022 | $todo['TA'][] = array($t, $n, !empty($item['Collation']) ? $item['Collation'] : '', $item['Auto_increment'], $item['Rows'], $item['Data_length']); |
| 953 | 1023 | $header['TA'][] = "{$n}`{$item['Rows']}`{$item['Data_length']}"; |
| 954 | 1024 | $tabs++; |
@@ -979,7 +1049,9 @@ discard block |
||
| 979 | 1049 | foreach($views AS $n => $view) { |
| 980 | 1050 | $can_dumped = true; |
| 981 | 1051 | foreach($view AS $k) { |
| 982 | - if (isset($views[$k]) && !isset($dumped[$k])) $can_dumped = false; |
|
| 1052 | + if (isset($views[$k]) && !isset($dumped[$k])) { |
|
| 1053 | + $can_dumped = false; |
|
| 1054 | + } |
|
| 983 | 1055 | } |
| 984 | 1056 | if ($can_dumped) { |
| 985 | 1057 | if(sxd_check($n, $object['VI'], $filter['VI'])){ |
@@ -999,7 +1071,9 @@ discard block |
||
| 999 | 1071 | $this->JOB['file_rtl'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.rtl'; |
| 1000 | 1072 | $this->JOB['file_log'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.log'; |
| 1001 | 1073 | $this->JOB['file_stp'] = $this->CFG['backup_path'] . $this->JOB['job'] . '.stp'; |
| 1002 | - if(file_exists($this->JOB['file_stp'])) unlink($this->JOB['file_stp']); |
|
| 1074 | + if(file_exists($this->JOB['file_stp'])) { |
|
| 1075 | + unlink($this->JOB['file_stp']); |
|
| 1076 | + } |
|
| 1003 | 1077 | $this->fh_tmp = $this->openFile($this->JOB['file_tmp'], 'w'); |
| 1004 | 1078 | $this->JOB['file'] = sprintf('%s_%s.%s', (isset($this->JOB['title']) ? $this->JOB['job'] : $this->JOB['db']), date('Y-m-d_H-i-s'), $this->JOB['file_ext']); |
| 1005 | 1079 | $this->JOB['file_name'] = $this->CFG['backup_path'] . $this->JOB['file']; |
@@ -1007,7 +1081,9 @@ discard block |
||
| 1007 | 1081 | $this->saveJob($this->JOB['job'], $this->JOB); |
| 1008 | 1082 | $fcache = implode('|', array('#SXD20', V_SXD, V_MYSQL, V_PHP, date('Y.m.d H:i:s'), $this->JOB['db'], $this->JOB['charset'], $tabs, $rows, sxd_esc($this->JOB['comment'], false))) . "\n"; |
| 1009 | 1083 | foreach($header AS $t => $o){ |
| 1010 | - if (!empty($o)) $fcache .= "#{$t} " . implode('|', $o) . "\n"; |
|
| 1084 | + if (!empty($o)) { |
|
| 1085 | + $fcache .= "#{$t} " . implode('|', $o) . "\n"; |
|
| 1086 | + } |
|
| 1011 | 1087 | } |
| 1012 | 1088 | $this->fh_rtl = fopen($this->JOB['file_rtl'], 'wb'); |
| 1013 | 1089 | $this->fh_log = fopen($this->JOB['file_log'], 'wb'); |
@@ -1027,20 +1103,26 @@ discard block |
||
| 1027 | 1103 | $fcache = ''; |
| 1028 | 1104 | $writes = 0; |
| 1029 | 1105 | |
| 1030 | - if(V_MYSQL > 40101) mysql_query("SET SESSION character_set_results = '" . ($this->JOB['charset'] ? $this->JOB['charset'] : 'binary') ."'") or sxd_my_error(); |
|
| 1106 | + if(V_MYSQL > 40101) { |
|
| 1107 | + mysql_query("SET SESSION character_set_results = '" . ($this->JOB['charset'] ? $this->JOB['charset'] : 'binary') ."'") or sxd_my_error(); |
|
| 1108 | + } |
|
| 1031 | 1109 | $time_old = time(); |
| 1032 | 1110 | $exit_time = $time_old + $this->CFG['time_web'] - 1; |
| 1033 | 1111 | $no_cache = V_MYSQL < 40101 ? 'SQL_NO_CACHE ' : ''; |
| 1034 | 1112 | foreach($this->JOB['todo'] AS $t => $o){ |
| 1035 | - if (empty($this->rtl[4])) $this->rtl[4] = $t; |
|
| 1036 | - elseif ($this->rtl[4] != $t) continue; |
|
| 1113 | + if (empty($this->rtl[4])) { |
|
| 1114 | + $this->rtl[4] = $t; |
|
| 1115 | + } elseif ($this->rtl[4] != $t) { |
|
| 1116 | + continue; |
|
| 1117 | + } |
|
| 1037 | 1118 | foreach($o AS $n){ |
| 1038 | 1119 | if (empty($this->rtl[5])) { |
| 1039 | 1120 | $this->rtl[5] = $n[1]; |
| 1040 | 1121 | $this->rtl[7] = 0; |
| 1041 | 1122 | $this->rtl[8] = !empty($n[4]) ? $n[4] : 0; |
| 1123 | + } elseif ($this->rtl[5] != $n[1]) { |
|
| 1124 | + continue; |
|
| 1042 | 1125 | } |
| 1043 | - elseif ($this->rtl[5] != $n[1]) continue; |
|
| 1044 | 1126 | // Делаем бэкап |
| 1045 | 1127 | switch($n[0]){ |
| 1046 | 1128 | case 'TC': |
@@ -1054,11 +1136,12 @@ discard block |
||
| 1054 | 1136 | $fcache .= "#\tTC`{$n[1]}`{$n[2]}\t;\n{$item['Create Table']}\t;\n"; |
| 1055 | 1137 | $this->addLog(sprintf($this->LNG['backup_TC'], $n[1])); |
| 1056 | 1138 | $this->rtl[7] = 0; |
| 1057 | - if($n[0] == 'TC' || !$n[4]) break; |
|
| 1139 | + if($n[0] == 'TC' || !$n[4]) { |
|
| 1140 | + break; |
|
| 1141 | + } |
|
| 1058 | 1142 | // Бэкапим данные таблицы |
| 1059 | 1143 | $fcache .= "#\tTD`{$n[1]}`{$n[2]}\t;\nINSERT INTO `{$n[1]}` VALUES \n"; |
| 1060 | - } |
|
| 1061 | - else { |
|
| 1144 | + } else { |
|
| 1062 | 1145 | $from = " LIMIT {$this->rtl[7]}, {$this->rtl[8]}"; |
| 1063 | 1146 | $this->addLog(sprintf("{$this->LNG['backup_TC']} {$this->LNG['continue_from']}", $n[1], $this->rtl[7])); |
| 1064 | 1147 | } |
@@ -1101,8 +1184,7 @@ discard block |
||
| 1101 | 1184 | $this->write($fcache); |
| 1102 | 1185 | } |
| 1103 | 1186 | for($k = 0; $k < $fields; $k++){ |
| 1104 | - if(!isset($row[$k])) {$row[$k] = '\N';} |
|
| 1105 | - elseif($notNum[$k]) {$row[$k] = '\'' . mysql_real_escape_string($row[$k]) . '\'';} // TODO: Потестить скорость эскэйпинга строк |
|
| 1187 | + if(!isset($row[$k])) {$row[$k] = '\N';} elseif($notNum[$k]) {$row[$k] = '\'' . mysql_real_escape_string($row[$k]) . '\'';} // TODO: Потестить скорость эскэйпинга строк |
|
| 1106 | 1188 | } |
| 1107 | 1189 | $fcache .= '(' . implode(',', $row) . "),\n"; |
| 1108 | 1190 | $this->rtl[7]++; |
@@ -1119,8 +1201,7 @@ discard block |
||
| 1119 | 1201 | $r = mysql_query("SELECT * FROM `INFORMATION_SCHEMA`.`TRIGGERS` WHERE `TRIGGER_SCHEMA` = '{$this->JOB['db']}' AND `TRIGGER_NAME` = '{$n[1]}'") or sxd_my_error(); |
| 1120 | 1202 | $item = mysql_fetch_assoc($r); |
| 1121 | 1203 | $fcache .= "#\tTR`{$n[1]}`{$n[2]}\t;\nCREATE TRIGGER `{$item['TRIGGER_NAME']}` {$item['ACTION_TIMING']} {$item['EVENT_MANIPULATION']} ON `{$item['EVENT_OBJECT_TABLE']}` FOR EACH ROW {$item['ACTION_STATEMENT']}\t;\n"; |
| 1122 | - } |
|
| 1123 | - else { |
|
| 1204 | + } else { |
|
| 1124 | 1205 | $this->addLog(sprintf($this->LNG['backup_' . $n[0]], $n[1])); |
| 1125 | 1206 | $r = mysql_query("SHOW CREATE {$types[$n[0]]} `{$n[1]}`") or sxd_my_error(); |
| 1126 | 1207 | $item = mysql_fetch_assoc($r); |
@@ -1141,7 +1222,9 @@ discard block |
||
| 1141 | 1222 | fclose($this->fh_tmp); |
| 1142 | 1223 | rename($this->JOB['file_tmp'], $this->JOB['file_name']); |
| 1143 | 1224 | $this->addLog(sprintf($this->LNG['backup_end'], $this->JOB['db'])); |
| 1144 | - if(file_exists('sxd2ftp.php')) include('sxd2ftp.php'); |
|
| 1225 | + if(file_exists('sxd2ftp.php')) { |
|
| 1226 | + include('sxd2ftp.php'); |
|
| 1227 | + } |
|
| 1145 | 1228 | if ($this->JOB['del_time'] || $this->JOB['del_count']) { |
| 1146 | 1229 | $this->addLog($this->LNG['autodelete']); |
| 1147 | 1230 | $deldate = ''; |
@@ -1155,11 +1238,13 @@ discard block |
||
| 1155 | 1238 | while (false !== ($file = readdir($dh))) { |
| 1156 | 1239 | if (preg_match("/^{$name}_(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})\.sql/", $file, $m)) { |
| 1157 | 1240 | if ($deldate && $m[1] < $deldate) { |
| 1158 | - if(unlink($this->CFG['backup_path'] . $file)) $this->addLog(sprintf($this->LNG['del_by_date'], $file)); |
|
| 1159 | - else $this->addLog(sprintf($this->LNG['del_fail'], $file)); |
|
| 1241 | + if(unlink($this->CFG['backup_path'] . $file)) { |
|
| 1242 | + $this->addLog(sprintf($this->LNG['del_by_date'], $file)); |
|
| 1243 | + } else { |
|
| 1244 | + $this->addLog(sprintf($this->LNG['del_fail'], $file)); |
|
| 1245 | + } |
|
| 1160 | 1246 | $deleted = true; |
| 1161 | - } |
|
| 1162 | - else {$files[$m[1]] = $file;} |
|
| 1247 | + } else {$files[$m[1]] = $file;} |
|
| 1163 | 1248 | } |
| 1164 | 1249 | } |
| 1165 | 1250 | closedir($dh); |
@@ -1169,20 +1254,27 @@ discard block |
||
| 1169 | 1254 | $file_to_delete = count($files) - $this->JOB['del_count']; |
| 1170 | 1255 | foreach ($files AS $file){ |
| 1171 | 1256 | if ($file_to_delete-- > 0){ |
| 1172 | - if(unlink($this->CFG['backup_path'] . $file)) $this->addLog(sprintf($this->LNG['del_by_count'], $file)); |
|
| 1173 | - else $this->addLog(sprintf($this->LNG['del_fail'], $file)); |
|
| 1257 | + if(unlink($this->CFG['backup_path'] . $file)) { |
|
| 1258 | + $this->addLog(sprintf($this->LNG['del_by_count'], $file)); |
|
| 1259 | + } else { |
|
| 1260 | + $this->addLog(sprintf($this->LNG['del_fail'], $file)); |
|
| 1261 | + } |
|
| 1174 | 1262 | $deleted = true; |
| 1175 | 1263 | } |
| 1176 | 1264 | } |
| 1177 | 1265 | } |
| 1178 | 1266 | } |
| 1179 | - if(!$deleted) $this->addLog($this->LNG['del_nothing']); |
|
| 1267 | + if(!$deleted) { |
|
| 1268 | + $this->addLog($this->LNG['del_nothing']); |
|
| 1269 | + } |
|
| 1180 | 1270 | } |
| 1181 | 1271 | fclose($this->fh_log); |
| 1182 | 1272 | fclose($this->fh_rtl); |
| 1183 | 1273 | } |
| 1184 | 1274 | function setNames($collation){ |
| 1185 | - if(empty($collation)) return; |
|
| 1275 | + if(empty($collation)) { |
|
| 1276 | + return; |
|
| 1277 | + } |
|
| 1186 | 1278 | if($this->rtl[6] != $collation) { |
| 1187 | 1279 | mysql_query('SET NAMES \'' . preg_replace('/^(\w+?)_/', '\\1\' COLLATE \'\\1_', $collation) . '\'') or sxd_my_error(); |
| 1188 | 1280 | /*if(!$this->rtl[7])*/ $this->addLog(sprintf($this->LNG['set_names'], $collation)); |
@@ -1201,7 +1293,9 @@ discard block |
||
| 1201 | 1293 | } |
| 1202 | 1294 | function getDBList(){ |
| 1203 | 1295 | $dbs = $items = array(); |
| 1204 | - if (!V_MYSQL) return $dbs; |
|
| 1296 | + if (!V_MYSQL) { |
|
| 1297 | + return $dbs; |
|
| 1298 | + } |
|
| 1205 | 1299 | $qq = (V_MYSQL < 50000) ? '' : '\''; |
| 1206 | 1300 | if ($this->CFG['my_db']) { |
| 1207 | 1301 | $tmp = explode(',', $this->CFG['my_db']); |
@@ -1210,11 +1304,12 @@ discard block |
||
| 1210 | 1304 | $items[] = $qq . sxd_esc($d, false) . $qq; |
| 1211 | 1305 | $dbs[$d] = "{$d} (0)"; |
| 1212 | 1306 | } |
| 1213 | - } |
|
| 1214 | - else{ |
|
| 1307 | + } else{ |
|
| 1215 | 1308 | $result = mysql_query("SHOW DATABASES") or sxd_my_error(); |
| 1216 | 1309 | while($item = mysql_fetch_row($result)){ |
| 1217 | - if($item[0] == 'information_schema' || $item[0] == 'mysql' || $item[0] == 'performance_schema') continue; |
|
| 1310 | + if($item[0] == 'information_schema' || $item[0] == 'mysql' || $item[0] == 'performance_schema') { |
|
| 1311 | + continue; |
|
| 1312 | + } |
|
| 1218 | 1313 | $items[] = $qq . sxd_esc($item[0], false) . $qq; |
| 1219 | 1314 | $dbs[$item[0]] = "{$item[0]} (0)"; |
| 1220 | 1315 | } |
@@ -1227,12 +1322,13 @@ discard block |
||
| 1227 | 1322 | $dbs[$item] = "{$item} ({$tabs})"; |
| 1228 | 1323 | } |
| 1229 | 1324 | } |
| 1230 | - } |
|
| 1231 | - else { |
|
| 1325 | + } else { |
|
| 1232 | 1326 | $where = (count($items) > 0) ? 'WHERE `table_schema` IN (' . implode(',', $items) . ')' : ''; |
| 1233 | 1327 | $result = mysql_query("SELECT `table_schema`, COUNT(*) FROM `information_schema`.`tables` {$where} GROUP BY `table_schema`") or sxd_my_error(); |
| 1234 | 1328 | while($item = mysql_fetch_row($result)){ |
| 1235 | - if($item[0] == 'information_schema' || $item[0] == 'mysql' || $item[0] == 'performance_schema') continue; |
|
| 1329 | + if($item[0] == 'information_schema' || $item[0] == 'mysql' || $item[0] == 'performance_schema') { |
|
| 1330 | + continue; |
|
| 1331 | + } |
|
| 1236 | 1332 | $dbs[$item[0]] = "{$item[0]} ({$item[1]})"; |
| 1237 | 1333 | } |
| 1238 | 1334 | } |
@@ -1240,7 +1336,9 @@ discard block |
||
| 1240 | 1336 | } |
| 1241 | 1337 | function getCharsetList(){ |
| 1242 | 1338 | $tmp = array(0 => '- auto -'); |
| 1243 | - if (!V_MYSQL) return $tmp; |
|
| 1339 | + if (!V_MYSQL) { |
|
| 1340 | + return $tmp; |
|
| 1341 | + } |
|
| 1244 | 1342 | if(V_MYSQL > 40101) { |
| 1245 | 1343 | $def_charsets = ''; |
| 1246 | 1344 | if(!empty($this->CFG['charsets'])){ |
@@ -1249,7 +1347,10 @@ discard block |
||
| 1249 | 1347 | $r = mysql_query("SHOW CHARACTER SET") or sxd_my_error(); |
| 1250 | 1348 | if ($r) { |
| 1251 | 1349 | while($item = mysql_fetch_assoc($r)){ |
| 1252 | - if (empty($def_charsets) || preg_match($def_charsets, $item['Charset'])) $tmp[$item['Charset']] = "{$item['Charset']}"; // ({$item['Description']}) |
|
| 1350 | + if (empty($def_charsets) || preg_match($def_charsets, $item['Charset'])) { |
|
| 1351 | + $tmp[$item['Charset']] = "{$item['Charset']}"; |
|
| 1352 | + } |
|
| 1353 | + // ({$item['Description']}) |
|
| 1253 | 1354 | } |
| 1254 | 1355 | } |
| 1255 | 1356 | } |
@@ -1257,7 +1358,9 @@ discard block |
||
| 1257 | 1358 | } |
| 1258 | 1359 | function getCollationList(){ |
| 1259 | 1360 | $tmp = array(); |
| 1260 | - if (!V_MYSQL) return $tmp; |
|
| 1361 | + if (!V_MYSQL) { |
|
| 1362 | + return $tmp; |
|
| 1363 | + } |
|
| 1261 | 1364 | if(V_MYSQL > 40101) { |
| 1262 | 1365 | $def_charsets = ''; |
| 1263 | 1366 | if(!empty($this->CFG['charsets'])){ |
@@ -1266,7 +1369,9 @@ discard block |
||
| 1266 | 1369 | $r = mysql_query("SHOW COLLATION") or sxd_my_error(); |
| 1267 | 1370 | if ($r) { |
| 1268 | 1371 | while($item = mysql_fetch_assoc($r)){ |
| 1269 | - if (empty($def_charsets) || preg_match($def_charsets, $item['Charset'])) $tmp[$item['Charset']][$item['Collation']] = $item['Default'] == 'Yes' ? 1 : 0; |
|
| 1372 | + if (empty($def_charsets) || preg_match($def_charsets, $item['Charset'])) { |
|
| 1373 | + $tmp[$item['Charset']][$item['Collation']] = $item['Default'] == 'Yes' ? 1 : 0; |
|
| 1374 | + } |
|
| 1270 | 1375 | } |
| 1271 | 1376 | } |
| 1272 | 1377 | } |
@@ -1282,8 +1387,7 @@ discard block |
||
| 1282 | 1387 | while($item = mysql_fetch_assoc($r)){ |
| 1283 | 1388 | if(V_MYSQL > 40101 && is_null($item['Engine']) && preg_match('/^VIEW/i', $item['Comment'])) { |
| 1284 | 1389 | $objects['VI'][]= $item['Name']; |
| 1285 | - } |
|
| 1286 | - else{ |
|
| 1390 | + } else{ |
|
| 1287 | 1391 | $objects['TA'][] = array($item['Name'], $item['Rows'], $item['Data_length']); |
| 1288 | 1392 | } |
| 1289 | 1393 | } |
@@ -1294,7 +1398,9 @@ discard block |
||
| 1294 | 1398 | "FUNCTION STATUS WHERE db='{$db_name}'", |
| 1295 | 1399 | 'TRIGGERS' |
| 1296 | 1400 | ); |
| 1297 | - if(V_MYSQL > 50100) $shows[] = "EVENTS WHERE db='{$db_name}'"; |
|
| 1401 | + if(V_MYSQL > 50100) { |
|
| 1402 | + $shows[] = "EVENTS WHERE db='{$db_name}'"; |
|
| 1403 | + } |
|
| 1298 | 1404 | // TODO: Поправить проверку событий и триггеров |
| 1299 | 1405 | for($i = 0, $l = count($shows); $i < $l; $i++){ |
| 1300 | 1406 | $r = mysql_query('SHOW ' . $shows[$i]); |
@@ -1306,8 +1412,7 @@ discard block |
||
| 1306 | 1412 | } |
| 1307 | 1413 | } |
| 1308 | 1414 | } |
| 1309 | - } |
|
| 1310 | - else { |
|
| 1415 | + } else { |
|
| 1311 | 1416 | $objects['VI'] = array(); |
| 1312 | 1417 | } |
| 1313 | 1418 | } |
@@ -1316,7 +1421,9 @@ discard block |
||
| 1316 | 1421 | function getFileObjects($tree, $name, $formatTree = true){ |
| 1317 | 1422 | // Достаем таблицы |
| 1318 | 1423 | $objects = array('TA' => array(), 'VI' => array(), 'PR' => array(), 'FU' => array(), 'TR' => array(), 'EV' => array()); |
| 1319 | - if(!preg_match('/\.sql(\.(gz|bz2))?$/i', $name, $m)) return ''; |
|
| 1424 | + if(!preg_match('/\.sql(\.(gz|bz2))?$/i', $name, $m)) { |
|
| 1425 | + return ''; |
|
| 1426 | + } |
|
| 1320 | 1427 | $name = $this->CFG['backup_path'] . $name; |
| 1321 | 1428 | if(!is_readable($name)) {return "sxd.tree.{$tree}.error(sxd.lng('err_fopen'))";} |
| 1322 | 1429 | $fp = $this->openFile($name, 'r'); |
@@ -1332,8 +1439,7 @@ discard block |
||
| 1332 | 1439 | for($i = 0, $l = count($objects['TA']); $i < $l; $i++){ |
| 1333 | 1440 | $objects['TA'][$i] = explode('`', $objects['TA'][$i]); |
| 1334 | 1441 | } |
| 1335 | - } |
|
| 1336 | - else { |
|
| 1442 | + } else { |
|
| 1337 | 1443 | $h[9] = ''; |
| 1338 | 1444 | } |
| 1339 | 1445 | return $formatTree ? $this->formatTree($tree, $objects) . "sxd.comment.restore.value = '{$h[9]}';z('restore_savejob').disabled = z('restore_runjob').disabled = false;" : $objects; |
@@ -1355,14 +1461,18 @@ discard block |
||
| 1355 | 1461 | $t = $objects['TA'][$i]; |
| 1356 | 1462 | $tab_prefix = preg_match("/^([a-z0-9]+_)/", $t[0], $m) ? $m[1] : '*'; |
| 1357 | 1463 | if ($tab_prefix != $tab_prefix_last) { |
| 1358 | - if ($tab_prefix != '*') $objects['TA']['*'][] = $tab_prefix; |
|
| 1464 | + if ($tab_prefix != '*') { |
|
| 1465 | + $objects['TA']['*'][] = $tab_prefix; |
|
| 1466 | + } |
|
| 1359 | 1467 | $tab_prefix_last = $tab_prefix; |
| 1360 | 1468 | } |
| 1361 | 1469 | $objects['TA'][$tab_prefix][] = $t; |
| 1362 | 1470 | unset($objects['TA'][$i]); |
| 1363 | 1471 | } |
| 1364 | 1472 | foreach($objects AS $type => $o){ |
| 1365 | - if(!count($o)) continue; |
|
| 1473 | + if(!count($o)) { |
|
| 1474 | + continue; |
|
| 1475 | + } |
|
| 1366 | 1476 | if($type == 'TA') { |
| 1367 | 1477 | $open_childs = count($o['*']) > 1 ? 0 : 1; |
| 1368 | 1478 | $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ",1,1,1],"; |
@@ -1377,8 +1487,7 @@ discard block |
||
| 1377 | 1487 | $obj .= "[{$row},{$pid}," . sxd_esc($o[$value][$i][0]) . ",2,{$checked},{$o[$value][$i][2]}],"; |
| 1378 | 1488 | $row++; |
| 1379 | 1489 | } |
| 1380 | - } |
|
| 1381 | - else { |
|
| 1490 | + } else { |
|
| 1382 | 1491 | $value = $o[$value][0]; |
| 1383 | 1492 | } |
| 1384 | 1493 | } |
@@ -1389,8 +1498,7 @@ discard block |
||
| 1389 | 1498 | $row++; |
| 1390 | 1499 | } |
| 1391 | 1500 | } |
| 1392 | - } |
|
| 1393 | - else { |
|
| 1501 | + } else { |
|
| 1394 | 1502 | $obj .= "[{$row},0," . sxd_esc($info[$type][0]) . ",{$info[$type][1]},1,1],"; |
| 1395 | 1503 | $pid = $row++; |
| 1396 | 1504 | $info[$type][1]++; |
@@ -1402,7 +1510,9 @@ discard block |
||
| 1402 | 1510 | } |
| 1403 | 1511 | } |
| 1404 | 1512 | $add = ''; |
| 1405 | - if($tree == 'restore') $add = "z('autoinc').disabled = z('restore_type').disabled = " . ($obj ? 'false' : 'true') . ";"; |
|
| 1513 | + if($tree == 'restore') { |
|
| 1514 | + $add = "z('autoinc').disabled = z('restore_type').disabled = " . ($obj ? 'false' : 'true') . ";"; |
|
| 1515 | + } |
|
| 1406 | 1516 | return ($obj ? 'sxd.tree.' . $tree . '.drawTree([' . substr_replace($obj, ']', -1) . ");" : "sxd.tree.{$tree}.error(sxd.lng('err_sxd2'));") . $add; |
| 1407 | 1517 | } |
| 1408 | 1518 | function getFileList(){ |
@@ -1431,14 +1541,12 @@ discard block |
||
| 1431 | 1541 | } |
| 1432 | 1542 | if(count($sj['sj_backup']) > 0){ |
| 1433 | 1543 | ksort($sj['sj_backup']); |
| 1434 | - } |
|
| 1435 | - else { |
|
| 1544 | + } else { |
|
| 1436 | 1545 | $sj['sj_backup'] = array(0 => '<b>No Saved Jobs</b><br>' . $this->LNG['no_saved']); |
| 1437 | 1546 | } |
| 1438 | 1547 | if(count($sj['sj_restore']) > 0){ |
| 1439 | 1548 | ksort($sj['sj_restore']); |
| 1440 | - } |
|
| 1441 | - else { |
|
| 1549 | + } else { |
|
| 1442 | 1550 | $sj['sj_restore'] = array(0 => '<b>No Saved Jobs</b><br>' . $this->LNG['no_saved']); |
| 1443 | 1551 | } |
| 1444 | 1552 | return "sxd.clearOpt('sj_backup');sxd.clearOpt('sj_restore');sxd.addOpt(" . sxd_php2json($sj) . ");"; |
@@ -1454,12 +1562,10 @@ discard block |
||
| 1454 | 1562 | if(preg_match('/^(#SXD20\|.+?)\n/s', $temp, $m)){ |
| 1455 | 1563 | $h = explode('|', $m[1]); |
| 1456 | 1564 | $files[] = array($h[5], substr($h[4], 0, -3), $ext, $h[7], number_format($h[8], 0, '', ' '), filesize($this->CFG['backup_path'] . $file), $h[9], $file); |
| 1457 | - } |
|
| 1458 | - elseif(preg_match('/^(#SKD101\|.+?)\n/s', $temp, $m)){ |
|
| 1565 | + } elseif(preg_match('/^(#SKD101\|.+?)\n/s', $temp, $m)){ |
|
| 1459 | 1566 | $h = explode('|', $m[1]); |
| 1460 | 1567 | $files[] = array($h[1], substr($h[3], 0, -3), $ext, $h[2], number_format($h[4], 0, '', ' '), filesize($this->CFG['backup_path'] . $file), 'SXD 1.0.x', $file); |
| 1461 | - } |
|
| 1462 | - else { |
|
| 1568 | + } else { |
|
| 1463 | 1569 | $files[] = array($file, '-', $ext, '-', '-', filesize($this->CFG['backup_path'] . $file), '', $file); |
| 1464 | 1570 | } |
| 1465 | 1571 | } |
@@ -1477,9 +1583,10 @@ discard block |
||
| 1477 | 1583 | } |
| 1478 | 1584 | function openFile($name, $mode){ |
| 1479 | 1585 | if($mode == 'r') { |
| 1480 | - if(preg_match('/\.(sql|sql\.bz2|sql\.gz)$/i', $name, $m)) $this->JOB['file_ext'] = strtolower($m[1]); |
|
| 1481 | - } |
|
| 1482 | - else{ |
|
| 1586 | + if(preg_match('/\.(sql|sql\.bz2|sql\.gz)$/i', $name, $m)) { |
|
| 1587 | + $this->JOB['file_ext'] = strtolower($m[1]); |
|
| 1588 | + } |
|
| 1589 | + } else{ |
|
| 1483 | 1590 | switch($this->JOB['zip']) { |
| 1484 | 1591 | case 0 : $this->JOB['file_ext'] = 'sql'; break; |
| 1485 | 1592 | case 10: $this->JOB['file_ext'] = 'sql.bz2'; break; |
@@ -1506,7 +1613,9 @@ discard block |
||
| 1506 | 1613 | $fs = ftell($f); |
| 1507 | 1614 | $delim_len = strlen($delimiter . $eol); |
| 1508 | 1615 | while($r || $s = fread($f, 61440)){ |
| 1509 | - if(!$r) $l .= $s; |
|
| 1616 | + if(!$r) { |
|
| 1617 | + $l .= $s; |
|
| 1618 | + } |
|
| 1510 | 1619 | $pos = strpos($l, $delimiter . $eol); |
| 1511 | 1620 | if ($pos !== false) { |
| 1512 | 1621 | // Есть окончание запроса |
@@ -1538,16 +1647,24 @@ discard block |
||
| 1538 | 1647 | return isset($obj[$n]) || ($filt && preg_match($filt, $n)); |
| 1539 | 1648 | } |
| 1540 | 1649 | function sxd_php2json($obj){ |
| 1541 | - if(count($obj) == 0) return '[]'; |
|
| 1650 | + if(count($obj) == 0) { |
|
| 1651 | + return '[]'; |
|
| 1652 | + } |
|
| 1542 | 1653 | $is_obj = isset($obj[0]) && isset($obj[count($obj) - 1]) ? false : true; |
| 1543 | 1654 | $str = $is_obj ? '{' : '['; |
| 1544 | 1655 | foreach ($obj AS $key => $value) { |
| 1545 | 1656 | $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
| 1546 | - if (is_array($value)) $str .= sxd_php2json($value); |
|
| 1547 | - elseif (is_null($value)) $str .= 'null'; |
|
| 1548 | - elseif (is_bool($value)) $str .= $value ? 'true' : 'false'; |
|
| 1549 | - elseif (is_numeric($value)) $str .= $value; |
|
| 1550 | - else $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 1657 | + if (is_array($value)) { |
|
| 1658 | + $str .= sxd_php2json($value); |
|
| 1659 | + } elseif (is_null($value)) { |
|
| 1660 | + $str .= 'null'; |
|
| 1661 | + } elseif (is_bool($value)) { |
|
| 1662 | + $str .= $value ? 'true' : 'false'; |
|
| 1663 | + } elseif (is_numeric($value)) { |
|
| 1664 | + $str .= $value; |
|
| 1665 | + } else { |
|
| 1666 | + $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 1667 | + } |
|
| 1551 | 1668 | $str .= ','; |
| 1552 | 1669 | } |
| 1553 | 1670 | return substr_replace($str, $is_obj ? '}' : ']', -1); |
@@ -1557,25 +1674,34 @@ discard block |
||
| 1557 | 1674 | } |
| 1558 | 1675 | function sxd_error_handler($errno, $errmsg, $filename, $linenum, $vars){ |
| 1559 | 1676 | global $SXD; |
| 1560 | - if($SXD->try) return; |
|
| 1561 | - if($errno == 8192) return; |
|
| 1562 | - if(strpos($errmsg, 'timezone settings')) return; |
|
| 1677 | + if($SXD->try) { |
|
| 1678 | + return; |
|
| 1679 | + } |
|
| 1680 | + if($errno == 8192) { |
|
| 1681 | + return; |
|
| 1682 | + } |
|
| 1683 | + if(strpos($errmsg, 'timezone settings')) { |
|
| 1684 | + return; |
|
| 1685 | + } |
|
| 1563 | 1686 | $errortype = array(1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', |
| 1564 | 1687 | 128 => 'Compile Warning', 256 => 'MySQL Error', 512 => 'Warning', 1024 => 'Notice', |
| 1565 | 1688 | 2048 => 'Strict', 8192 => 'Deprecated', 16384 => 'Deprecated'); |
| 1566 | 1689 | $str = sxd_esc("{$errortype[$errno]}: {$errmsg} ({$filename}:{$linenum})", false); |
| 1567 | - if(SXD_DEBUG) error_log("[index.php]\n{$str}\n", 3, "backup/error.log"); |
|
| 1690 | + if(SXD_DEBUG) { |
|
| 1691 | + error_log("[index.php]\n{$str}\n", 3, "backup/error.log"); |
|
| 1692 | + } |
|
| 1568 | 1693 | |
| 1569 | 1694 | if($errno == 8 || $errno == 1024) { |
| 1570 | - if (!$SXD->fh_log && !$SXD->fh_rtl) echo isset($_POST['ajax']) ? "alert('" . ($str) . "');" : $str; |
|
| 1571 | - else { |
|
| 1695 | + if (!$SXD->fh_log && !$SXD->fh_rtl) { |
|
| 1696 | + echo isset($_POST['ajax']) ? "alert('" . ($str) . "');" : $str; |
|
| 1697 | + } else { |
|
| 1572 | 1698 | fwrite($SXD->fh_log, date('Y.m.d H:i:s') . "\t3\t{$str}\n"); |
| 1573 | 1699 | } |
| 1574 | - } |
|
| 1575 | - elseif($errno < 1024) { |
|
| 1700 | + } elseif($errno < 1024) { |
|
| 1576 | 1701 | $SXD->error = true; |
| 1577 | - if (!$SXD->fh_log && !$SXD->fh_rtl) echo isset($_POST['ajax']) ? "alert('" . ($str) . "');" : $str; |
|
| 1578 | - else { |
|
| 1702 | + if (!$SXD->fh_log && !$SXD->fh_rtl) { |
|
| 1703 | + echo isset($_POST['ajax']) ? "alert('" . ($str) . "');" : $str; |
|
| 1704 | + } else { |
|
| 1579 | 1705 | $SXD->rtl[1] = time(); |
| 1580 | 1706 | $SXD->rtl[9] = 5; |
| 1581 | 1707 | fseek($SXD->fh_rtl, 0); |
@@ -1600,8 +1726,9 @@ discard block |
||
| 1600 | 1726 | if(!empty($SXD->JOB['file_stp']) && file_exists(dirname(__FILE__) . '/' . $SXD->JOB['file_stp'])){ |
| 1601 | 1727 | $type = file_get_contents(dirname(__FILE__) . '/' . $SXD->JOB['file_stp']); |
| 1602 | 1728 | $SXD->rtl[9] = !empty($type) ? $type : 2; |
| 1729 | + } else { |
|
| 1730 | + $SXD->rtl[9] = 5; |
|
| 1603 | 1731 | } |
| 1604 | - else $SXD->rtl[9] = 5; |
|
| 1605 | 1732 | fseek($SXD->fh_rtl, 0); |
| 1606 | 1733 | fwrite($SXD->fh_rtl, implode("\t", $SXD->rtl)); |
| 1607 | 1734 | } |
@@ -20,15 +20,21 @@ discard block |
||
| 20 | 20 | $job_name = $_POST['ajax']['job']; |
| 21 | 21 | $log_seek = !empty($_POST['ajax']['lseek']) ? (int) $_POST['ajax']['lseek'] : 0; |
| 22 | 22 | $job_file = "{$CFG['backup_path']}{$job_name}.job.php"; |
| 23 | - if (!file_exists($job_file)) exit; |
|
| 23 | + if (!file_exists($job_file)) { |
|
| 24 | + exit; |
|
| 25 | + } |
|
| 24 | 26 | include($job_file); |
| 25 | 27 | switch($_POST['ajax']['act']) { |
| 26 | 28 | case 'info': |
| 27 | - if (!file_exists($JOB['file_rtl'])) exit; |
|
| 29 | + if (!file_exists($JOB['file_rtl'])) { |
|
| 30 | + exit; |
|
| 31 | + } |
|
| 28 | 32 | $fh = fopen($JOB['file_rtl'], 'r+b'); |
| 29 | 33 | $time = time(); |
| 30 | 34 | $f = explode("\t", fgets($fh)); |
| 31 | - if(empty($f[0])) $f[0] = $time; |
|
| 35 | + if(empty($f[0])) { |
|
| 36 | + $f[0] = $time; |
|
| 37 | + } |
|
| 32 | 38 | $pt = !empty($f[2]) ? round(100 * $f[10] / $f[2], 2) : 100; |
| 33 | 39 | $pc = !empty($f[8]) ? round(100 * $f[7] / $f[8], 2) : 100; |
| 34 | 40 | $lh = fopen($JOB['file_log'], 'rb'); |
@@ -40,17 +46,25 @@ discard block |
||
| 40 | 46 | if(!empty($rawlog)){ |
| 41 | 47 | $temp = explode("\n", $rawlog); |
| 42 | 48 | foreach($temp AS $l){ |
| 43 | - if(empty($l)) continue; |
|
| 49 | + if(empty($l)) { |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 44 | 52 | $t = explode("\t", $l); |
| 45 | - if(count($t) < 3) continue; |
|
| 53 | + if(count($t) < 3) { |
|
| 54 | + continue; |
|
| 55 | + } |
|
| 46 | 56 | if($t[0] != $old_time){ |
| 47 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 57 | + if(!empty($logs)) { |
|
| 58 | + $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 59 | + } |
|
| 48 | 60 | $old_time = $t[0]; |
| 49 | 61 | $logs = array(); |
| 50 | 62 | } |
| 51 | 63 | $logs[] = esc($t[2]); |
| 52 | 64 | } |
| 53 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 65 | + if(!empty($logs)) { |
|
| 66 | + $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 67 | + } |
|
| 54 | 68 | } |
| 55 | 69 | $log_seek = ftell($lh); |
| 56 | 70 | echo $log . "sxd.job.log_seek = {$log_seek};"; |
@@ -59,22 +73,29 @@ discard block |
||
| 59 | 73 | $pt = $pc = 100; |
| 60 | 74 | fclose($lh); |
| 61 | 75 | fclose($fh); |
| 62 | - if (function_exists('usleep')) usleep(400000); |
|
| 63 | - else sleep(1); |
|
| 64 | - if($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 76 | + if (function_exists('usleep')) { |
|
| 77 | + usleep(400000); |
|
| 78 | + } else { |
|
| 79 | + sleep(1); |
|
| 80 | + } |
|
| 81 | + if($JOB['act'] == 'backup') { |
|
| 82 | + $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 83 | + } |
|
| 65 | 84 | // Обновляем список файлов |
| 66 | - if($JOB['act'] == 'backup') print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 85 | + if($JOB['act'] == 'backup') { |
|
| 86 | + print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 87 | + } |
|
| 67 | 88 | echo "sxd.timer.set({$f[0]},{$f[1]},{$pt});sxd.progress.current.set({$pc}, 0, {$f[8]}, {$f[8]});sxd.progress.total.set({$pt},{$f[3]});"; |
| 68 | 89 | echo "sxd.log.add({$d},['{$LNG['job_done']}', '{$LNG['js']['records']}: {$f[10]}', '{$LNG['file_size']}: ' + sxd.formatSize({$f[3]},2), '{$LNG['job_time']}: {$f[5]} {$LNG['seconds']}']);sxd.hideLoading();"; |
| 69 | 90 | unlink($JOB['file_log']); |
| 70 | 91 | unlink($JOB['file_rtl']); |
| 71 | 92 | unlink($job_file); |
| 72 | - } |
|
| 73 | - else if($f[9] > 0){ |
|
| 93 | + } else if($f[9] > 0){ |
|
| 74 | 94 | echo "sxd.log.add({$d},[" . esc($LNG['stop_' . $f[9]]) . "]);" . (($f[9] == 3 || $f[9] == 4) ? 'sxd.resumeJob();' : 'sxd.hideLoading();'); |
| 75 | - } |
|
| 76 | - else{ |
|
| 77 | - if($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 95 | + } else{ |
|
| 96 | + if($JOB['act'] == 'backup') { |
|
| 97 | + $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 98 | + } |
|
| 78 | 99 | if($f[4] != 'EK' && time() > $f[1] + 45) { |
| 79 | 100 | fopen($JOB['file_stp'],'w'); |
| 80 | 101 | $f[9] = 0; |
@@ -95,8 +116,9 @@ discard block |
||
| 95 | 116 | echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
| 96 | 117 | break; |
| 97 | 118 | } |
| 119 | +} else { |
|
| 120 | + echo "sxd.hideLoading();"; |
|
| 98 | 121 | } |
| 99 | -else echo "sxd.hideLoading();"; |
|
| 100 | 122 | |
| 101 | 123 | function load_lang($lng_name = 'auto'){ |
| 102 | 124 | if($lng_name == 'auto'){ |
@@ -111,26 +133,34 @@ discard block |
||
| 111 | 133 | } |
| 112 | 134 | } |
| 113 | 135 | } |
| 114 | - if(file_exists("lang/lng_{$lng_name}.php")) return "lang/lng_{$lng_name}.php"; |
|
| 115 | - else return "lang/lng_en.php"; |
|
| 116 | -} |
|
| 136 | + if(file_exists("lang/lng_{$lng_name}.php")) { |
|
| 137 | + return "lang/lng_{$lng_name}.php"; |
|
| 138 | + } else { |
|
| 139 | + return "lang/lng_en.php"; |
|
| 140 | + } |
|
| 141 | + } |
|
| 117 | 142 | function esc($str){ |
| 118 | 143 | return "'" . addcslashes($str, "\\\0\n\r\t\'") . "'"; |
| 119 | 144 | } |
| 120 | 145 | |
| 121 | 146 | function sxd_error($errno, $errmsg, $filename, $linenum, $vars){ |
| 122 | 147 | global $JOB; |
| 123 | - if($errno == 8192) return; |
|
| 124 | - if(strpos($errmsg, 'timezone settings')) return; |
|
| 125 | - if(!empty($JOB['file_stp'])) fopen($JOB['file_stp'],'w'); |
|
| 148 | + if($errno == 8192) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 151 | + if(strpos($errmsg, 'timezone settings')) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 154 | + if(!empty($JOB['file_stp'])) { |
|
| 155 | + fopen($JOB['file_stp'],'w'); |
|
| 156 | + } |
|
| 126 | 157 | $errortype = array(1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', |
| 127 | 158 | 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024 => 'User Notice'); |
| 128 | 159 | $str = "{$errortype[$errno]}: {$errmsg} ({$filename}:{$linenum})"; |
| 129 | 160 | //error_log("[info.php]\n{$str}\n", 3, "error.log"); |
| 130 | 161 | if($errno == 8 || $errno == 1024) { |
| 131 | 162 | echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
| 132 | - } |
|
| 133 | - elseif($errno < 1024) { |
|
| 163 | + } elseif($errno < 1024) { |
|
| 134 | 164 | echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
| 135 | 165 | die; |
| 136 | 166 | } |
@@ -27,16 +27,24 @@ |
||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | function sxd_php2json($obj){ |
| 30 | - if(count($obj) == 0) return '[]'; |
|
| 30 | + if(count($obj) == 0) { |
|
| 31 | + return '[]'; |
|
| 32 | + } |
|
| 31 | 33 | $is_obj = isset($obj[count($obj) - 1]) ? false : true; |
| 32 | 34 | $str = $is_obj ? '{' : '['; |
| 33 | 35 | foreach ($obj AS $key => $value) { |
| 34 | 36 | $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
| 35 | - if (is_array($value)) $str .= sxd_php2json($value); |
|
| 36 | - elseif (is_null($value)) $str .= 'null'; |
|
| 37 | - elseif (is_bool($value)) $str .= $value ? 'true' : 'false'; |
|
| 38 | - elseif (is_numeric($value)) $str .= $value; |
|
| 39 | - else $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 37 | + if (is_array($value)) { |
|
| 38 | + $str .= sxd_php2json($value); |
|
| 39 | + } elseif (is_null($value)) { |
|
| 40 | + $str .= 'null'; |
|
| 41 | + } elseif (is_bool($value)) { |
|
| 42 | + $str .= $value ? 'true' : 'false'; |
|
| 43 | + } elseif (is_numeric($value)) { |
|
| 44 | + $str .= $value; |
|
| 45 | + } else { |
|
| 46 | + $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 47 | + } |
|
| 40 | 48 | $str .= ','; |
| 41 | 49 | } |
| 42 | 50 | return substr_replace($str, $is_obj ? '}' : ']', -1); |
@@ -22,12 +22,10 @@ discard block |
||
| 22 | 22 | if($delete = sys_get_param_id('delete')) |
| 23 | 23 | { |
| 24 | 24 | doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;"); |
| 25 | -} |
|
| 26 | -elseif(sys_get_param_str('delete_update_info')) |
|
| 25 | +} elseif(sys_get_param_str('delete_update_info')) |
|
| 27 | 26 | { |
| 28 | 27 | doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);"); |
| 29 | -} |
|
| 30 | -elseif(sys_get_param_str('deleteall') == 'yes') |
|
| 28 | +} elseif(sys_get_param_str('deleteall') == 'yes') |
|
| 31 | 29 | { |
| 32 | 30 | // doquery("TRUNCATE TABLE `{{logs}}`"); |
| 33 | 31 | } |
@@ -51,8 +49,7 @@ discard block |
||
| 51 | 49 | } |
| 52 | 50 | } |
| 53 | 51 | $template->assign_vars($errorInfo); |
| 54 | -} |
|
| 55 | -else |
|
| 52 | +} else |
|
| 56 | 53 | { |
| 57 | 54 | $template = gettemplate('admin/adm_log_main', true); |
| 58 | 55 | |
@@ -72,8 +72,7 @@ |
||
| 72 | 72 | if(sys_get_param('page_prev') && $int_page_current > 1) |
| 73 | 73 | { |
| 74 | 74 | $int_page_current--; |
| 75 | -} |
|
| 76 | -elseif(sys_get_param('page_next') && $int_page_current < $page_max) |
|
| 75 | +} elseif(sys_get_param('page_next') && $int_page_current < $page_max) |
|
| 77 | 76 | { |
| 78 | 77 | $int_page_current++; |
| 79 | 78 | } |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | $unit_amount = round($unit_amount); |
| 51 | 51 | $unit_name = get_unit_param($unit_id, P_NAME); |
| 52 | 52 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
| 53 | - } |
|
| 54 | - else |
|
| 53 | + } else |
|
| 55 | 54 | { |
| 56 | 55 | $result = ''; |
| 57 | 56 | } |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | 'TEXT' => $error, |
| 76 | 76 | )); |
| 77 | 77 | } |
| 78 | - } |
|
| 79 | - else |
|
| 78 | + } else |
|
| 80 | 79 | { |
| 81 | 80 | $template->assign_var('CHECK', 1); |
| 82 | 81 | |