/** * Get the response for a forbidden operation. * * @param array $errors * @return \Symfony\Component\HttpFoundation\Response */ public function response(array $errors) { $redirectURL = $this->getRedirectUrl(); if ($this->ban) { return redirect($this->ban->getRedirectUrl()); } return redirect($redirectURL)->withInput($this->except($this->dontFlash))->withErrors($errors, $this->errorBag); }
/** * Returns the response if authorize() fails. * * @return Response */ public function forbiddenResponse() { if ($this->ban) { $url = $this->ban->getRedirectUrl(); if ($this->wantsJson()) { return response()->json(['redirect' => $url]); } else { return redirect($url); } } return abort(403); }
/** * Execute the console command. * * @return mixed */ public function handle() { $bans = Ban::where('status', true)->get(); $count = 0; foreach ($bans as $ban) { if ($ban->banned_till != null && $ban->banned_till <= Carbon::now()) { $count++; $ban->status = false; $ban->updated_by = "Bans-Manager"; $ban->updated_by_site = true; $ban->save(); $ban->tellServerToRemove("Bans-Manager"); } } $this->info($count . " expired bans cleared!"); }
public function storeForBan($id, Request $request) { $ban = Ban::findOrFail($id); $comment = \Input::get('body'); if ($comment == '') { return \Redirect::back(); } if ($request->user()->muted) { return \Redirect::back()->with('error', 'You are muted.'); } $ban->comments()->create(['body' => $comment, 'user_id' => Auth::user()->id]); // Create notification $not = new Notification(); $not->from($request->user())->withType('UserCommentOnBan')->withSubject('A comment is done on ban')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on a ban " . link_to_route('bans.show', '#' . $ban->id, $ban->id))->withStream(true)->regarding($ban)->deliver(); return \Redirect::back()->with('success', 'Success! Comment posted for the ban.'); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::table('bans', function (Blueprint $table) { $table->string('ban_ip', 46)->after('ban_ip_end'); }); Schema::table('posts', function (Blueprint $table) { $table->string('author_ip_string', 46)->after('author_ip'); }); Schema::table('reports', function (Blueprint $table) { $table->string('ip', 46)->after('reporter_ip'); }); Ban::chunk(100, function ($bans) { foreach ($bans as $ban) { $ban->ban_ip_start = inet_ntop($ban->ban_ip); $ban->ban_ip_end = inet_ntop($ban->ban_ip); $ban->save(); } }); Post::withTrashed()->chunk(100, function ($posts) { foreach ($posts as $post) { $post->author_ip_string = null; if (!is_null($post->author_ip)) { $post->author_ip_string = inet_ntop($post->author_ip); } $post->save(); } }); Report::chunk(100, function ($reports) { foreach ($reports as $report) { $report->ip = inet_ntop($report->reporter_ip); $report->save(); } }); Schema::table('bans', function (Blueprint $table) { $table->dropColumn('ban_ip_start', 'ban_ip_end'); }); Schema::table('posts', function (Blueprint $table) { $table->dropColumn('author_ip'); }); Schema::table('posts', function (Blueprint $table) { $table->renameColumn('author_ip_string', 'author_ip'); }); Schema::table('reports', function (Blueprint $table) { $table->dropColumn('reporter_ip'); }); }
public function putAppeal(Board $board, Ban $ban) { if (!$ban->canAppeal() || !$ban->isBanForIP()) { return abort(403); } $input = Input::all(); $validator = Validator::make($input, ['appeal_text' => ["string", "between:0,2048"]]); if (!$validator->passes()) { return redirect()->back()->withErrors($validator->errors()); } $appeal = $ban->appeals()->create(['appeal_ip' => inet_pton(Request::ip()), 'appeal_text' => $input['appeal_text']]); $ban->setRelation('appeals', $ban->appeals->push($appeal)); return $this->getBan($board, $ban); }
/** * */ public function putMod(Request $request, Board $board, Post $post) { if (!$post->exists) { abort(404); } // Take trailing arguments, // compare them against a list of real actions, // intersect the liss to find the true commands. $actions = ["delete", "ban", "all", "global"]; $argList = func_get_args(); $modActions = array_intersect($actions, array_splice($argList, 2)); sort($modActions); $ban = in_array("ban", $modActions); $delete = in_array("delete", $modActions); $all = in_array("all", $modActions); $global = in_array("global", $modActions); if (!$ban) { return abort(404); } $validator = Validator::make(Input::all(), ['raw_ip' => 'required|boolean', 'ban_ip' => 'required_if:raw_ip,true|ip', 'ban_ip_range' => 'required|between:0,128', 'justification' => 'max:255', 'expires_days' => 'required|integer|min:0|max:' . $this->option('banMaxLength'), 'expires_hours' => 'required|integer|min:0|max:23', 'expires_minutes' => 'required|integer|min:0|max:59']); if (!$validator->passes()) { return redirect()->back()->withInput(Input::all())->withErrors($validator->errors()); } $banLengthStr = []; $expiresDays = Input::get('expires_days'); $expiresHours = Input::get('expires_hours'); $expiresMinutes = Input::get('expires_minutes'); if ($expiresDays > 0) { $banLengthStr[] = "{$expiresDays}d"; } if ($expiresHours > 0) { $banLengthStr[] = "{$expiresHours}h"; } if ($expiresMinutes > 0) { $banLengthStr[] = "{$expiresMinutes}m"; } if ($expiresDays == 0 && $expiresHours == 0 && $expiresMinutes == 0) { $banLengthStr[] = "Ø"; } $banLengthStr = implode($banLengthStr, " "); // If we're banning without the ability to view IP addresses, we will get our address directly from the post in human-readable format. $banIpAddr = $this->user->canViewRawIP() ? Input::get('ban_ip') : $post->getAuthorIpAsString(); // The CIDR is passed from our post parameters. By default, it is 32/128 for IPv4/IPv6 respectively. $banCidr = Input::get('ban_ip_range'); // This generates a range from start to finish. I.E. 192.168.1.3/22 becomes [192.168.0.0, 192.168.3.255]. // If we just pass the CDIR into the construct, we get 192.168.1.3-129.168.3.255 for some reason. $banCidrRange = IP::cidr_to_range("{$banIpAddr}/{$banCidr}"); // We then pass this range into the construct method. $banIp = new IP($banCidrRange[0], $banCidrRange[1]); $ban = new Ban(); $ban->ban_ip_start = $banIp->getStart(); $ban->ban_ip_end = $banIp->getEnd(); $ban->seen = false; $ban->created_at = $ban->freshTimestamp(); $ban->updated_at = clone $ban->created_at; $ban->expires_at = clone $ban->created_at; $ban->expires_at = $ban->expires_at->addDays($expiresDays); $ban->expires_at = $ban->expires_at->addHours($expiresHours); $ban->expires_at = $ban->expires_at->addMinutes($expiresMinutes); $ban->mod_id = $this->user->user_id; $ban->post_id = $post->post_id; $ban->ban_reason_id = null; $ban->justification = Input::get('justification'); if ($global) { if ($ban && !$this->user->canBanGlobally() || $delete && !$this->user->canDeleteGlobally()) { return abort(403); } if ($ban) { $ban->board_uri = null; $ban->save(); } $this->log('log.post.ban.global', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->getAuthorIpAsString(), "justification" => $ban->justification, "time" => $banLengthStr]); if ($delete) { $posts = Post::ipBinary($post->author_ip); $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => $posts->count()]); $posts->delete(); return redirect($board->board_uri); } } else { if ($ban && !$board->canBan($this->user) || $delete && !$board->canDelete($this->user)) { return abort(403); } if ($ban) { $ban->board_uri = $post->board_uri; $ban->save(); } $this->log('log.post.ban.local', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->getAuthorIpAsString(), "justification" => $ban->justification, "time" => $banLengthStr]); if ($delete) { if ($all) { $posts = Post::ipBinary($post->author_ip)->where('board_uri', $board->board_uri); $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => $posts->count()]); $posts->delete(); return redirect($board->board_uri); } else { $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => 1]); $post->delete(); } } } Event::fire(new PostWasBanned($post)); Event::fire(new PostWasModerated($post, $this->user)); return back(); }
/** * Returns if the client has access to this form. * * @return boolean */ public function authorize() { // Ban check. $ban = Ban::getBan($this->ip(), $this->board->board_uri); if ($ban) { $this->ban = $ban; return false; } ## TODO ## // Separate these permsisions. return $this->user->canPostThread() || $this->user->canPostReply(); }
/** * Fetches all applicable bans. * * @param string $ip Human-readable IP. * @param string|null|false $board_uri Board|Global Only|Both * @return Ban */ public static function getBans($ip, $board_uri = null, $fetch = true) { $query = Ban::ipString($ip)->board($board_uri)->whereActive()->orderBy('board_uri', 'desc')->with('mod'); return $fetch ? $query->get() : $query; }
public function getIndex() { if (!Cookie::has('seen_donation_info')) { $cookie = Cookie::make('seen_donation_info', 'true', 21600); Cookie::queue($cookie); $show_donation = true; } else { $show_donation = false; } if (!Cookie::has('seen_add_info')) { $cookie = Cookie::make('seen_add_info', 'true', 4320); Cookie::queue($cookie); $show_add = true; } else { $show_add = false; } /* $data1 = '{"0":"DUYFu8ao","1":"1.0.0","2":"10480","3":"1437386880","4":"11cc6f19","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19371","16":"569","17":"900","19":"1","21":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"86","11":"1","17":"1","38":"4"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"71","8":"1","9":"1","15":"1","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"66","38":"2"}]}'; {"0":"4VPwFgFe","1":"1.2.0","2":"10480","3":"1464673260","4":"39869856","6":"1.0","7":"Swat4 Server","9":"13","11":"1","12":"16","13":"3","14":"5","15":"300","16":"300","17":"900","22":"5","27_0_0":"0","27_0_1":"127.0.0.1","27_0_3":"1","27_0_5":"Kinnngg","27_0_6":"1","27_0_7":"294","27_0_38":"2","27_0_39_0":"10","27_0_39_1":"16","27_0_39_2":"16","27_0_39_3":"25","27_0_39_4":"25","27_0_39_5":"23","27_0_39_6":"25","27_0_39_7":"25","27_0_39_8":"25","27_0_39_9":"3","27_0_39_10":"19","27_0_39_11":"22","27_0_40_0_0":"10","27_0_40_0_1":"277","27_0_40_0_2":"24","27_0_40_1_0":"25","27_0_40_1_1":"8","27_0_40_1_2":"2"} $data2 = '{"0":"AIq1F3LG","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19301","16":"499","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"19"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"4"}]}'; $data3 = '{"0":"FTuq4Tox","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19331","16":"529","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"48","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"33","38":"1"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"28","38":"1"}]}'; $data4 = '{"0":"aoCjMXOs","1":"1.0.0","2":"10480","3":"1437386940","4":"6512549a","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19457","16":"656","17":"900","19":"1","20":"11","21":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","2":"1","5":"YUG_X_Gmr","7":"98","11":"1","17":"1","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"154","8":"1","9":"1","11":"1","14":"2","15":"1","17":"1","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"149","8":"10","13":"2","16":"2","38":"2"},{"0":"6","1":"182.181.184.161","5":"YUG_X_Gmr","7":"58","8":"1","9":"1","15":"1","38":"2"}]}'; $data5 = '{"0":"gZzV5JGQ","1":"1.0.0","2":"10480","3":"1437386880","4":"11cc6f19","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19362","16":"560","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"77","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"62","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"58","38":"2"}]}'; $data6 = '{"0":"hdr5q4FG","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19343","16":"541","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"60","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"44","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"40","38":"2"}]}'; $data6 = '{"0":"jWO6l3xa","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19339","16":"537","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"56","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"40","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"36","38":"2"}]}'; $data7 = '{"0":"kZ4Jk2DK","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19334","16":"532","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"51","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"36","38":"2"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"32","38":"2"}]}'; $data8 = '{"0":"yTuq4Toy","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19331","16":"529","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"48","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"33","38":"1"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"28","38":"1"}]}'; $data9 = '{"0":"gcqo6buP","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19331","16":"529","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"48","38":"2"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"33","38":"1"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo","7":"28","38":"1"}]}'; $data10 = '{"0":"rTjAGcAF","1":"1.0.0","2":"10480","3":"1437386820","4":"481b525e","6":"1.0","7":"[c=FFFF00]WWW.KNIGHTofSORROW.TK (Antics)","11":"3","12":"12","13":"1","14":"5","15":"19301","16":"499","17":"900","19":"1","22":"0","27":[{"0":"0","1":"182.185.80.115","2":"1","5":"YUG_X_Gmr","7":"67","38":"2"},{"0":"1","1":"182.185.83.84","2":"1","5":"YUG_X_Gmr","7":"139"},{"0":"2","1":"182.181.216.180","2":"1","5":"||KhaN||Namo(VIEW)","7":"247","11":"1","17":"1","38":"4"},{"0":"3","1":"182.181.184.161","5":"YUG_X_Gmr","7":"20"},{"0":"4","1":"182.185.27.16","5":"RainBoW","6":"1","7":"4"},{"0":"5","1":"182.181.216.180","5":"||KhaN||_Namo"}]}'; $s1 = new App\Server\ServerTracker(json_decode($data1,true)); $s2 = new App\Server\ServerTracker(json_decode($data2,true)); $s3 = new App\Server\ServerTracker(json_decode($data3,true)); $s4 = new App\Server\ServerTracker(json_decode($data4,true)); $s5 = new App\Server\ServerTracker(json_decode($data5,true)); $s6 = new App\Server\ServerTracker(json_decode($data6,true)); $s7 = new App\Server\ServerTracker(json_decode($data7,true)); $s8 = new App\Server\ServerTracker(json_decode($data8,true)); $s9 = new App\Server\ServerTracker(json_decode($data9,true)); $s10 = new App\Server\ServerTracker(json_decode($data10,true)); $s1->track(); $s2->track(); $s3->track(); $s4->track(); $s5->track(); $s6->track(); $s7->track(); $s8->track(); $s9->track(); $s10->track(); */ if (Cache::has('top_players')) { $topPlayers = Cache::get('top_players'); } else { $topPlayers = \App\PlayerTotal::with(['country', 'rank'])->orderBy('position')->limit(10)->get(); } $latestGames = \App\Game::normal()->orderBy('created_at', 'desc')->limit(5)->get(); //return (Carbon\Carbon::now()->subYears(100)); $player = \App\Player::first(); $AllTime = new \Illuminate\Support\Collection(); $PastWeek = new \Illuminate\Support\Collection(); $PastMonth = new \Illuminate\Support\Collection(); $PastYear = new \Illuminate\Support\Collection(); if ($player != null) { //All Time Total Score if (Cache::has('alltime_totalScore')) { $AllTime->totalScore = Cache::get('alltime_totalScore'); } else { $AllTime->totalScore = $player->getBestIn('SUM(score) as totalscore', 'totalscore'); Cache::put('alltime_totalScore', $AllTime->totalScore, 720); } //All Time Highest Score if (Cache::has('alltime_highestScore')) { $AllTime->highestScore = Cache::get('alltime_highestScore'); } else { $AllTime->highestScore = $player->getBestIn('MAX(score) as highestscore', 'highestscore'); Cache::put('alltime_highestScore', $AllTime->highestScore, 720); } //All Time Total Arrests if (Cache::has('alltime_totalArrests')) { $AllTime->totalArrests = Cache::get('alltime_totalArrests'); } else { $AllTime->totalArrests = $player->getBestIn('SUM(arrests) as totalarrests', 'totalarrests'); Cache::put('alltime_totalArrests', $AllTime->totalArrests, 720); } //All Time Total Arrested if (Cache::has('alltime_totalArrested')) { $AllTime->totalArrested = Cache::get('alltime_totalArrested'); } else { $AllTime->totalArrested = $player->getBestIn('SUM(arrested) as totalarrested', 'totalarrested'); Cache::put('alltime_totalArrested', $AllTime->totalArrested, 720); } //All Time Total Kills if (Cache::has('alltime_totalKills')) { $AllTime->totalKills = Cache::get('alltime_totalKills'); } else { $AllTime->totalKills = $player->getBestIn('SUM(kills) as totalkills', 'totalkills'); Cache::put('alltime_totalKills', $AllTime->totalKills, 720); } //All Time Total Deaths if (Cache::has('alltime_totalDeaths')) { $AllTime->totalDeaths = Cache::get('alltime_totalDeaths'); } else { $AllTime->totalDeaths = $player->getBestIn('SUM(deaths) as totaldeaths', 'totaldeaths'); Cache::put('alltime_totalDeaths', $AllTime->totalDeaths, 720); } //All Time Best Arrest Steak if (Cache::has('alltime_bestArrestStreak')) { $AllTime->bestArrestStreak = Cache::get('alltime_bestArrestStreak'); } else { $AllTime->bestArrestStreak = $player->getBestIn('MAX(arrest_streak) as best_arrest_streak', 'best_arrest_streak'); Cache::put('alltime_bestArrestStreak', $AllTime->bestArrestStreak, 720); } //All Time best Kill Streak if (Cache::has('alltime_bestKillStreak')) { $AllTime->bestKillStreak = Cache::get('alltime_bestKillStreak'); } else { $AllTime->bestKillStreak = $player->getBestIn('MAX(kill_streak) as best_kill_streak', 'best_kill_streak'); Cache::put('alltime_bestKillStreak', $AllTime->bestKillStreak, 720); } //All Time best Death Streak if (Cache::has('alltime_bestDeathStreak')) { $AllTime->bestDeathStreak = Cache::get('alltime_bestDeathStreak'); } else { $AllTime->bestDeathStreak = $player->getBestIn('MAX(death_streak) as best_death_streak', 'best_death_streak'); Cache::put('alltime_bestDeathStreak', $AllTime->bestDeathStreak, 720); } //All Time Total Team Kills if (Cache::has('alltime_totalTeamKills')) { $AllTime->totalTeamKills = Cache::get('alltime_totalTeamKills'); } else { $AllTime->totalTeamKills = $player->getBestIn('SUM(team_kills) as totalteamkills', 'totalteamkills'); Cache::put('alltime_totalTeamKills', $AllTime->totalTeamKills, 720); } //All Time Total Time Played if (Cache::has('alltime_totalTimePlayed')) { $AllTime->totalTimePlayed = Cache::get('alltime_totalTimePlayed'); } else { $AllTime->totalTimePlayed = $player->getBestIn('SUM(time_played) as totaltimeplayed', 'totaltimeplayed'); Cache::put('alltime_totalTimePlayed', $AllTime->totalTimePlayed, 720); } //All Time bestScorePerMin if (Cache::has('alltime_bestScorePerMin')) { $AllTime->bestScorePerMin = Cache::get('alltime_bestScorePerMin'); } else { $AllTime->bestScorePerMin = $player->getBestIn('SUM(score)/SUM(time_played)*60 as scorepermin', 'scorepermin'); Cache::put('alltime_bestScorePerMin', $AllTime->bestScorePerMin, 720); } //dd($AllTime); $pastWeekDate = \Carbon\Carbon::now()->subWeek(1); //Past Week totalScore if (Cache::has('pastweek_totalScore')) { $PastWeek->totalScore = Cache::get('pastweek_totalScore'); } else { $PastWeek->totalScore = $player->getBestIn('SUM(score) as totalscore', 'totalscore', $pastWeekDate); Cache::put('pastweek_totalScore', $PastWeek->totalScore, 720); } //Past Week highestScore if (Cache::has('pastweek_highestScore')) { $PastWeek->highestScore = Cache::get('pastweek_highestScore'); } else { $PastWeek->highestScore = $player->getBestIn('MAX(score) as highestscore', 'highestscore', $pastWeekDate); Cache::put('pastweek_highestScore', $PastWeek->highestScore, 720); } //Past Week totalArrests if (Cache::has('pastweek_totalArrests')) { $PastWeek->totalArrests = Cache::get('pastweek_totalArrests'); } else { $PastWeek->totalArrests = $player->getBestIn('SUM(arrests) as totalarrests', 'totalarrests', $pastWeekDate); Cache::put('pastweek_totalArrests', $PastWeek->totalArrests, 720); } //Past Week totalArrested if (Cache::has('pastweek_totalArrested')) { $PastWeek->totalArrested = Cache::get('pastweek_totalArrested'); } else { $PastWeek->totalArrested = $player->getBestIn('SUM(arrested) as totalarrested', 'totalarrested', $pastWeekDate); Cache::put('pastweek_totalArrested', $PastWeek->totalArrested, 720); } //Past Week totalKills if (Cache::has('pastweek_totalKills')) { $PastWeek->totalKills = Cache::get('pastweek_totalKills'); } else { $PastWeek->totalKills = $player->getBestIn('SUM(kills) as totalkills', 'totalkills', $pastWeekDate); Cache::put('pastweek_totalKills', $PastWeek->totalKills, 720); } //Past Week totalDeaths if (Cache::has('pastweek_totalDeaths')) { $PastWeek->totalDeaths = Cache::get('pastweek_totalDeaths'); } else { $PastWeek->totalDeaths = $player->getBestIn('SUM(deaths) as totaldeaths', 'totaldeaths', $pastWeekDate); Cache::put('pastweek_totalDeaths', $PastWeek->totalDeaths, 720); } //Past Week bestArrestStreak if (Cache::has('pastweek_bestArrestStreak')) { $PastWeek->bestArrestStreak = Cache::get('pastweek_bestArrestStreak'); } else { $PastWeek->bestArrestStreak = $player->getBestIn('MAX(arrest_streak) as best_arrest_streak', 'best_arrest_streak', $pastWeekDate); Cache::put('pastweek_bestArrestStreak', $PastWeek->bestArrestStreak, 720); } //Past Week bestKillStreak if (Cache::has('pastweek_bestKillStreak')) { $PastWeek->bestKillStreak = Cache::get('pastweek_bestKillStreak'); } else { $PastWeek->bestKillStreak = $player->getBestIn('MAX(kill_streak) as best_kill_streak', 'best_kill_streak', $pastWeekDate); Cache::put('pastweek_bestKillStreak', $PastWeek->bestKillStreak, 720); } //Past Week bestDeathStreak if (Cache::has('pastweek_bestDeathStreak')) { $PastWeek->bestDeathStreak = Cache::get('pastweek_bestDeathStreak'); } else { $PastWeek->bestDeathStreak = $player->getBestIn('MAX(death_streak) as best_death_streak', 'best_death_streak', $pastWeekDate); Cache::put('pastweek_bestDeathStreak', $PastWeek->bestDeathStreak, 720); } //Past Week totalTeamKills if (Cache::has('pastweek_totalTeamKills')) { $PastWeek->totalTeamKills = Cache::get('pastweek_totalTeamKills'); } else { $PastWeek->totalTeamKills = $player->getBestIn('SUM(team_kills) as totalteamkills', 'totalteamkills', $pastWeekDate); Cache::put('pastweek_totalTeamKills', $PastWeek->totalTeamKills, 720); } //Past Week totalTimePlayed if (Cache::has('pastweek_totalTimePlayed')) { $PastWeek->totalTimePlayed = Cache::get('pastweek_totalTimePlayed'); } else { $PastWeek->totalTimePlayed = $player->getBestIn('SUM(time_played) as totaltimeplayed', 'totaltimeplayed', $pastWeekDate); Cache::put('pastweek_totalTimePlayed', $PastWeek->totalTimePlayed, 720); } //Past Week bestScorePerMin if (Cache::has('pastweek_bestScorePerMin')) { $PastWeek->bestScorePerMin = Cache::get('pastweek_bestScorePerMin'); } else { $PastWeek->bestScorePerMin = $player->getBestIn('SUM(score)/SUM(time_played)*60 as scorepermin', 'scorepermin', $pastWeekDate); Cache::put('pastweek_bestScorePerMin', $PastWeek->bestScorePerMin, 720); } $pastMonthDate = \Carbon\Carbon::now()->subMonth(1); //Past Month totalScore if (Cache::has('pastmonth_totalScore')) { $PastMonth->totalScore = Cache::get('pastmonth_totalScore'); } else { $PastMonth->totalScore = $player->getBestIn('SUM(score) as totalscore', 'totalscore', $pastMonthDate); Cache::put('pastmonth_totalScore', $PastMonth->totalScore, 720); } //Past Month highestScore if (Cache::has('pastmonth_highestScore')) { $PastMonth->highestScore = Cache::get('pastmonth_highestScore'); } else { $PastMonth->highestScore = $player->getBestIn('MAX(score) as highestscore', 'highestscore', $pastMonthDate); Cache::put('pastmonth_highestScore', $PastMonth->highestScore, 720); } //Past Month totalArrests if (Cache::has('pastmonth_totalArrests')) { $PastMonth->totalArrests = Cache::get('pastmonth_totalArrests'); } else { $PastMonth->totalArrests = $player->getBestIn('SUM(arrests) as totalarrests', 'totalarrests', $pastMonthDate); Cache::put('pastmonth_totalArrests', $PastMonth->totalArrests, 720); } //Past Month totalArrested if (Cache::has('pastmonth_totalArrested')) { $PastMonth->totalArrested = Cache::get('pastmonth_totalArrested'); } else { $PastMonth->totalArrested = $player->getBestIn('SUM(arrested) as totalarrested', 'totalarrested', $pastMonthDate); Cache::put('pastmonth_totalArrested', $PastMonth->totalArrested, 720); } //Past Month totalKills if (Cache::has('pastmonth_totalKills')) { $PastMonth->totalKills = Cache::get('pastmonth_totalKills'); } else { $PastMonth->totalKills = $player->getBestIn('SUM(kills) as totalkills', 'totalkills', $pastMonthDate); Cache::put('pastmonth_totalKills', $PastMonth->totalKills, 720); } //Past Month totalDeaths if (Cache::has('pastmonth_totalDeaths')) { $PastMonth->totalDeaths = Cache::get('pastmonth_totalDeaths'); } else { $PastMonth->totalDeaths = $player->getBestIn('SUM(deaths) as totaldeaths', 'totaldeaths', $pastMonthDate); Cache::put('pastmonth_totalDeaths', $PastMonth->totalDeaths, 720); } //Past Month bestArrestStreak if (Cache::has('pastmonth_bestArrestStreak')) { $PastMonth->bestArrestStreak = Cache::get('pastmonth_bestArrestStreak'); } else { $PastMonth->bestArrestStreak = $player->getBestIn('MAX(arrest_streak) as best_arrest_streak', 'best_arrest_streak', $pastMonthDate); Cache::put('pastmonth_bestArrestStreak', $PastMonth->bestArrestStreak, 720); } //Past Month bestKillStreak if (Cache::has('pastmonth_bestKillStreak')) { $PastMonth->bestKillStreak = Cache::get('pastmonth_bestKillStreak'); } else { $PastMonth->bestKillStreak = $player->getBestIn('MAX(kill_streak) as best_kill_streak', 'best_kill_streak', $pastMonthDate); Cache::put('pastmonth_bestKillStreak', $PastMonth->bestKillStreak, 720); } //Past Month bestDeathStreak if (Cache::has('pastmonth_bestDeathStreak')) { $PastMonth->bestDeathStreak = Cache::get('pastmonth_bestDeathStreak'); } else { $PastMonth->bestDeathStreak = $player->getBestIn('MAX(death_streak) as best_death_streak', 'best_death_streak', $pastMonthDate); Cache::put('pastmonth_bestDeathStreak', $PastMonth->bestDeathStreak, 720); } //Past Month totalTeamKills if (Cache::has('pastmonth_totalTeamKills')) { $PastMonth->totalTeamKills = Cache::get('pastmonth_totalTeamKills'); } else { $PastMonth->totalTeamKills = $player->getBestIn('SUM(team_kills) as totalteamkills', 'totalteamkills', $pastMonthDate); Cache::put('pastmonth_totalTeamKills', $PastMonth->totalTeamKills, 720); } //Past Month totalTimePlayed if (Cache::has('pastmonth_totalTimePlayed')) { $PastMonth->totalTimePlayed = Cache::get('pastmonth_totalTimePlayed'); } else { $PastMonth->totalTimePlayed = $player->getBestIn('SUM(time_played) as totaltimeplayed', 'totaltimeplayed', $pastMonthDate); Cache::put('pastmonth_totalTimePlayed', $PastMonth->totalTimePlayed, 720); } //Past Month bestScorePerMin if (Cache::has('pastmonth_bestScorePerMin')) { $PastMonth->bestScorePerMin = Cache::get('pastmonth_bestScorePerMin'); } else { $PastMonth->bestScorePerMin = $player->getBestIn('SUM(score)/SUM(time_played)*60 as scorepermin', 'scorepermin', $pastMonthDate); Cache::put('pastmonth_bestScorePerMin', $PastMonth->bestScorePerMin, 720); } $pastYearDate = \Carbon\Carbon::now()->subYear(1); //Past Year totalScore if (Cache::has('pastyear_totalScore')) { $PastYear->totalScore = Cache::get('pastyear_totalScore'); } else { $PastYear->totalScore = $player->getBestIn('SUM(score) as totalscore', 'totalscore', $pastYearDate); Cache::put('pastyear_totalScore', $PastYear->totalScore, 720); } //Past Year highestScore if (Cache::has('pastyear_highestScore')) { $PastYear->highestScore = Cache::get('pastyear_highestScore'); } else { $PastYear->highestScore = $player->getBestIn('MAX(score) as highestscore', 'highestscore', $pastYearDate); Cache::put('pastyear_highestScore', $PastYear->highestScore, 720); } //Past Year totalArrests if (Cache::has('pastyear_totalArrests')) { $PastYear->totalArrests = Cache::get('pastyear_totalArrests'); } else { $PastYear->totalArrests = $player->getBestIn('SUM(arrests) as totalarrests', 'totalarrests', $pastYearDate); Cache::put('pastyear_totalArrests', $PastYear->totalArrests, 720); } //Past Year totalArrested if (Cache::has('pastyear_totalArrested')) { $PastYear->totalArrested = Cache::get('pastyear_totalArrested'); } else { $PastYear->totalArrested = $player->getBestIn('SUM(arrested) as totalarrested', 'totalarrested', $pastYearDate); Cache::put('pastyear_totalArrested', $PastYear->totalArrested, 720); } //Past Year totalKills if (Cache::has('pastyear_totalKills')) { $PastYear->totalKills = Cache::get('pastyear_totalKills'); } else { $PastYear->totalKills = $player->getBestIn('SUM(kills) as totalkills', 'totalkills', $pastYearDate); Cache::put('pastyear_totalKills', $PastYear->totalKills, 720); } //Past Year totalDeaths if (Cache::has('pastyear_totalDeaths')) { $PastYear->totalDeaths = Cache::get('pastyear_totalDeaths'); } else { $PastYear->totalDeaths = $player->getBestIn('SUM(deaths) as totaldeaths', 'totaldeaths', $pastYearDate); Cache::put('pastyear_totalDeaths', $PastYear->totalDeaths, 720); } //Past Year bestArrestStreak if (Cache::has('pastyear_bestArrestStreak')) { $PastYear->bestArrestStreak = Cache::get('pastyear_bestArrestStreak'); } else { $PastYear->bestArrestStreak = $player->getBestIn('MAX(arrest_streak) as best_arrest_streak', 'best_arrest_streak', $pastYearDate); Cache::put('pastyear_bestArrestStreak', $PastYear->bestArrestStreak, 720); } //Past Year bestKillStreak if (Cache::has('pastyear_bestKillStreak')) { $PastYear->bestKillStreak = Cache::get('pastyear_bestKillStreak'); } else { $PastYear->bestKillStreak = $player->getBestIn('MAX(kill_streak) as best_kill_streak', 'best_kill_streak', $pastYearDate); Cache::put('pastyear_bestKillStreak', $PastYear->bestKillStreak, 720); } //Past Year bestDeathStreak if (Cache::has('pastyear_bestDeathStreak')) { $PastYear->bestDeathStreak = Cache::get('pastyear_bestDeathStreak'); } else { $PastYear->bestDeathStreak = $player->getBestIn('MAX(death_streak) as best_death_streak', 'best_death_streak', $pastYearDate); Cache::put('pastyear_bestDeathStreak', $PastYear->bestDeathStreak, 720); } //Past Year totalTeamKills if (Cache::has('pastyear_totalTeamKills')) { $PastYear->totalTeamKills = Cache::get('pastyear_totalTeamKills'); } else { $PastYear->totalTeamKills = $player->getBestIn('SUM(team_kills) as totalteamkills', 'totalteamkills', $pastYearDate); Cache::put('pastyear_totalTeamKills', $PastYear->totalTeamKills, 720); } //Past Year totalTimePlayed if (Cache::has('pastyear_totalTimePlayed')) { $PastYear->totalTimePlayed = Cache::get('pastyear_totalTimePlayed'); } else { $PastYear->totalTimePlayed = $player->getBestIn('SUM(time_played) as totaltimeplayed', 'totaltimeplayed', $pastYearDate); Cache::put('pastyear_totalTimePlayed', $PastYear->totalTimePlayed, 720); } //Past Year bestScorePerMin if (Cache::has('pastyear_bestScorePerMin')) { $PastYear->bestScorePerMin = Cache::get('pastyear_bestScorePerMin'); } else { $PastYear->bestScorePerMin = $player->getBestIn('SUM(score)/SUM(time_played)*60 as scorepermin', 'scorepermin', $pastYearDate); Cache::put('pastyear_bestScorePerMin', $PastYear->bestScorePerMin, 720); } } else { $AllTime->totalScore = 0; $AllTime->highestScore = 0; $AllTime->totalArrests = 0; $AllTime->totalArrested = 0; $AllTime->totalKills = 0; $AllTime->totalDeaths = 0; $AllTime->bestArrestStreak = 0; $AllTime->bestKillStreak = 0; $AllTime->bestDeathStreak = 0; $AllTime->totalTeamKills = 0; $AllTime->totalTimePlayed = 0; $AllTime->bestScorePerMin = 0; $pastWeekDate = \Carbon\Carbon::now()->subWeek(1); $PastWeek->totalScore = 0; $PastWeek->highestScore = 0; $PastWeek->totalArrests = 0; $PastWeek->totalArrested = 0; $PastWeek->totalKills = 0; $PastWeek->totalDeaths = 0; $PastWeek->bestArrestStreak = 0; $PastWeek->bestKillStreak = 0; $PastWeek->bestDeathStreak = 0; $PastWeek->totalTeamKills = 0; $PastWeek->totalTimePlayed = 0; $PastWeek->bestScorePerMin = 0; $pastMonthDate = \Carbon\Carbon::now()->subMonth(1); $PastMonth->totalScore = 0; $PastMonth->highestScore = 0; $PastMonth->totalArrests = 0; $PastMonth->totalArrested = 0; $PastMonth->totalKills = 0; $PastMonth->totalDeaths = 0; $PastMonth->bestArrestStreak = 0; $PastMonth->bestKillStreak = 0; $PastMonth->bestDeathStreak = 0; $PastMonth->totalTeamKills = 0; $PastMonth->totalTimePlayed = 0; $PastMonth->bestScorePerMin = 0; $pastYearDate = \Carbon\Carbon::now()->subYear(1); $PastYear->totalScore = 0; $PastYear->highestScore = 0; $PastYear->totalArrests = 0; $PastYear->totalArrested = 0; $PastYear->totalKills = 0; $PastYear->totalDeaths = 0; $PastYear->bestArrestStreak = 0; $PastYear->bestKillStreak = 0; $PastYear->bestDeathStreak = 0; $PastYear->totalTeamKills = 0; $PastYear->totalTimePlayed = 0; $PastYear->bestScorePerMin = 0; } if ($PastYear->totalScore == null) { $PastYear = $AllTime; } if ($PastMonth->totalScore == null) { $PastMonth = $PastYear; } if ($PastWeek->totalScore == null) { $PastWeek = $PastMonth; } //Latest Feeds //$feeds = Status::with('user')->latest()->limit(5)->get(); $notifications = Notification::stream()->latest()->limit(5)->get(); $activeUsers = User::orderBy('updated_at', 'DESC')->limit(50)->get(); $bans = Ban::orderBy('updated_at', 'desc')->limit(5)->get(); $array = ['topPlayers' => $topPlayers, 'latestGames' => $latestGames, 'AllTime' => $AllTime, 'PastWeek' => $PastWeek, 'PastMonth' => $PastMonth, 'PastYear' => $PastYear, 'bans' => $bans, 'notifications' => $notifications, 'activeUsers' => $activeUsers, 'show_donation' => $show_donation, 'show_add' => $show_add]; return view('home', $array); }
/** * Get the proper failed validation response for the request. * * @param array $errors * @return \Symfony\Component\HttpFoundation\Response */ public function response(array $errors) { if (!$this->respectTheRobot) { $this->ban = Ban::addRobotBan($this->board); return $this->forbiddenResponse(); } $redirectURL = $this->getRedirectUrl(); if ($this->wantsJson()) { return $this->apiResponse(['errors' => $errors]); } return redirect($redirectURL)->withInput($this->except($this->dontFlash))->withErrors($errors, $this->errorBag); }
public function getIndex(Board $board) { $bans = Ban::getBans(Request::ip()); return $this->view(static::VIEW_BANNED, ['bans' => $bans]); }
public static function getBan($ip, $board_uri = null) { return Ban::where('ban_ip', 'like', $ip)->board($board_uri)->current()->get()->last(); }
public function deleteBan($id) { $ban = Ban::findOrFail($id); $ban->delete(); flash()->info('Postać o ID <b>' . $id . '</b> została odbanowana!'); return redirect('/admin/ban'); }
/** * */ public function putMod(Request $request, Board $board, $post) { // Validate the request parameters. if (!($post = $this->validatePost($board, $post)) instanceof Post) { // If the response isn't a Post, it's a redirect or error. // Return the message. return $post; } // Take trailing arguments, // compare them against a list of real actions, // intersect the liss to find the true commands. $actions = ["delete", "ban", "all", "global"]; $argList = func_get_args(); $modActions = array_intersect($actions, array_splice($argList, 2)); sort($modActions); $ban = in_array("ban", $modActions); $delete = in_array("delete", $modActions); $all = in_array("all", $modActions); $global = in_array("global", $modActions); if (!$ban) { return abort(404); } $validator = Validator::make(Input::all(), ['ban_ip' => 'required|ip', 'justification' => 'max:255', 'expires_days' => 'required|integer|min:0|max:' . $this->option('banMaxLength'), 'expires_hours' => 'required|integer|min:0|max:23', 'expires_minutes' => 'required|integer|min:0|max:59']); if (!$validator->passes()) { return redirect()->back()->withInput(Input::all())->withErrors($validator->errors()); } $banLengthStr = []; $expiresDays = Input::get('expires_days'); $expiresHours = Input::get('expires_hours'); $expiresMinutes = Input::get('expires_minutes'); if ($expiresDays > 0) { $banLengthStr[] = "{$expiresDays}d"; } if ($expiresHours > 0) { $banLengthStr[] = "{$expiresHours}h"; } if ($expiresMinutes > 0) { $banLengthStr[] = "{$expiresMinutes}m"; } if ($expiresDays == 0 && $expiresHours == 0 && $expiresMinutes == 0) { $banLengthStr[] = "Ø"; } $banLengthStr = implode($banLengthStr, " "); $ban = new Ban(); $ban->ban_ip = Input::get('ban_ip'); $ban->seen = false; $ban->created_at = $ban->freshTimestamp(); $ban->updated_at = clone $ban->created_at; $ban->expires_at = clone $ban->created_at; $ban->expires_at->addDays($expiresDays); $ban->expires_at->addHours($expiresHours); $ban->expires_at->addMinutes($expiresMinutes); $ban->mod_id = $this->user->user_id; $ban->post_id = $post->post_id; $ban->ban_reason_id = null; $ban->justification = Input::get('justification'); if ($global) { if ($ban && !$this->user->canBanGlobally() || $delete && !$this->user->canDeleteGlobally()) { return abort(403); } if ($ban) { $ban->board_uri = null; $ban->save(); } $this->log('log.post.ban.global', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->author_ip, "justification" => $ban->justification, "time" => $banLengthStr]); if ($delete) { $posts = Post::where('author_ip', $post->author_ip); $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => $posts->count()]); $posts->delete(); return redirect($board->board_uri); } } else { if ($ban && !$board->canBan($this->user) || $delete && !$board->canDelete($this->user)) { return abort(403); } if ($ban) { $ban->board_uri = $post->board_uri; $ban->save(); } $this->log('log.post.ban.local', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->author_ip, "justification" => $ban->justification, "time" => $banLengthStr]); if ($delete) { if ($all) { $posts = Post::where('author_ip', $post->author_ip)->where('board_uri', $board->board_uri); $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => $posts->count()]); $posts->delete(); return redirect($board->board_uri); } else { $this->log('log.post.ban.delete', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "posts" => 1]); $post->delete(); if ($post->reply_to) { return redirect("{$post->board_uri}/thread/{$post->op->board_id}"); } else { return redirect($board->board_uri); } } } } Event::fire(new PostWasBanned($post)); if ($post->reply_to) { return redirect("{$post->board_uri}/thread/{$post->op->board_id}#{$post->board_id}"); } else { return redirect("{$post->board_uri}/thread/{$post->board_id}"); } }
/** * Fetches all applicable bans. * * @param string $ip Human-readable IP. * @param string|null|false $board_uri Board|Global Only|Both * @return Ban */ public static function getBans($ip, $board_uri = null) { return Ban::ipString($ip)->board($board_uri)->whereActive()->orderBy('board_uri', 'desc')->with('mod')->get(); }
/** * Returns if the client has access to this form. * * @return boolean */ public function authorize() { return !Ban::isBanned($this->ip(), $this->board); }
/** * Validate the class instance. * This overrides the default invocation to provide additional rules after the controller is setup. * * @return void */ public function validate() { $board = $this->board; $user = $this->user; if (is_null($board) || is_null($user)) { return parent::validate(); } $validator = $this->getValidatorInstance(); $messages = $validator->errors(); // Check global flood. $lastPost = Post::where('author_ip', inet_pton($this->ip()))->where('created_at', '>', \Carbon\Carbon::now()->subSeconds(30))->op()->first(); if ($lastPost instanceof Post) { $timeDiff = 30 - $lastPost->created_at->diffInSeconds(); $messages = $validator->errors(); $messages->add("flood", trans_choice("validation.custom.thread_flood", $timeDiff, ['time_left' => $timeDiff])); $this->failedValidation($validator); return; } // Ban check. $ban = Ban::getBan($this->ip(), $board->board_uri); if ($ban) { $messages = $validator->errors(); $messages->add("body", trans("validation.custom.banned")); $this->ban = $ban; $this->failedValidation($validator); return; } // Board-level setting validaiton. $validator->sometimes('captcha', "required|captcha", function ($input) use($board) { return !$board->canPostWithoutCaptcha($this->user); }); if (!$validator->passes()) { $this->failedValidation($validator); } else { if (!$this->user->canAdminConfig() && $board->canPostWithoutCaptcha($this->user)) { // Check last post time for flood. $floodTime = site_setting('postFloodTime'); if ($floodTime > 0) { $lastPost = Post::getLastPostForIP(); if ($lastPost) { $floodTimer = clone $lastPost->created_at; $floodTimer->addSeconds($floodTime); if ($floodTimer->isFuture()) { $messages->add("body", trans("validation.custom.post_flood", ['time_left' => $floodTimer->diffInSeconds()])); } } } } // Validate individual files. $input = $this->all(); // Process uploads. if (isset($input['files'])) { $uploads = $input['files']; if (count($uploads) > 0) { foreach ($uploads as $uploadIndex => $upload) { // If a file is uploaded that has a specific filename, it breaks the process. if (method_exists($upload, "getPathname") && !file_exists($upload->getPathname())) { $messages->add("files.{$uploadIndex}", trans("validation.custom.file_corrupt", ["filename" => $upload->getClientOriginalName()])); } } } } } if (count($validator->errors())) { $this->failedValidation($validator); } }
/** * Masterban masterbanlist.txt maker * @return null * @print txt */ public function masterbantxt() { //$filename = "masterbanlist.txt"; $bans = Ban::where('status', '1')->get(); $banlist = ""; foreach ($bans as $ban) { $banlist = $banlist . $ban->ip_address . ","; } printf("%s", $banlist); exit(0); //$headers = ['Content-type' => 'plain/txt', 'Connection' => 'close', 'Content-Disposition' => sprintf('attachment; filename=%s',$filename),'Content-length' => sizeof($banlist)]; //return \Response::make($banlist,200,$headers); }