Inheritance: extends Illuminate\Database\Eloquent\Model
 public function index(Server $server)
 {
     $servers = $server->getActiveServers();
     // Убираем сервера без информации
     foreach ($servers as $key => $server) {
         if ($server->information == null) {
             unset($servers[$key]);
         }
     }
     return view('monitoring.list', ['servers' => $servers]);
 }
Exemple #2
0
 function getApacheMailcatcher(Request $request)
 {
     if ($request->get('key') != env('WEBDB_BACKEND_KEY')) {
         return;
     }
     header("Content-Type: text/plain");
     foreach (Server::get() as $server) {
         echo '<VirtualHost *:80>' . "\n";
         echo "    ServerName " . $server->hostname . "-mail." . env('WEBDB_URL') . "\n";
         echo "    RewriteEngine On\n";
         echo "    RewriteRule ^/?(.*) https://%{SERVER_NAME}/\$1 [R,L]\n";
         echo "</VirtualHost>\n\n";
         echo '<VirtualHost *:443>' . "\n";
         echo "    ServerName " . $server->hostname . "-mail." . env('WEBDB_URL') . "\n";
         echo "    SSLEngine on\n";
         echo "    SSLCertificateFile " . env('WEBDB_MAILCATCHER_SSL_PATH') . "cert.pem\n";
         echo "    SSLCertificateKeyFile " . env('WEBDB_MAILCATCHER_SSL_PATH') . "privkey.pem\n";
         echo "    SSLCACertificateFile " . env('WEBDB_MAILCATCHER_SSL_PATH') . "chain.pem\n";
         echo "    SSLProxyEngine on\n";
         echo "    SSLProxyVerify none\n";
         echo "    SSLProxyCheckPeerCN off\n";
         echo "    SSLProxyCheckPeerName off\n";
         echo "    SSLProxyCheckPeerExpire off\n";
         echo "    ProxyPass /messages-ws wss://" . $server->ip_address . ":81/messages-ws\n";
         echo "    ProxyPassReverse /messages-ws wss://" . $server->ip_address . ":81/messages-ws\n";
         echo "    ProxyPass / https://" . $server->ip_address . ":81/\n";
         echo "    ProxyPassReverse / https://" . $server->ip_address . ":81/\n";
         echo "</VirtualHost>\n\n";
     }
 }
Exemple #3
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $connections = [];
     foreach (\App\Models\Server::where('created', 1)->get() as $server) {
         $connections[$server->name] = ['host' => $server->ip_address, 'username' => 'root', 'key' => storage_path('webdb.key'), 'keyphrase' => '', 'timeout' => 10];
     }
     config(['remote.connections' => $connections]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $serverInstance = $this->teamspeak->getInstance();
     foreach ($serverInstance as $virtualServer) {
         $serverInstance->serverStop(['sid' => $virtualServer['virtualserver_id']]);
         $serverInstance->serverDelete(['sid' => $virtualServer['virtualserver_id']]);
     }
     $servers = Server::truncate();
 }
Exemple #5
0
 /**
  * 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();
         }
     }
 }
Exemple #6
0
 public function handle(Requests\OrderRequest $request, Product $product, $id)
 {
     $product = $product->where('id', $id)->first();
     if ($product !== null) {
         $quantity = 1;
         if ($product->countable == true) {
             $quantity = $request->get('quantity');
         }
         // TODO вынести обработку steam id в отдельный класс или в Request
         // Нужно полученый STEAM ID проверить в зависимости от игры
         $steam_id = $request->get('steam_id');
         $server = Server::where('id', $product->server_id)->first();
         switch ($server->engine) {
             case 1:
                 if (preg_match("/\\[U:1:(\\d+)\\]/", $steam_id)) {
                     $steam_id = preg_replace("/\\[U:1:(\\d+)\\]/", "\$1", $steam_id);
                     $A = $steam_id % 2;
                     $B = intval($steam_id / 2);
                     $steam_id = "STEAM_0:" . $A . ":" . $B;
                 }
                 break;
         }
         //=======
         $order = new Order();
         $order->product_id = $product->id;
         $order->quantity = $quantity;
         $order->sum = intval($product->discount_price * $quantity);
         $order->email = $request->get('email');
         $order->steam_id = $steam_id;
         $order->status = 0;
         $order->save();
         $payment = new Payment(config('robokassa.login'), config('robokassa.paymentPassword'), config('robokassa.validationPassword'));
         $payment->setInvoiceId($order->id)->setSum($order->sum)->setDescription('Покупка ' . $product->title);
         return redirect($payment->getPaymentUrl());
     }
     return redirect()->route('shop.index');
 }
Exemple #7
0
 /**
  * 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();
         }
     }
 }
Exemple #8
0
 /**
  * Finds the Server model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Server the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Server::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #9
0
 function getServerOff(Server $server)
 {
     $server->stop();
     return redirect()->back();
 }
 public function postConfigure($id, Request $request)
 {
     $server = Server::findOrFail($id);
     $data = $request->all();
     if (array_key_exists('_token', $data)) {
         unset($data['_token']);
     }
     $result = (new TeamspeakHelper())->updateConfiguration($server, $data);
     return redirect()->action('ServerController@show', $server)->with('success', 'Server successfully updated');
 }
 /**
  * Cron to review server thresholds
  */
 public function actionCron()
 {
     $model = new Server();
     $servers = $model->cron();
     $this->layout = 'app';
     return "";
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $server_count = Server::count();
     return view('pages.dashboard', compact('server_count'));
 }
Exemple #13
0
 public function store()
 {
     return Server::create(Input::get());
 }
Exemple #14
0
 public function index()
 {
     return view('servers', ['servers' => Server::all()]);
 }