Passed
Push — master ( 7a263d...e0b6af )
by Ferry
05:04
created
src/controllers/AdminAuthController.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function getLogin()
22 22
     {
23
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
23
+        if (!auth()->guest()) return redirect(cb()->getAdminUrl());
24 24
 
25 25
         cbHook()->hookGetLogin();
26 26
 
27 27
         $data = [];
28
-        $data['no1'] = rand(1,10);
29
-        $data['no2'] = rand(1,10);
30
-        Session::put("captcha_result", $data['no1']+$data['no2']);
28
+        $data['no1'] = rand(1, 10);
29
+        $data['no2'] = rand(1, 10);
30
+        Session::put("captcha_result", $data['no1'] + $data['no2']);
31 31
 
32
-        return view( str_replace(".blade.php", "", getSetting('login_page_view','crudbooster::login')), $data );
32
+        return view(str_replace(".blade.php", "", getSetting('login_page_view', 'crudbooster::login')), $data);
33 33
     }
34 34
 
35 35
     public function postLogin()
36 36
     {
37
-        try{
38
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
37
+        try {
38
+            if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
39 39
 
40 40
             cb()->validation([
41 41
                 'email'=>'required|email',
42 42
                 'password'=>'required'
43 43
             ]);
44 44
 
45
-            $credential = request()->only(['email','password']);
45
+            $credential = request()->only(['email', 'password']);
46 46
             if (auth()->attempt($credential)) {
47 47
 
48 48
                 // When login user success, clear suspend attempt
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
                 return redirect(cb()->getAdminUrl());
54 54
             } else {
55 55
                 $this->incrementFailedLogin();
56
-                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
56
+                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']);
57 57
             }
58
-        }catch (CBValidationException $e) {
59
-            return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
58
+        } catch (CBValidationException $e) {
59
+            return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning');
60 60
         }
61 61
     }
62 62
 
Please login to merge, or discard this patch.
src/controllers/RegisterController.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
                 "captcha"=>"required|integer"
30 30
             ]);
31 31
 
