@@ -56,7 +56,7 @@ |
||
| 56 | 56 | } catch (ErrorException $e) { |
| 57 | 57 | } catch (Exception $e) { |
| 58 | 58 | } |
| 59 | - $className = "App\\Babel\\Extension\\$name\\$judgerProvider"; |
|
| 59 | + $className="App\\Babel\\Extension\\$name\\$judgerProvider"; |
|
| 60 | 60 | if (class_exists($className)) { |
| 61 | 61 | return new $className(); |
| 62 | 62 | } else { |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | if (!isset($data["ori"]) || !isset($data["path"]) || !isset($data["baseurl"]) || !isset($data["space_deli"]) || !isset($data["cookie"])) { |
| 89 | 89 | throw new Exception("data is not completely exist in cacheImage"); |
| 90 | 90 | } |
| 91 | - $ori = $data["ori"]; |
|
| 92 | - $path = $data["path"]; |
|
| 93 | - $baseurl = $data["baseurl"]; |
|
| 94 | - $space_deli = $data["space_deli"]; |
|
| 95 | - $cookie = $data["cookie"]; |
|
| 91 | + $ori=$data["ori"]; |
|
| 92 | + $path=$data["path"]; |
|
| 93 | + $baseurl=$data["baseurl"]; |
|
| 94 | + $space_deli=$data["space_deli"]; |
|
| 95 | + $cookie=$data["cookie"]; |
|
| 96 | 96 | |
| 97 | 97 | $para["path"]=$path; |
| 98 | 98 | $para["base"]=$baseurl; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $reg="/< *im[a]?g[^>]*src *= *[\"\\']?([^\"\\'>]*)[^>]*>/si"; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - return preg_replace_callback($reg, function ($matches) use ($para) { |
|
| 108 | + return preg_replace_callback($reg, function($matches) use ($para) { |
|
| 109 | 109 | global $config; |
| 110 | 110 | $url=trim($matches[1]); |
| 111 | 111 | if (stripos($url, "http://")===false && stripos($url, "https://")===false) { |
@@ -138,24 +138,24 @@ discard block |
||
| 138 | 138 | public function procInfo($data) |
| 139 | 139 | { |
| 140 | 140 | if (isset($data["path"])) { |
| 141 | - $path = $data["path"]; |
|
| 141 | + $path=$data["path"]; |
|
| 142 | 142 | } else { |
| 143 | 143 | throw new Exception("path is not exist in data"); |
| 144 | 144 | } |
| 145 | 145 | if (isset($data["baseurl"])) { |
| 146 | - $baseurl = $data["baseurl"]; |
|
| 146 | + $baseurl=$data["baseurl"]; |
|
| 147 | 147 | } else { |
| 148 | 148 | throw new Exception("baseurl is not exist in data"); |
| 149 | 149 | } |
| 150 | 150 | if (isset($data["space_deli"])) { |
| 151 | - $space_deli = $data["space_deli"]; |
|
| 151 | + $space_deli=$data["space_deli"]; |
|
| 152 | 152 | } else { |
| 153 | - $space_deli = true; |
|
| 153 | + $space_deli=true; |
|
| 154 | 154 | } |
| 155 | 155 | if (isset($data["cookie"])) { |
| 156 | - $cookie = $data["cookie"]; |
|
| 156 | + $cookie=$data["cookie"]; |
|
| 157 | 157 | } else { |
| 158 | - $cookie = ""; |
|
| 158 | + $cookie=""; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $this->pro["description"]=$this->_cacheImage($this->pro["description"], $path, $baseurl, $space_deli, $cookie); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | } catch (ErrorException $e) { |
| 33 | 33 | } catch (Exception $e) { |
| 34 | 34 | } |
| 35 | - $className = "App\\Babel\\Extension\\$name\\$crawlerProvider"; |
|
| 35 | + $className="App\\Babel\\Extension\\$name\\$crawlerProvider"; |
|
| 36 | 36 | if (class_exists($className)) { |
| 37 | 37 | $temp=new $className(); |
| 38 | 38 | $temp->importCommandLine($commandLineObject); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | } catch (ErrorException $e) { |
| 34 | 34 | } catch (Exception $e) { |
| 35 | 35 | } |
| 36 | - $className = "App\\Babel\\Extension\\$name\\$monitorProvider"; |
|
| 36 | + $className="App\\Babel\\Extension\\$name\\$monitorProvider"; |
|
| 37 | 37 | if (class_exists($className)) { |
| 38 | 38 | return new $className(); |
| 39 | 39 | } else { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | if (!function_exists('emailVerified')) { |
| 54 | 54 | function emailVerified() |
| 55 | 55 | { |
| 56 | - if(Auth::check()){ |
|
| 56 | + if (Auth::check()) { |
|
| 57 | 57 | return !is_null(Auth::user()->email_verified_at); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,20 +61,20 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | -if (! function_exists('babel_path')) { |
|
| 64 | +if (!function_exists('babel_path')) { |
|
| 65 | 65 | /** |
| 66 | 66 | * Get the path to the application folder. |
| 67 | 67 | * |
| 68 | 68 | * @param string $path |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - function babel_path($path = '') |
|
| 71 | + function babel_path($path='') |
|
| 72 | 72 | { |
| 73 | 73 | return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -if (! function_exists('glob_recursive')) { |
|
| 77 | +if (!function_exists('glob_recursive')) { |
|
| 78 | 78 | /** |
| 79 | 79 | * Find pathnames matching a pattern recursively. |
| 80 | 80 | * |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | * @param int $flags Valid flags: GLOB_MARK |
| 83 | 83 | * @return array|false an array containing the matched files/directories, an empty array if no file matched or false on error. |
| 84 | 84 | */ |
| 85 | - function glob_recursive($pattern, $flags = 0) |
|
| 85 | + function glob_recursive($pattern, $flags=0) |
|
| 86 | 86 | { |
| 87 | - $files = glob($pattern, $flags); |
|
| 88 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
| 89 | - $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 87 | + $files=glob($pattern, $flags); |
|
| 88 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
| 89 | + $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 90 | 90 | } |
| 91 | 91 | return $files; |
| 92 | 92 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | if (!function_exists('adminMenu')) { |
| 96 | 96 | function adminMenu() |
| 97 | 97 | { |
| 98 | - return json_decode(file_get_contents(app_path('Admin/menu.json')),true); |
|
| 98 | + return json_decode(file_get_contents(app_path('Admin/menu.json')), true); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | private $member_data; |
| 17 | 17 | private $config; |
| 18 | 18 | |
| 19 | - public function __construct($data, $config = []) |
|
| 19 | + public function __construct($data, $config=[]) |
|
| 20 | 20 | { |
| 21 | - if ($config['mode'] == 'contest') { |
|
| 22 | - $this->contest_data = $data['contest_data']; |
|
| 23 | - $this->member_data = $data['member_data']; |
|
| 21 | + if ($config['mode']=='contest') { |
|
| 22 | + $this->contest_data=$data['contest_data']; |
|
| 23 | + $this->member_data=$data['member_data']; |
|
| 24 | 24 | } else { |
| 25 | - $this->member_data = $data['member_data']; |
|
| 26 | - $this->tag_problems = $data['tag_problems']; |
|
| 25 | + $this->member_data=$data['member_data']; |
|
| 26 | + $this->tag_problems=$data['tag_problems']; |
|
| 27 | 27 | } |
| 28 | - $this->config = $config; |
|
| 28 | + $this->config=$config; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | public function registerEvents(): array |
| 35 | 35 | { |
| 36 | 36 | return [ |
| 37 | - AfterSheet::class => function (AfterSheet $event) { |
|
| 38 | - if ($this->config['mode'] === 'contest') { |
|
| 39 | - $mergeCell = ['A1:A2','B1:E1']; |
|
| 37 | + AfterSheet::class => function(AfterSheet $event) { |
|
| 38 | + if ($this->config['mode']==='contest') { |
|
| 39 | + $mergeCell=['A1:A2', 'B1:E1']; |
|
| 40 | 40 | foreach ($this->contest_data as $c) { |
| 41 | 41 | array_push($mergeCell, $this->mergeCellColumnNext()); |
| 42 | 42 | } |
@@ -51,44 +51,44 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function collection() |
| 53 | 53 | { |
| 54 | - $maxium = $this->config['maxium'] ?? false; |
|
| 55 | - $percent = $this->config['percent'] ?? false; |
|
| 54 | + $maxium=$this->config['maxium'] ?? false; |
|
| 55 | + $percent=$this->config['percent'] ?? false; |
|
| 56 | 56 | |
| 57 | - if ($this->config['mode'] == 'contest') { |
|
| 58 | - $row_1 = ['Member','Total','','','']; |
|
| 59 | - $row_2 = ['','Elo','Rank','Solved','Penalty']; |
|
| 57 | + if ($this->config['mode']=='contest') { |
|
| 58 | + $row_1=['Member', 'Total', '', '', '']; |
|
| 59 | + $row_2=['', 'Elo', 'Rank', 'Solved', 'Penalty']; |
|
| 60 | 60 | foreach ($this->contest_data as $contest) { |
| 61 | 61 | array_push($row_1, $contest['name'], ''); |
| 62 | 62 | array_push($row_2, 'Solved', 'Penalty'); |
| 63 | 63 | } |
| 64 | - $data = [$row_1,$row_2]; |
|
| 64 | + $data=[$row_1, $row_2]; |
|
| 65 | 65 | foreach ($this->member_data as $member) { |
| 66 | - $display_name = $member['name']; |
|
| 66 | + $display_name=$member['name']; |
|
| 67 | 67 | if (!empty($member['nick_name'])) { |
| 68 | - $display_name .= ' ('.$member['nick_name'].')'; |
|
| 68 | + $display_name.=' ('.$member['nick_name'].')'; |
|
| 69 | 69 | } |
| 70 | - $row = [ |
|
| 70 | + $row=[ |
|
| 71 | 71 | $display_name, |
| 72 | 72 | $member['elo'], |
| 73 | 73 | !empty($member['rank_ave']) ? round($member['rank_ave'], 1) : '-', |
| 74 | - $percent === 'true' ? ($member['problem_all'] != 0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-'). ' %' |
|
| 75 | - : ($maxium === 'true' ? $member['solved_all'] . ' / ' . $member['problem_all'] : $member['solved_all']), |
|
| 74 | + $percent==='true' ? ($member['problem_all']!=0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-').' %' |
|
| 75 | + : ($maxium==='true' ? $member['solved_all'].' / '.$member['problem_all'] : $member['solved_all']), |
|
| 76 | 76 | round($member['penalty']), |
| 77 | 77 | ]; |
| 78 | 78 | foreach ($this->contest_data as $contest) { |
| 79 | 79 | if (in_array($contest['cid'], array_keys($member['contest_detial']))) { |
| 80 | - $contest_detial = $member['contest_detial'][$contest['cid']]; |
|
| 80 | + $contest_detial=$member['contest_detial'][$contest['cid']]; |
|
| 81 | 81 | array_push( |
| 82 | 82 | $row, |
| 83 | - $percent === 'true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1) . ' %') |
|
| 84 | - : ($maxium === 'true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']), |
|
| 83 | + $percent==='true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1).' %') |
|
| 84 | + : ($maxium==='true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']), |
|
| 85 | 85 | round($contest_detial['penalty']) |
| 86 | 86 | ); |
| 87 | 87 | } else { |
| 88 | 88 | array_push( |
| 89 | 89 | $row, |
| 90 | - $percent === 'true' ? '- %' |
|
| 91 | - : ($maxium === 'true' ? '- / -' : ' - '), |
|
| 90 | + $percent==='true' ? '- %' |
|
| 91 | + : ($maxium==='true' ? '- / -' : ' - '), |
|
| 92 | 92 | 0 |
| 93 | 93 | ); |
| 94 | 94 | } |
@@ -96,27 +96,27 @@ discard block |
||
| 96 | 96 | array_push($data, $row); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - $row_1 = ['Member']; |
|
| 100 | - $row_2 = ['']; |
|
| 99 | + $row_1=['Member']; |
|
| 100 | + $row_2=['']; |
|
| 101 | 101 | foreach ($this->tag_problems as $tag => $tag_problem_set) { |
| 102 | 102 | array_push($row_1, $tag); |
| 103 | 103 | array_push($row_2, 'Solved'); |
| 104 | 104 | } |
| 105 | - $data = [$row_1,$row_2]; |
|
| 105 | + $data=[$row_1, $row_2]; |
|
| 106 | 106 | foreach ($this->member_data as $member) { |
| 107 | - $display_name = $member['name']; |
|
| 107 | + $display_name=$member['name']; |
|
| 108 | 108 | if (!empty($member['nick_name'])) { |
| 109 | - $display_name .= ' ('.$member['nick_name'].')'; |
|
| 109 | + $display_name.=' ('.$member['nick_name'].')'; |
|
| 110 | 110 | } |
| 111 | - $row = [ |
|
| 111 | + $row=[ |
|
| 112 | 112 | $display_name, |
| 113 | 113 | ]; |
| 114 | 114 | foreach ($member['completion'] as $tag => $tag_completion) { |
| 115 | - $count = count($tag_completion); |
|
| 116 | - $solved = eval('return '.join('+', array_values($tag_completion)).';'); |
|
| 115 | + $count=count($tag_completion); |
|
| 116 | + $solved=eval('return '.join('+', array_values($tag_completion)).';'); |
|
| 117 | 117 | array_push( |
| 118 | 118 | $row, |
| 119 | - $percent === 'true' ? (round($solved / $count * 100, 1) . ' %') : ($maxium === 'true' ? $solved .' / '.$count : $solved) |
|
| 119 | + $percent==='true' ? (round($solved / $count * 100, 1).' %') : ($maxium==='true' ? $solved.' / '.$count : $solved) |
|
| 120 | 120 | ); |
| 121 | 121 | } |
| 122 | 122 | array_push($data, $row); |
@@ -127,33 +127,33 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | private function mergeCellColumnNext() |
| 129 | 129 | { |
| 130 | - static $columns = [ |
|
| 131 | - [3],[4] |
|
| 130 | + static $columns=[ |
|
| 131 | + [3], [4] |
|
| 132 | 132 | ]; |
| 133 | - $columns_str = ['','']; |
|
| 134 | - $chars = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
| 133 | + $columns_str=['', '']; |
|
| 134 | + $chars=str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
| 135 | 135 | foreach ($columns as $key => &$column) { |
| 136 | - $column[0] += 2; |
|
| 137 | - if ($column[0] > 25) { |
|
| 136 | + $column[0]+=2; |
|
| 137 | + if ($column[0]>25) { |
|
| 138 | 138 | if (isset($column[1])) { |
| 139 | - $column[1] += 1; |
|
| 140 | - if ($column[1] > 25) { |
|
| 139 | + $column[1]+=1; |
|
| 140 | + if ($column[1]>25) { |
|
| 141 | 141 | if (isset($column[2])) { |
| 142 | - $column[2] += 1; |
|
| 142 | + $column[2]+=1; |
|
| 143 | 143 | } else { |
| 144 | - $column[2] = 0; |
|
| 144 | + $column[2]=0; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } else { |
| 148 | - $column[1] = 0; |
|
| 148 | + $column[1]=0; |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | - $columns_str[$key] = ''; |
|
| 152 | - $reverse_column = array_reverse($column); |
|
| 151 | + $columns_str[$key]=''; |
|
| 152 | + $reverse_column=array_reverse($column); |
|
| 153 | 153 | foreach ($reverse_column as $ord) { |
| 154 | - $columns_str[$key] .= $chars[$ord]; |
|
| 154 | + $columns_str[$key].=$chars[$ord]; |
|
| 155 | 155 | } |
| 156 | - $columns_str[$key] .= '1'; |
|
| 156 | + $columns_str[$key].='1'; |
|
| 157 | 157 | } |
| 158 | 158 | return $columns_str[0].':'.$columns_str[1]; |
| 159 | 159 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | { |
| 14 | 14 | $version=UpdateModel::checkUpdate(); |
| 15 | 15 | |
| 16 | - $status = [ |
|
| 17 | - ['name' => 'NOJ Version', 'value' => version()], |
|
| 18 | - ['name' => 'Lastest Version', 'value' => is_null($version)?'Failed to fetch latest version':$version["name"]], |
|
| 19 | - ['name' => 'Problems', 'value' => \App\Models\Eloquent\ProblemModel::count()], |
|
| 20 | - ['name' => 'Solutions', 'value' => \App\Models\Eloquent\ProblemSolutionModel::count()], |
|
| 21 | - ['name' => 'Submissions', 'value' => \App\Models\Eloquent\SubmissionModel::count()], |
|
| 22 | - ['name' => 'Contests', 'value' => \App\Models\Eloquent\ContestModel::count()], |
|
| 23 | - ['name' => 'Users', 'value' => \App\Models\Eloquent\UserModel::count()], |
|
| 24 | - ['name' => 'Groups', 'value' => \App\Models\Eloquent\GroupModel::count()], |
|
| 16 | + $status=[ |
|
| 17 | + ['name' => 'NOJ Version', 'value' => version()], |
|
| 18 | + ['name' => 'Lastest Version', 'value' => is_null($version) ? 'Failed to fetch latest version' : $version["name"]], |
|
| 19 | + ['name' => 'Problems', 'value' => \App\Models\Eloquent\ProblemModel::count()], |
|
| 20 | + ['name' => 'Solutions', 'value' => \App\Models\Eloquent\ProblemSolutionModel::count()], |
|
| 21 | + ['name' => 'Submissions', 'value' => \App\Models\Eloquent\SubmissionModel::count()], |
|
| 22 | + ['name' => 'Contests', 'value' => \App\Models\Eloquent\ContestModel::count()], |
|
| 23 | + ['name' => 'Users', 'value' => \App\Models\Eloquent\UserModel::count()], |
|
| 24 | + ['name' => 'Groups', 'value' => \App\Models\Eloquent\GroupModel::count()], |
|
| 25 | 25 | ]; |
| 26 | 26 | |
| 27 | 27 | return view('admin::dashboard.general', [ |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $extensionList=ExtensionModel::list(); |
| 34 | 34 | |
| 35 | - if(empty($extensionList)){ |
|
| 35 | + if (empty($extensionList)) { |
|
| 36 | 36 | return redirect('/admin'); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | $router->resource('contests', ContestController::class); |
| 18 | 18 | $router->resource('groups', GroupController::class); |
| 19 | 19 | |
| 20 | - Route::group(['prefix' => 'babel'], function (Router $router) { |
|
| 20 | + Route::group(['prefix' => 'babel'], function(Router $router) { |
|
| 21 | 21 | $router->get('/', 'BabelController@index'); |
| 22 | 22 | }); |
| 23 | 23 | |