@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - }elseif ($config['type'] == 2) { //to a leader that member agree to join the group |
|
| 38 | + } elseif ($config['type'] == 2) { //to a leader that member agree to join the group |
|
| 39 | 39 | $messages = Message::where([ |
| 40 | 40 | 'receiver' => $config['receiver'], |
| 41 | 41 | 'type' => $config['type'], |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | - }elseif ($config['type'] == 3) { //to a person that solution was passed |
|
| 55 | + } elseif ($config['type'] == 3) { //to a person that solution was passed |
|
| 56 | 56 | $message = Message::where([ |
| 57 | 57 | 'receiver' => $config['receiver'], |
| 58 | 58 | 'type' => $config['type'], |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $message->save(); |
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | - }elseif ($config['type'] == 4) { //to a person that solution was blocked |
|
| 68 | + } elseif ($config['type'] == 4) { //to a person that solution was blocked |
|
| 69 | 69 | $message = Message::where([ |
| 70 | 70 | 'receiver' => $config['receiver'], |
| 71 | 71 | 'type' => $config['type'], |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | if(isset($config['data']) && isset($config['type'])){ |
| 88 | 88 | $message->type = $config['type'] ?? null; |
| 89 | 89 | $message->data = json_encode($config['data']); |
| 90 | - }else{ |
|
| 90 | + } else{ |
|
| 91 | 91 | $message->content = $config['content']; |
| 92 | 92 | } |
| 93 | 93 | /* |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $del_count ++; |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | - }else{ |
|
| 204 | + } else{ |
|
| 205 | 205 | $message = static::find($messages); |
| 206 | 206 | if(!empty($message)){ |
| 207 | 207 | $message->delete(); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $content = substr($content,0,strlen($content)-2); |
| 224 | 224 | $content .= " want to join your group [{$data['group']['name']}]({$data['group']['url']})"; |
| 225 | 225 | return $content; |
| 226 | - }elseif($this->type == 2) { |
|
| 226 | + } elseif($this->type == 2) { |
|
| 227 | 227 | foreach($data['user'] as $user) { |
| 228 | 228 | $content .= "[{$user['name']}]({$user['url']}), "; |
| 229 | 229 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $content .= " have agreed to join your group [{$data['group']['name']}]({$data['group']['url']})"; |
| 232 | 232 | return $content; |
| 233 | 233 | } //todo |
| 234 | - }else{ |
|
| 234 | + } else{ |
|
| 235 | 235 | return $value; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -42,8 +42,12 @@ |
||
| 42 | 42 | public function getAvailabilityAttribute() |
| 43 | 43 | { |
| 44 | 44 | foreach(explode(',', $this->precondition) as $dojo_id){ |
| 45 | - if(blank($dojo_id)) continue; |
|
| 46 | - if(!DojoPass::isPassed($dojo_id)) return 'locked'; |
|
| 45 | + if(blank($dojo_id)) { |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 48 | + if(!DojoPass::isPassed($dojo_id)) { |
|
| 49 | + return 'locked'; |
|
| 50 | + } |
|
| 47 | 51 | } |
| 48 | 52 | return $this->passed?'passed':'available'; |
| 49 | 53 | } |
@@ -9,7 +9,9 @@ |
||
| 9 | 9 | { |
| 10 | 10 | public static function info($ltxsource, $type="png") |
| 11 | 11 | { |
| 12 | - if(!in_array($type,['png','svg'])) return []; |
|
| 12 | + if(!in_array($type,['png','svg'])) { |
|
| 13 | + return []; |
|
| 14 | + } |
|
| 13 | 15 | $url=route("latex.$type", ['ltxsource' => $ltxsource]); |
| 14 | 16 | $image = new Imagick(); |
| 15 | 17 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 229 | 229 | } |
| 230 | 230 | $paginator = $paginator ->paginate(10); |
| 231 | - }elseif($filter['public']=='0'){ |
|
| 231 | + } elseif($filter['public']=='0'){ |
|
| 232 | 232 | $paginator=DB::table('group_member') |
| 233 | 233 | ->groupBy('contest.cid') |
| 234 | 234 | ->select('contest.*') |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | ) |
| 259 | 259 | ->orderBy('contest.begin_time', 'desc') |
| 260 | 260 | ->paginate(10); |
| 261 | - }else{ |
|
| 261 | + } else{ |
|
| 262 | 262 | $paginator=DB::table('group_member') |
| 263 | 263 | ->groupBy('contest.cid') |
| 264 | 264 | ->select('contest.*') |
@@ -810,13 +810,13 @@ discard block |
||
| 810 | 810 | if(time() < $end_time){ |
| 811 | 811 | if($clearance == 3){ |
| 812 | 812 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 813 | - }else{ |
|
| 813 | + } else{ |
|
| 814 | 814 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 815 | 815 | } |
| 816 | 816 | if(!isset($contestRankRaw)){ |
| 817 | 817 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 818 | 818 | } |
| 819 | - }else{ |
|
| 819 | + } else{ |
|
| 820 | 820 | if($clearance == 3){ |
| 821 | 821 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 822 | 822 | if (!isset($contestRankRaw)) { |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | - }else{ |
|
| 829 | + } else{ |
|
| 830 | 830 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
| 831 | 831 | if(!isset($contestRankRaw)){ |
| 832 | 832 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | return DB::table("contest_clarification")->where([ |
| 912 | 912 | "cid"=>$cid |
| 913 | 913 | ])->orderBy('created_at', 'desc')->get()->all(); |
| 914 | - }else{ |
|
| 914 | + } else{ |
|
| 915 | 915 | return DB::table("contest_clarification")->where([ |
| 916 | 916 | "cid"=>$cid |
| 917 | 917 | ])->where(function ($query) { |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
| 1077 | 1077 | if($filter['pid']==false){ |
| 1078 | 1078 | $filter['pid'] = null; |
| 1079 | - }else{ |
|
| 1079 | + } else{ |
|
| 1080 | 1080 | $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | "records"=>[] |
| 1185 | 1185 | ]; |
| 1186 | 1186 | } |
| 1187 | - }else{ |
|
| 1187 | + } else{ |
|
| 1188 | 1188 | if ($basicInfo["status_visibility"]==2) { |
| 1189 | 1189 | // View all |
| 1190 | 1190 | $paginator=DB::table("submission")->where([ |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | if($ratingCalculator->calculate()){ |
| 1435 | 1435 | $ratingCalculator->storage(); |
| 1436 | 1436 | return true; |
| 1437 | - }else{ |
|
| 1437 | + } else{ |
|
| 1438 | 1438 | return false; |
| 1439 | 1439 | } |
| 1440 | 1440 | } else { |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | $contestRankRaw = $this->contestRankCache($cid); |
| 1484 | 1484 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 1485 | 1485 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 1486 | - }else{ |
|
| 1486 | + } else{ |
|
| 1487 | 1487 | DB::table($this->tableName) |
| 1488 | 1488 | ->where('cid',$cid) |
| 1489 | 1489 | ->update($data); |
@@ -1585,8 +1585,7 @@ discard block |
||
| 1585 | 1585 | if(time() > $chache['end_time']){ |
| 1586 | 1586 | $this->storeContestRankInMySQL($cid, $ret); |
| 1587 | 1587 | } |
| 1588 | - } |
|
| 1589 | - else{ |
|
| 1588 | + } else{ |
|
| 1590 | 1589 | $ret=[]; |
| 1591 | 1590 | $chache=[]; |
| 1592 | 1591 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1601,7 +1600,7 @@ discard block |
||
| 1601 | 1600 | "cid"=>$cid, |
| 1602 | 1601 | "audit"=>1 |
| 1603 | 1602 | ])->select('uid')->get()->all(); |
| 1604 | - }else{ |
|
| 1603 | + } else{ |
|
| 1605 | 1604 | $submissionUsers=DB::table("submission")->where([ |
| 1606 | 1605 | "cid"=>$cid |
| 1607 | 1606 | ])->where( |
@@ -1636,9 +1635,9 @@ discard block |
||
| 1636 | 1635 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
| 1637 | 1636 | } |
| 1638 | 1637 | } |
| 1639 | - }catch(LockTimeoutException $e){ |
|
| 1638 | + } catch(LockTimeoutException $e){ |
|
| 1640 | 1639 | Log::warning("Contest Rank Lock Timed Out"); |
| 1641 | - }finally{ |
|
| 1640 | + } finally{ |
|
| 1642 | 1641 | optional($lock)->release(); |
| 1643 | 1642 | } |
| 1644 | 1643 | } |
@@ -1661,7 +1660,7 @@ discard block |
||
| 1661 | 1660 | return 1; |
| 1662 | 1661 | } |
| 1663 | 1662 | }); |
| 1664 | - }else if ($contest_info["rule"]==2){ |
|
| 1663 | + } else if ($contest_info["rule"]==2){ |
|
| 1665 | 1664 | usort($ret, function ($a, $b) { |
| 1666 | 1665 | if ($a["score"]==$b["score"]) { |
| 1667 | 1666 | if ($a["solved"]==$b["solved"]) { |
@@ -1685,8 +1684,9 @@ discard block |
||
| 1685 | 1684 | { |
| 1686 | 1685 | $id = count($ret); |
| 1687 | 1686 | foreach($ret as $key => $r){ |
| 1688 | - if($r['uid'] == $uid) |
|
| 1689 | - $id = $key; |
|
| 1687 | + if($r['uid'] == $uid) { |
|
| 1688 | + $id = $key; |
|
| 1689 | + } |
|
| 1690 | 1690 | } |
| 1691 | 1691 | if ($contest_info["rule"]==1) { |
| 1692 | 1692 | // ACM/ICPC Mode |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | $prob_detail = []; |
| 1695 | 1695 | $totPen = 0; |
| 1696 | 1696 | $totScore = 0; |
| 1697 | - }else{ |
|
| 1697 | + } else{ |
|
| 1698 | 1698 | $prob_detail = $ret[$id]['problem_detail']; |
| 1699 | 1699 | $totPen=$ret[$id]['penalty']; |
| 1700 | 1700 | $totScore=$ret[$id]['score']; |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | $prob_detail = []; |
| 1750 | 1750 | $totSolved = 0; |
| 1751 | 1751 | $totScore = 0; |
| 1752 | - }else{ |
|
| 1752 | + } else{ |
|
| 1753 | 1753 | $prob_detail = $ret[$id]['problem_detail']; |
| 1754 | 1754 | $totSolved=$ret[$id]['solved']; |
| 1755 | 1755 | $totScore=$ret[$id]['score']; |
@@ -1812,18 +1812,18 @@ discard block |
||
| 1812 | 1812 | return false; |
| 1813 | 1813 | } |
| 1814 | 1814 | return true; |
| 1815 | - }else if($status === 0){ |
|
| 1815 | + } else if($status === 0){ |
|
| 1816 | 1816 | if($begin_time_new !== null){ |
| 1817 | 1817 | return false; |
| 1818 | 1818 | } |
| 1819 | 1819 | if($end_time_new !== null){ |
| 1820 | 1820 | if(strtotime($end_time_new) <= time()){ |
| 1821 | 1821 | return false; |
| 1822 | - }else{ |
|
| 1822 | + } else{ |
|
| 1823 | 1823 | return true; |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
| 1826 | - }else{ |
|
| 1826 | + } else{ |
|
| 1827 | 1827 | return false; |
| 1828 | 1828 | } |
| 1829 | 1829 | |
@@ -1844,8 +1844,7 @@ discard block |
||
| 1844 | 1844 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
| 1845 | 1845 | "public"=>1 |
| 1846 | 1846 | ]); |
| 1847 | - } |
|
| 1848 | - else |
|
| 1847 | + } else |
|
| 1849 | 1848 | { |
| 1850 | 1849 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
| 1851 | 1850 | "public"=>0 |
@@ -1869,7 +1868,7 @@ discard block |
||
| 1869 | 1868 | ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
| 1870 | 1869 | ->select('pid','title') |
| 1871 | 1870 | ->get()->all(); |
| 1872 | - }else{ |
|
| 1871 | + } else{ |
|
| 1873 | 1872 | $all_problems = []; |
| 1874 | 1873 | } |
| 1875 | 1874 | $tags = DB::table('group_problem_tag') |
@@ -2022,12 +2021,10 @@ discard block |
||
| 2022 | 2021 | $zipFile |
| 2023 | 2022 | ->saveAsFile(base_path('storage/app/private/'.$path.$cid.".zip")); // save the archive to a file |
| 2024 | 2023 | //->extractTo(base_path('storage/app/private/'.$path)); // extract files to the specified directory |
| 2025 | - } |
|
| 2026 | - catch(\PhpZip\Exception\ZipException $e){ |
|
| 2024 | + } catch(\PhpZip\Exception\ZipException $e){ |
|
| 2027 | 2025 | // handle exception |
| 2028 | 2026 | Log::debug($e); |
| 2029 | - } |
|
| 2030 | - finally{ |
|
| 2027 | + } finally{ |
|
| 2031 | 2028 | $zipFile->close(); |
| 2032 | 2029 | } |
| 2033 | 2030 | } |
@@ -2053,7 +2050,7 @@ discard block |
||
| 2053 | 2050 | return [ |
| 2054 | 2051 | 'result' => true |
| 2055 | 2052 | ]; |
| 2056 | - }else{ |
|
| 2053 | + } else{ |
|
| 2057 | 2054 | return [ |
| 2058 | 2055 | 'result' => false, |
| 2059 | 2056 | 'sid' => $submissions |
@@ -55,7 +55,7 @@ |
||
| 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 | } |
@@ -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); |