Andrea Pollastri 5 rokov pred
rodič
commit
5be70b426e

+ 4 - 5
app/Http/Controllers/ApplicationsController.php

@@ -42,11 +42,10 @@ class ApplicationsController extends Controller {
         if(!$server) {
             return abort(403);
         }
-        $usrchars = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890');
-        $pwdchars = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890-_+!?');
-        $code   = hash('crc32', substr($usrchars, 0, 64)).uniqid().substr($usrchars, 0, 3);
-        $pass   = substr($pwdchars, 0, 32);
-        $dbpass = substr($pwdchars, 0, 24);
+        $chars  = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890');
+        $code   = hash('crc32', substr($chars, 0, 64)).uniqid().substr($chars, 0, 3);
+        $pass   = substr($chars, 0, 32);
+        $dbpass = substr($chars, 0, 24);
         $appcode= sha1(uniqid().microtime().$request->name);
         $base   = $request->basepath;
         Application::create([

+ 11 - 5
app/Http/Controllers/ServersController.php

@@ -8,15 +8,18 @@ use App\Server;
 class ServersController extends Controller
 {
 
+
     public function index() {
         $servers = Server::all();
         return view('servers', compact('servers'));
     }
 
+
     public function api() {
         return Server::orderBy('name')->get();
     }
 
+
     public function get($servercode) {
         $server = Server::where('servercode', $servercode)->with('applications')->first();
         if(!$server) {
@@ -25,6 +28,7 @@ class ServersController extends Controller
         return view('server', compact('server'));
     }
 
+
     public function create(Request $request) {
         $this->validate($request, [
             'name' => 'required',
@@ -34,23 +38,23 @@ class ServersController extends Controller
             $request->session()->flash('alert-error', 'You can\'t install a client server into the same Cipi Server!');
             return redirect('/servers');
         }
-        $usrchars = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890');
-        $pwdchars = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890-_+!?');
+        $chars = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ1234567890');
         Server::create([
             'name'      => $request->name,
             'provider'  => $request->provider,
             'location'  => $request->location,
             'ip'        => $request->ip,
             'port'      => 22,
-            'username'  => hash('crc32', substr($usrchars, 0, 64)).uniqid().substr($usrchars, 0, 11),
-            'password'  => substr($pwdchars, 0, 64),
-            'dbroot'    => substr($pwdchars, 0, 48),
+            'username'  => hash('crc32', substr($chars, 0, 64)).uniqid().substr($chars, 0, 11),
+            'password'  => substr($chars, 0, 64),
+            'dbroot'    => substr($chars, 0, 48),
             'servercode'=> md5(uniqid().microtime().$request->name),
         ]);
         $request->session()->flash('alert-success', 'Server '.$request->name.' has been created!');
         return redirect('/servers');
     }
 
+
     public function changeip(Request $request) {
         $this->validate($request, [
             'servercode' => 'required',
@@ -67,6 +71,7 @@ class ServersController extends Controller
         return redirect('/servers');
     }
 
+
     public function destroy(Request $request) {
         $this->validate($request, [
             'servercode' => 'required',
@@ -77,4 +82,5 @@ class ServersController extends Controller
         return redirect('/servers');
     }
 
+
 }