예제 #1
0
 /**
  * Update the specified resource in storage.
  * @return Response
  * @internal param int $id
  */
 public function updateProfile(Request $request)
 {
     $type = $request->type;
     switch ($type) {
         case "UpdatePassword":
             $validator = \Validator::make($request->all(), ['email' => 'required|email|max:255', 'password' => 'required|confirmed|min:6']);
             if ($validator->fails()) {
                 return \Redirect::back()->with('errors', $validator->errors())->withInput();
             }
             if ($request->email != Auth::user()->getEmailForPasswordReset()) {
                 return \Redirect::back()->with('error', 'Email doesnot match current users.');
             }
             $user = Auth::user();
             $user->password = bcrypt($request->password);
             $user->save();
             return \Redirect::back()->with('message', 'Password has been updated successfully! :)');
             break;
         case "LinkPlayer":
             $playerIP = $request->getClientIp();
             $inGamePlayerName = $request->ingameplayer;
             $playerTotal = \App\PlayerTotal::where('last_ip_address', 'LIKE', $playerIP)->where('name', 'LIKE', $inGamePlayerName)->get();
             if ($inGamePlayerName == $request->user()->player_totals_name) {
                 return \Redirect::back()->with('message', 'This player is already linked to your account. ;)');
             }
             $playerAlreadyClaimed = \App\PlayerTotal::isClaimed($inGamePlayerName);
             if ($playerTotal->isEmpty()) {
                 $user = Auth::user();
                 $user->player_totals_name = null;
                 $user->save();
                 return \Redirect::back()->with('message', 'You have successfully unlinked player from your profile.');
             } elseif ($playerAlreadyClaimed) {
                 return \Redirect::back()->with('error', "Player already claimed by @{$playerAlreadyClaimed->username} :/");
             } else {
                 $user = Auth::user();
                 $user->player_totals_name = $inGamePlayerName;
                 $user->save();
                 return \Redirect::back()->with('message', "You have successfully linked {$inGamePlayerName} to your profile.");
             }
             break;
         default:
             return \Redirect::back()->with('error', "Something went wrong :(");
             break;
     }
     return \Redirect::back()->with('error', "Something went wrong :(");
 }