32
-            if(Session::get("captcha_result") != request("captcha")) {
32
+            if (Session::get("captcha_result") != request("captcha")) {
33 33
                 return cb()->redirectBack("The captcha that you input is wrong!");
34 34
             }
35 35
 
36
-            if($user = cb()->find("users",["email"=>request("email")])) {
36
+            if ($user = cb()->find("users", ["email"=>request("email")])) {
37 37
                 return cb()->redirectBack("The email you input has already exists!");
38 38
             }
39 39
 
40
-            if(getSetting("register_mail_verification")) {
41
-                Cache::put("register_".$token,[
40
+            if (getSetting("register_mail_verification")) {
41
+                Cache::put("register_".$token, [
42 42
                     "name"=>request("name"),
43 43
                     "email"=>request("email"),
44 44
                     "password"=>request("password")
45
-                ],now()->addHours(24));
45
+                ], now()->addHours(24));
46 46
 
47 47
                 $mail = new MailHelper();
48 48
                 $mail->to(request("email"));
49
-                $mail->sender(getSetting("register_mail_verification_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
50
-                $mail->content("Verify Your Registration","
49
+                $mail->sender(getSetting("register_mail_verification_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
50
+                $mail->content("Verify Your Registration", "
51 51
                 Hi ".request("name")."<br/>
52 52
                 Thank you for register at ".cb()->getAppName()." to continue your registration, please click on the following link: <br/>
53 53
                 <p>$linkToken</p>
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
                         "cb_roles_id"=> getSetting("register_as_role")
67 67
                     ]);
68 68
 
69
-                return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
69
+                return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success");
70 70
             }
71 71
 
72
-        }catch (CBValidationException $e) {
72
+        } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
74 74
         }
75 75
 
76
-        return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email","success");
76
+        return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email", "success");
77 77
     }
78 78
 
79 79
     public function postContinueRegister($token) {
80
-        if($token = Cache::get("register_".$token)) {
80
+        if ($token = Cache::get("register_".$token)) {
81 81
             DB::table("users")
82 82
                 ->insert([
83 83
                     "created_at"=>date("Y-m-d H:i:s"),
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
                     "cb_roles_id"=> getSetting("register_as_role")
88 88
                 ]);
89 89
 
90
-            return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
90
+            return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success");
91 91
         } else {
92
-            return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the URL has been expired!");
92
+            return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the URL has been expired!");
93 93
         }
94 94
     }
95 95
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
                 return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
70 70
             }
71 71
 
72
-        }catch (CBValidationException $e) {
72
+        } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
74 74
         }
75 75
 
Please login to merge, or discard this patch.
src/controllers/AuthSuspend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
     {
29 29
         $key = md5(request()->ip().request()->userAgent());
30 30
 
31
-        if(Cache::has("loginSuspended".$key)) {
31
+        if (Cache::has("loginSuspended".$key)) {
32 32
             return true;
33 33
         }
34 34
 
35
-        if(getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) {
35
+        if (getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) {
36 36
             Cache::put("loginSuspended".$key, true, 30);
37 37
             $this->clearSuspendAttempt();
38 38
             return true;
Please login to merge, or discard this patch.
src/controllers/DeveloperMiscellaneousController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@
 block discarded – undo
24 24
 
25 25
     public function getIndex() {
26 26
         $data = [];
27
-        return view($this->view.".index",$data);
27
+        return view($this->view.".index", $data);
28 28
     }
29 29
 
30 30
     public function postSave()
31 31
     {
32
-        foreach(request()->except("_token") as $key=>$val) {
33
-            putSetting( $key,  $val);
32
+        foreach (request()->except("_token") as $key=>$val) {
33
+            putSetting($key, $val);
34 34
         }
35 35
 
36
-        putSetting("enable_register",request("enable_register"));
36
+        putSetting("enable_register", request("enable_register"));
37 37
         putSetting("enable_forget", request("enable_forget"));
38 38
         putSetting("register_mail_verification", request("register_mail_verification"));
39 39
 
40
-        return cb()->redirectBack("Setting has been updated!","success");
40
+        return cb()->redirectBack("Setting has been updated!", "success");
41 41
     }
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/DeveloperSecurityController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function getIndex() {
26 26
         $data = [];
27
-        return view($this->view.".index",$data);
27
+        return view($this->view.".index", $data);
28 28
     }
29 29
 
30 30
     public function postSave()
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
         putSetting("AUTO_REDIRECT_TO_LOGIN", request("AUTO_REDIRECT_TO_LOGIN"));
40 40
         putSetting("LOGIN_NOTIFICATION", request("LOGIN_NOTIFICATION"));
41 41
 
42
-        if(request("htaccess_ServerSignature")) {
42
+        if (request("htaccess_ServerSignature")) {
43 43
             putHtaccess("ServerSignature Off");
44 44
         }
45 45
 
46
-        if(request("htaccess_IndexIgnore")) {
46
+        if (request("htaccess_IndexIgnore")) {
47 47
             putHtaccess("IndexIgnore *");
48 48
         }
49 49
 
50
-        if(request("htaccess_dotAccess")) {
50
+        if (request("htaccess_dotAccess")) {
51 51
 putHtaccess("
52 52
 <FilesMatch \"^\.\">
53 53
 Order allow,deny
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 </FilesMatch>");
56 56
         }
57 57
 
58
-        if(request("htaccess_preventVendor")) {
58
+        if (request("htaccess_preventVendor")) {
59 59
             putHtaccess("RewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]");
60 60
         }
61 61
 
62 62
 
63
-        return cb()->redirectBack("Security has been updated!","success");
63
+        return cb()->redirectBack("Security has been updated!", "success");
64 64
     }
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/ForgetController.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         try {
25 25
             cb()->validation(['email'=>'required|email']);
26 26
 
27
-            if($user = cb()->find("users",["email"=>request("email")])) {
27
+            if ($user = cb()->find("users", ["email"=>request("email")])) {
28 28
                 $token = Str::random(6);
29 29
                 $linkToken = cb()->getAdminUrl("continue-reset/".$token);
30 30
                 Cache::put("forget_".$token, $user->id, now()->addHours(12));
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
                 $mail = new MailHelper();
39 39
                 $mail->to($user->email);
40
-                $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
41
-                $mail->content("Please Confirm Your Forgot Password","
40
+                $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
41
+                $mail->content("Please Confirm Your Forgot Password", "
42 42
                     Hi $user->name,<br/><br>
43 43
                     Someone with the detail bellow: <br/>
44 44
                     Time = ".now()->format("Y-m-d H:i:s")."<br/>
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
                 return cb()->redirectBack("Your email is not registered");
59 59
             }
60 60
 
61
-        }catch (CBValidationException $e) {
61
+        } catch (CBValidationException $e) {
62 62
             return cb()->redirectBack($e->getMessage());
63 63
         } catch (\Exception $e) {
64 64
             Log::error($e);
65 65
             return cb()->redirectBack(cbLang("something_went_wrong"));
66 66
         }
67 67
 
68
-        return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email","success");
68
+        return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email", "success");
69 69
     }
70 70
 
71 71
     public function getContinueReset($token) {
72
-        if(Cache::has("forget_".$token)) {
72
+        if (Cache::has("forget_".$token)) {
73 73
             $id = Cache::get("forget_".$token);
74 74
             $newPassword = Str::random(6);
75 75
             cb()->update("users", $id, ["password"=>Hash::make($newPassword)]);
76 76
 
77
-            $user = cb()->find("users",$id);
77
+            $user = cb()->find("users", $id);
78 78
 
79 79
             $mail = new MailHelper();
80 80
             $mail->to($user->email);
81
-            $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName());
82
-            $mail->content("This Is Your New Password","
81
+            $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName());
82
+            $mail->content("This Is Your New Password", "
83 83
                     Hi $user->name,<br/><br>
84 84
                     Thank you for confirming the request new password. Here is your new password: <br>
85 85
                     <h2>$newPassword</h2>
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
                 ");
91 91
             $mail->send();
92 92
 
93
-            return cb()->redirect(cb()->getAdminUrl("login"),"We've sent you new password email. Please check at your mail inbox or spambox","success");
93
+            return cb()->redirect(cb()->getAdminUrl("login"), "We've sent you new password email. Please check at your mail inbox or spambox", "success");
94 94
         } else {
95
-            return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the url has been expired!");
95
+            return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the url has been expired!");
96 96
         }
97 97
     }
98 98
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
                 return cb()->redirectBack("Your email is not registered");
59 59
             }
60 60
 
61
-        }catch (CBValidationException $e) {
61
+        } catch (CBValidationException $e) {
62 62
             return cb()->redirectBack($e->getMessage());
63 63
         } catch (\Exception $e) {
64 64
             Log::error($e);
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,58 +1,58 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Developer Backend Middleware
4
-Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
4
+Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
5 5
     'prefix'=>"developer/".getSetting('developer_path'),
6
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
6
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
7 7
     cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController");
8 8
     cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController");
9
-    cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
-    cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
-    cb()->routeController("plugins","\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
-    cb()->routeController("mail","\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
-    cb()->routeController("security","\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
-    cb()->routeController("appearance","\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
15
-    cb()->routeController("miscellaneous","\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
16
-    cb()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial");
17
-    cb()->routeGet("/","DeveloperDashboardController@getIndex");
9
+    cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
+    cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
+    cb()->routeController("plugins", "\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
+    cb()->routeController("mail", "\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
+    cb()->routeController("security", "\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
+    cb()->routeController("appearance", "\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
15
+    cb()->routeController("miscellaneous", "\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
16
+    cb()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial");
17
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
18 18
 });
19 19
 
20 20
 // Developer Auth Middleware
21 21
 Route::group(['middleware' => ['web'],
22 22
     'prefix'=>"developer/".getSetting('developer_path'),
23
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
24
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
25
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
26
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
23
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
24
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
25
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
26
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
27 27
 });
28 28
 
29 29
 // Routing without any middleware
30
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
31
-    if(getSetting("AUTO_REDIRECT_TO_LOGIN")) {
32
-        cb()->routeGet("/","AdminAuthController@getRedirectToLogin");
30
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
31
+    if (getSetting("AUTO_REDIRECT_TO_LOGIN")) {
32
+        cb()->routeGet("/", "AdminAuthController@getRedirectToLogin");
33 33
     }
34 34
 });
35 35
 
36 36
 // Routing without any middleware with admin prefix
37
-Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
37
+Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
38 38
     cb()->routeGet('logout', "AdminAuthController@getLogout");
39 39
 
40
-    if(!getSetting("DISABLE_LOGIN")) {
40
+    if (!getSetting("DISABLE_LOGIN")) {
41 41
         cb()->routePost('login', "AdminAuthController@postLogin");
42 42
         cb()->routeGet('login', "AdminAuthController@getLogin");
43 43
     }
44 44
 
45
-    if(getSetting("enable_forget")) {
46
-        cb()->routePost("forget","AdminAuthController@postForget");
45
+    if (getSetting("enable_forget")) {
46
+        cb()->routePost("forget", "AdminAuthController@postForget");
47 47
     }
48 48
 
49
-    if(getSetting("enable_register")) {
50
-        cb()->routePost("register","AdminAuthController@postRegister");
49
+    if (getSetting("enable_register")) {
50
+        cb()->routePost("register", "AdminAuthController@postRegister");
51 51
     }
52 52
 });
53 53
 
54 54
 // Routing package controllers
55
-cb()->routeGroupBackend(function () {
55
+cb()->routeGroupBackend(function() {
56 56
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
57 57
 });
58 58
 
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
62 62
     'prefix' => cb()->getAdminPath(),
63 63
     'namespace' => 'App\Http\Controllers',
64
-], function () {
64
+], function() {
65 65
 
66 66
     if (Request::is(cb()->getAdminPath())) {
67
-        if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
67
+        if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
68 68
             cb()->routeGet("/", $dashboard);
69
-        }else{
69
+        } else {
70 70
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
71 71
         }
72 72
     }
73 73
 
74 74
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
75 75
 
76
-    foreach($controllers as $controller) {
76
+    foreach ($controllers as $controller) {
77 77
         $controllerName = basename($controller);
78
-        $controllerName = rtrim($controllerName,".php");
78
+        $controllerName = rtrim($controllerName, ".php");
79 79
         $className = '\App\Http\Controllers\\'.$controllerName;
80 80
         $controllerClass = new $className();
81
-        if(method_exists($controllerClass, 'cbInit')) {
81
+        if (method_exists($controllerClass, 'cbInit')) {
82 82
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
83 83
         }
84 84
     }
Please login to merge, or discard this patch.