@@ -66,20 +66,20 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -if (! function_exists('babel_path')) { |
|
| 69 | +if (!function_exists('babel_path')) { |
|
| 70 | 70 | /** |
| 71 | 71 | * Get the path to the application folder. |
| 72 | 72 | * |
| 73 | 73 | * @param string $path |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - function babel_path($path = '') |
|
| 76 | + function babel_path($path='') |
|
| 77 | 77 | { |
| 78 | 78 | return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -if (! function_exists('glob_recursive')) { |
|
| 82 | +if (!function_exists('glob_recursive')) { |
|
| 83 | 83 | /** |
| 84 | 84 | * Find pathnames matching a pattern recursively. |
| 85 | 85 | * |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | * @param int $flags Valid flags: GLOB_MARK |
| 88 | 88 | * @return array|false an array containing the matched files/directories, an empty array if no file matched or false on error. |
| 89 | 89 | */ |
| 90 | - function glob_recursive($pattern, $flags = 0) |
|
| 90 | + function glob_recursive($pattern, $flags=0) |
|
| 91 | 91 | { |
| 92 | - $files = glob($pattern, $flags); |
|
| 93 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
| 94 | - $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 92 | + $files=glob($pattern, $flags); |
|
| 93 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
| 94 | + $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags)); |
|
| 95 | 95 | } |
| 96 | 96 | return $files; |
| 97 | 97 | } |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | function delFile($dirName) |
| 126 | 126 | { |
| 127 | 127 | if (file_exists($dirName) && $handle=opendir($dirName)) { |
| 128 | - while (false!==($item = readdir($handle))) { |
|
| 129 | - if ($item!= "." && $item != "..") { |
|
| 128 | + while (false!==($item=readdir($handle))) { |
|
| 129 | + if ($item!="." && $item!="..") { |
|
| 130 | 130 | if (file_exists($dirName.'/'.$item) && is_dir($dirName.'/'.$item)) { |
| 131 | 131 | delFile($dirName.'/'.$item); |
| 132 | 132 | } else { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | if (!function_exists('convertMarkdownToHtml')) { |
| 145 | 145 | function convertMarkdownToHtml($md) |
| 146 | 146 | { |
| 147 | - return is_string($md)?Markdown::convertToHtml($md):''; |
|
| 147 | + return is_string($md) ?Markdown::convertToHtml($md) : ''; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $periods[$j]=__("helper.time.singular.$periods[$j]"); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return __("helper.time.formatter",[ |
|
| 191 | + return __("helper.time.formatter", [ |
|
| 192 | 192 | "time" => $difference, |
| 193 | 193 | "unit" => $periods[$j], |
| 194 | 194 | "tense" => $tense, |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | if (!function_exists('latex2Image')) { |
| 214 | 214 | function latex2Image($content) |
| 215 | 215 | { |
| 216 | - $callback = function ($matches) use (&$patch, &$display) { |
|
| 217 | - [$url,$width,$height]=LatexModel::info("$patch$matches[1]$patch"); |
|
| 216 | + $callback=function($matches) use (&$patch, &$display) { |
|
| 217 | + [$url, $width, $height]=LatexModel::info("$patch$matches[1]$patch"); |
|
| 218 | 218 | return "<img src=\"$url\" style=\"display: $display;\" class=\"rendered-tex\" width=\"$width\" height=\"$height\">"; |
| 219 | 219 | }; |
| 220 | - $patch = '$'; |
|
| 221 | - $display = 'inline-block'; |
|
| 222 | - $content = preg_replace_callback('/\\$\\$\\$(.*?)\\$\\$\\$/', $callback, $content); |
|
| 223 | - $content = preg_replace_callback('/\\\\\\((.*?)\\\\\\)/', $callback, $content); |
|
| 224 | - $patch = '$$'; |
|
| 225 | - $display = 'block'; |
|
| 226 | - $content = preg_replace_callback('/\\$\\$(.*?)\\$\\$/', $callback, $content); |
|
| 227 | - $content = preg_replace_callback('/\\\\\\[(.*?)\\\\\\]/', $callback, $content); |
|
| 220 | + $patch='$'; |
|
| 221 | + $display='inline-block'; |
|
| 222 | + $content=preg_replace_callback('/\\$\\$\\$(.*?)\\$\\$\\$/', $callback, $content); |
|
| 223 | + $content=preg_replace_callback('/\\\\\\((.*?)\\\\\\)/', $callback, $content); |
|
| 224 | + $patch='$$'; |
|
| 225 | + $display='block'; |
|
| 226 | + $content=preg_replace_callback('/\\$\\$(.*?)\\$\\$/', $callback, $content); |
|
| 227 | + $content=preg_replace_callback('/\\\\\\[(.*?)\\\\\\]/', $callback, $content); |
|
| 228 | 228 | return $content; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $locale=Str::lower(App::getLocale()); |
| 236 | 236 | $vscodelocale=''; |
| 237 | - if(in_array($locale,['de','es','fr','it','ja','ko','ru','zh-cn','zh-tw'])){ |
|
| 237 | + if (in_array($locale, ['de', 'es', 'fr', 'it', 'ja', 'ko', 'ru', 'zh-cn', 'zh-tw'])) { |
|
| 238 | 238 | $vscodelocale=$locale; |
| 239 | 239 | } |
| 240 | 240 | return $vscodelocale; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if (!function_exists('getTheme')) { |
| 245 | 245 | function getTheme($id=null) |
| 246 | 246 | { |
| 247 | - if(is_null($id)){ |
|
| 247 | + if (is_null($id)) { |
|
| 248 | 248 | $id=config('app.theme'); |
| 249 | 249 | } |
| 250 | 250 | return Theme::getTheme($id); |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | if (!function_exists('setting')) { |
| 255 | 255 | function setting($identifier, $default=null) |
| 256 | 256 | { |
| 257 | - if(is_array($identifier)) { |
|
| 258 | - foreach($identifier as $key=>$content){ |
|
| 257 | + if (is_array($identifier)) { |
|
| 258 | + foreach ($identifier as $key=>$content) { |
|
| 259 | 259 | AppSettings::set($key, $content); |
| 260 | 260 | } |
| 261 | 261 | return true; |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | public function boot() |
| 15 | 15 | { |
| 16 | 16 | // |
| 17 | - if(config('app.multidomain')) { |
|
| 17 | + if (config('app.multidomain')) { |
|
| 18 | 18 | config(['app.url' => request()->root()]); |
| 19 | 19 | config(['filesystems.disks.public.url' => request()->root().'/storage']); |
| 20 | 20 | config(['filesystems.disks.NOJPublic.url' => request()->root()]); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable; |
| 25 | 25 | |
| 26 | - public $tries = 1; |
|
| 26 | + public $tries=1; |
|
| 27 | 27 | public $progressVal=40; |
| 28 | 28 | public $stepVal=0; |
| 29 | 29 | protected $cid; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $cid=$this->cid; |
| 58 | 58 | $contest=EloquentContestModel::find($cid); |
| 59 | 59 | |
| 60 | - if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 60 | + if (!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 61 | 61 | |
| 62 | 62 | $acceptedSubmissions=$contest->submissions->whereIn('verdict', [ |
| 63 | 63 | 'Accepted', |
@@ -72,25 +72,25 @@ discard block |
||
| 72 | 72 | $probLangs=[]; |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - foreach($acceptedSubmissions as $submission){ |
|
| 75 | + foreach ($acceptedSubmissions as $submission) { |
|
| 76 | 76 | $lang=$submission->compiler->lang; |
| 77 | - if(Arr::has($this->supportLang, $lang)){ |
|
| 77 | + if (Arr::has($this->supportLang, $lang)) { |
|
| 78 | 78 | $prob=$probIndex[$submission->pid]; |
| 79 | 79 | $lang=$this->supportLang[$lang]; |
| 80 | 80 | $ext=$lang; |
| 81 | 81 | Storage::put("contest/anticheat/$cid/raw/$prob/$lang/[$submission->uid][$submission->sid].$ext", $submission->solution); |
| 82 | - if(!isset($probLangs[$prob][$lang])) $probLangs[$prob][$lang]=1; |
|
| 82 | + if (!isset($probLangs[$prob][$lang])) $probLangs[$prob][$lang]=1; |
|
| 83 | 83 | else $probLangs[$prob][$lang]++; |
| 84 | 84 | $totProb++; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $this->setProgressNow(40); |
| 89 | - $this->stepVal=50/($totProb*2); |
|
| 89 | + $this->stepVal=50 / ($totProb * 2); |
|
| 90 | 90 | $this->progressVal=40; |
| 91 | 91 | |
| 92 | - foreach($probLangs as $prob=>$langs){ |
|
| 93 | - foreach($langs as $lang=>$submissionCount){ |
|
| 92 | + foreach ($probLangs as $prob=>$langs) { |
|
| 93 | + foreach ($langs as $lang=>$submissionCount) { |
|
| 94 | 94 | $this->detectPlagiarism([ |
| 95 | 95 | 'lang'=>$lang, |
| 96 | 96 | 'cid'=>$cid, |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | $this->setProgressNow(100); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - private function incProgress($factor=1){ |
|
| 109 | - $this->progressVal+=($this->stepVal)*$factor; |
|
| 108 | + private function incProgress($factor=1) { |
|
| 109 | + $this->progressVal+=($this->stepVal) * $factor; |
|
| 110 | 110 | $this->setProgressNow(intval($this->progressVal)); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | $cid=$config['cid']; |
| 117 | 117 | $prob=$config['prob']; |
| 118 | 118 | $count=$config['count']; |
| 119 | - if (strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN') { |
|
| 119 | + if (strtoupper(substr(php_uname('s'), 0, 3))==='WIN') { |
|
| 120 | 120 | // Windows |
| 121 | 121 | $exe=base_path('binary'.DIRECTORY_SEPARATOR.'win'.DIRECTORY_SEPARATOR.'sim_'.$lang.'.exe'); |
| 122 | 122 | } else { |
| 123 | 123 | // Linux or else |
| 124 | - $process = new Process(['chmod', '+x', base_path('binary'.DIRECTORY_SEPARATOR.'linux'.DIRECTORY_SEPARATOR.'sim*')]); |
|
| 124 | + $process=new Process(['chmod', '+x', base_path('binary'.DIRECTORY_SEPARATOR.'linux'.DIRECTORY_SEPARATOR.'sim*')]); |
|
| 125 | 125 | $process->run(); |
| 126 | 126 | $exe=base_path('binary'.DIRECTORY_SEPARATOR.'linux'.DIRECTORY_SEPARATOR.'sim_'.$lang); |
| 127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // wildcardly add all files |
| 132 | 132 | $exec.='*.'.$lang; |
| 133 | 133 | |
| 134 | - $process = new Process($exec); |
|
| 134 | + $process=new Process($exec); |
|
| 135 | 135 | $process->setWorkingDirectory(Storage::path('contest'.DIRECTORY_SEPARATOR.'anticheat'.DIRECTORY_SEPARATOR.$cid.DIRECTORY_SEPARATOR.'raw'.DIRECTORY_SEPARATOR.$prob.DIRECTORY_SEPARATOR.$lang)); |
| 136 | 136 | $process->run(); |
| 137 | 137 | if (!$process->isSuccessful()) { |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | $this->incProgress($count); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - private function afterWork($cid,$prob,$lang, $rawContent) |
|
| 148 | + private function afterWork($cid, $prob, $lang, $rawContent) |
|
| 149 | 149 | { |
| 150 | - foreach(preg_split('~[\r\n]+~', $rawContent) as $line){ |
|
| 151 | - if(blank($line) or ctype_space($line)) continue; |
|
| 150 | + foreach (preg_split('~[\r\n]+~', $rawContent) as $line) { |
|
| 151 | + if (blank($line) or ctype_space($line)) continue; |
|
| 152 | 152 | // [3057][64659].c++ consists for 100 % of [3057][64679].c++ material |
| 153 | 153 | $line=explode('%', $line); |
| 154 | - if(!isset($line[1])) continue; |
|
| 155 | - [$uid1,$sid1,$percentage]=sscanf($line[0], "[%d][%d].$lang consists for %d "); |
|
| 156 | - [$uid2,$sid2]=sscanf($line[1], " of [%d][%d].$lang material"); |
|
| 157 | - if($uid1==$uid2) continue; |
|
| 154 | + if (!isset($line[1])) continue; |
|
| 155 | + [$uid1, $sid1, $percentage]=sscanf($line[0], "[%d][%d].$lang consists for %d "); |
|
| 156 | + [$uid2, $sid2]=sscanf($line[1], " of [%d][%d].$lang material"); |
|
| 157 | + if ($uid1==$uid2) continue; |
|
| 158 | 158 | $username1=User::find($uid1)->name; |
| 159 | 159 | $username2=User::find($uid2)->name; |
| 160 | 160 | $this->retArr[]=[ |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | private function finalizeReport() |
| 175 | 175 | { |
| 176 | 176 | $retArr=$this->retArr; |
| 177 | - usort($retArr, function($a, $b){ |
|
| 177 | + usort($retArr, function($a, $b) { |
|
| 178 | 178 | return $b['similarity']<=>$a['similarity']; |
| 179 | 179 | }); |
| 180 | 180 | Log::debug($retArr); |
| 181 | 181 | $cid=$this->cid; |
| 182 | 182 | $index=0; |
| 183 | 183 | $generalPage="<table><tr><th>Language</th><th>Submission 1</th><th>Submission 2</th><th>Sub 1 Consists for x% of Sub 2</th></tr>"; |
| 184 | - foreach($retArr as $ret) { |
|
| 184 | + foreach ($retArr as $ret) { |
|
| 185 | 185 | $lang=strtoupper($ret['lang']); |
| 186 | 186 | $sub1=$ret['sub1']; |
| 187 | 187 | $sub2=$ret['sub2']; |
@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | $cid=$this->cid; |
| 58 | 58 | $contest=EloquentContestModel::find($cid); |
| 59 | 59 | |
| 60 | - if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 60 | + if(!$contest->isJudgingComplete()) { |
|
| 61 | + throw new Exception('Judging Incompleted'); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | $acceptedSubmissions=$contest->submissions->whereIn('verdict', [ |
| 63 | 65 | 'Accepted', |
@@ -79,8 +81,11 @@ discard block |
||
| 79 | 81 | $lang=$this->supportLang[$lang]; |
| 80 | 82 | $ext=$lang; |
| 81 | 83 | Storage::put("contest/anticheat/$cid/raw/$prob/$lang/[$submission->uid][$submission->sid].$ext", $submission->solution); |
| 82 | - if(!isset($probLangs[$prob][$lang])) $probLangs[$prob][$lang]=1; |
|
| 83 | - else $probLangs[$prob][$lang]++; |
|
| 84 | + if(!isset($probLangs[$prob][$lang])) { |
|
| 85 | + $probLangs[$prob][$lang]=1; |
|
| 86 | + } else { |
|
| 87 | + $probLangs[$prob][$lang]++; |
|
| 88 | + } |
|
| 84 | 89 | $totProb++; |
| 85 | 90 | } |
| 86 | 91 | } |
@@ -148,13 +153,19 @@ discard block |
||
| 148 | 153 | private function afterWork($cid,$prob,$lang, $rawContent) |
| 149 | 154 | { |
| 150 | 155 | foreach(preg_split('~[\r\n]+~', $rawContent) as $line){ |
| 151 | - if(blank($line) or ctype_space($line)) continue; |
|
| 156 | + if(blank($line) or ctype_space($line)) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 152 | 159 | // [3057][64659].c++ consists for 100 % of [3057][64679].c++ material |
| 153 | 160 | $line=explode('%', $line); |
| 154 | - if(!isset($line[1])) continue; |
|
| 161 | + if(!isset($line[1])) { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 155 | 164 | [$uid1,$sid1,$percentage]=sscanf($line[0], "[%d][%d].$lang consists for %d "); |
| 156 | 165 | [$uid2,$sid2]=sscanf($line[1], " of [%d][%d].$lang material"); |
| 157 | - if($uid1==$uid2) continue; |
|
| 166 | + if($uid1==$uid2) { |
|
| 167 | + continue; |
|
| 168 | + } |
|
| 158 | 169 | $username1=User::find($uid1)->name; |
| 159 | 170 | $username2=User::find($uid2)->name; |
| 160 | 171 | $this->retArr[]=[ |
@@ -142,23 +142,23 @@ |
||
| 142 | 142 | $form->select('leader_uid', 'Group Leader')->options(User::all()->pluck('name', 'id'))->required(); |
| 143 | 143 | } |
| 144 | 144 | $form->ignore(['leader_uid']); |
| 145 | - $form->saving(function (Form $form){ |
|
| 146 | - $err = function ($msg, $title = 'Error occur.') { |
|
| 147 | - $error = new MessageBag([ |
|
| 145 | + $form->saving(function(Form $form) { |
|
| 146 | + $err=function($msg, $title='Error occur.') { |
|
| 147 | + $error=new MessageBag([ |
|
| 148 | 148 | 'title' => $title, |
| 149 | 149 | 'message' => $msg, |
| 150 | 150 | ]); |
| 151 | 151 | return back()->with(compact('error')); |
| 152 | 152 | }; |
| 153 | - $gcode = $form->gcode; |
|
| 154 | - $g = Group::where('gcode',$gcode)->first(); |
|
| 153 | + $gcode=$form->gcode; |
|
| 154 | + $g=Group::where('gcode', $gcode)->first(); |
|
| 155 | 155 | //check gcode has been token. |
| 156 | - $gid = $form->pid ?? null; |
|
| 157 | - if(!empty($gcode) && !blank($g) && $g->gid != $gid){ |
|
| 156 | + $gid=$form->pid ?? null; |
|
| 157 | + if (!empty($gcode) && !blank($g) && $g->gid!=$gid) { |
|
| 158 | 158 | $err('Gcode has been token', 'Error occur.'); |
| 159 | 159 | } |
| 160 | 160 | }); |
| 161 | - $form->saved(function (Form $form) { |
|
| 161 | + $form->saved(function(Form $form) { |
|
| 162 | 162 | $form->model()->members()->saveMany([new GroupMember([ |
| 163 | 163 | 'gid' => $form->model()->gid, |
| 164 | 164 | 'uid' => request('leader_uid'), |
@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | $version=UpdateModel::checkUpdate(); |
| 17 | 17 | |
| 18 | - $status = [ |
|
| 19 | - ['name' => __("admin.home.version"), 'value' => version()], |
|
| 20 | - ['name' => __("admin.home.latest"), 'value' => is_null($version)?'Failed to fetch latest version':$version["name"]], |
|
| 21 | - ['name' => __("admin.home.problems"), 'value' => \App\Models\Eloquent\Problem::count()], |
|
| 22 | - ['name' => __("admin.home.solutions"), 'value' => \App\Models\Eloquent\ProblemSolution::count()], |
|
| 18 | + $status=[ |
|
| 19 | + ['name' => __("admin.home.version"), 'value' => version()], |
|
| 20 | + ['name' => __("admin.home.latest"), 'value' => is_null($version) ? 'Failed to fetch latest version' : $version["name"]], |
|
| 21 | + ['name' => __("admin.home.problems"), 'value' => \App\Models\Eloquent\Problem::count()], |
|
| 22 | + ['name' => __("admin.home.solutions"), 'value' => \App\Models\Eloquent\ProblemSolution::count()], |
|
| 23 | 23 | ['name' => __("admin.home.submissions"), 'value' => \App\Models\Eloquent\Submission::count()], |
| 24 | - ['name' => __("admin.home.contests"), 'value' => \App\Models\Eloquent\Contest::count()], |
|
| 25 | - ['name' => __("admin.home.users"), 'value' => \App\Models\Eloquent\User::count()], |
|
| 26 | - ['name' => __("admin.home.groups"), 'value' => \App\Models\Eloquent\Group::count()], |
|
| 24 | + ['name' => __("admin.home.contests"), 'value' => \App\Models\Eloquent\Contest::count()], |
|
| 25 | + ['name' => __("admin.home.users"), 'value' => \App\Models\Eloquent\User::count()], |
|
| 26 | + ['name' => __("admin.home.groups"), 'value' => \App\Models\Eloquent\Group::count()], |
|
| 27 | 27 | ]; |
| 28 | 28 | |
| 29 | 29 | return view('admin::dashboard.general', [ |
@@ -37,66 +37,66 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function environment() |
| 39 | 39 | { |
| 40 | - $envs = [ |
|
| 41 | - ['name' => __('admin.home.envs.php'), 'value' => 'PHP/'.PHP_VERSION], |
|
| 42 | - ['name' => __('admin.home.envs.laravel'), 'value' => app()->version()], |
|
| 43 | - ['name' => __('admin.home.envs.cgi'), 'value' => php_sapi_name()], |
|
| 44 | - ['name' => __('admin.home.envs.uname'), 'value' => php_uname()], |
|
| 45 | - ['name' => __('admin.home.envs.server'), 'value' => Arr::get($_SERVER, 'SERVER_SOFTWARE')], |
|
| 46 | - |
|
| 47 | - ['name' => __('admin.home.envs.cache'), 'value' => config('cache.default')], |
|
| 48 | - ['name' => __('admin.home.envs.session'), 'value' => config('session.driver')], |
|
| 49 | - ['name' => __('admin.home.envs.queue'), 'value' => config('queue.default')], |
|
| 50 | - |
|
| 51 | - ['name' => __('admin.home.envs.timezone'), 'value' => config('app.timezone')], |
|
| 52 | - ['name' => __('admin.home.envs.locale'), 'value' => config('app.locale')], |
|
| 53 | - ['name' => __('admin.home.envs.env'), 'value' => config('app.env')], |
|
| 54 | - ['name' => __('admin.home.envs.url'), 'value' => config('app.url')], |
|
| 55 | - |
|
| 56 | - ['name' => __('admin.home.envs.tlsv13'), 'value' => ["Not Supported", "Supported"][in_array("tlsv1.3", stream_get_transports())]], |
|
| 40 | + $envs=[ |
|
| 41 | + ['name' => __('admin.home.envs.php'), 'value' => 'PHP/'.PHP_VERSION], |
|
| 42 | + ['name' => __('admin.home.envs.laravel'), 'value' => app()->version()], |
|
| 43 | + ['name' => __('admin.home.envs.cgi'), 'value' => php_sapi_name()], |
|
| 44 | + ['name' => __('admin.home.envs.uname'), 'value' => php_uname()], |
|
| 45 | + ['name' => __('admin.home.envs.server'), 'value' => Arr::get($_SERVER, 'SERVER_SOFTWARE')], |
|
| 46 | + |
|
| 47 | + ['name' => __('admin.home.envs.cache'), 'value' => config('cache.default')], |
|
| 48 | + ['name' => __('admin.home.envs.session'), 'value' => config('session.driver')], |
|
| 49 | + ['name' => __('admin.home.envs.queue'), 'value' => config('queue.default')], |
|
| 50 | + |
|
| 51 | + ['name' => __('admin.home.envs.timezone'), 'value' => config('app.timezone')], |
|
| 52 | + ['name' => __('admin.home.envs.locale'), 'value' => config('app.locale')], |
|
| 53 | + ['name' => __('admin.home.envs.env'), 'value' => config('app.env')], |
|
| 54 | + ['name' => __('admin.home.envs.url'), 'value' => config('app.url')], |
|
| 55 | + |
|
| 56 | + ['name' => __('admin.home.envs.tlsv13'), 'value' => ["Not Supported", "Supported"][in_array("tlsv1.3", stream_get_transports())]], |
|
| 57 | 57 | ]; |
| 58 | 58 | |
| 59 | - foreach($envs as &$env){ |
|
| 60 | - $env['icon'] = "check-circle"; |
|
| 61 | - $env['color'] = "wemd-teal-text"; |
|
| 59 | + foreach ($envs as &$env) { |
|
| 60 | + $env['icon']="check-circle"; |
|
| 61 | + $env['color']="wemd-teal-text"; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // PHP Version Check |
| 65 | 65 | $installedVersion=new Version(PHP_VERSION); |
| 66 | 66 | $requireVersion=new Version("7.4.0"); |
| 67 | - if(!($installedVersion->isGreaterThan($requireVersion) || $installedVersion->getVersionString()===$requireVersion->getVersionString())){ |
|
| 68 | - $envs[0]['icon'] = "close-circle"; |
|
| 69 | - $envs[0]['color'] = "wemd-pink-text"; |
|
| 67 | + if (!($installedVersion->isGreaterThan($requireVersion) || $installedVersion->getVersionString()===$requireVersion->getVersionString())) { |
|
| 68 | + $envs[0]['icon']="close-circle"; |
|
| 69 | + $envs[0]['color']="wemd-pink-text"; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Cache Driver Check |
| 73 | - if(config('cache.default')!="redis"){ |
|
| 74 | - $envs[5]['icon'] = "close-circle"; |
|
| 75 | - $envs[5]['color'] = "wemd-pink-text"; |
|
| 73 | + if (config('cache.default')!="redis") { |
|
| 74 | + $envs[5]['icon']="close-circle"; |
|
| 75 | + $envs[5]['color']="wemd-pink-text"; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Session Driver Check |
| 79 | - if(config('session.driver')!="redis"){ |
|
| 80 | - $envs[6]['icon'] = "close-circle"; |
|
| 81 | - $envs[6]['color'] = "wemd-pink-text"; |
|
| 79 | + if (config('session.driver')!="redis") { |
|
| 80 | + $envs[6]['icon']="close-circle"; |
|
| 81 | + $envs[6]['color']="wemd-pink-text"; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Queue Driver Check |
| 85 | - if(config('queue.default')!="database"){ |
|
| 86 | - $envs[7]['icon'] = "close-circle"; |
|
| 87 | - $envs[7]['color'] = "wemd-pink-text"; |
|
| 85 | + if (config('queue.default')!="database") { |
|
| 86 | + $envs[7]['icon']="close-circle"; |
|
| 87 | + $envs[7]['color']="wemd-pink-text"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Locale Check |
| 91 | - if(!in_array(strtolower(config('app.locale')), ['en','zh-cn'])){ |
|
| 92 | - $envs[9]['icon'] = "close-circle"; |
|
| 93 | - $envs[9]['color'] = "wemd-pink-text"; |
|
| 91 | + if (!in_array(strtolower(config('app.locale')), ['en', 'zh-cn'])) { |
|
| 92 | + $envs[9]['icon']="close-circle"; |
|
| 93 | + $envs[9]['color']="wemd-pink-text"; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // TLSv1.3 Check |
| 97 | - if($envs[12]['value']=="Not Supported"){ |
|
| 98 | - $envs[12]['icon'] = "close-circle"; |
|
| 99 | - $envs[12]['color'] = "wemd-pink-text"; |
|
| 97 | + if ($envs[12]['value']=="Not Supported") { |
|
| 98 | + $envs[12]['icon']="close-circle"; |
|
| 99 | + $envs[12]['color']="wemd-pink-text"; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return view('admin::dashboard.environment', compact('envs')); |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | } |
| 121 | 121 | $form->text('name', __('admin.users.name'))->rules('required'); |
| 122 | 122 | $form->email('email', __('admin.users.email'))->rules('required'); |
| 123 | - if($form->isEditing()){ |
|
| 123 | + if ($form->isEditing()) { |
|
| 124 | 124 | $form->display('created_at', __('admin.created_at')); |
| 125 | 125 | $form->display('updated_at', __('admin.updated_at')); |
| 126 | 126 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected function form() |
| 40 | 40 | { |
| 41 | - $box = new Box(__('admin.settings.form.header')); |
|
| 41 | + $box=new Box(__('admin.settings.form.header')); |
|
| 42 | 42 | $box->style('success'); |
| 43 | 43 | $form=new Form(); |
| 44 | 44 | $form->simplemde('terms', __('admin.settings.form.terms'))->default(setting('terms'))->help(__('admin.settings.help.terms')); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected function grid() |
| 83 | 83 | { |
| 84 | - $grid = new Grid(new Announcement()); |
|
| 84 | + $grid=new Grid(new Announcement()); |
|
| 85 | 85 | |
| 86 | 86 | $grid->column('anid', 'ANID'); |
| 87 | 87 | $grid->column('user', __('admin.announcements.user'))->display(function() { |
| 88 | 88 | return $this->user->name; |
| 89 | - });; |
|
| 89 | + }); ; |
|
| 90 | 90 | $grid->column('title', __('admin.announcements.title'))->editable(); |
| 91 | 91 | $grid->column('created_at', __('admin.created_at')); |
| 92 | 92 | $grid->column('updated_at', __('admin.updated_at')); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | protected function detail($id) |
| 109 | 109 | { |
| 110 | - $show = new Show(Announcement::findOrFail($id)); |
|
| 110 | + $show=new Show(Announcement::findOrFail($id)); |
|
| 111 | 111 | |
| 112 | 112 | $show->field('anid', 'ANID'); |
| 113 | 113 | $show->field('user.name', __('admin.announcements.user')); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function form() |
| 128 | 128 | { |
| 129 | - $form = new Form(new Announcement()); |
|
| 129 | + $form=new Form(new Announcement()); |
|
| 130 | 130 | $form->text('title', __('admin.announcements.title'))->required(); |
| 131 | 131 | $form->simplemde('content', __('admin.announcements.content'))->help(__('admin.announcements.help.markdown'))->required(); |
| 132 | 132 | $form->select('uid', __('admin.announcements.user'))->options(User::all()->pluck('name', 'id'))->required(); |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | $form->select('public', 'Contest Publicity')->options([ |
| 146 | 146 | 0 => "Private", |
| 147 | 147 | 1 => "Public" |
| 148 | - ])->when(0, function (Form $form) { |
|
| 148 | + ])->when(0, function(Form $form) { |
|
| 149 | 149 | $form->switch('practice', 'Practice Contest')->default(false); |
| 150 | 150 | |
| 151 | 151 | $form->hidden('verified', 'Verified Contest')->default(0); |
| 152 | 152 | $form->hidden('rated', 'Rated Contest')->default(0); |
| 153 | 153 | $form->hidden('anticheated', 'AntiCheated Contest')->default(0); |
| 154 | 154 | $form->hidden('featured', 'Featured Contest')->default(0); |
| 155 | - })->when(1, function (Form $form) { |
|
| 155 | + })->when(1, function(Form $form) { |
|
| 156 | 156 | $form->hidden('practice', 'Practice Contest')->default(0); |
| 157 | 157 | |
| 158 | 158 | $form->switch('verified', 'Verified Contest')->default(true); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $form->switch('featured', 'Featured Contest')->default(true); |
| 162 | 162 | })->default(0)->required(); |
| 163 | 163 | $form->switch('desktop', 'Enable NOJ Desktop (Experimental)')->default(false); |
| 164 | - $form->hidden('is_rated',"is_rated")->default(0); |
|
| 164 | + $form->hidden('is_rated', "is_rated")->default(0); |
|
| 165 | 165 | $form->hidden('pdf', 'Provide PDF')->default(0); |
| 166 | 166 | |
| 167 | 167 | $form->divider(); |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | $form->text('custom_title', 'Custom Navigation Title'); |
| 199 | 199 | $form->image('custom_icon', 'Custom Navigation Icon')->uniqueName()->move("static/img/contest"); |
| 200 | 200 | $form->image('img', 'Contest Focus Image')->uniqueName()->move("static/img/contest"); |
| 201 | - $form->hasMany('problems', 'Contest Problems', function (Form\NestedForm $form) { |
|
| 201 | + $form->hasMany('problems', 'Contest Problems', function(Form\NestedForm $form) { |
|
| 202 | 202 | $form->number('number', 'Problem Numerical Index')->default(1)->required(); |
| 203 | 203 | $ncodeArr=[]; |
| 204 | - foreach(range('A', 'Z') as $alpha){ |
|
| 204 | + foreach (range('A', 'Z') as $alpha) { |
|
| 205 | 205 | $ncodeArr[$alpha]=$alpha; |
| 206 | 206 | } |
| 207 | 207 | $form->select('ncode', 'Problem Alphabetical Index')->options($ncodeArr)->default("A")->required(); |