@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @var string |
15 | 15 | */ |
16 | - protected $signature = 'manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}'; |
|
16 | + protected $signature='manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * The console command description. |
20 | 20 | * |
21 | 21 | * @var string |
22 | 22 | */ |
23 | - protected $description = 'Ban a user'; |
|
23 | + protected $description='Ban a user'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Create a new command instance. |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function handle() |
41 | 41 | { |
42 | - $uid=(int)$this->option('uid'); |
|
42 | + $uid=(int) $this->option('uid'); |
|
43 | 43 | $reason=$this->option('reason'); |
44 | 44 | $time=$this->option('time'); |
45 | - $user = User::find($uid); |
|
46 | - if(empty($user)) { |
|
45 | + $user=User::find($uid); |
|
46 | + if (empty($user)) { |
|
47 | 47 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>User Not Found</>\n"); |
48 | 48 | return; |
49 | 49 | } |
50 | - try{ |
|
51 | - $ban_time = date('Y-m-d H:i:s',strtotime($time)); |
|
50 | + try { |
|
51 | + $ban_time=date('Y-m-d H:i:s', strtotime($time)); |
|
52 | 52 | UserBanned::create([ |
53 | 53 | 'user_id' => $user->id, |
54 | 54 | 'reason' => $reason, |
55 | 55 | 'removed_at' => $ban_time |
56 | 56 | ]); |
57 | 57 | $this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>"); |
58 | - }catch(Throwable $e){ |
|
58 | + } catch (Throwable $e) { |
|
59 | 59 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>Wrong Time.</>\n"); |
60 | 60 | return; |
61 | 61 | } |
@@ -11,25 +11,25 @@ |
||
11 | 11 | * |
12 | 12 | * @var string |
13 | 13 | */ |
14 | - protected $signature = 'manage:create-admin'; |
|
14 | + protected $signature='manage:create-admin'; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * The console command description. |
18 | 18 | * |
19 | 19 | * @var string |
20 | 20 | */ |
21 | - protected $description = 'Create a admin user'; |
|
21 | + protected $description='Create a admin user'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Execute the console command. |
25 | 25 | */ |
26 | 26 | public function handle() |
27 | 27 | { |
28 | - $userModel = config('admin.database.users_model'); |
|
29 | - $username = $this->ask('Please enter a username to login'); |
|
30 | - $password = bcrypt($this->secret('Please enter a password to login')); |
|
31 | - $name = $this->ask('Please enter a name to display'); |
|
32 | - $user = new $userModel(compact('username', 'password', 'name')); |
|
28 | + $userModel=config('admin.database.users_model'); |
|
29 | + $username=$this->ask('Please enter a username to login'); |
|
30 | + $password=bcrypt($this->secret('Please enter a password to login')); |
|
31 | + $name=$this->ask('Please enter a name to display'); |
|
32 | + $user=new $userModel(compact('username', 'password', 'name')); |
|
33 | 33 | $user->save(); |
34 | 34 | $this->info("Admin User [$name] created successfully."); |
35 | 35 | } |
@@ -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); |
@@ -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 | } |
@@ -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', |
@@ -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', |