@@ -12,16 +12,16 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function judge_servers() |
| 14 | 14 | { |
| 15 | - return $this->hasMany('App\Models\Eloquent\JudgeServer', 'oid','oid'); |
|
| 15 | + return $this->hasMany('App\Models\Eloquent\JudgeServer', 'oid', 'oid'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function compilers() |
| 19 | 19 | { |
| 20 | - return $this->hasMany('App\Models\Eloquent\Compiler', 'oid','oid'); |
|
| 20 | + return $this->hasMany('App\Models\Eloquent\Compiler', 'oid', 'oid'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function judgers() |
| 24 | 24 | { |
| 25 | - return $this->hasMany('App\Models\Eloquent\Judger', 'oid','oid'); |
|
| 25 | + return $this->hasMany('App\Models\Eloquent\Judger', 'oid', 'oid'); |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | |
| 14 | 14 | public static function oid($ocode) |
| 15 | 15 | { |
| 16 | - $ret = DB::table('oj')->where(["ocode"=>$ocode])->first(); |
|
| 17 | - return is_null($ret)?null:$ret["oid"]; |
|
| 16 | + $ret=DB::table('oj')->where(["ocode"=>$ocode])->first(); |
|
| 17 | + return is_null($ret) ?null:$ret["oid"]; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public static function ocode($oid) |
@@ -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 | } |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @var string |
| 18 | 18 | */ |
| 19 | - protected $signature = 'manage:resetpass {--uid= : the user you want to reset} {--digit= : the number of the password, should be larger than 8}'; |
|
| 19 | + protected $signature='manage:resetpass {--uid= : the user you want to reset} {--digit= : the number of the password, should be larger than 8}'; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * The console command description. |
| 23 | 23 | * |
| 24 | 24 | * @var string |
| 25 | 25 | */ |
| 26 | - protected $description = 'Reset user passwords of NOJ'; |
|
| 26 | + protected $description='Reset user passwords of NOJ'; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Create a new command instance. |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - protected $signature = 'manage:permission |
|
| 17 | + protected $signature='manage:permission |
|
| 18 | 18 | {--action=list : specific action, can be list, grant or revoke} |
| 19 | 19 | {--uid= : the user you want to manage permission} |
| 20 | 20 | {--permission= : the permission id number, use list action to check all available permission ids}'; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var string |
| 26 | 26 | */ |
| 27 | - protected $description = 'Manage user permissions of NOJ'; |
|
| 27 | + protected $description='Manage user permissions of NOJ'; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Create a new command instance. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if($action=='list'){ |
|
| 55 | + if ($action=='list') { |
|
| 56 | 56 | $this->listPermission(); |
| 57 | 57 | return; |
| 58 | 58 | } |
@@ -63,24 +63,24 @@ discard block |
||
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if(!isset(UserPermission::$permInfo[$permission_id])){ |
|
| 66 | + if (!isset(UserPermission::$permInfo[$permission_id])) { |
|
| 67 | 67 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>Unknown Permission</>\n"); |
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | $permissionInfo=UserPermission::$permInfo[$permission_id]; |
| 71 | 71 | |
| 72 | - if($action=='grant'){ |
|
| 72 | + if ($action=='grant') { |
|
| 73 | 73 | $this->grantPermission($uid, $permission_id, $permissionInfo); |
| 74 | - }else{ |
|
| 74 | + } else { |
|
| 75 | 75 | $this->revokePermission($uid, $permission_id, $permissionInfo); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | protected function listPermission() |
| 80 | 80 | { |
| 81 | - $headers = ['ID', 'Permission']; |
|
| 81 | + $headers=['ID', 'Permission']; |
|
| 82 | 82 | $permInfo=[]; |
| 83 | - foreach(UserPermission::$permInfo as $permID=>$permDesc){ |
|
| 83 | + foreach (UserPermission::$permInfo as $permID=>$permDesc) { |
|
| 84 | 84 | $permInfo[]=[$permID, $permDesc]; |
| 85 | 85 | } |
| 86 | 86 | $this->table($headers, $permInfo); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | 'permission_id' => $permission_id, |
| 96 | 96 | ])->count(); |
| 97 | 97 | |
| 98 | - if(!$permissionExists){ |
|
| 98 | + if (!$permissionExists) { |
|
| 99 | 99 | UserPermission::create([ |
| 100 | 100 | 'user_id' => $uid, |
| 101 | 101 | 'permission_id' => $permission_id, |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | 'permission_id' => $permission_id, |
| 115 | 115 | ])->count(); |
| 116 | 116 | |
| 117 | - if($permissionExists){ |
|
| 117 | + if ($permissionExists) { |
|
| 118 | 118 | UserPermission::where([ |
| 119 | 119 | 'user_id' => $uid, |
| 120 | 120 | 'permission_id' => $permission_id, |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | |
| 72 | 72 | if($action=='grant'){ |
| 73 | 73 | $this->grantPermission($uid, $permission_id, $permissionInfo); |
| 74 | - }else{ |
|
| 74 | + } else{ |
|
| 75 | 75 | $this->revokePermission($uid, $permission_id, $permissionInfo); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - protected $signature = 'babel:require {extension : The package name of the extension} {--ignore-platform-reqs : Ignore the Platform Requirements when install} {--exception}'; |
|
| 17 | + protected $signature='babel:require {extension : The package name of the extension} {--ignore-platform-reqs : Ignore the Platform Requirements when install} {--exception}'; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The console command description. |
| 21 | 21 | * |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - protected $description = 'Download a given Babel Extension to NOJ'; |
|
| 24 | + protected $description='Download a given Babel Extension to NOJ'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Create a new command instance. |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function handle() |
| 42 | 42 | { |
| 43 | - $extension = $this->argument('extension'); |
|
| 44 | - $exception = $this->option('exception'); |
|
| 45 | - $ignoreReqs = $this->option('ignore-platform-reqs'); |
|
| 46 | - $output = new BufferedOutput(); |
|
| 43 | + $extension=$this->argument('extension'); |
|
| 44 | + $exception=$this->option('exception'); |
|
| 45 | + $ignoreReqs=$this->option('ignore-platform-reqs'); |
|
| 46 | + $output=new BufferedOutput(); |
|
| 47 | 47 | if (is_dir(babel_path("Extension/$extension/"))) { |
| 48 | 48 | if (!$exception) { |
| 49 | 49 | $this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>An extension named <fg=green>$extension</> already took place, did you mean <fg=green>php artisan bable:update $extension</>?</>\n"); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | mkdir(babel_path("Tmp/$extension/")); |
| 76 | 76 | } |
| 77 | 77 | try { |
| 78 | - $zipFile = new ZipFile(); |
|
| 78 | + $zipFile=new ZipFile(); |
|
| 79 | 79 | $zipFile->openFile(babel_path("Tmp/$filename"))->extractTo(babel_path("Tmp/$extension/"))->close(); |
| 80 | 80 | $babelPath=glob_recursive(babel_path("Tmp/$extension/babel.json")); |
| 81 | 81 | if (empty($babelPath)) { |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | if (!is_dir($dir)) { |
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | - $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); |
|
| 131 | - $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); |
|
| 130 | + $it=new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS); |
|
| 131 | + $files=new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); |
|
| 132 | 132 | foreach ($files as $file) { |
| 133 | 133 | if ($file->isDir()) { |
| 134 | 134 | rmdir($file->getRealPath()); |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @var string |
| 15 | 15 | */ |
| 16 | - protected $signature = 'babel:judge'; |
|
| 16 | + protected $signature='babel:judge'; |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * The console command description. |
| 20 | 20 | * |
| 21 | 21 | * @var string |
| 22 | 22 | */ |
| 23 | - protected $description = 'Synchronize remote verdict for all Babel Extensions of NOJ'; |
|
| 23 | + protected $description='Synchronize remote verdict for all Babel Extensions of NOJ'; |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Create a new command instance. |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function handle() |
| 41 | 41 | { |
| 42 | 42 | $babel=new Babel(); |
| 43 | - while(true){ |
|
| 43 | + while (true) { |
|
| 44 | 44 | $time=date("Y-m-d H:i:s"); |
| 45 | 45 | $this->line("<fg=yellow>[$time] Processing: </>NOJ Babel Judge Sync"); |
| 46 | 46 | $babel->judge(); |
@@ -35,35 +35,35 @@ discard block |
||
| 35 | 35 | protected function schedule(Schedule $schedule) |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - $schedule->call(function () { |
|
| 38 | + $schedule->call(function() { |
|
| 39 | 39 | $rankModel=new RankModel(); |
| 40 | 40 | $rankModel->rankList(); |
| 41 | 41 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated Rank"); |
| 42 | 42 | })->dailyAt('02:00')->description("Update Rank"); |
| 43 | 43 | |
| 44 | - $schedule->call(function () { |
|
| 44 | + $schedule->call(function() { |
|
| 45 | 45 | $siteMapModel=new SiteMapModel(); |
| 46 | 46 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated SiteMap"); |
| 47 | 47 | })->dailyAt('02:00')->description("Update SiteMap"); |
| 48 | 48 | |
| 49 | - $schedule->call(function () { |
|
| 49 | + $schedule->call(function() { |
|
| 50 | 50 | $groupModel=new GroupModel(); |
| 51 | 51 | $groupModel->cacheTrendingGroups(); |
| 52 | 52 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Cached Trending Groups"); |
| 53 | 53 | })->dailyAt('03:00')->description("Update Trending Groups"); |
| 54 | 54 | |
| 55 | 55 | $schedule->call(function() { |
| 56 | - $groupModel = new GroupModel(); |
|
| 57 | - $ret = $groupModel->refreshAllElo(); |
|
| 56 | + $groupModel=new GroupModel(); |
|
| 57 | + $ret=$groupModel->refreshAllElo(); |
|
| 58 | 58 | foreach ($ret as $gid => $group) { |
| 59 | - if(empty($group['result'])){ |
|
| 59 | + if (empty($group['result'])) { |
|
| 60 | 60 | Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']); |
| 61 | - }else{ |
|
| 61 | + } else { |
|
| 62 | 62 | Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']); |
| 63 | 63 | foreach ($group['result'] as $contest) { |
| 64 | - if($contest['ret'] == 'success'){ |
|
| 64 | + if ($contest['ret']=='success') { |
|
| 65 | 65 | Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']); |
| 66 | - }else{ |
|
| 66 | + } else { |
|
| 67 | 67 | Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:'); |
| 68 | 68 | foreach ($contest['submissions'] as $sid) { |
| 69 | 69 | Log::channel('group_elo')->info(' '.$sid['sid']); |
@@ -74,46 +74,46 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | })->dailyAt('04:00')->description("Update Group Elo"); |
| 76 | 76 | |
| 77 | - $schedule->call(function () { |
|
| 78 | - $contestModel = new ContestModel(); |
|
| 79 | - $syncList = $contestModel->runningContest(); |
|
| 77 | + $schedule->call(function() { |
|
| 78 | + $contestModel=new ContestModel(); |
|
| 79 | + $syncList=$contestModel->runningContest(); |
|
| 80 | 80 | foreach ($syncList as $syncContest) { |
| 81 | 81 | if (!isset($syncContest['vcid'])) { |
| 82 | - $contest = EloquentContestModel::find($syncContest['cid']); |
|
| 83 | - $contestRankRaw = $contest->rankRefresh(); |
|
| 82 | + $contest=EloquentContestModel::find($syncContest['cid']); |
|
| 83 | + $contestRankRaw=$contest->rankRefresh(); |
|
| 84 | 84 | $cid=$syncContest['cid']; |
| 85 | 85 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 86 | 86 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 87 | - continue ; |
|
| 87 | + continue; |
|
| 88 | 88 | } |
| 89 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
| 90 | - $all_data = [ |
|
| 89 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
| 90 | + $all_data=[ |
|
| 91 | 91 | 'oj'=>"hdu", |
| 92 | 92 | 'vcid'=>$syncContest['vcid'], |
| 93 | 93 | 'gid'=>$syncContest['gid'], |
| 94 | 94 | 'cid'=>$syncContest['cid'], |
| 95 | 95 | ]; |
| 96 | - $hduSync = new $className($all_data); |
|
| 96 | + $hduSync=new $className($all_data); |
|
| 97 | 97 | $hduSync->crawlRank(); |
| 98 | 98 | $hduSync->crawlClarification(); |
| 99 | 99 | } |
| 100 | 100 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Remote Rank and Clarification"); |
| 101 | 101 | })->everyMinute()->description("Sync Remote Rank and Clarification"); |
| 102 | 102 | |
| 103 | - $schedule->call(function () { |
|
| 104 | - $contestModel = new ContestModel(); |
|
| 105 | - $syncList = $contestModel->runningContest(); |
|
| 103 | + $schedule->call(function() { |
|
| 104 | + $contestModel=new ContestModel(); |
|
| 105 | + $syncList=$contestModel->runningContest(); |
|
| 106 | 106 | foreach ($syncList as $syncContest) { |
| 107 | 107 | if (isset($syncContest['crawled'])) { |
| 108 | 108 | if (!$syncContest['crawled']) { |
| 109 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
| 110 | - $all_data = [ |
|
| 109 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
| 110 | + $all_data=[ |
|
| 111 | 111 | 'oj'=>"hdu", |
| 112 | 112 | 'vcid'=>$syncContest['vcid'], |
| 113 | 113 | 'gid'=>$syncContest['gid'], |
| 114 | 114 | 'cid'=>$syncContest['cid'], |
| 115 | 115 | ]; |
| 116 | - $hduSync = new $className($all_data); |
|
| 116 | + $hduSync=new $className($all_data); |
|
| 117 | 117 | $hduSync->scheduleCrawl(); |
| 118 | 118 | $contestModel->updateCrawlStatus($syncContest['cid']); |
| 119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | })->everyMinute()->description("Sync Contest Problem"); |
| 123 | 123 | |
| 124 | - $schedule->call(function () { |
|
| 124 | + $schedule->call(function() { |
|
| 125 | 125 | $oidList=EloquentJudgeServerModel::column('oid'); |
| 126 | 126 | $babel=new Babel(); |
| 127 | 127 | foreach ($oidList as $oid) { |