/** * Handle the event. * * @param ProductWasPurchased $event * @return void */ public function handle(ProductWasPurchased $event) { // if ($event->oreder->status != 2) { $product = Product::where('id', $event->oreder->product_id)->first(); $server = Server::where('id', $product->server_id)->first(); $command = str_replace(':steam_id', $event->oreder->steam_id, $product->command); $command = str_replace(':quantity', $event->oreder->quantity, $command); $data = new SourceQuery(); try { $data->Connect($server->ip, $server->port, 3, $server->engine); $data->SetRconPassword($server->rcon_password); $data->Rcon($command); $event->oreder->status = 2; $event->oreder->completed_at = Carbon::now(); $event->oreder->save(); } catch (\Exception $e) { $e->getMessage(); } } }
/** * Handle the event. * * @param ServersUpdate $event * @return void */ public function handle(ServersUpdate $event) { $servers = Server::all()->where('active', 1); if ($servers) { foreach ($servers as $server) { $data = new SourceQuery(); try { $engine = $server->engine >= 1 ? 1 : 0; $data->Connect($server->ip, $server->port, 3, $engine); $information = $data->GetInfo(); $players = $data->GetPlayers(); $rules = $data->GetRules(); } catch (\Exception $e) { $information = ''; $players = ''; $rules = ''; } $server->information = json_encode($information); $server->players = json_encode($data->GetPlayers($players)); $server->rules = json_encode($data->GetRules($rules)); $server->save(); } } }
private function getlock($match, $model, $serv) { $Query = new SourceQuery(); if (!is_null($serv)) { $server = $serv; } else { $server = $model->getServersByID($match->sid); } /* if (is_null($server)) { return ''; }*/ $addr = explode(':', $server->addr); try { $Query->Connect($addr[0], $addr[1], 1, SourceQuery::SOURCE); $info = $Query->GetInfo(); $players = $info['Players']; $serverLock = $model->getServerLock($match->id, $server->id, INTERVAL_LOCK); if ($players == 0 && is_null($serverLock)) { return 'Go to our server : ' . $server->addr . ' <a href="steam://connect/' . $server->addr . '" id="join" title="Join">Join</a>'; } } catch (Exception $e) { return ' Error: ' . $e->getMessage(); //echo $e->getMessage(); } finally { $Query->Disconnect(); } return ' Error: Server not found'; }
<?php require __DIR__ . '/../SourceQuery/bootstrap.php'; use xPaw\SourceQuery\SourceQuery; // For the sake of this example Header('Content-Type: text/plain'); Header('X-Content-Type-Options: nosniff'); // Edit this -> define('SQ_SERVER_ADDR', '69.30.238.74'); define('SQ_SERVER_PORT', 27017); define('SQ_TIMEOUT', 1); define('SQ_ENGINE', SourceQuery::SOURCE); // Edit this <- $Query = new SourceQuery(); try { $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); //$info = $Query->GetInfo( ); //print_r( $Query->GetPlayers( ) ); //print_r( $Query->GetRules( ) ); } catch (Exception $e) { echo $e->getMessage(); } finally { $Query->Disconnect(); }
private function LinkOnlinePlayers() { // $Timer = MicroTime(true); // $online = new SSQL().Players(new IPEndPoint(IPAddress.Parse(ipString), port))).ToList(); $Query = new SourceQuery(); try { $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); //$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound // $Info = $Query->GetInfo(); $queryPlayers = $Query->GetPlayers(); // $Rules = $Query->GetRules(); // $Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' ); foreach ($queryPlayers as $key => $var) { $var = (object) $var; if (empty($var->Name)) { continue; } foreach ($this->Players as $key => $value) { if ($value->SteamName == $var->Name) { $this->Players[$value->Id]->Online = true; } } } } catch (Exception $e) { $Exception = $e; die($Exception->getMessage()); } finally { $Query->Disconnect(); } }
public function joueurShow($id) { $user = $this->auth->user(); $player = DB::table('players')->where('playerid', $id)->first(); if (empty($player)) { return redirect(url('admin'))->with('error', 'Le joueur demander n\'à pas été trouver'); } $user_show = DB::table('users')->where('arma', $id)->first(); $offenses = DB::table('offenses')->where('arma_id', $id)->get(); $vehicles_cars = DB::table('vehicles')->where('pid', $id)->where('type', 'Car')->get(); $vehicles_airs = DB::table('vehicles')->where('pid', $id)->where('type', 'Air')->get(); $vehicles_ships = DB::table('vehicles')->where('pid', $id)->where('type', 'Ship')->get(); $ranks_cop = DB::table('ranks')->where('side', 'COP')->get(); $ranks_medic = DB::table('ranks')->where('side', 'MEDIC')->get(); $ranks_admin = DB::table('ranks')->where('side', 'ADMIN')->get(); $ranks_donator = DB::table('ranks')->where('side', 'DONATOR')->get(); $insure = DB::table('settings')->where('name', 'insure')->first(); $alias = DB::table('settings')->where('name', 'alias')->first(); $houses = DB::table('houses')->where('pid', $id)->get(); $licensesName = DB::table('settings')->where('action', 'LICENSES')->get(); if (env('RCON_INIT') == true) { $Query = new SourceQuery(); $Query->Connect(env('RCON_IP'), env('RCON_PORT', 2303), 1, SourceQuery::SOURCE); } else { $Query = false; } $gang = DB::table('gangs')->where('owner', $id)->first(); return view('admin.players.show', compact('Query', 'ranks_donator', 'alias', 'houses', 'licensesName', 'insure', 'ranks_admin', 'ranks_cop', 'ranks_medic', 'offenses', 'user', 'player', 'vehicles_cars', 'vehicles_airs', 'vehicles_ships', 'gang', 'user_show')); }
<?php require __DIR__ . '/../SourceQuery/bootstrap.php'; use xPaw\SourceQuery\SourceQuery; // For the sake of this example Header('Content-Type: text/plain'); Header('X-Content-Type-Options: nosniff'); // Edit this -> define('SQ_SERVER_ADDR', '162.251.166.186'); define('SQ_SERVER_PORT', 27016); define('SQ_TIMEOUT', 1); define('SQ_ENGINE', SourceQuery::SOURCE); // Edit this <- $Query = new SourceQuery(); try { $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); print_r($Query->GetInfo()); print_r($Query->GetPlayers()); print_r($Query->GetRules()); } catch (Exception $e) { echo $e->getMessage(); } finally { $Query->Disconnect(); }
<?php require __DIR__ . '/../SourceQuery/bootstrap.php'; use xPaw\SourceQuery\SourceQuery; // Edit this -> define('SQ_SERVER_ADDR', 'localhost'); define('SQ_SERVER_PORT', 27015); define('SQ_TIMEOUT', 3); define('SQ_ENGINE', SourceQuery::SOURCE); // Edit this <- $Timer = MicroTime(true); $Query = new SourceQuery(); $Info = array(); $Rules = array(); $Players = array(); try { $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); //$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound $Info = $Query->GetInfo(); $Players = $Query->GetPlayers(); $Rules = $Query->GetRules(); } catch (Exception $e) { $Exception = $e; } finally { $Query->Disconnect(); } $Timer = Number_Format(MicroTime(true) - $Timer, 4, '.', ''); ?> <!DOCTYPE html> <html> <head>
<?php require __DIR__ . '/../SourceQuery/bootstrap.php'; use xPaw\SourceQuery\SourceQuery; // For the sake of this example Header('Content-Type: text/plain'); Header('X-Content-Type-Options: nosniff'); // Edit this -> define('SQ_SERVER_ADDR', 'localhost'); define('SQ_SERVER_PORT', 27015); define('SQ_TIMEOUT', 1); define('SQ_ENGINE', SourceQuery::SOURCE); // Edit this <- $Query = new SourceQuery(); try { $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); $Query->SetRconPassword('my_awesome_password'); var_dump($Query->Rcon('say hello')); } catch (Exception $e) { echo $e->getMessage(); } finally { $Query->Disconnect(); }
public function startServer($model, $match) { $servers = $model->getServersList(); //Header('Content-Type: text/plain'); //Header('X-Content-Type-Options: nosniff'); //define('SQ_TIMEOUT', 1); //define('SQ_ENGINE', SourceQuery::SOURCE); $Query = new SourceQuery(); foreach ($servers as $server) { $addr = explode(':', $server->addr); //define('SQ_SERVER_ADDR', $addr[0]); //define('SQ_SERVER_PORT', $addr[1]); try { $Query->Connect($addr[0], $addr[1], 1, SourceQuery::SOURCE); $info = $Query->GetInfo(); $players = $info['Players']; //print_r($Query->GetInfo()); //print_r($Query->GetPlayers()); //print_r($Query->GetRules()); $serverLock = $model->getServerLock($server->id, INTERVAL_LOCK); if ($players == 0 && is_null($serverLock)) { //$response['target_h']['#map_note'] = 'Go to our '. var_export($server->addr, true). ' '. var_export($match->id, true); $response['target_h']['#map_note'] = 'Go to our server : ' . $server->addr . ' <a href="steam://connect/' . $server->addr . '" id="join" title="Join">Join</a>'; $model->setMatchServer($match->id, $server->id); //update matches with server id break; } } catch (Exception $e) { $response['target_h']['#map_note'] = 'error: ' . $e->getMessage(); //echo $e->getMessage(); } finally { $Query->Disconnect(); } } }