@@ -4,134 +4,134 @@ |
||
| 4 | 4 | error_reporting(0); |
| 5 | 5 | set_error_handler("sxd_error"); |
| 6 | 6 | if(!empty($_POST['ajax']['job']) && preg_match("/^[\w-]+$/", $_POST['ajax']['job'])){ |
| 7 | - $d = date("'Y.m.d H:i:s'"); |
|
| 8 | - if(!empty($_COOKIE['sxd'])) { |
|
| 9 | - include('ses.php'); |
|
| 10 | - if(!empty($SES[$_COOKIE['sxd']])) { |
|
| 11 | - $CFG = &$SES[$_COOKIE['sxd']]['cfg']; |
|
| 12 | - include(load_lang($SES[$_COOKIE['sxd']]['lng'])); |
|
| 13 | - } |
|
| 14 | - } |
|
| 15 | - if(empty($LNG)) { |
|
| 16 | - include('cfg.php'); |
|
| 17 | - include(load_lang($CFG['lang'])); |
|
| 18 | - if(!empty($CFG['auth'])) {echo "sxd.log.add({$d},[" . esc($LNG['stop_5']) . " (1)]);sxd.hideLoading();"; exit;} |
|
| 19 | - } |
|
| 20 | - $job_name = $_POST['ajax']['job']; |
|
| 21 | - $log_seek = !empty($_POST['ajax']['lseek']) ? (int) $_POST['ajax']['lseek'] : 0; |
|
| 22 | - $job_file = "{$CFG['backup_path']}{$job_name}.job.php"; |
|
| 23 | - if (!file_exists($job_file)) exit; |
|
| 24 | - include($job_file); |
|
| 25 | - switch($_POST['ajax']['act']) { |
|
| 26 | - case 'info': |
|
| 27 | - if (!file_exists($JOB['file_rtl'])) exit; |
|
| 28 | - $fh = fopen($JOB['file_rtl'], 'r+b'); |
|
| 29 | - $time = time(); |
|
| 30 | - $f = explode("\t", fgets($fh)); |
|
| 31 | - if(empty($f[0])) $f[0] = $time; |
|
| 32 | - $pt = !empty($f[2]) ? round(100 * $f[10] / $f[2], 2) : 100; |
|
| 33 | - $pc = !empty($f[8]) ? round(100 * $f[7] / $f[8], 2) : 100; |
|
| 34 | - $lh = fopen($JOB['file_log'], 'rb'); |
|
| 35 | - fseek($lh, $log_seek); |
|
| 36 | - $rawlog = fread($lh, 8192); |
|
| 37 | - $log = ''; |
|
| 38 | - $old_time = ''; |
|
| 39 | - $logs = array(); |
|
| 40 | - if(!empty($rawlog)){ |
|
| 41 | - $temp = explode("\n", $rawlog); |
|
| 42 | - foreach($temp AS $l){ |
|
| 43 | - if(empty($l)) continue; |
|
| 44 | - $t = explode("\t", $l); |
|
| 45 | - if(count($t) < 3) continue; |
|
| 46 | - if($t[0] != $old_time){ |
|
| 47 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 48 | - $old_time = $t[0]; |
|
| 49 | - $logs = array(); |
|
| 50 | - } |
|
| 51 | - $logs[] = esc($t[2]); |
|
| 52 | - } |
|
| 53 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 54 | - } |
|
| 55 | - $log_seek = ftell($lh); |
|
| 56 | - echo $log . "sxd.job.log_seek = {$log_seek};"; |
|
| 57 | - // Читаем лог |
|
| 58 | - if($f[4] == 'EOJ') { |
|
| 59 | - $pt = $pc = 100; |
|
| 60 | - fclose($lh); |
|
| 61 | - 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']); |
|
| 65 | - // Обновляем список файлов |
|
| 66 | - if($JOB['act'] == 'backup') print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 67 | - 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 | - 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 | - unlink($JOB['file_log']); |
|
| 70 | - unlink($JOB['file_rtl']); |
|
| 71 | - unlink($job_file); |
|
| 72 | - } |
|
| 73 | - else if($f[9] > 0){ |
|
| 74 | - 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']); |
|
| 78 | - if($f[4] != 'EK' && time() > $f[1] + 45) { |
|
| 79 | - fopen($JOB['file_stp'],'w'); |
|
| 80 | - $f[9] = 0; |
|
| 81 | - $f[1] = $time; |
|
| 82 | - fwrite($fh, implode("\t", $f) . "\n"); |
|
| 83 | - echo "sxd.log.add({$d},[" . esc($LNG['job_freeze']) . "]);sxd.hideLoading();z('btn_resume').style.display = '';z('btn_pause').style.display = 'none';"; |
|
| 84 | - } |
|
| 85 | - echo "sxd.timer.set({$f[0]},{$time},{$pt});sxd.progress.current.set({$pc},0,{$f[7]}, {$f[8]});sxd.progress.total.set({$pt},{$f[3]});"; |
|
| 86 | - } |
|
| 87 | - break; |
|
| 88 | - case 'stop': |
|
| 89 | - $fs = fopen($JOB['file_stp'],'w'); |
|
| 90 | - fwrite($fs, 1); |
|
| 91 | - echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
|
| 92 | - break; |
|
| 93 | - case 'pause': |
|
| 94 | - fopen($JOB['file_stp'],'w'); |
|
| 95 | - echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
|
| 96 | - break; |
|
| 97 | - } |
|
| 7 | + $d = date("'Y.m.d H:i:s'"); |
|
| 8 | + if(!empty($_COOKIE['sxd'])) { |
|
| 9 | + include('ses.php'); |
|
| 10 | + if(!empty($SES[$_COOKIE['sxd']])) { |
|
| 11 | + $CFG = &$SES[$_COOKIE['sxd']]['cfg']; |
|
| 12 | + include(load_lang($SES[$_COOKIE['sxd']]['lng'])); |
|
| 13 | + } |
|
| 14 | + } |
|
| 15 | + if(empty($LNG)) { |
|
| 16 | + include('cfg.php'); |
|
| 17 | + include(load_lang($CFG['lang'])); |
|
| 18 | + if(!empty($CFG['auth'])) {echo "sxd.log.add({$d},[" . esc($LNG['stop_5']) . " (1)]);sxd.hideLoading();"; exit;} |
|
| 19 | + } |
|
| 20 | + $job_name = $_POST['ajax']['job']; |
|
| 21 | + $log_seek = !empty($_POST['ajax']['lseek']) ? (int) $_POST['ajax']['lseek'] : 0; |
|
| 22 | + $job_file = "{$CFG['backup_path']}{$job_name}.job.php"; |
|
| 23 | + if (!file_exists($job_file)) exit; |
|
| 24 | + include($job_file); |
|
| 25 | + switch($_POST['ajax']['act']) { |
|
| 26 | + case 'info': |
|
| 27 | + if (!file_exists($JOB['file_rtl'])) exit; |
|
| 28 | + $fh = fopen($JOB['file_rtl'], 'r+b'); |
|
| 29 | + $time = time(); |
|
| 30 | + $f = explode("\t", fgets($fh)); |
|
| 31 | + if(empty($f[0])) $f[0] = $time; |
|
| 32 | + $pt = !empty($f[2]) ? round(100 * $f[10] / $f[2], 2) : 100; |
|
| 33 | + $pc = !empty($f[8]) ? round(100 * $f[7] / $f[8], 2) : 100; |
|
| 34 | + $lh = fopen($JOB['file_log'], 'rb'); |
|
| 35 | + fseek($lh, $log_seek); |
|
| 36 | + $rawlog = fread($lh, 8192); |
|
| 37 | + $log = ''; |
|
| 38 | + $old_time = ''; |
|
| 39 | + $logs = array(); |
|
| 40 | + if(!empty($rawlog)){ |
|
| 41 | + $temp = explode("\n", $rawlog); |
|
| 42 | + foreach($temp AS $l){ |
|
| 43 | + if(empty($l)) continue; |
|
| 44 | + $t = explode("\t", $l); |
|
| 45 | + if(count($t) < 3) continue; |
|
| 46 | + if($t[0] != $old_time){ |
|
| 47 | + if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 48 | + $old_time = $t[0]; |
|
| 49 | + $logs = array(); |
|
| 50 | + } |
|
| 51 | + $logs[] = esc($t[2]); |
|
| 52 | + } |
|
| 53 | + if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 54 | + } |
|
| 55 | + $log_seek = ftell($lh); |
|
| 56 | + echo $log . "sxd.job.log_seek = {$log_seek};"; |
|
| 57 | + // Читаем лог |
|
| 58 | + if($f[4] == 'EOJ') { |
|
| 59 | + $pt = $pc = 100; |
|
| 60 | + fclose($lh); |
|
| 61 | + 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']); |
|
| 65 | + // Обновляем список файлов |
|
| 66 | + if($JOB['act'] == 'backup') print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 67 | + 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 | + 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 | + unlink($JOB['file_log']); |
|
| 70 | + unlink($JOB['file_rtl']); |
|
| 71 | + unlink($job_file); |
|
| 72 | + } |
|
| 73 | + else if($f[9] > 0){ |
|
| 74 | + 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']); |
|
| 78 | + if($f[4] != 'EK' && time() > $f[1] + 45) { |
|
| 79 | + fopen($JOB['file_stp'],'w'); |
|
| 80 | + $f[9] = 0; |
|
| 81 | + $f[1] = $time; |
|
| 82 | + fwrite($fh, implode("\t", $f) . "\n"); |
|
| 83 | + echo "sxd.log.add({$d},[" . esc($LNG['job_freeze']) . "]);sxd.hideLoading();z('btn_resume').style.display = '';z('btn_pause').style.display = 'none';"; |
|
| 84 | + } |
|
| 85 | + echo "sxd.timer.set({$f[0]},{$time},{$pt});sxd.progress.current.set({$pc},0,{$f[7]}, {$f[8]});sxd.progress.total.set({$pt},{$f[3]});"; |
|
| 86 | + } |
|
| 87 | + break; |
|
| 88 | + case 'stop': |
|
| 89 | + $fs = fopen($JOB['file_stp'],'w'); |
|
| 90 | + fwrite($fs, 1); |
|
| 91 | + echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
|
| 92 | + break; |
|
| 93 | + case 'pause': |
|
| 94 | + fopen($JOB['file_stp'],'w'); |
|
| 95 | + echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
|
| 96 | + break; |
|
| 97 | + } |
|
| 98 | 98 | } |
| 99 | 99 | else echo "sxd.hideLoading();"; |
| 100 | 100 | |
| 101 | 101 | function load_lang($lng_name = 'auto'){ |
| 102 | - if($lng_name == 'auto'){ |
|
| 103 | - include('lang/list.php'); |
|
| 104 | - $lng = 'en'; |
|
| 105 | - if(preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { |
|
| 106 | - foreach($m[0] AS $l){ |
|
| 107 | - if(isset($langs[$l])){ |
|
| 108 | - $lng_name = $l; |
|
| 109 | - break; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - if(file_exists("lang/lng_{$lng_name}.php")) return "lang/lng_{$lng_name}.php"; |
|
| 115 | - else return "lang/lng_en.php"; |
|
| 102 | + if($lng_name == 'auto'){ |
|
| 103 | + include('lang/list.php'); |
|
| 104 | + $lng = 'en'; |
|
| 105 | + if(preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { |
|
| 106 | + foreach($m[0] AS $l){ |
|
| 107 | + if(isset($langs[$l])){ |
|
| 108 | + $lng_name = $l; |
|
| 109 | + break; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + if(file_exists("lang/lng_{$lng_name}.php")) return "lang/lng_{$lng_name}.php"; |
|
| 115 | + else return "lang/lng_en.php"; |
|
| 116 | 116 | } |
| 117 | 117 | function esc($str){ |
| 118 | - return "'" . addcslashes($str, "\\\0\n\r\t\'") . "'"; |
|
| 118 | + return "'" . addcslashes($str, "\\\0\n\r\t\'") . "'"; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function sxd_error($errno, $errmsg, $filename, $linenum, $vars){ |
| 122 | - 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'); |
|
| 126 | - $errortype = array(1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', |
|
| 127 | - 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024 => 'User Notice'); |
|
| 128 | - $str = "{$errortype[$errno]}: {$errmsg} ({$filename}:{$linenum})"; |
|
| 129 | - //error_log("[info.php]\n{$str}\n", 3, "error.log"); |
|
| 122 | + 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'); |
|
| 126 | + $errortype = array(1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', |
|
| 127 | + 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024 => 'User Notice'); |
|
| 128 | + $str = "{$errortype[$errno]}: {$errmsg} ({$filename}:{$linenum})"; |
|
| 129 | + //error_log("[info.php]\n{$str}\n", 3, "error.log"); |
|
| 130 | 130 | if($errno == 8 || $errno == 1024) { |
| 131 | - echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
|
| 132 | - } |
|
| 131 | + echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
|
| 132 | + } |
|
| 133 | 133 | elseif($errno < 1024) { |
| 134 | - echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
|
| 135 | - die; |
|
| 136 | - } |
|
| 134 | + echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
|
| 135 | + die; |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | \ No newline at end of file |
@@ -3,32 +3,32 @@ discard block |
||
| 3 | 3 | header("Content-Type: text/html; charset=utf-8"); |
| 4 | 4 | error_reporting(0); |
| 5 | 5 | set_error_handler("sxd_error"); |
| 6 | -if(!empty($_POST['ajax']['job']) && preg_match("/^[\w-]+$/", $_POST['ajax']['job'])){ |
|
| 6 | +if (!empty($_POST['ajax']['job']) && preg_match("/^[\w-]+$/", $_POST['ajax']['job'])) { |
|
| 7 | 7 | $d = date("'Y.m.d H:i:s'"); |
| 8 | - if(!empty($_COOKIE['sxd'])) { |
|
| 8 | + if (!empty($_COOKIE['sxd'])) { |
|
| 9 | 9 | include('ses.php'); |
| 10 | - if(!empty($SES[$_COOKIE['sxd']])) { |
|
| 10 | + if (!empty($SES[$_COOKIE['sxd']])) { |
|
| 11 | 11 | $CFG = &$SES[$_COOKIE['sxd']]['cfg']; |
| 12 | 12 | include(load_lang($SES[$_COOKIE['sxd']]['lng'])); |
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | - if(empty($LNG)) { |
|
| 15 | + if (empty($LNG)) { |
|
| 16 | 16 | include('cfg.php'); |
| 17 | 17 | include(load_lang($CFG['lang'])); |
| 18 | - if(!empty($CFG['auth'])) {echo "sxd.log.add({$d},[" . esc($LNG['stop_5']) . " (1)]);sxd.hideLoading();"; exit;} |
|
| 18 | + if (!empty($CFG['auth'])) {echo "sxd.log.add({$d},[" . esc($LNG['stop_5']) . " (1)]);sxd.hideLoading();"; exit; } |
|
| 19 | 19 | } |
| 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 | 23 | if (!file_exists($job_file)) exit; |
| 24 | 24 | include($job_file); |
| 25 | - switch($_POST['ajax']['act']) { |
|
| 25 | + switch ($_POST['ajax']['act']) { |
|
| 26 | 26 | case 'info': |
| 27 | 27 | if (!file_exists($JOB['file_rtl'])) exit; |
| 28 | 28 | $fh = fopen($JOB['file_rtl'], 'r+b'); |
| 29 | 29 | $time = time(); |
| 30 | 30 | $f = explode("\t", fgets($fh)); |
| 31 | - if(empty($f[0])) $f[0] = $time; |
|
| 31 | + if (empty($f[0])) $f[0] = $time; |
|
| 32 | 32 | $pt = !empty($f[2]) ? round(100 * $f[10] / $f[2], 2) : 100; |
| 33 | 33 | $pc = !empty($f[8]) ? round(100 * $f[7] / $f[8], 2) : 100; |
| 34 | 34 | $lh = fopen($JOB['file_log'], 'rb'); |
@@ -37,46 +37,46 @@ discard block |
||
| 37 | 37 | $log = ''; |
| 38 | 38 | $old_time = ''; |
| 39 | 39 | $logs = array(); |
| 40 | - if(!empty($rawlog)){ |
|
| 40 | + if (!empty($rawlog)) { |
|
| 41 | 41 | $temp = explode("\n", $rawlog); |
| 42 | - foreach($temp AS $l){ |
|
| 43 | - if(empty($l)) continue; |
|
| 42 | + foreach ($temp AS $l) { |
|
| 43 | + if (empty($l)) continue; |
|
| 44 | 44 | $t = explode("\t", $l); |
| 45 | - if(count($t) < 3) continue; |
|
| 46 | - if($t[0] != $old_time){ |
|
| 47 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 45 | + if (count($t) < 3) continue; |
|
| 46 | + if ($t[0] != $old_time) { |
|
| 47 | + if (!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 48 | 48 | $old_time = $t[0]; |
| 49 | 49 | $logs = array(); |
| 50 | 50 | } |
| 51 | 51 | $logs[] = esc($t[2]); |
| 52 | 52 | } |
| 53 | - if(!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 53 | + if (!empty($logs)) $log .= "sxd.log.add('{$old_time}',[" . implode(',', $logs) . "]);"; |
|
| 54 | 54 | } |
| 55 | 55 | $log_seek = ftell($lh); |
| 56 | 56 | echo $log . "sxd.job.log_seek = {$log_seek};"; |
| 57 | 57 | // Читаем лог |
| 58 | - if($f[4] == 'EOJ') { |
|
| 58 | + if ($f[4] == 'EOJ') { |
|
| 59 | 59 | $pt = $pc = 100; |
| 60 | 60 | fclose($lh); |
| 61 | 61 | fclose($fh); |
| 62 | 62 | if (function_exists('usleep')) usleep(400000); |
| 63 | 63 | else sleep(1); |
| 64 | - if($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 64 | + if ($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 65 | 65 | // Обновляем список файлов |
| 66 | - if($JOB['act'] == 'backup') print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 66 | + if ($JOB['act'] == 'backup') print "sxd.actions.filelist(); z('btn_down').file = '{$JOB['file']}'; z('btn_down').style.display = '';"; |
|
| 67 | 67 | 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 | 68 | 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 | 69 | unlink($JOB['file_log']); |
| 70 | 70 | unlink($JOB['file_rtl']); |
| 71 | 71 | unlink($job_file); |
| 72 | 72 | } |
| 73 | - else if($f[9] > 0){ |
|
| 73 | + else if ($f[9] > 0) { |
|
| 74 | 74 | echo "sxd.log.add({$d},[" . esc($LNG['stop_' . $f[9]]) . "]);" . (($f[9] == 3 || $f[9] == 4) ? 'sxd.resumeJob();' : 'sxd.hideLoading();'); |
| 75 | 75 | } |
| 76 | - else{ |
|
| 77 | - if($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 78 | - if($f[4] != 'EK' && time() > $f[1] + 45) { |
|
| 79 | - fopen($JOB['file_stp'],'w'); |
|
| 76 | + else { |
|
| 77 | + if ($JOB['act'] == 'backup') $f[3] = filesize(file_exists($JOB['file_name']) ? $JOB['file_name'] : $JOB['file_tmp']); |
|
| 78 | + if ($f[4] != 'EK' && time() > $f[1] + 45) { |
|
| 79 | + fopen($JOB['file_stp'], 'w'); |
|
| 80 | 80 | $f[9] = 0; |
| 81 | 81 | $f[1] = $time; |
| 82 | 82 | fwrite($fh, implode("\t", $f) . "\n"); |
@@ -86,51 +86,51 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | break; |
| 88 | 88 | case 'stop': |
| 89 | - $fs = fopen($JOB['file_stp'],'w'); |
|
| 89 | + $fs = fopen($JOB['file_stp'], 'w'); |
|
| 90 | 90 | fwrite($fs, 1); |
| 91 | 91 | echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
| 92 | 92 | break; |
| 93 | 93 | case 'pause': |
| 94 | - fopen($JOB['file_stp'],'w'); |
|
| 94 | + fopen($JOB['file_stp'], 'w'); |
|
| 95 | 95 | echo "sxd.log.add({$d},[" . esc($LNG['stop_job']) . "]);"; |
| 96 | 96 | break; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | else echo "sxd.hideLoading();"; |
| 100 | 100 | |
| 101 | -function load_lang($lng_name = 'auto'){ |
|
| 102 | - if($lng_name == 'auto'){ |
|
| 101 | +function load_lang($lng_name = 'auto') { |
|
| 102 | + if ($lng_name == 'auto') { |
|
| 103 | 103 | include('lang/list.php'); |
| 104 | 104 | $lng = 'en'; |
| 105 | - if(preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { |
|
| 106 | - foreach($m[0] AS $l){ |
|
| 107 | - if(isset($langs[$l])){ |
|
| 105 | + if (preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { |
|
| 106 | + foreach ($m[0] AS $l) { |
|
| 107 | + if (isset($langs[$l])) { |
|
| 108 | 108 | $lng_name = $l; |
| 109 | 109 | break; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if(file_exists("lang/lng_{$lng_name}.php")) return "lang/lng_{$lng_name}.php"; |
|
| 114 | + if (file_exists("lang/lng_{$lng_name}.php")) return "lang/lng_{$lng_name}.php"; |
|
| 115 | 115 | else return "lang/lng_en.php"; |
| 116 | 116 | } |
| 117 | -function esc($str){ |
|
| 117 | +function esc($str) { |
|
| 118 | 118 | return "'" . addcslashes($str, "\\\0\n\r\t\'") . "'"; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -function sxd_error($errno, $errmsg, $filename, $linenum, $vars){ |
|
| 121 | +function sxd_error($errno, $errmsg, $filename, $linenum, $vars) { |
|
| 122 | 122 | 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'); |
|
| 123 | + if ($errno == 8192) return; |
|
| 124 | + if (strpos($errmsg, 'timezone settings')) return; |
|
| 125 | + if (!empty($JOB['file_stp'])) fopen($JOB['file_stp'], 'w'); |
|
| 126 | 126 | $errortype = array(1 => 'Error', 2 => 'Warning', 4 => 'Parsing Error', 8 => 'Notice', 16 => 'Core Error', 32 => 'Core Warning', 64 => 'Compile Error', |
| 127 | 127 | 128 => 'Compile Warning', 256 => 'User Error', 512 => 'User Warning', 1024 => 'User Notice'); |
| 128 | 128 | $str = "{$errortype[$errno]}: {$errmsg} ({$filename}:{$linenum})"; |
| 129 | 129 | //error_log("[info.php]\n{$str}\n", 3, "error.log"); |
| 130 | - if($errno == 8 || $errno == 1024) { |
|
| 130 | + if ($errno == 8 || $errno == 1024) { |
|
| 131 | 131 | echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
| 132 | 132 | } |
| 133 | - elseif($errno < 1024) { |
|
| 133 | + elseif ($errno < 1024) { |
|
| 134 | 134 | echo "sxd.log.add('" . date("Y.m.d H:i:s") . "',[" . esc($str) . "], 4);sxd.hideLoading();"; |
| 135 | 135 | die; |
| 136 | 136 | } |
@@ -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,10 +116,11 @@ 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 | -function load_lang($lng_name = 'auto'){ |
|
| 123 | +function load_lang($lng_name = 'auto') { |
|
| 102 | 124 | if($lng_name == 'auto'){ |
| 103 | 125 | include('lang/list.php'); |
| 104 | 126 | $lng = 'en'; |
@@ -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 | -} |
|
| 117 | -function esc($str){ |
|
| 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 | + } |
|
| 142 | +function esc($str) { |
|
| 118 | 143 | return "'" . addcslashes($str, "\\\0\n\r\t\'") . "'"; |
| 119 | 144 | } |
| 120 | 145 | |
| 121 | -function sxd_error($errno, $errmsg, $filename, $linenum, $vars){ |
|
| 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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $logs = array(); |
| 40 | 40 | if(!empty($rawlog)){ |
| 41 | 41 | $temp = explode("\n", $rawlog); |
| 42 | - foreach($temp AS $l){ |
|
| 42 | + foreach($temp as $l){ |
|
| 43 | 43 | if(empty($l)) continue; |
| 44 | 44 | $t = explode("\t", $l); |
| 45 | 45 | if(count($t) < 3) continue; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | include('lang/list.php'); |
| 104 | 104 | $lng = 'en'; |
| 105 | 105 | if(preg_match_all('/[a-z]{2}(-[a-z]{2})?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m)) { |
| 106 | - foreach($m[0] AS $l){ |
|
| 106 | + foreach($m[0] as $l){ |
|
| 107 | 107 | if(isset($langs[$l])){ |
| 108 | 108 | $lng_name = $l; |
| 109 | 109 | break; |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -$CFG = array ( |
|
| 2 | +$CFG = array( |
|
| 3 | 3 | 'charsets' => 'cp1251 utf8 latin1', |
| 4 | 4 | 'lang' => 'auto', |
| 5 | 5 | 'time_web' => '600', |
@@ -1,43 +1,43 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | error_reporting(0); |
| 3 | 3 | if(!empty($_SERVER['QUERY_STRING']) && preg_match("/^(\w+)(\.v\d+)?(pro)?\.(lng\.js|js|css|gif|png|ico)$/", $_SERVER['QUERY_STRING'], $m)){ |
| 4 | - $compress = true; |
|
| 5 | - $skin = ''; |
|
| 6 | - $file = $skin; |
|
| 7 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 1209600) . ' GMT'); |
|
| 8 | - header('Cache-Control: max-age=1209600, public'); |
|
| 9 | - switch($m[4]) { |
|
| 10 | - case 'css': $type = 'text/css; charset=UTF-8'; break; |
|
| 11 | - case 'js': $type = 'application/x-javascript; charset=UTF-8'; break; |
|
| 12 | - case 'lng.js': |
|
| 13 | - header('Content-Type: application/x-javascript; charset=UTF-8'); |
|
| 14 | - //if(!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
|
| 15 | - include("lang/lng_{$m[1]}.php"); |
|
| 16 | - echo 'sxdlng = ' . sxd_php2json($LNG['js']) . ';'; |
|
| 17 | - exit; |
|
| 18 | - case 'png': $file = 'img/'; $type = 'image/png';$compress = false; break; |
|
| 19 | - case 'gif': $file = 'img/'; $type = 'image/gif';$compress = false; break; |
|
| 20 | - case 'ico': $file = ''; $type = 'image/x-icon';$compress = false; break; |
|
| 21 | - } |
|
| 22 | - $file .= $m[1] . '.' . $m[4]; |
|
| 23 | - if(is_file($file)){ |
|
| 24 | - //if($compress) if(!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
|
| 25 | - header('Content-Type: ' . $type); |
|
| 26 | - readfile($file);exit; |
|
| 27 | - } |
|
| 4 | + $compress = true; |
|
| 5 | + $skin = ''; |
|
| 6 | + $file = $skin; |
|
| 7 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 1209600) . ' GMT'); |
|
| 8 | + header('Cache-Control: max-age=1209600, public'); |
|
| 9 | + switch($m[4]) { |
|
| 10 | + case 'css': $type = 'text/css; charset=UTF-8'; break; |
|
| 11 | + case 'js': $type = 'application/x-javascript; charset=UTF-8'; break; |
|
| 12 | + case 'lng.js': |
|
| 13 | + header('Content-Type: application/x-javascript; charset=UTF-8'); |
|
| 14 | + //if(!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
|
| 15 | + include("lang/lng_{$m[1]}.php"); |
|
| 16 | + echo 'sxdlng = ' . sxd_php2json($LNG['js']) . ';'; |
|
| 17 | + exit; |
|
| 18 | + case 'png': $file = 'img/'; $type = 'image/png';$compress = false; break; |
|
| 19 | + case 'gif': $file = 'img/'; $type = 'image/gif';$compress = false; break; |
|
| 20 | + case 'ico': $file = ''; $type = 'image/x-icon';$compress = false; break; |
|
| 21 | + } |
|
| 22 | + $file .= $m[1] . '.' . $m[4]; |
|
| 23 | + if(is_file($file)){ |
|
| 24 | + //if($compress) if(!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
|
| 25 | + header('Content-Type: ' . $type); |
|
| 26 | + readfile($file);exit; |
|
| 27 | + } |
|
| 28 | 28 | } |
| 29 | 29 | function sxd_php2json($obj){ |
| 30 | - if(count($obj) == 0) return '[]'; |
|
| 31 | - $is_obj = isset($obj[count($obj) - 1]) ? false : true; |
|
| 32 | - $str = $is_obj ? '{' : '['; |
|
| 30 | + if(count($obj) == 0) return '[]'; |
|
| 31 | + $is_obj = isset($obj[count($obj) - 1]) ? false : true; |
|
| 32 | + $str = $is_obj ? '{' : '['; |
|
| 33 | 33 | foreach ($obj AS $key => $value) { |
| 34 | - $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
|
| 34 | + $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
|
| 35 | 35 | if (is_array($value)) $str .= sxd_php2json($value); |
| 36 | 36 | elseif (is_null($value)) $str .= 'null'; |
| 37 | 37 | elseif (is_bool($value)) $str .= $value ? 'true' : 'false'; |
| 38 | - elseif (is_numeric($value)) $str .= $value; |
|
| 39 | - else $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 40 | - $str .= ','; |
|
| 38 | + elseif (is_numeric($value)) $str .= $value; |
|
| 39 | + else $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'"; |
|
| 40 | + $str .= ','; |
|
| 41 | 41 | } |
| 42 | - return substr_replace($str, $is_obj ? '}' : ']', -1); |
|
| 42 | + return substr_replace($str, $is_obj ? '}' : ']', -1); |
|
| 43 | 43 | } |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | error_reporting(0); |
| 3 | -if(!empty($_SERVER['QUERY_STRING']) && preg_match("/^(\w+)(\.v\d+)?(pro)?\.(lng\.js|js|css|gif|png|ico)$/", $_SERVER['QUERY_STRING'], $m)){ |
|
| 3 | +if (!empty($_SERVER['QUERY_STRING']) && preg_match("/^(\w+)(\.v\d+)?(pro)?\.(lng\.js|js|css|gif|png|ico)$/", $_SERVER['QUERY_STRING'], $m)) { |
|
| 4 | 4 | $compress = true; |
| 5 | 5 | $skin = ''; |
| 6 | 6 | $file = $skin; |
| 7 | 7 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 1209600) . ' GMT'); |
| 8 | 8 | header('Cache-Control: max-age=1209600, public'); |
| 9 | - switch($m[4]) { |
|
| 9 | + switch ($m[4]) { |
|
| 10 | 10 | case 'css': $type = 'text/css; charset=UTF-8'; break; |
| 11 | 11 | case 'js': $type = 'application/x-javascript; charset=UTF-8'; break; |
| 12 | 12 | case 'lng.js': |
@@ -15,24 +15,24 @@ discard block |
||
| 15 | 15 | include("lang/lng_{$m[1]}.php"); |
| 16 | 16 | echo 'sxdlng = ' . sxd_php2json($LNG['js']) . ';'; |
| 17 | 17 | exit; |
| 18 | - case 'png': $file = 'img/'; $type = 'image/png';$compress = false; break; |
|
| 19 | - case 'gif': $file = 'img/'; $type = 'image/gif';$compress = false; break; |
|
| 20 | - case 'ico': $file = ''; $type = 'image/x-icon';$compress = false; break; |
|
| 18 | + case 'png': $file = 'img/'; $type = 'image/png'; $compress = false; break; |
|
| 19 | + case 'gif': $file = 'img/'; $type = 'image/gif'; $compress = false; break; |
|
| 20 | + case 'ico': $file = ''; $type = 'image/x-icon'; $compress = false; break; |
|
| 21 | 21 | } |
| 22 | 22 | $file .= $m[1] . '.' . $m[4]; |
| 23 | - if(is_file($file)){ |
|
| 23 | + if (is_file($file)) { |
|
| 24 | 24 | //if($compress) if(!ini_get('zlib.output_compression') && function_exists('ob_gzhandler')) ob_start('ob_gzhandler'); |
| 25 | 25 | header('Content-Type: ' . $type); |
| 26 | - readfile($file);exit; |
|
| 26 | + readfile($file); exit; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -function sxd_php2json($obj){ |
|
| 30 | - if(count($obj) == 0) return '[]'; |
|
| 29 | +function sxd_php2json($obj) { |
|
| 30 | + if (count($obj) == 0) return '[]'; |
|
| 31 | 31 | $is_obj = isset($obj[count($obj) - 1]) ? false : true; |
| 32 | 32 | $str = $is_obj ? '{' : '['; |
| 33 | 33 | foreach ($obj AS $key => $value) { |
| 34 | 34 | $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
| 35 | - if (is_array($value)) $str .= sxd_php2json($value); |
|
| 35 | + if (is_array($value)) $str .= sxd_php2json($value); |
|
| 36 | 36 | elseif (is_null($value)) $str .= 'null'; |
| 37 | 37 | elseif (is_bool($value)) $str .= $value ? 'true' : 'false'; |
| 38 | 38 | elseif (is_numeric($value)) $str .= $value; |
@@ -26,17 +26,25 @@ |
||
| 26 | 26 | readfile($file);exit; |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -function sxd_php2json($obj){ |
|
| 30 | - if(count($obj) == 0) return '[]'; |
|
| 29 | +function sxd_php2json($obj) { |
|
| 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); |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | if(count($obj) == 0) return '[]'; |
| 31 | 31 | $is_obj = isset($obj[count($obj) - 1]) ? false : true; |
| 32 | 32 | $str = $is_obj ? '{' : '['; |
| 33 | - foreach ($obj AS $key => $value) { |
|
| 33 | + foreach ($obj as $key => $value) { |
|
| 34 | 34 | $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : ''; |
| 35 | 35 | if (is_array($value)) $str .= sxd_php2json($value); |
| 36 | 36 | elseif (is_null($value)) $str .= 'null'; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 8 | 8 | |
| 9 | 9 | // if($user['authlevel'] < 2) |
| 10 | -if($user['authlevel'] < 3) |
|
| 10 | +if ($user['authlevel'] < 3) |
|
| 11 | 11 | { |
| 12 | 12 | AdminMessage($lang['adm_err_denied']); |
| 13 | 13 | } |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | $planet_id = sys_get_param_id('planet_id'); |
| 22 | 22 | |
| 23 | 23 | $unit_list = sys_get_param('unit_list'); |
| 24 | -if(sys_get_param('change_data') && !empty($unit_list)) |
|
| 24 | +if (sys_get_param('change_data') && !empty($unit_list)) |
|
| 25 | 25 | { |
| 26 | 26 | $query_string = array(); |
| 27 | - foreach($unit_list as $unit_id => $unit_amount) |
|
| 27 | + foreach ($unit_list as $unit_id => $unit_amount) |
|
| 28 | 28 | { |
| 29 | - if($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode)) |
|
| 29 | + if ($unit_query_string = admin_planet_edit_query_string($unit_id, $unit_amount, $mode)) |
|
| 30 | 30 | { |
| 31 | 31 | $query_string[] = $unit_query_string; |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!empty($query_string)) |
|
| 35 | + if (!empty($query_string)) |
|
| 36 | 36 | { |
| 37 | 37 | db_planet_set_by_id($planet_id, implode(', ', $query_string)); |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -if($planet_id) |
|
| 41 | +if ($planet_id) |
|
| 42 | 42 | { |
| 43 | 43 | $edit_planet_row = db_planet_by_id($planet_id); |
| 44 | 44 | admin_planet_edit_template($template, $edit_planet_row, $mode); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -foreach($admin_planet_edit_mode_list as $page_mode => $mode_locale) |
|
| 47 | +foreach ($admin_planet_edit_mode_list as $page_mode => $mode_locale) |
|
| 48 | 48 | { |
| 49 | 49 | $template->assign_block_vars('page_menu', array( |
| 50 | 50 | 'ID' => $page_mode, |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -define('INSIDE' , true); |
|
| 11 | -define('INSTALL' , false); |
|
| 12 | -define('IN_ADMIN' , true); |
|
| 10 | +define('INSIDE', true); |
|
| 11 | +define('INSTALL', false); |
|
| 12 | +define('IN_ADMIN', true); |
|
| 13 | 13 | |
| 14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 15 | 15 | |
| 16 | -if($user['authlevel'] < 2) |
|
| 16 | +if ($user['authlevel'] < 2) |
|
| 17 | 17 | { |
| 18 | 18 | AdminMessage($lang['adm_err_denied']); |
| 19 | 19 | } |
@@ -7,25 +7,25 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -define('INSIDE' , true); |
|
| 11 | -define('INSTALL' , false); |
|
| 12 | -define('IN_ADMIN' , true); |
|
| 10 | +define('INSIDE', true); |
|
| 11 | +define('INSTALL', false); |
|
| 12 | +define('IN_ADMIN', true); |
|
| 13 | 13 | |
| 14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 15 | 15 | |
| 16 | -if($user['authlevel'] < 3) { |
|
| 16 | +if ($user['authlevel'] < 3) { |
|
| 17 | 17 | AdminMessage($lang['adm_err_denied']); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function adm_lng_assign_string($lang_id, $locale_string_name, $value) { |
| 21 | 21 | global $locale_string_template, $languages_info, $languages, $domain; |
| 22 | 22 | |
| 23 | - if(is_array($value)) { |
|
| 24 | - foreach($value as $sub_key => $sub_value) { |
|
| 23 | + if (is_array($value)) { |
|
| 24 | + foreach ($value as $sub_key => $sub_value) { |
|
| 25 | 25 | adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value); |
| 26 | 26 | } |
| 27 | - } elseif($value) { |
|
| 28 | - if(!isset($locale_string_template[$locale_string_name])) { |
|
| 27 | + } elseif ($value) { |
|
| 28 | + if (!isset($locale_string_template[$locale_string_name])) { |
|
| 29 | 29 | $locale_string_template[$locale_string_name] = array(); |
| 30 | 30 | } |
| 31 | 31 | $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8'))); |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | global $domain, $lang_id; |
| 47 | 47 | |
| 48 | 48 | $return = "{$ident}'{$string_name}' => "; |
| 49 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
| 49 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
| 50 | 50 | $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"; |
| 51 | 51 | } else { |
| 52 | 52 | $return .= "array(\r\n"; |
| 53 | - foreach($string_value as $arr_name => $arr_data) { |
|
| 53 | + foreach ($string_value as $arr_name => $arr_data) { |
|
| 54 | 54 | $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . ' '); |
| 55 | 55 | } |
| 56 | 56 | $return .= "{$ident}),\r\n"; |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $string_name_new = false; |
| 105 | 105 | |
| 106 | - if(isset($honor_constants[$domain][$string_name_prefix])) { |
|
| 106 | + if (isset($honor_constants[$domain][$string_name_prefix])) { |
|
| 107 | 107 | $found_constants = array_keys($constants, $string_name); |
| 108 | - foreach($found_constants as $constant_name) { |
|
| 108 | + foreach ($found_constants as $constant_name) { |
|
| 109 | 109 | $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]); |
| 110 | - foreach($honor_prefix_list as $honor_prefix) { |
|
| 111 | - if(strpos($constant_name, $honor_prefix) === 0) { |
|
| 110 | + foreach ($honor_prefix_list as $honor_prefix) { |
|
| 111 | + if (strpos($constant_name, $honor_prefix) === 0) { |
|
| 112 | 112 | $string_name_new = $constant_name; |
| 113 | 113 | break; |
| 114 | 114 | } |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'"; |
| 120 | 120 | fwrite($file_handler, "{$ident}{$string_name_new} => "); |
| 121 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
| 121 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
| 122 | 122 | fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"); |
| 123 | 123 | } else { |
| 124 | 124 | $string_name_prefix = $string_name_prefix . "[{$string_name}]"; |
| 125 | 125 | fwrite($file_handler, "array(\r\n"); |
| 126 | - foreach($string_value as $arr_name => $arr_data) { |
|
| 126 | + foreach ($string_value as $arr_name => $arr_data) { |
|
| 127 | 127 | adm_lng_write_string($arr_name, $arr_data, $ident . ' ', $string_name_prefix); |
| 128 | 128 | } |
| 129 | 129 | fwrite($file_handler, "{$ident}),\r\n"); |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | $languages_info = lng_get_list(); |
| 144 | 144 | $domain = sys_get_param_str('domain'); |
| 145 | 145 | |
| 146 | -if($domain) { |
|
| 146 | +if ($domain) { |
|
| 147 | 147 | $lang_new = sys_get_param('lang_new'); |
| 148 | - if(!empty($lang_new)) { |
|
| 148 | + if (!empty($lang_new)) { |
|
| 149 | 149 | $constants = get_defined_constants(true); |
| 150 | 150 | $constants = $constants['user']; |
| 151 | 151 | ksort($constants); |
| 152 | - foreach($languages_info as $lang_id => $land_data) { |
|
| 152 | + foreach ($languages_info as $lang_id => $land_data) { |
|
| 153 | 153 | $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w'); |
| 154 | 154 | fwrite($file_handler, "<?php\r\n\r\n/*\r\n############################################################################# |
| 155 | 155 | # Filename: {$domain}.mo.php |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | # Website: http://www.supernova.ws |
| 158 | 158 | # Description: Massive Multiplayer Online Browser Space Startegy Game\r\n#\r\n"); |
| 159 | 159 | |
| 160 | - foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
| 160 | + foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
| 161 | 161 | $lang_copyright = str_replace(array('©', '"', '<', '>'), array('©', '"', '<', '>'), $lang_copyright); |
| 162 | 162 | fwrite($file_handler, "# {$lang_copyright}\r\n"); |
| 163 | 163 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n |
| 166 | 166 | /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n |
| 167 | 167 | \$a_lang_array = array(\r\n"); |
| 168 | - foreach($lang_new as $string_name => $string_value) { |
|
| 168 | + foreach ($lang_new as $string_name => $string_value) { |
|
| 169 | 169 | adm_lng_write_string($string_name, $string_value); |
| 170 | 170 | } |
| 171 | 171 | fwrite($file_handler, ");\r\n"); |
@@ -176,21 +176,21 @@ discard block |
||
| 176 | 176 | die(); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - foreach($languages_info as $lang_id => $lang_data) { |
|
| 179 | + foreach ($languages_info as $lang_id => $lang_data) { |
|
| 180 | 180 | $template->assign_block_vars('language', $lang_data); |
| 181 | 181 | $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php"; |
| 182 | 182 | $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : '')); |
| 183 | - foreach($languages[$lang_id] as $locale_string_name => $cork) { |
|
| 183 | + foreach ($languages[$lang_id] as $locale_string_name => $cork) { |
|
| 184 | 184 | adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - foreach($locale_string_template as $locale_string_name => $locale_string_list) { |
|
| 188 | + foreach ($locale_string_template as $locale_string_name => $locale_string_list) { |
|
| 189 | 189 | $template->assign_block_vars('string', array( |
| 190 | 190 | 'NAME' => $locale_string_name, |
| 191 | 191 | )); |
| 192 | 192 | |
| 193 | - foreach($languages_info as $lang_id => $cork2) { |
|
| 193 | + foreach ($languages_info as $lang_id => $cork2) { |
|
| 194 | 194 | $template->assign_block_vars('string.locale', array( |
| 195 | 195 | 'LANG' => $lang_id, |
| 196 | 196 | 'VALUE' => $locale_string_list["[{$lang_id}]"], |
@@ -206,17 +206,17 @@ discard block |
||
| 206 | 206 | $dir = dir($path); |
| 207 | 207 | while (false !== ($lang_id = $dir->read())) { |
| 208 | 208 | $full_path = $path . $lang_id; |
| 209 | - if($lang_id[0] != "." && is_dir($full_path)) { |
|
| 209 | + if ($lang_id[0] != "." && is_dir($full_path)) { |
|
| 210 | 210 | $lang_file_list = dir($full_path); |
| 211 | 211 | while (false !== ($filename = $lang_file_list->read())) { |
| 212 | 212 | $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.'))); |
| 213 | - if(!$lang_domain) { |
|
| 213 | + if (!$lang_domain) { |
|
| 214 | 214 | continue; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $file_ext = strtolower(substr($filename, strpos($filename, '.'))); |
| 218 | - if($lang_domain != 'language') { |
|
| 219 | - if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
| 218 | + if ($lang_domain != 'language') { |
|
| 219 | + if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
| 220 | 220 | $language_domains[$lang_domain] = $lang_domain; |
| 221 | 221 | $languages[$lang_id][$lang_domain] = $lang_domain; |
| 222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | $dir->close(); |
| 228 | 228 | |
| 229 | - foreach($language_domains as $lang_domain) { |
|
| 229 | + foreach ($language_domains as $lang_domain) { |
|
| 230 | 230 | $template->assign_block_vars('domain', array( |
| 231 | 231 | 'NAME' => $lang_domain, |
| 232 | 232 | )); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 17 | 17 | |
| 18 | -if($user['authlevel'] < 3) { |
|
| 18 | +if ($user['authlevel'] < 3) { |
|
| 19 | 19 | AdminMessage($lang['adm_err_denied']); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | $message = ''; |
| 25 | 25 | $message_status = ERR_ERROR; |
| 26 | 26 | |
| 27 | -if($points = sys_get_param_float('points')) { |
|
| 27 | +if ($points = sys_get_param_float('points')) { |
|
| 28 | 28 | // If points not empty... |
| 29 | - if($username = sys_get_param_str_unsafe('id_user')) { |
|
| 29 | + if ($username = sys_get_param_str_unsafe('id_user')) { |
|
| 30 | 30 | $row = db_user_by_id($username, false, 'id, username', true, true); |
| 31 | - if(!isset($row['id'])) { |
|
| 31 | + if (!isset($row['id'])) { |
|
| 32 | 32 | $row = db_user_by_username($username, false, 'id, username', true, true); |
| 33 | 33 | } |
| 34 | - if(is_array($row) && isset($row['id'])) { |
|
| 34 | + if (is_array($row) && isset($row['id'])) { |
|
| 35 | 35 | // Does anything post to DB? |
| 36 | - if(rpg_points_change( |
|
| 36 | + if (rpg_points_change( |
|
| 37 | 37 | $row['id'], |
| 38 | 38 | RPG_ADMIN, |
| 39 | 39 | $points, |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | // Points not empty but destination is not set - this means error |
| 52 | 52 | $message = $lang['adm_dm_no_dest']; |
| 53 | 53 | } |
| 54 | -} elseif($id_user) { |
|
| 54 | +} elseif ($id_user) { |
|
| 55 | 55 | // Points is empty but destination is set - this again means error |
| 56 | 56 | $message = $lang['adm_dm_no_quant']; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -if(!$isNoError) { |
|
| 59 | +if (!$isNoError) { |
|
| 60 | 60 | $template->assign_vars(array( |
| 61 | 61 | 'ID_USER' => $id_user, |
| 62 | 62 | 'POINTS' => $points, |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | )); |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | -if($message) { |
|
| 67 | +if ($message) { |
|
| 68 | 68 | $template->assign_block_vars('result', array('MESSAGE' => $message, 'STATUS' => $message_status ? $message_status : ERR_NONE)); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | $time_server = $time_local - $time_diff |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if($font_size = sys_get_param_str('font_size')) { |
|
| 17 | - if(strpos($font_size, '%') !== false) { |
|
| 16 | +if ($font_size = sys_get_param_str('font_size')) { |
|
| 17 | + if (strpos($font_size, '%') !== false) { |
|
| 18 | 18 | // Размер шрифта в процентах |
| 19 | 19 | $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%'; |
| 20 | - } elseif(strpos($font_size, 'px') !== false) { |
|
| 20 | + } elseif (strpos($font_size, 'px') !== false) { |
|
| 21 | 21 | // Размер шрифта в пикселях |
| 22 | 22 | $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px'; |
| 23 | 23 | } else { |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | classSupernova::$user_options[PLAYER_OPTION_BASE_FONT_SIZE] = $font_size; |
| 30 | 30 | } else { |
| 31 | 31 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
| 32 | - if($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
| 32 | + if ($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
| 33 | 33 | $time_diff = intval($user_time_diff[PLAYER_OPTION_TIME_DIFF]); |
| 34 | 34 | } else { |
| 35 | 35 | $user_time_diff = playerTimeDiff::user_time_diff_probe(); |
@@ -1,52 +1,52 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function dump($value,$varname = "",$level=0,$dumper = "") |
|
| 3 | +function dump($value, $varname = "", $level = 0, $dumper = "") |
|
| 4 | 4 | { |
| 5 | 5 | if ($varname) $varname .= " = "; |
| 6 | 6 | |
| 7 | - if ($level==-1) |
|
| 7 | + if ($level == -1) |
|
| 8 | 8 | { |
| 9 | - $trans[' ']='∴'; |
|
| 10 | - $trans["\t"]='⇒'; |
|
| 11 | - $trans["\n"]='¶;'; |
|
| 12 | - $trans["\r"]='⇐'; |
|
| 13 | - $trans["\0"]='⊕'; |
|
| 14 | - return strtr(htmlspecialchars($value),$trans); |
|
| 9 | + $trans[' '] = '∴'; |
|
| 10 | + $trans["\t"] = '⇒'; |
|
| 11 | + $trans["\n"] = '¶;'; |
|
| 12 | + $trans["\r"] = '⇐'; |
|
| 13 | + $trans["\0"] = '⊕'; |
|
| 14 | + return strtr(htmlspecialchars($value), $trans); |
|
| 15 | 15 | } |
| 16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
| 16 | + if ($level == 0) $dumper = '<pre>' . $varname; |
|
| 17 | 17 | |
| 18 | 18 | $type = gettype($value); |
| 19 | 19 | $dumper .= $type; |
| 20 | 20 | |
| 21 | - if ($type=='string') |
|
| 21 | + if ($type == 'string') |
|
| 22 | 22 | { |
| 23 | - $dumper .= '('.strlen($value).')'; |
|
| 24 | - $value = dump($value,"",-1); |
|
| 23 | + $dumper .= '(' . strlen($value) . ')'; |
|
| 24 | + $value = dump($value, "", -1); |
|
| 25 | 25 | } |
| 26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
| 27 | - elseif ($type=='object') |
|
| 26 | + elseif ($type == 'boolean') $value = ($value ? 'true' : 'false'); |
|
| 27 | + elseif ($type == 'object') |
|
| 28 | 28 | { |
| 29 | - $props= get_class_vars(get_class($value)); |
|
| 30 | - $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
| 31 | - foreach($props as $key=>$val) |
|
| 29 | + $props = get_class_vars(get_class($value)); |
|
| 30 | + $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
| 31 | + foreach ($props as $key=>$val) |
|
| 32 | 32 | { |
| 33 | - $dumper .= "\n".str_repeat("\t",$level+1).$key.' => '; |
|
| 34 | - $dumper .= dump($value->$key,"",$level+1); |
|
| 33 | + $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
| 34 | + $dumper .= dump($value->$key, "", $level + 1); |
|
| 35 | 35 | } |
| 36 | - $value= ''; |
|
| 36 | + $value = ''; |
|
| 37 | 37 | } |
| 38 | - elseif ($type=='array') |
|
| 38 | + elseif ($type == 'array') |
|
| 39 | 39 | { |
| 40 | - $dumper .= '('.count($value).')'; |
|
| 41 | - foreach($value as $key=>$val) |
|
| 40 | + $dumper .= '(' . count($value) . ')'; |
|
| 41 | + foreach ($value as $key=>$val) |
|
| 42 | 42 | { |
| 43 | - $dumper .= "\n".str_repeat("\t",$level+1).dump($key,"",-1).' => '; |
|
| 44 | - $dumper .= dump($val,"",$level+1); |
|
| 43 | + $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, "", -1) . ' => '; |
|
| 44 | + $dumper .= dump($val, "", $level + 1); |
|
| 45 | 45 | } |
| 46 | - $value= ''; |
|
| 46 | + $value = ''; |
|
| 47 | 47 | } |
| 48 | 48 | $dumper .= " <b>$value</b>"; |
| 49 | - if ($level==0) $dumper .= '</pre>'; |
|
| 49 | + if ($level == 0) $dumper .= '</pre>'; |
|
| 50 | 50 | return $dumper; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $output_buffer .= $string; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -if(substr(getcwd(), -4) != 'docs') |
|
| 70 | +if (substr(getcwd(), -4) != 'docs') |
|
| 71 | 71 | { |
| 72 | 72 | $path_prefix = 'docs/'; |
| 73 | 73 | } |
@@ -80,22 +80,22 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $filename = 'changelog'; |
| 82 | 82 | |
| 83 | -$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
| 83 | +$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
| 84 | 84 | //$input = iconv('CP1251', 'UTF-8', $input); |
| 85 | 85 | |
| 86 | 86 | $input = preg_replace("/\r\n\d\d\d\d\-\d\d\-\d\d\ \d\d\:\d\d/", "[D] $0", $input); |
| 87 | 87 | |
| 88 | -while(strpos($input, "\r\n\r\n") !== false) |
|
| 88 | +while (strpos($input, "\r\n\r\n") !== false) |
|
| 89 | 89 | { |
| 90 | 90 | $input = str_replace("\r\n\r\n", "\r\n", $input); |
| 91 | 91 | } |
| 92 | -while(strpos($input, "~~~") !== false) |
|
| 92 | +while (strpos($input, "~~~") !== false) |
|
| 93 | 93 | { |
| 94 | 94 | $input = str_replace("~~~", "~~", $input); |
| 95 | 95 | } |
| 96 | 96 | $input = str_replace("\r\n~~", "~~", $input); |
| 97 | 97 | |
| 98 | -while(strpos($input, "===") !== false) |
|
| 98 | +while (strpos($input, "===") !== false) |
|
| 99 | 99 | { |
| 100 | 100 | $input = str_replace("===", "==", $input); |
| 101 | 101 | } |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $prev_chapter_is_header = false; |
| 107 | 107 | $output = array(); |
| 108 | 108 | $buffer = array(); |
| 109 | -foreach($input as &$chapter) |
|
| 109 | +foreach ($input as &$chapter) |
|
| 110 | 110 | { |
| 111 | 111 | $chapter = preg_split("/(\r\n[\[])/", $chapter, -1, PREG_SPLIT_NO_EMPTY); // , PREG_SPLIT_DELIM_CAPTURE |
| 112 | 112 | |
| 113 | - if(count($chapter) == 1 && !$prev_chapter_is_header) |
|
| 113 | + if (count($chapter) == 1 && !$prev_chapter_is_header) |
|
| 114 | 114 | { |
| 115 | - if(!empty($chapter)) |
|
| 115 | + if (!empty($chapter)) |
|
| 116 | 116 | { |
| 117 | 117 | $output[] = $buffer; |
| 118 | 118 | $buffer = array(); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | else |
| 124 | 124 | { |
| 125 | 125 | $prev_chapter_is_header = false; |
| 126 | - foreach($chapter as &$note) |
|
| 126 | + foreach ($chapter as &$note) |
|
| 127 | 127 | { |
| 128 | 128 | $note = explode("\r\n", $note); |
| 129 | 129 | $new_note = true; |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $note_out = array(); |
| 133 | 133 | |
| 134 | - foreach($note as &$line) |
|
| 134 | + foreach ($note as &$line) |
|
| 135 | 135 | { |
| 136 | - if(!$line) |
|
| 136 | + if (!$line) |
|
| 137 | 137 | { |
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | - if($new_note) |
|
| 140 | + if ($new_note) |
|
| 141 | 141 | { |
| 142 | 142 | // 78 - 3 = 75 |
| 143 | 143 | $note_out['style'] = $line[0]; |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $buf_str .= $line; |
| 148 | - if(mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
| 148 | + if (mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
| 149 | 149 | { |
| 150 | - if(!isset($note_out['name'])) |
|
| 150 | + if (!isset($note_out['name'])) |
|
| 151 | 151 | { |
| 152 | 152 | $note_out['name'] = $buf_str; |
| 153 | 153 | } |
@@ -201,31 +201,31 @@ discard block |
||
| 201 | 201 | 'D' => 'date', |
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | -foreach($output as $chapter) |
|
| 204 | +foreach ($output as $chapter) |
|
| 205 | 205 | { |
| 206 | - if(!$chapter) |
|
| 206 | + if (!$chapter) |
|
| 207 | 207 | { |
| 208 | 208 | continue; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | buf_print("<h1>{$chapter['name']}</h1>\r\n"); |
| 212 | - foreach($chapter['content'] as $block) |
|
| 212 | + foreach ($chapter['content'] as $block) |
|
| 213 | 213 | { |
| 214 | 214 | buf_print("<div class=\"{$styles[$block['style']]}\">" . ($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
| 215 | 215 | buf_print(preg_replace("/\s{2,10}/", " ", $block['name']) . '<br />'); |
| 216 | - if(isset($block['lines'])) |
|
| 216 | + if (isset($block['lines'])) |
|
| 217 | 217 | { |
| 218 | 218 | $last_spaces = ''; |
| 219 | 219 | $depth = array(); |
| 220 | - foreach($block['lines'] as $line) |
|
| 220 | + foreach ($block['lines'] as $line) |
|
| 221 | 221 | { |
| 222 | - if(preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
| 222 | + if (preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
| 223 | 223 | { |
| 224 | 224 | //$line = strlen($matches[1]) . '/' . $matches[2] . '/' . $matches[3]; |
| 225 | 225 | $line = $matches[3]; |
| 226 | - if(strlen($matches[1]) > strlen($last_spaces)) |
|
| 226 | + if (strlen($matches[1]) > strlen($last_spaces)) |
|
| 227 | 227 | { |
| 228 | - if($matches[2]) |
|
| 228 | + if ($matches[2]) |
|
| 229 | 229 | { |
| 230 | 230 | buf_print("<ol>\r\n"); |
| 231 | 231 | } |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | $last_spaces = $matches[1]; |
| 238 | 238 | $depth[] = $matches[2]; |
| 239 | 239 | } |
| 240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
| 240 | + elseif (strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
| 241 | 241 | { |
| 242 | - if(array_pop($depth)) |
|
| 242 | + if (array_pop($depth)) |
|
| 243 | 243 | { |
| 244 | 244 | buf_print("</ol>\r\n"); |
| 245 | 245 | } |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | $last_spaces = $matches[1]; |
| 251 | 251 | buf_print('<li>'); |
| 252 | 252 | } |
| 253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
| 253 | + elseif (strlen($last_spaces) == strlen($matches[1])) |
|
| 254 | 254 | { |
| 255 | - if($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
| 255 | + if ($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
| 256 | 256 | { |
| 257 | 257 | buf_print("</ol>\r\n"); |
| 258 | 258 | buf_print("<ul>\r\n"); |
| 259 | 259 | } |
| 260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
| 260 | + elseif ($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
| 261 | 261 | { |
| 262 | 262 | buf_print("</ul>\r\n"); |
| 263 | 263 | buf_print("<ol>\r\n"); |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | $line = preg_replace("/\s{2,10}/", " ", $line); |
| 270 | 270 | buf_print($line . "<br />\r\n"); |
| 271 | 271 | } |
| 272 | - while(count($depth)) |
|
| 272 | + while (count($depth)) |
|
| 273 | 273 | { |
| 274 | - if(array_pop($depth)) |
|
| 274 | + if (array_pop($depth)) |
|
| 275 | 275 | { |
| 276 | 276 | buf_print("</ol>\r\n"); |
| 277 | 277 | } |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | buf_print("</body>\r\n</html>\r\n"); |
| 288 | 288 | |
| 289 | 289 | $html = file_get_contents($path_prefix . 'html/' . $filename . '.html'); |
| 290 | -if($html != $output_buffer) |
|
| 290 | +if ($html != $output_buffer) |
|
| 291 | 291 | { |
| 292 | 292 | file_put_contents($path_prefix . 'html/' . $filename . '.html', $output_buffer); |
| 293 | - if(!$path_prefix) |
|
| 293 | + if (!$path_prefix) |
|
| 294 | 294 | { |
| 295 | 295 | print($output_buffer); |
| 296 | 296 | } |
@@ -1,8 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function dump($value,$varname = "",$level=0,$dumper = "") |
|
| 4 | -{ |
|
| 5 | - if ($varname) $varname .= " = "; |
|
| 3 | +function dump($value,$varname = "",$level=0,$dumper = "") { |
|
| 4 | + if ($varname) { |
|
| 5 | + $varname .= " = "; |
|
| 6 | + } |
|
| 6 | 7 | |
| 7 | 8 | if ($level==-1) |
| 8 | 9 | { |
@@ -13,7 +14,9 @@ discard block |
||
| 13 | 14 | $trans["\0"]='⊕'; |
| 14 | 15 | return strtr(htmlspecialchars($value),$trans); |
| 15 | 16 | } |
| 16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
| 17 | + if ($level==0) { |
|
| 18 | + $dumper = '<pre>' . $varname; |
|
| 19 | + } |
|
| 17 | 20 | |
| 18 | 21 | $type = gettype($value); |
| 19 | 22 | $dumper .= $type; |
@@ -22,9 +25,9 @@ discard block |
||
| 22 | 25 | { |
| 23 | 26 | $dumper .= '('.strlen($value).')'; |
| 24 | 27 | $value = dump($value,"",-1); |
| 25 | - } |
|
| 26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
| 27 | - elseif ($type=='object') |
|
| 28 | + } elseif ($type=='boolean') { |
|
| 29 | + $value= ($value?'true':'false'); |
|
| 30 | + } elseif ($type=='object') |
|
| 28 | 31 | { |
| 29 | 32 | $props= get_class_vars(get_class($value)); |
| 30 | 33 | $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
@@ -34,8 +37,7 @@ discard block |
||
| 34 | 37 | $dumper .= dump($value->$key,"",$level+1); |
| 35 | 38 | } |
| 36 | 39 | $value= ''; |
| 37 | - } |
|
| 38 | - elseif ($type=='array') |
|
| 40 | + } elseif ($type=='array') |
|
| 39 | 41 | { |
| 40 | 42 | $dumper .= '('.count($value).')'; |
| 41 | 43 | foreach($value as $key=>$val) |
@@ -46,22 +48,21 @@ discard block |
||
| 46 | 48 | $value= ''; |
| 47 | 49 | } |
| 48 | 50 | $dumper .= " <b>$value</b>"; |
| 49 | - if ($level==0) $dumper .= '</pre>'; |
|
| 51 | + if ($level==0) { |
|
| 52 | + $dumper .= '</pre>'; |
|
| 53 | + } |
|
| 50 | 54 | return $dumper; |
| 51 | 55 | } |
| 52 | 56 | |
| 53 | -function pdump($value, $varname = '') |
|
| 54 | -{ |
|
| 57 | +function pdump($value, $varname = '') { |
|
| 55 | 58 | print('<span style="text-align: left">' . dump($value, $varname) . '</span>'); |
| 56 | 59 | } |
| 57 | 60 | |
| 58 | -function debug($value, $varname = '') |
|
| 59 | -{ |
|
| 61 | +function debug($value, $varname = '') { |
|
| 60 | 62 | return pdump($value, $varname); |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | -function buf_print($string) |
|
| 64 | -{ |
|
| 65 | +function buf_print($string) { |
|
| 65 | 66 | global $output_buffer; |
| 66 | 67 | |
| 67 | 68 | $output_buffer .= $string; |
@@ -70,8 +71,7 @@ discard block |
||
| 70 | 71 | if(substr(getcwd(), -4) != 'docs') |
| 71 | 72 | { |
| 72 | 73 | $path_prefix = 'docs/'; |
| 73 | -} |
|
| 74 | -else |
|
| 74 | +} else |
|
| 75 | 75 | { |
| 76 | 76 | $path_prefix = ''; |
| 77 | 77 | } |
@@ -119,8 +119,7 @@ discard block |
||
| 119 | 119 | $buffer['name'] = $chapter[0]; |
| 120 | 120 | } |
| 121 | 121 | $prev_chapter_is_header = true; |
| 122 | - } |
|
| 123 | - else |
|
| 122 | + } else |
|
| 124 | 123 | { |
| 125 | 124 | $prev_chapter_is_header = false; |
| 126 | 125 | foreach($chapter as &$note) |
@@ -150,8 +149,7 @@ discard block |
||
| 150 | 149 | if(!isset($note_out['name'])) |
| 151 | 150 | { |
| 152 | 151 | $note_out['name'] = $buf_str; |
| 153 | - } |
|
| 154 | - else |
|
| 152 | + } else |
|
| 155 | 153 | { |
| 156 | 154 | $note_out['lines'][] = $buf_str; |
| 157 | 155 | } |
@@ -228,36 +226,31 @@ discard block |
||
| 228 | 226 | if($matches[2]) |
| 229 | 227 | { |
| 230 | 228 | buf_print("<ol>\r\n"); |
| 231 | - } |
|
| 232 | - else |
|
| 229 | + } else |
|
| 233 | 230 | { |
| 234 | 231 | buf_print("<ul>\r\n"); |
| 235 | 232 | } |
| 236 | 233 | buf_print('<li>'); |
| 237 | 234 | $last_spaces = $matches[1]; |
| 238 | 235 | $depth[] = $matches[2]; |
| 239 | - } |
|
| 240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
| 236 | + } elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
| 241 | 237 | { |
| 242 | 238 | if(array_pop($depth)) |
| 243 | 239 | { |
| 244 | 240 | buf_print("</ol>\r\n"); |
| 245 | - } |
|
| 246 | - else |
|
| 241 | + } else |
|
| 247 | 242 | { |
| 248 | 243 | buf_print("</ul>\r\n"); |
| 249 | 244 | } |
| 250 | 245 | $last_spaces = $matches[1]; |
| 251 | 246 | buf_print('<li>'); |
| 252 | - } |
|
| 253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
| 247 | + } elseif(strlen($last_spaces) == strlen($matches[1])) |
|
| 254 | 248 | { |
| 255 | 249 | if($matches[2] == '' && $depth[count($depth) - 1] != '') |
| 256 | 250 | { |
| 257 | 251 | buf_print("</ol>\r\n"); |
| 258 | 252 | buf_print("<ul>\r\n"); |
| 259 | - } |
|
| 260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
| 253 | + } elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
| 261 | 254 | { |
| 262 | 255 | buf_print("</ul>\r\n"); |
| 263 | 256 | buf_print("<ol>\r\n"); |
@@ -274,8 +267,7 @@ discard block |
||
| 274 | 267 | if(array_pop($depth)) |
| 275 | 268 | { |
| 276 | 269 | buf_print("</ol>\r\n"); |
| 277 | - } |
|
| 278 | - else |
|
| 270 | + } else |
|
| 279 | 271 | { |
| 280 | 272 | buf_print("</ul>\r\n"); |
| 281 | 273 | } |