示例#1
0
 public function postInstall(Request $request)
 {
     $server = Models\Server::where('uuid', $request->input('server'))->first();
     if (!$server) {
         return response()->json(['error' => 'No server by that ID was found on the system.'], 422);
     }
     $node = Models\Node::findOrFail($server->node);
     $hmac = $request->input('signed');
     $status = $request->input('installed');
     if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
         return response()->json(['error' => 'Signed HMAC was invalid.'], 403);
     }
     $server->installed = $status === 'installed' ? 1 : 2;
     $server->save();
     return response()->json(['message' => 'Recieved!'], 200);
 }
示例#2
0
 public function delete($id)
 {
     $option = Models\ServiceOptions::findOrFail($id);
     $servers = Models\Server::where('option', $option->id)->get();
     if (count($servers) !== 0) {
         throw new DisplayException('You cannot delete an option that has servers attached to it currently.');
     }
     DB::beginTransaction();
     try {
         Models\ServiceVariables::where('option_id', $option->id)->delete();
         $option->delete();
         DB::commit();
     } catch (\Exception $ex) {
         DB::rollBack();
         throw $ex;
     }
 }
示例#3
0
 public function delete($id)
 {
     $service = Models\Service::findOrFail($id);
     $servers = Models\Server::where('service', $service->id)->get();
     $options = Models\ServiceOptions::select('id')->where('parent_service', $service->id);
     if (count($servers) !== 0) {
         throw new DisplayException('You cannot delete a service that has servers associated with it.');
     }
     DB::beginTransaction();
     try {
         Models\ServiceVariables::whereIn('option_id', $options->get()->toArray())->delete();
         $options->delete();
         $service->delete();
         DB::commit();
     } catch (\Exception $ex) {
         DB::rollBack();
         throw $ex;
     }
 }
示例#4
0
 /**
  * Deletes a user on the panel, returns the number of records deleted.
  *
  * @param  integer $id
  * @return integer
  */
 public function delete($id)
 {
     if (Models\Server::where('owner', $id)->count() > 0) {
         throw new DisplayException('Cannot delete a user with active servers attached to thier account.');
     }
     DB::beginTransaction();
     try {
         Models\Permission::where('user_id', $id)->delete();
         Models\Subuser::where('user_id', $id)->delete();
         Models\User::destroy($id);
         DB::commit();
         return true;
     } catch (\Exception $ex) {
         DB::rollBack();
         throw $ex;
     }
 }
示例#5
0
 /**
  * List Specific Server
  *
  * Lists specific fields about a server or all fields pertaining to that server.
  *
  * @Get("/servers/{id}{?fields}")
  * @Versions({"v1"})
  * @Parameters({
  *      @Parameter("id", type="integer", required=true, description="The ID of the server to get information on."),
  *      @Parameter("fields", type="string", required=false, description="A comma delimidated list of fields to include.")
  * })
  * @Response(200)
  */
 public function view(Request $request, $id)
 {
     $query = Models\Server::where('id', $id);
     if (!is_null($request->input('fields'))) {
         foreach (explode(',', $request->input('fields')) as $field) {
             if (!empty($field)) {
                 $query->addSelect($field);
             }
         }
     }
     try {
         if (!$query->first()) {
             throw new NotFoundHttpException('No server by that ID was found.');
         }
         return $query->first();
     } catch (NotFoundHttpException $ex) {
         throw $ex;
     } catch (\Exception $ex) {
         throw new BadRequestHttpException('There was an issue with the fields passed in the request.');
     }
 }
示例#6
0
 public function deleteNode(Request $request, $id)
 {
     $node = Models\Node::findOrFail($id);
     $servers = Models\Server::where('node', $id)->count();
     if ($servers > 0) {
         Alert::danger('You cannot delete a node with servers currently attached to it.')->flash();
         return redirect()->route('admin.nodes.view', ['id' => $id, 'tab' => 'tab_delete']);
     }
     $node->delete();
     Alert::success('Node successfully deleted.')->flash();
     return redirect()->route('admin.nodes');
 }