Пример #1
0
 public function deleteServer(Request $request, $id)
 {
     try {
         $repo = new DatabaseRepository();
         $repo->delete($id);
     } catch (\Exception $ex) {
         Log::error($ex);
         return response()->json(['error' => $ex instanceof DisplayException ? $ex->getMessage() : 'An error occurred while attempting to delete this database server from the system.'], 500);
     }
 }
Пример #2
0
 public function postResetDatabasePassword(Request $request, $uuid)
 {
     $server = Models\Server::getByUUID($uuid);
     $database = Models\Database::where('id', $request->input('database'))->where('server_id', $server->id)->firstOrFail();
     $this->authorize('reset-db-password', $server);
     try {
         $repo = new Repositories\DatabaseRepository();
         $password = str_random(16);
         $repo->modifyPassword($request->input('database'), $password);
         return response($password);
     } catch (\Pterodactyl\Exceptions\DisplayException $ex) {
         return response()->json(['error' => $ex->getMessage()], 503);
     } catch (\Exception $ex) {
         Log::error($ex);
         return response()->json(['error' => 'An unhandled error occured while attempting to modify this database\'s password.'], 503);
     }
 }
Пример #3
0
 public function postDatabase(Request $request, $id)
 {
     try {
         $repo = new DatabaseRepository();
         $repo->create($id, $request->except(['_token']));
         Alert::success('Added new database to this server.')->flash();
     } catch (DisplayValidationException $ex) {
         return redirect()->route('admin.servers.view', ['id' => $id, 'tab' => 'tab_database'])->withInput()->withErrors(json_decode($ex->getMessage()))->withInput();
     } catch (\Exception $ex) {
         Log::error($ex);
         Alert::danger('An exception occured while attempting to add a new database for this server.')->flash();
     }
     return redirect()->route('admin.servers.view', ['id' => $id, 'tab' => 'tab_database'])->withInput();
 }