@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable; |
| 17 | 17 | |
| 18 | - public $tries = 5; |
|
| 18 | + public $tries=5; |
|
| 19 | 19 | protected $cid; |
| 20 | 20 | protected $config; |
| 21 | 21 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'cover'=>false, |
| 34 | 34 | 'advice'=>false, |
| 35 | 35 | ]; |
| 36 | - $this->config=array_merge($default,$config); |
|
| 36 | + $this->config=array_merge($default, $config); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $cid=$this->cid; |
| 47 | 47 | $config=$this->config; |
| 48 | 48 | |
| 49 | - if (!is_dir(storage_path("app/contest/pdf/"))){ |
|
| 49 | + if (!is_dir(storage_path("app/contest/pdf/"))) { |
|
| 50 | 50 | mkdir(storage_path("app/contest/pdf/"), 0777, true); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, Trackable; |
| 23 | 23 | |
| 24 | - public $tries = 1; |
|
| 24 | + public $tries=1; |
|
| 25 | 25 | public $progressVal=40; |
| 26 | 26 | public $stepVal=0; |
| 27 | 27 | protected $cid; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $cid=$this->cid; |
| 55 | 55 | $contest=EloquentContestModel::find($cid); |
| 56 | 56 | |
| 57 | - if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 57 | + if (!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 58 | 58 | |
| 59 | 59 | $acceptedSubmissions=$contest->submissions->whereIn('verdict', [ |
| 60 | 60 | 'Accepted', |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | $this->setProgressNow(20); |
| 68 | 68 | $totMOSS=0; |
| 69 | 69 | |
| 70 | - foreach($acceptedSubmissions as $submission){ |
|
| 70 | + foreach ($acceptedSubmissions as $submission) { |
|
| 71 | 71 | $lang=$submission->compiler->lang; |
| 72 | - if(Arr::has($this->supportLang, $lang)){ |
|
| 72 | + if (Arr::has($this->supportLang, $lang)) { |
|
| 73 | 73 | $prob=$probIndex[$submission->pid]; |
| 74 | 74 | $lang=$this->supportLang[$lang]; |
| 75 | 75 | $ext=$lang; |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $this->setProgressNow(40); |
| 83 | - $this->stepVal=50/$totMOSS*3; |
|
| 83 | + $this->stepVal=50 / $totMOSS * 3; |
|
| 84 | 84 | $this->progressVal=40; |
| 85 | 85 | |
| 86 | - foreach($probLangs as $prob=>$langs){ |
|
| 87 | - foreach($langs as $lang=>$availableVal){ |
|
| 86 | + foreach ($probLangs as $prob=>$langs) { |
|
| 87 | + foreach ($langs as $lang=>$availableVal) { |
|
| 88 | 88 | $this->detectPlagiarism([ |
| 89 | 89 | 'lang'=>$lang, |
| 90 | 90 | 'cid'=>$cid, |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | $this->setProgressNow(100); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - private function incProgress(){ |
|
| 101 | + private function incProgress() { |
|
| 102 | 102 | $this->progressVal+=$this->stepVal; |
| 103 | 103 | $this->setProgressNow(intval($this->progressVal)); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | private function detectPlagiarism($config) |
| 107 | 107 | { |
| 108 | - $userid = config('moss.userid'); |
|
| 108 | + $userid=config('moss.userid'); |
|
| 109 | 109 | $lang=$config['lang']; |
| 110 | 110 | $cid=$config['cid']; |
| 111 | 111 | $prob=$config['prob']; |
| 112 | 112 | $comment=$config['comment']; |
| 113 | - $moss = new MOSS($userid); |
|
| 113 | + $moss=new MOSS($userid); |
|
| 114 | 114 | $moss->setLanguage($lang); |
| 115 | 115 | $moss->addByWildcard(storage_path("app/contest/anticheat/$cid/raw/$prob/$lang/*")); |
| 116 | 116 | $moss->setCommentString($comment); |
@@ -118,25 +118,25 @@ discard block |
||
| 118 | 118 | $this->incProgress(); |
| 119 | 119 | $moss->saveTo(storage_path("app/contest/anticheat/$cid/report/$prob/$lang"), $id); |
| 120 | 120 | $this->incProgress(); |
| 121 | - $this->afterWork($cid,$prob,$lang); |
|
| 121 | + $this->afterWork($cid, $prob, $lang); |
|
| 122 | 122 | $this->incProgress(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - private function afterWork($cid,$prob,$lang) |
|
| 125 | + private function afterWork($cid, $prob, $lang) |
|
| 126 | 126 | { |
| 127 | 127 | $rawPath="contest/anticheat/$cid/raw/$prob/$lang"; |
| 128 | 128 | $reportPath="contest/anticheat/$cid/report/$prob/$lang"; |
| 129 | 129 | $generalPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("$reportPath/index.html"), true, true, DEFAULT_TARGET_CHARSET, false); |
| 130 | 130 | $table=$generalPage->find('table', 0); |
| 131 | - if(is_null($table)) return; |
|
| 132 | - foreach($table->find('tr') as $tr){ |
|
| 133 | - if(Str::contains($tr->outertext, '<th>')) continue; |
|
| 131 | + if (is_null($table)) return; |
|
| 132 | + foreach ($table->find('tr') as $tr) { |
|
| 133 | + if (Str::contains($tr->outertext, '<th>')) continue; |
|
| 134 | 134 | $firstUID=null; |
| 135 | - foreach($tr->find('a') as $a){ |
|
| 136 | - $a->innertext=explode("$rawPath/",$a->plaintext)[1]; |
|
| 137 | - $a->innertext=str_replace(".$lang (",' (',$a->plaintext); |
|
| 138 | - [$uid,$sid,$percent]=sscanf($a->innertext,"[%d][%d] (%d"); |
|
| 139 | - if($firstUID==$uid){ |
|
| 135 | + foreach ($tr->find('a') as $a) { |
|
| 136 | + $a->innertext=explode("$rawPath/", $a->plaintext)[1]; |
|
| 137 | + $a->innertext=str_replace(".$lang (", ' (', $a->plaintext); |
|
| 138 | + [$uid, $sid, $percent]=sscanf($a->innertext, "[%d][%d] (%d"); |
|
| 139 | + if ($firstUID==$uid) { |
|
| 140 | 140 | $tr->outertext=''; |
| 141 | 141 | break; |
| 142 | 142 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $a->innertext="$sid. [$prob][$username][$percent%]"; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | - Storage::disk('local')->put("$reportPath/index.html",$table->outertext); |
|
| 148 | + Storage::disk('local')->put("$reportPath/index.html", $table->outertext); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private function finalizeReport($probLangs) |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | $cid=$this->cid; |
| 154 | 154 | $generalPage="<table><tr><th>File 1</th><th>File 2</th><th>Lines Matched</th></tr>"; |
| 155 | 155 | $index=0; |
| 156 | - foreach($probLangs as $prob=>$langs){ |
|
| 157 | - foreach($langs as $lang=>$availableVal){ |
|
| 156 | + foreach ($probLangs as $prob=>$langs) { |
|
| 157 | + foreach ($langs as $lang=>$availableVal) { |
|
| 158 | 158 | $probPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("contest/anticheat/$cid/report/$prob/$lang/index.html"), true, true, DEFAULT_TARGET_CHARSET, false); |
| 159 | 159 | $table=$probPage->find('table', 0); |
| 160 | - if(is_null($table)) continue; |
|
| 161 | - foreach($table->find('tr') as $tr){ |
|
| 162 | - if(Str::contains($tr->outertext, '<th>')) continue; |
|
| 160 | + if (is_null($table)) continue; |
|
| 161 | + foreach ($table->find('tr') as $tr) { |
|
| 162 | + if (Str::contains($tr->outertext, '<th>')) continue; |
|
| 163 | 163 | $submissionA=$tr->children(0)->children(0); |
| 164 | 164 | $submissionB=$tr->children(1)->children(0); |
| 165 | 165 | $linesMatch=$tr->children(2); |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | $cid=$this->cid; |
| 55 | 55 | $contest=EloquentContestModel::find($cid); |
| 56 | 56 | |
| 57 | - if(!$contest->isJudgingComplete()) throw new Exception('Judging Incompleted'); |
|
| 57 | + if(!$contest->isJudgingComplete()) { |
|
| 58 | + throw new Exception('Judging Incompleted'); |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | 61 | $acceptedSubmissions=$contest->submissions->whereIn('verdict', [ |
| 60 | 62 | 'Accepted', |
@@ -128,9 +130,13 @@ discard block |
||
| 128 | 130 | $reportPath="contest/anticheat/$cid/report/$prob/$lang"; |
| 129 | 131 | $generalPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("$reportPath/index.html"), true, true, DEFAULT_TARGET_CHARSET, false); |
| 130 | 132 | $table=$generalPage->find('table', 0); |
| 131 | - if(is_null($table)) return; |
|
| 133 | + if(is_null($table)) { |
|
| 134 | + return; |
|
| 135 | + } |
|
| 132 | 136 | foreach($table->find('tr') as $tr){ |
| 133 | - if(Str::contains($tr->outertext, '<th>')) continue; |
|
| 137 | + if(Str::contains($tr->outertext, '<th>')) { |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 134 | 140 | $firstUID=null; |
| 135 | 141 | foreach($tr->find('a') as $a){ |
| 136 | 142 | $a->innertext=explode("$rawPath/",$a->plaintext)[1]; |
@@ -157,9 +163,13 @@ discard block |
||
| 157 | 163 | foreach($langs as $lang=>$availableVal){ |
| 158 | 164 | $probPage=HtmlDomParser::str_get_html(Storage::disk('local')->get("contest/anticheat/$cid/report/$prob/$lang/index.html"), true, true, DEFAULT_TARGET_CHARSET, false); |
| 159 | 165 | $table=$probPage->find('table', 0); |
| 160 | - if(is_null($table)) continue; |
|
| 166 | + if(is_null($table)) { |
|
| 167 | + continue; |
|
| 168 | + } |
|
| 161 | 169 | foreach($table->find('tr') as $tr){ |
| 162 | - if(Str::contains($tr->outertext, '<th>')) continue; |
|
| 170 | + if(Str::contains($tr->outertext, '<th>')) { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 163 | 173 | $submissionA=$tr->children(0)->children(0); |
| 164 | 174 | $submissionB=$tr->children(1)->children(0); |
| 165 | 175 | $linesMatch=$tr->children(2); |
@@ -17,18 +17,18 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function handle($request, Closure $next) |
| 19 | 19 | { |
| 20 | - $contest = Contest::find($request->cid); |
|
| 21 | - if(!empty($contest) && $contest->desktop && !$contest->is_end) { |
|
| 22 | - if(auth()->check()) { |
|
| 23 | - $user = auth()->user(); |
|
| 24 | - $contestModel = new OutdatedContestModel(); |
|
| 25 | - if($contestModel->judgeClearance($contest->cid, $user->id) == 3){ |
|
| 20 | + $contest=Contest::find($request->cid); |
|
| 21 | + if (!empty($contest) && $contest->desktop && !$contest->is_end) { |
|
| 22 | + if (auth()->check()) { |
|
| 23 | + $user=auth()->user(); |
|
| 24 | + $contestModel=new OutdatedContestModel(); |
|
| 25 | + if ($contestModel->judgeClearance($contest->cid, $user->id)==3) { |
|
| 26 | 26 | return $next($request); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - if(strtolower($request->method()) == 'get'){ |
|
| 30 | - return response()->redirectToRoute('contest.detail',['cid' => $contest->cid]); |
|
| 31 | - }else{ |
|
| 29 | + if (strtolower($request->method())=='get') { |
|
| 30 | + return response()->redirectToRoute('contest.detail', ['cid' => $contest->cid]); |
|
| 31 | + } else { |
|
| 32 | 32 | return header("HTTP/1.1 403 Forbidden"); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | } |
| 29 | 29 | if(strtolower($request->method()) == 'get'){ |
| 30 | 30 | return response()->redirectToRoute('contest.detail',['cid' => $contest->cid]); |
| 31 | - }else{ |
|
| 31 | + } else{ |
|
| 32 | 32 | return header("HTTP/1.1 403 Forbidden"); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -15,9 +15,9 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function handle($request, Closure $next) |
| 17 | 17 | { |
| 18 | - $contest_problem = $request->contest_problem; |
|
| 19 | - $compiler = $contest_problem->compilers->where('coid', $request->coid)->first(); |
|
| 20 | - if(empty($compiler)) { |
|
| 18 | + $contest_problem=$request->contest_problem; |
|
| 19 | + $compiler=$contest_problem->compilers->where('coid', $request->coid)->first(); |
|
| 20 | + if (empty($compiler)) { |
|
| 21 | 21 | return response()->json([ |
| 22 | 22 | 'success' => false, |
| 23 | 23 | 'message' => 'Compiler Not Found', |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function handle($request, Closure $next, $clearance) |
| 19 | 19 | { |
| 20 | - $clearance = [ |
|
| 20 | + $clearance=[ |
|
| 21 | 21 | 'visible' => 1, |
| 22 | 22 | 'participated' => 2, |
| 23 | 23 | 'admin' => 3, |
| 24 | 24 | 'public_visible' => 4 |
| 25 | 25 | ][$clearance]; |
| 26 | - $user = auth()->user(); |
|
| 27 | - $contest = new OutdatedContestModel(); |
|
| 28 | - if($clearance == 4) { |
|
| 29 | - if($contest->judgeOutsideClearance($request->cid,$user->id)){ |
|
| 30 | - $contest = Contest::find($request->cid); |
|
| 26 | + $user=auth()->user(); |
|
| 27 | + $contest=new OutdatedContestModel(); |
|
| 28 | + if ($clearance==4) { |
|
| 29 | + if ($contest->judgeOutsideClearance($request->cid, $user->id)) { |
|
| 30 | + $contest=Contest::find($request->cid); |
|
| 31 | 31 | $request->merge([ |
| 32 | 32 | 'contest' => $contest |
| 33 | 33 | ]); |
| 34 | 34 | return $next($request); |
| 35 | - }else{ |
|
| 35 | + } else { |
|
| 36 | 36 | return response()->json([ |
| 37 | 37 | 'success' => false, |
| 38 | 38 | 'message' => 'Contest Not Found', |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | ] |
| 45 | 45 | ]); |
| 46 | 46 | } |
| 47 | - }else if($contest->judgeClearance($request->cid,$user->id) >= $clearance) { |
|
| 48 | - $contest = Contest::find($request->cid); |
|
| 47 | + } else if ($contest->judgeClearance($request->cid, $user->id)>=$clearance) { |
|
| 48 | + $contest=Contest::find($request->cid); |
|
| 49 | 49 | $request->merge([ |
| 50 | 50 | 'contest' => $contest |
| 51 | 51 | ]); |
| 52 | 52 | return $next($request); |
| 53 | - }else{ |
|
| 53 | + } else { |
|
| 54 | 54 | return response()->json([ |
| 55 | 55 | 'success' => false, |
| 56 | 56 | 'message' => 'Permission Denied', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | 'contest' => $contest |
| 33 | 33 | ]); |
| 34 | 34 | return $next($request); |
| 35 | - }else{ |
|
| 35 | + } else{ |
|
| 36 | 36 | return response()->json([ |
| 37 | 37 | 'success' => false, |
| 38 | 38 | 'message' => 'Contest Not Found', |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | ] |
| 45 | 45 | ]); |
| 46 | 46 | } |
| 47 | - }else if($contest->judgeClearance($request->cid,$user->id) >= $clearance) { |
|
| 47 | + } else if($contest->judgeClearance($request->cid,$user->id) >= $clearance) { |
|
| 48 | 48 | $contest = Contest::find($request->cid); |
| 49 | 49 | $request->merge([ |
| 50 | 50 | 'contest' => $contest |
| 51 | 51 | ]); |
| 52 | 52 | return $next($request); |
| 53 | - }else{ |
|
| 53 | + } else{ |
|
| 54 | 54 | return response()->json([ |
| 55 | 55 | 'success' => false, |
| 56 | 56 | 'message' => 'Permission Denied', |
@@ -15,9 +15,9 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function handle($request, Closure $next) |
| 17 | 17 | { |
| 18 | - $contest = $request->contest; |
|
| 19 | - $contest_problem = $contest->problems()->where('pid', $request->pid)->first(); |
|
| 20 | - if(empty($contest_problem)) { |
|
| 18 | + $contest=$request->contest; |
|
| 19 | + $contest_problem=$contest->problems()->where('pid', $request->pid)->first(); |
|
| 20 | + if (empty($contest_problem)) { |
|
| 21 | 21 | return response()->json([ |
| 22 | 22 | 'success' => false, |
| 23 | 23 | 'message' => 'Problem Not Found', |
@@ -16,8 +16,8 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function handle($request, Closure $next) |
| 18 | 18 | { |
| 19 | - $submission = Submission::find($request->sid); |
|
| 20 | - if(empty($submission)) { |
|
| 19 | + $submission=Submission::find($request->sid); |
|
| 20 | + if (empty($submission)) { |
|
| 21 | 21 | return response()->json([ |
| 22 | 22 | 'success' => false, |
| 23 | 23 | 'message' => 'Submission Not Found', |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | class SystemController extends Controller |
| 9 | 9 | { |
| 10 | - public function info(){ |
|
| 10 | + public function info() { |
|
| 11 | 11 | return response()->json([ |
| 12 | 12 | 'success' => true, |
| 13 | 13 | 'message' => 'To Boldly Go', |
@@ -8,19 +8,19 @@ |
||
| 8 | 8 | class AccountController extends Controller |
| 9 | 9 | { |
| 10 | 10 | public function login(Request $request) { |
| 11 | - $credentials = [ |
|
| 11 | + $credentials=[ |
|
| 12 | 12 | 'email' => $request->email, |
| 13 | 13 | 'password' => $request->password |
| 14 | 14 | ]; |
| 15 | 15 | |
| 16 | - if(auth()->attempt($credentials)) { |
|
| 17 | - $user = auth()->user(); |
|
| 18 | - if(!empty($user->tokens)){ |
|
| 19 | - foreach($user->tokens as $token){ |
|
| 16 | + if (auth()->attempt($credentials)) { |
|
| 17 | + $user=auth()->user(); |
|
| 18 | + if (!empty($user->tokens)) { |
|
| 19 | + foreach ($user->tokens as $token) { |
|
| 20 | 20 | $token->delete(); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | - $token = $user->createToken('NOJ Password Grant Client')->accessToken; |
|
| 23 | + $token=$user->createToken('NOJ Password Grant Client')->accessToken; |
|
| 24 | 24 | return response()->json([ |
| 25 | 25 | 'success' => true, |
| 26 | 26 | 'message' => 'Successfully Login', |