예제 #2
0
 public function whoisforserver(Request $request)
 {
     $data = $request->data;
     $data = explode("\$\$", $data);
     $playerName = $data[0];
     $playerIp = $data[1];
     $bOffline = $data[2];
     $key = $data[3];
     if ($data == NULL || empty($data) || "koswhois1337" != $key) {
         printf("%s", "[b]([c=00ff00]KNIGHTofSORROW.TK[\\c]): [c=ff0000]Unable to Query Server");
         exit;
     }
     /**
      * Player Query System
      */
     /**
      * If the Searched Name is Not Present in Server
      *
      */
     if ($bOffline == "yes") {
         $players = PlayerTotal::where('name', 'LIKE', "%{$playerName}%")->get();
         /**
          * If Not Found
          */
         if ($players->isEmpty() || is_null($players)) {
             return view('api.whois.notfound')->with('playerName', $playerName);
         } elseif ($players->count() == 1) {
             $player = $players->first();
             /*$data = [
                   'player' => $player,
                   'playerAddr' => $player->country->countryName,
               ];*/
             printf("[c=FFFF00][b][u]%s[\\u][\\b][\\c] is from [b][c=EBFFFF]%s[\\c][\\b]", $player->name, $player->country->countryName);
             exit;
             //return view('api.whois.onefound', $data);
         } else {
             $playerss = PlayerTotal::where('name', 'LIKE', "{$playerName}")->get();
             // Display single one
             if ($playerss->count() == 1) {
                 $player = $playerss->first();
                 printf("[c=FFFF00][b][u]%s[\\u][\\b][\\c] is from [b][c=EBFFFF]%s[\\c][\\b]", $player->name, $player->country->countryName);
                 exit;
                 /*$data = [
                       'player' => $player,
                       'playerAddr' => $player->country->countryName,
                   ];
                   return view('api.whois.onefound', $data);*/
             } else {
                 $playerlist = "";
                 $i = 1;
                 foreach ($players->take(2) as $player) {
                     // If the limit exceed 4 players then only show 2
                     $playerlist = $playerlist . "[c=FFFF00]" . $player->name . "[\\c][c=00ff00] - [\\c]";
                 }
                 $playerlist = substr($playerlist, 0, -17);
                 printf("Found [b]%s[\\b] players matching [b]%s[\\b]:\\n [b]%s[\\b]", $players->count(), $playerName, $playerlist);
                 exit;
                 /*$data = [
                       'players' => $players,
                       'searchQuery' => $playerName
                   ];
                   return view('api.whois.manyfound', $data);*/
             }
         }
     } else {
         if ($bOffline == "no") {
             $geoip = \App::make('geoip');
             $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
             try {
                 if ($player_geoip = $geoip->city($playerIp)) {
                     $playerCountryName = $player_geoip->city->names['en'] == "" ? "" : $player_geoip->city->names['en'] . ",";
                     $playerCountryName = $playerCountryName . $player_geoip->country->names['en'];
                 }
             } catch (\Exception $e) {
                 switch ($e) {
                     case $e instanceof \InvalidArgumentException:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                     case $e instanceof \GeoIp2\Exception\AddressNotFoundException:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                     default:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                 }
             }
             /**
              * Player has never played in this server before
              */
             printf("[c=FFFF00][b][u]%s[\\u][\\b][\\c] is from [b][c=EBFFFF]%s[\\c][\\b]", $playerName, $playerCountryName);
             exit;
         } elseif ($bOffline == "justjoined") {
             $geoip = \App::make('geoip');
             $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
             try {
                 if ($player_geoip = $geoip->city($playerIp)) {
                     $playerCountryName = $player_geoip->city->names['en'] == "" ? "" : $player_geoip->city->names['en'] . ",";
                     $playerCountryName = $playerCountryName . $player_geoip->country->names['en'];
                 }
             } catch (\Exception $e) {
                 switch ($e) {
                     case $e instanceof \InvalidArgumentException:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                     case $e instanceof \GeoIp2\Exception\AddressNotFoundException:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                     default:
                         $playerCountryName = "[c=d3d3d3]Unknown Territory[\\c]";
                         break;
                 }
             }
             printf("[c=FFFF00][b][u]%s[\\u][\\b][\\c] is coming from [b][c=EBFFFF]%s[\\c][\\b]", $playerName, $playerCountryName);
             exit;
         }
     }
 }
 public function getTop10()
 {
     $top10KD = PlayerTotal::where('total_kills', '>', '99')->with('country', 'rank', 'lastGame')->orderBy('killdeath_ratio', 'DESC')->limit(10)->get();
     $top10AAR = PlayerTotal::where('total_arrests', '>', '49')->with('country', 'rank', 'lastGame')->orderBy('arr_ratio', 'DESC')->limit(10)->get();
     $top10Score = PlayerTotal::orderBy('total_score', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $top10Round = PlayerTotal::orderBy('total_round_played', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $top10HighestScore = PlayerTotal::orderBy('highest_score', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $top10Winners = PlayerTotal::orderBy('game_won', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $top10KillStreak = PlayerTotal::orderBy('best_killstreak', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $top10ArrestStreak = PlayerTotal::orderBy('best_arreststreak', 'DESC')->with('country', 'rank', 'lastGame')->limit(10)->get();
     $array = ['top10KD' => $top10KD, 'top10AAR' => $top10AAR, 'top10Score' => $top10Score, 'top10Round' => $top10Round, 'top10HighestScore' => $top10HighestScore, 'top10Winners' => $top10Winners, 'top10KillStreak' => $top10KillStreak, 'top10ArrestStreak' => $top10ArrestStreak, 'position1' => 1, 'position2' => 1, 'position3' => 1, 'position4' => 1, 'position5' => 1, 'position6' => 1, 'position7' => 1, 'position8' => 1];
     return view('statistics.top10', $array);
 }
예제 #4
0
 /**
  * Returns the playerTotal of this User if any.
  *
  * @return PlayerTotal
  */
 public function playerTotal()
 {
     return PlayerTotal::where('name', 'LIKE', "{$this->player_totals_name}")->first();
 }