Passed
Push — master ( c14ede...c50061 )
by Ferry
03:59
created
src/routes.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@  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()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial");
15
-    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()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial");
15
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
16 16
 });
17 17
 
18 18
 // Developer Auth Middleware
19 19
 Route::group(['middleware' => ['web'],
20 20
     'prefix'=>"developer/".getSetting('developer_path'),
21
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
22
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
23
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
24
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
21
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
22
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
23
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
24
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
25 25
 });
26 26
 
27 27
 // Routing without any middleware
28
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
28
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
29 29
     cb()->routeGet('uploads/{one?}/{two?}/{three?}/{four?}/{five?}', "FileController@getPreview");
30 30
 });
31 31
 
32 32
 // Routing without any middleware with admin prefix
33
-Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
33
+Route::group(['middleware' => ['web'], 'prefix' => cbConfig('ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
34 34
     cb()->routeGet('logout', "AdminAuthController@getLogout");
35 35
 
36
-    if(!env("CB_DISABLE_LOGIN")) {
36
+    if (!env("CB_DISABLE_LOGIN")) {
37 37
         cb()->routePost('login', "AdminAuthController@postLogin");
38 38
         cb()->routeGet('login', "AdminAuthController@getLogin");
39 39
     }
40 40
 });
41 41
 
42 42
 // Routing package controllers
43
-cb()->routeGroupBackend(function () {
43
+cb()->routeGroupBackend(function() {
44 44
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
45 45
 });
46 46
 
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
50 50
     'prefix' => cbConfig('ADMIN_PATH'),
51 51
     'namespace' => 'App\Http\Controllers',
52
-], function () {
52
+], function() {
53 53
 
54 54
     if (Request::is(cbConfig('ADMIN_PATH'))) {
55
-        if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
55
+        if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) {
56 56
             cb()->routeGet("/", $dashboard);
57
-        }else{
57
+        } else {
58 58
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
59 59
         }
60 60
     }
61 61
 
62 62
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
63 63
 
64
-    foreach($controllers as $controller) {
64
+    foreach ($controllers as $controller) {
65 65
         $controllerName = basename($controller);
66
-        $controllerName = rtrim($controllerName,".php");
66
+        $controllerName = rtrim($controllerName, ".php");
67 67
         $className = '\App\Http\Controllers\\'.$controllerName;
68 68
         $controllerClass = new $className();
69
-        if(method_exists($controllerClass, 'cbInit')) {
69
+        if (method_exists($controllerClass, 'cbInit')) {
70 70
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
71 71
         }
72 72
     }
Please login to merge, or discard this patch.
src/controllers/DeveloperMailController.php 1 patch
Spacing   +2 added lines, -2 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()
@@ -38,6 +38,6 @@  discard block
 block discarded – undo
38 38
             "MAIL_ENCRYPTION"=>request("MAIL_ENCRYPTION")
39 39
         ]);
40 40
 
41
-        return cb()->redirectBack("Mail configuration has been updated!","success");
41
+        return cb()->redirectBack("Mail configuration has been updated!", "success");
42 42
     }
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/AdminProfileController.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
     public function getIndex() {
12 12
         $data = [];
13 13
         $data['page_title'] = cbLang("profile");
14
-        return view('crudbooster::profile',$data);
14
+        return view('crudbooster::profile', $data);
15 15
     }
16 16
 
17 17
     public function postUpdate() {
18
-        validator(request()->all(),[
18
+        validator(request()->all(), [
19 19
             'name'=>'required|max:255|min:3',
20 20
             'email'=>'required|email',
21 21
             'photo'=>'image',
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
             $data = [];
27 27
             $data['name'] = request('name');
28 28
             $data['email'] = request('email');
29
-            if(request('password')) {
29
+            if (request('password')) {
30 30
                 $data['password'] = Hash::make(request('password'));
31 31
             }
32
-            if(request()->hasFile('photo')) {
32
+            if (request()->hasFile('photo')) {
33 33
                 $data['photo'] = cb()->uploadFile('photo', true, 200, 200);
34 34
             }
35 35
 
36 36
             DB::table("users")->where("id", auth()->id())->update($data);
37
-        }catch (\Exception $e) {
37
+        } catch (\Exception $e) {
38 38
             Log::error($e);
39
-            return cb()->redirectBack(cbLang("something_went_wrong"),"warning");
39
+            return cb()->redirectBack(cbLang("something_went_wrong"), "warning");
40 40
         }
41 41
 
42
-        return cb()->redirectBack("The profile data has been updated!","success");
42
+        return cb()->redirectBack("The profile data has been updated!", "success");
43 43
     }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             }
35 35
 
36 36
             DB::table("users")->where("id", auth()->id())->update($data);
37
-        }catch (\Exception $e) {
37
+        } catch (\Exception $e) {
38 38
             Log::error($e);
39 39
             return cb()->redirectBack(cbLang("something_went_wrong"),"warning");
40 40
         }
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()
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
             "CB_AUTO_REDIRECT_TO_LOGIN"=>request("CB_AUTO_REDIRECT_TO_LOGIN")
39 39
         ]);
40 40
 
41
-        if(request("htaccess_ServerSignature")) {
41
+        if (request("htaccess_ServerSignature")) {
42 42
             putHtaccess("ServerSignature Off");
43 43
         }
44 44
 
45
-        if(request("htaccess_IndexIgnore")) {
45
+        if (request("htaccess_IndexIgnore")) {
46 46
             putHtaccess("IndexIgnore *");
47 47
         }
48 48
 
49
-        if(request("htaccess_dotAccess")) {
49
+        if (request("htaccess_dotAccess")) {
50 50
 putHtaccess("
51 51
 <FilesMatch \"^\.\">
52 52
 Order allow,deny
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 </FilesMatch>");
55 55
         }
56 56
 
57
-        if(request("htaccess_preventVendor")) {
57
+        if (request("htaccess_preventVendor")) {
58 58
             putHtaccess("RewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]");
59 59
         }
60 60
 
61 61
 
62
-        return cb()->redirectBack("Security has been updated!","success");
62
+        return cb()->redirectBack("Security has been updated!", "success");
63 63
     }
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
src/controllers/DeveloperAuthController.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,25 +19,25 @@
 block discarded – undo
19 19
     }
20 20
 
21 21
     public function postLoginDeveloper() {
22
-        try{
22
+        try {
23 23
             cb()->validation([
24 24
                 'username'=>'required',
25 25
                 'password'=>'required'
26 26
             ]);
27 27
 
28
-            if(request('username') == getSetting('developer_username')
28
+            if (request('username') == getSetting('developer_username')
29 29
                 && request('password') == getSetting("developer_password")) {
30 30
 
31 31
                 session(['developer'=>getSetting('developer_username')]);
32 32
 
33 33
                 return redirect(cb()->getDeveloperUrl());
34 34
 
35
-            }else{
36
-                return cb()->redirectBack( cbLang("password_and_username_is_wrong"));
35
+            } else {
36
+                return cb()->redirectBack(cbLang("password_and_username_is_wrong"));
37 37
             }
38 38
 
39
-        }catch (CBValidationException $e) {
40
-            return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning');
39
+        } catch (CBValidationException $e) {
40
+            return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning');
41 41
         }
42 42
     }
43 43
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@
 block discarded – undo
32 32
 
33 33
                 return redirect(cb()->getDeveloperUrl());
34 34
 
35
-            }else{
35
+            } else{
36 36
                 return cb()->redirectBack( cbLang("password_and_username_is_wrong"));
37 37
             }
38 38
 
39
-        }catch (CBValidationException $e) {
39
+        } catch (CBValidationException $e) {
40 40
             return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning');
41 41
         }
42 42
     }
Please login to merge, or discard this patch.
src/controllers/AdminAuthController.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
     {
19 19
         $key = md5(request()->ip().request()->userAgent());
20 20
 
21
-        if(Cache::has("loginSuspended".$key)) {
21
+        if (Cache::has("loginSuspended".$key)) {
22 22
             return true;
23 23
         }
24 24
 
25
-        if(env("CB_AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= env("CB_AUTO_SUSPEND_LOGIN")) {
25
+        if (env("CB_AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= env("CB_AUTO_SUSPEND_LOGIN")) {
26 26
             Cache::put("loginSuspended".$key, true, 30);
27 27
             Cache::forget("loginFailed".$key);
28 28
             return true;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function getLogin()
35 35
     {
36
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
36
+        if (!auth()->guest()) return redirect(cb()->getAdminUrl());
37 37
 
38 38
         cbHook()->hookGetLogin();
39 39
 
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function postLogin()
44 44
     {
45
-        try{
46
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
45
+        try {
46
+            if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
47 47
 
48 48
             cb()->validation([
49 49
                 'email'=>'required|email',
50 50
                 'password'=>'required'
51 51
             ]);
52 52
 
53
-            $credential = request()->only(['email','password']);
53
+            $credential = request()->only(['email', 'password']);
54 54
             if (auth()->attempt($credential)) {
55 55
                 cbHook()->hookPostLogin();
56 56
                 return redirect(cb()->getAdminUrl());
57 57
             } else {
58 58
                 $this->incrementFailedLogin();
59
-                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
59
+                return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']);
60 60
             }
61
-        }catch (CBValidationException $e) {
62
-            return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
61
+        } catch (CBValidationException $e) {
62
+            return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning');
63 63
         }
64 64
     }
65 65
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function getLogin()
35 35
     {
36
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
36
+        if(!auth()->guest()) {
37
+            return redirect(cb()->getAdminUrl());
38
+        }
37 39
 
38 40
         cbHook()->hookGetLogin();
39 41
 
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
     public function postLogin()
44 46
     {
45 47
         try{
46
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
48
+            if($this->isSuspendedLogin()) {
49
+                throw new CBValidationException(cbLang("you_have_been_suspended"));
50
+            }
47 51
 
48 52
             cb()->validation([
49 53
                 'email'=>'required|email',
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 $this->incrementFailedLogin();
59 63
                 return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
60 64
             }
61
-        }catch (CBValidationException $e) {
65
+        } catch (CBValidationException $e) {
62 66
             return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
63 67
         }
64 68
     }
Please login to merge, or discard this patch.
src/controllers/DeveloperPluginStoreController.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function getIndex() {
30 30
 
31
-        if(request("refresh")) {
32
-            $this->fetchPluginData(false );
33
-            return cb()->redirectBack("Plugin list has been refreshed!","success");
31
+        if (request("refresh")) {
32
+            $this->fetchPluginData(false);
33
+            return cb()->redirectBack("Plugin list has been refreshed!", "success");
34 34
         }
35 35
 
36 36
         $data = [];
37 37
         $data['result'] = $this->fetchPluginData();
38
-        return view($this->view.'.index',$data);
38
+        return view($this->view.'.index', $data);
39 39
     }
40 40
 
41 41
     public function postLoginAccount() {
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
         ]);
51 51
         $response = $curl->send();
52 52
 
53
-        if($respArray = json_decode($response, true)) {
54
-            if($respArray['status'] && isset($respArray['token'])) {
53
+        if ($respArray = json_decode($response, true)) {
54
+            if ($respArray['status'] && isset($respArray['token'])) {
55 55
                 session(['account_token'=>$respArray['token']]);
56 56
             }
57
-            return response()->make($response,200,["Content-Type"=>"application/json"]);
57
+            return response()->make($response, 200, ["Content-Type"=>"application/json"]);
58 58
         } else {
59
-            return response()->json(['status'=>false,'message'=>'failed']);
59
+            return response()->json(['status'=>false, 'message'=>'failed']);
60 60
         }
61 61
     }
62 62
 
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
         ]);
74 74
         $response = $curl->send();
75 75
 
76
-        if($respArray = json_decode($response, true)) {
77
-            if($respArray['status']) {
76
+        if ($respArray = json_decode($response, true)) {
77
+            if ($respArray['status']) {
78 78
                 $form = base64_decode($respArray['payment']);
79
-                return response()->json(['status'=>true,'form'=>$form]);
79
+                return response()->json(['status'=>true, 'form'=>$form]);
80 80
             } else {
81 81
                 return response()->json($respArray);
82 82
             }
83 83
         } else {
84
-            return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]);
84
+            return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]);
85 85
         }
86 86
     }
87 87
 
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $pluginData = $this->fetchPluginData();
91 91
 
92
-        if(isset($pluginData[$key])) {
93
-            if(file_exists(app_path("CBPlugins/".$key))) {
92
+        if (isset($pluginData[$key])) {
93
+            if (file_exists(app_path("CBPlugins/".$key))) {
94 94
                 rrmdir(app_path("CBPlugins/".$key));
95 95
                 return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']);
96
-            }else{
97
-                return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']);
96
+            } else {
97
+                return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']);
98 98
             }
99
-        }else {
100
-            return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']);
99
+        } else {
100
+            return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']);
101 101
         }
102 102
     }
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $pluginData = $this->fetchPluginData();
107 107
 
108
-        if(isset($pluginData[$key])) {
108
+        if (isset($pluginData[$key])) {
109 109
             $plugin = $pluginData[$key];
110 110
 
111 111
             // Create temp file of zip plugin
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
                 fclose($temp);
124 124
 
125 125
                 // Rename
126
-                if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
126
+                if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
127 127
                 rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key));
128 128
 
129
-                return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']);
129
+                return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']);
130 130
 
131 131
             } else {
132
-                return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]);
132
+                return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]);
133 133
             }
134
-        }else{
135
-            return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']);
134
+        } else {
135
+            return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']);
136 136
         }
137 137
     }
138 138
 
139 139
     private function fetchPluginData($cache = true)
140 140
     {
141
-        if($cache === true && $data = Cache::get("plugin_store_data")) {
141
+        if ($cache === true && $data = Cache::get("plugin_store_data")) {
142 142
             return $data;
143 143
         }
144 144
 
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
             $context = stream_context_create($opts);
156 156
             $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context);
157 157
 
158
-            if($data) {
158
+            if ($data) {
159 159
                 $data = json_decode($data, true);
160
-                if($data['status']==true) {
160
+                if ($data['status'] == true) {
161 161
 
162
-                    foreach($data['data'] as $item) {
162
+                    foreach ($data['data'] as $item) {
163 163
                         $key = $item['key'];
164
-                        $result[ $key ] = $item;
164
+                        $result[$key] = $item;
165 165
                     }
166 166
 
167 167
                     $result = collect($result)->sortBy("name")->all();
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             if(file_exists(app_path("CBPlugins/".$key))) {
94 94
                 rrmdir(app_path("CBPlugins/".$key));
95 95
                 return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']);
96
-            }else{
96
+            } else{
97 97
                 return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']);
98 98
             }
99
-        }else {
99
+        } else {
100 100
             return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']);
101 101
         }
102 102
     }
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
                 fclose($temp);
124 124
 
125 125
                 // Rename
126
-                if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key));
126
+                if(file_exists(app_path("CBPlugins/".$key))) {
127
+                    rrmdir(app_path("CBPlugins/".$key));
128
+                }
127 129
                 rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key));
128 130
 
129 131
                 return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']);
@@ -131,7 +133,7 @@  discard block
 block discarded – undo
131 133
             } else {
132 134
                 return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]);
133 135
             }
134
-        }else{
136
+        } else{
135 137
             return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']);
136 138
         }
137 139
     }
Please login to merge, or discard this patch.
src/helpers/Helper.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -220,20 +220,20 @@  discard block
 block discarded – undo
220 220
 }
221 221
 
222 222
 if(!function_exists('extract_unit')) {	
223
-	/*
223
+    /*
224 224
 	Credits: Bit Repository
225 225
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
226 226
 	*/
227
-	function extract_unit($string, $start, $end)
228
-	{
229
-	$pos = stripos($string, $start);
230
-	$str = substr($string, $pos);
231
-	$str_two = substr($str, strlen($start));
232
-	$second_pos = stripos($str_two, $end);
233
-	$str_three = substr($str_two, 0, $second_pos);
234
-	$unit = trim($str_three); // remove whitespaces
235
-	return $unit;
236
-	}
227
+    function extract_unit($string, $start, $end)
228
+    {
229
+    $pos = stripos($string, $start);
230
+    $str = substr($string, $pos);
231
+    $str_two = substr($str, strlen($start));
232
+    $second_pos = stripos($str_two, $end);
233
+    $str_three = substr($str_two, 0, $second_pos);
234
+    $unit = trim($str_three); // remove whitespaces
235
+    return $unit;
236
+    }
237 237
 }
238 238
 
239 239
 /* 
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 }
408 408
 
409 409
 if(!function_exists('rrmdir')) {
410
-	/*
410
+    /*
411 411
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
412 412
 	*/
413
-	function rrmdir($dir) { 
414
-	   if (is_dir($dir)) { 
415
-	     $objects = scandir($dir); 
416
-	     foreach ($objects as $object) { 
417
-	       if ($object != "." && $object != "..") { 
418
-	         if (is_dir($dir."/".$object))
419
-	           rrmdir($dir."/".$object);
420
-	         else
421
-	           unlink($dir."/".$object); 
422
-	       } 
423
-	     }
424
-	     rmdir($dir); 
425
-	   } 
426
-	 }
413
+    function rrmdir($dir) { 
414
+        if (is_dir($dir)) { 
415
+            $objects = scandir($dir); 
416
+            foreach ($objects as $object) { 
417
+            if ($object != "." && $object != "..") { 
418
+                if (is_dir($dir."/".$object))
419
+                rrmdir($dir."/".$object);
420
+                else
421
+                unlink($dir."/".$object); 
422
+            } 
423
+            }
424
+            rmdir($dir); 
425
+        } 
426
+        }
427 427
 }
428 428
 
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!function_exists("putHtaccess")) {
3
+if (!function_exists("putHtaccess")) {
4 4
     function putHtaccess($stringToPut)
5 5
     {
6 6
         file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND);
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
     }
9 9
 }
10 10
 
11
-if(!function_exists("checkHtaccess")) {
11
+if (!function_exists("checkHtaccess")) {
12 12
     function checkHtaccess($stringToCheck)
13 13
     {
14
-        if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
14
+        if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
15 15
             $htaccess = file_get_contents(base_path(".htaccess"));
16
-            $htaccess2= file_get_contents(public_path(".htaccess"));
17
-            if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
16
+            $htaccess2 = file_get_contents(public_path(".htaccess"));
17
+            if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
18 18
                 return true;
19 19
             }
20 20
         }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     }
24 24
 }
25 25
 
26
-if(!function_exists("setEnvironmentValue")) {
26
+if (!function_exists("setEnvironmentValue")) {
27 27
     function setEnvironmentValue(array $values)
28 28
     {
29 29
         $envFile = app()->environmentFilePath();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 }
55 55
 
56 56
 
57
-if(!function_exists("cbLang")) {
57
+if (!function_exists("cbLang")) {
58 58
     /**
59 59
      * @param string $key
60 60
      * @param array $replace
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
     }
67 67
 }
68 68
 
69
-if(!function_exists('rglob')) {
69
+if (!function_exists('rglob')) {
70 70
     function rglob($pattern, $flags = 0) {
71 71
         $files = glob($pattern, $flags);
72
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
72
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
73 73
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
74 74
         }
75 75
         return $files;
76 76
     }
77 77
 }
78 78
 
79
-if(!function_exists('convertPHPToMomentFormat')) {
79
+if (!function_exists('convertPHPToMomentFormat')) {
80 80
     function convertPHPToMomentFormat($format)
81 81
     {
82 82
         $replacements = [
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
     }
124 124
 }
125 125
 
126
-if(!function_exists('slug')) {
126
+if (!function_exists('slug')) {
127 127
     function slug($string, $separator = '-') {
128 128
         return \Illuminate\Support\Str::slug($string, $separator);
129 129
     }
130 130
 }
131 131
 
132
-if(!function_exists('columnSingleton')) {
132
+if (!function_exists('columnSingleton')) {
133 133
     /**
134 134
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
135 135
      */
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     }
139 139
 }
140 140
 
141
-if(!function_exists('cbHook'))
141
+if (!function_exists('cbHook'))
142 142
 {
143 143
     /**
144 144
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     }
151 151
 }
152 152
 
153
-if(!function_exists('getTypeHook'))
153
+if (!function_exists('getTypeHook'))
154 154
 {
155 155
     /**
156 156
      * @param string $type
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     }
164 164
 }
165 165
 
166
-if(!function_exists('getPrimaryKey'))
166
+if (!function_exists('getPrimaryKey'))
167 167
 {
168 168
     function getPrimaryKey($table_name)
169 169
     {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     }
172 172
 }
173 173
 
174
-if(!function_exists('cb'))
174
+if (!function_exists('cb'))
175 175
 {
176 176
     function cb()
177 177
     {
@@ -179,25 +179,25 @@  discard block
 block discarded – undo
179 179
     }
180 180
 }
181 181
 
182
-if(!function_exists('cbAsset')) {
182
+if (!function_exists('cbAsset')) {
183 183
     function cbAsset($path, $secure = null) {
184 184
         return asset("cb_asset/".$path, $secure);
185 185
     }
186 186
 }
187 187
 
188
-if(!function_exists("cbConfig")) {
188
+if (!function_exists("cbConfig")) {
189 189
     function cbConfig($name, $default = null) {
190 190
         return config("crudbooster.".$name, $default);
191 191
     }
192 192
 }
193 193
 
194
-if(!function_exists("strRandom")) {
194
+if (!function_exists("strRandom")) {
195 195
     function strRandom($length = 5) {
196 196
         return \Illuminate\Support\Str::random($length);
197 197
     }
198 198
 }
199 199
 
200
-if(!function_exists('module')) {
200
+if (!function_exists('module')) {
201 201
     function module()
202 202
     {
203 203
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
     }
206 206
 }
207 207
 
208
-if(!function_exists('getAdminLoginURL')) {
208
+if (!function_exists('getAdminLoginURL')) {
209 209
     function getAdminLoginURL()
210 210
     {
211 211
         return cb()->getAdminUrl("login");
212 212
     }
213 213
 }
214 214
 
215
-if(!function_exists('dummyPhoto')) {
215
+if (!function_exists('dummyPhoto')) {
216 216
     function dummyPhoto()
217 217
     {
218 218
         return cbConfig("DUMMY_PHOTO");
219 219
     }
220 220
 }
221 221
 
222
-if(!function_exists('extract_unit')) {	
222
+if (!function_exists('extract_unit')) {	
223 223
 	/*
224 224
 	Credits: Bit Repository
225 225
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 |
245 245
 */
246 246
 
247
-if(!function_exists('putSetting')) {
247
+if (!function_exists('putSetting')) {
248 248
     function putSetting($key, $value)
249 249
     {
250
-        if(file_exists(storage_path('.cbconfig'))) {
250
+        if (file_exists(storage_path('.cbconfig'))) {
251 251
             $settings = file_get_contents(storage_path('.cbconfig'));
252 252
             $settings = decrypt($settings);
253 253
             $settings = unserialize($settings);
254
-        }else{
254
+        } else {
255 255
             $settings = [];
256 256
         }
257 257
 
@@ -265,31 +265,31 @@  discard block
 block discarded – undo
265 265
     }
266 266
 }
267 267
 
268
-if(!function_exists('getSetting')) {
268
+if (!function_exists('getSetting')) {
269 269
     function getSetting($key, $default = null)
270 270
     {
271
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
271
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
272 272
             return $cache;
273 273
         }
274 274
 
275
-        if(file_exists(storage_path('.cbconfig'))) {
275
+        if (file_exists(storage_path('.cbconfig'))) {
276 276
             $settings = file_get_contents(storage_path('.cbconfig'));
277 277
             $settings = decrypt($settings);
278 278
             $settings = unserialize($settings);
279
-        }else{
279
+        } else {
280 280
             $settings = [];
281 281
         }
282 282
 
283
-        if(isset($settings[$key])) {
283
+        if (isset($settings[$key])) {
284 284
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
285
-            return $settings[$key]?:$default;
286
-        }else{
285
+            return $settings[$key] ?: $default;
286
+        } else {
287 287
             return $default;
288 288
         }
289 289
     }
290 290
 }
291 291
 
292
-if(!function_exists('timeAgo')) {
292
+if (!function_exists('timeAgo')) {
293 293
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
294 294
     {
295 295
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             }
321 321
         }
322 322
 
323
-        if (! $full) {
323
+        if (!$full) {
324 324
             $string = array_slice($string, 0, 1);
325 325
         }
326 326
 
@@ -328,22 +328,22 @@  discard block
 block discarded – undo
328 328
     }
329 329
 }
330 330
 
331
-if(!function_exists("array_map_r")) {
332
-    function array_map_r( $func, $arr )
331
+if (!function_exists("array_map_r")) {
332
+    function array_map_r($func, $arr)
333 333
     {
334 334
         $newArr = array();
335 335
 
336
-        foreach( $arr as $key => $value )
336
+        foreach ($arr as $key => $value)
337 337
         {
338 338
             $key = $func($key);
339
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
339
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
340 340
         }
341 341
 
342 342
         return $newArr;
343 343
     }
344 344
 }
345 345
 
346
-if(!function_exists("sanitizeXSS"))
346
+if (!function_exists("sanitizeXSS"))
347 347
 {
348 348
     function sanitizeXSS($value)
349 349
     {
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     }
356 356
 }
357 357
 
358
-if(!function_exists("requestAll")) {
358
+if (!function_exists("requestAll")) {
359 359
     function requestAll() {
360 360
         $all = array_map_r("sanitizeXSS", request()->all());
361 361
         return $all;
@@ -364,22 +364,22 @@  discard block
 block discarded – undo
364 364
 
365 365
 
366 366
 
367
-if(!function_exists('getURLFormat')) {
367
+if (!function_exists('getURLFormat')) {
368 368
     function getURLFormat($name) {
369 369
         $url = request($name);
370
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
370
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
371 371
             return $url;
372
-        }else{
372
+        } else {
373 373
             return request()->url();
374 374
         }
375 375
     }
376 376
 }
377 377
 
378
-if(!function_exists('g')) {
378
+if (!function_exists('g')) {
379 379
     function g($name, $safe = true) {
380
-        if($safe == true) {
380
+        if ($safe == true) {
381 381
             $response = request($name);
382
-            if(is_string($response)) {
382
+            if (is_string($response)) {
383 383
                 $response = sanitizeXSS($response);
384 384
             }elseif (is_array($response)) {
385 385
                 array_walk_recursive($response, function(&$response) {
@@ -388,25 +388,25 @@  discard block
 block discarded – undo
388 388
             }
389 389
 
390 390
             return $response;
391
-        }else{
391
+        } else {
392 392
             return Request::get($name);
393 393
         }
394 394
     }
395 395
 }
396 396
 
397
-if(!function_exists('min_var_export')) {
397
+if (!function_exists('min_var_export')) {
398 398
     function min_var_export($input) {
399
-        if(is_array($input)) {
399
+        if (is_array($input)) {
400 400
             $buffer = [];
401
-            foreach($input as $key => $value)
401
+            foreach ($input as $key => $value)
402 402
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
403
-            return "[".implode(",",$buffer)."]";
403
+            return "[".implode(",", $buffer)."]";
404 404
         } else
405 405
             return var_export($input, true);
406 406
     }
407 407
 }
408 408
 
409
-if(!function_exists('rrmdir')) {
409
+if (!function_exists('rrmdir')) {
410 410
 	/*
411 411
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
412 412
 	*/
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@  discard block
 block discarded – undo
48 48
         }
49 49
 
50 50
         $str = substr($str, 0, -1);
51
-        if (!file_put_contents($envFile, $str)) return false;
51
+        if (!file_put_contents($envFile, $str)) {
52
+            return false;
53
+        }
52 54
         return true;
53 55
     }
54 56
 }
@@ -251,7 +253,7 @@  discard block
 block discarded – undo
251 253
             $settings = file_get_contents(storage_path('.cbconfig'));
252 254
             $settings = decrypt($settings);
253 255
             $settings = unserialize($settings);
254
-        }else{
256
+        } else{
255 257
             $settings = [];
256 258
         }
257 259
 
@@ -276,14 +278,14 @@  discard block
 block discarded – undo
276 278
             $settings = file_get_contents(storage_path('.cbconfig'));
277 279
             $settings = decrypt($settings);
278 280
             $settings = unserialize($settings);
279
-        }else{
281
+        } else{
280 282
             $settings = [];
281 283
         }
282 284
 
283 285
         if(isset($settings[$key])) {
284 286
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
285 287
             return $settings[$key]?:$default;
286
-        }else{
288
+        } else{
287 289
             return $default;
288 290
         }
289 291
     }
@@ -369,7 +371,7 @@  discard block
 block discarded – undo
369 371
         $url = request($name);
370 372
         if(filter_var($url, FILTER_VALIDATE_URL)) {
371 373
             return $url;
372
-        }else{
374
+        } else{
373 375
             return request()->url();
374 376
         }
375 377
     }
@@ -381,14 +383,14 @@  discard block
 block discarded – undo
381 383
             $response = request($name);
382 384
             if(is_string($response)) {
383 385
                 $response = sanitizeXSS($response);
384
-            }elseif (is_array($response)) {
386
+            } elseif (is_array($response)) {
385 387
                 array_walk_recursive($response, function(&$response) {
386 388
                     $response = sanitizeXSS($response);
387 389
                 });
388 390
             }
389 391
 
390 392
             return $response;
391
-        }else{
393
+        } else{
392 394
             return Request::get($name);
393 395
         }
394 396
     }
@@ -398,11 +400,13 @@  discard block
 block discarded – undo
398 400
     function min_var_export($input) {
399 401
         if(is_array($input)) {
400 402
             $buffer = [];
401
-            foreach($input as $key => $value)
402
-                $buffer[] = var_export($key, true)."=>".min_var_export($value);
403
+            foreach($input as $key => $value) {
404
+                            $buffer[] = var_export($key, true)."=>".min_var_export($value);
405
+            }
403 406
             return "[".implode(",",$buffer)."]";
404
-        } else
405
-            return var_export($input, true);
407
+        } else {
408
+                    return var_export($input, true);
409
+        }
406 410
     }
407 411
 }
408 412
 
@@ -415,10 +419,11 @@  discard block
 block discarded – undo
415 419
 	     $objects = scandir($dir); 
416 420
 	     foreach ($objects as $object) { 
417 421
 	       if ($object != "." && $object != "..") { 
418
-	         if (is_dir($dir."/".$object))
419
-	           rrmdir($dir."/".$object);
420
-	         else
421
-	           unlink($dir."/".$object); 
422
+	         if (is_dir($dir."/".$object)) {
423
+	         	           rrmdir($dir."/".$object);
424
+	         } else {
425
+	         	           unlink($dir."/".$object);
426
+	         }
422 427
 	       } 
423 428
 	     }
424 429
 	     rmdir($dir); 
Please login to merge, or discard this patch.
src/helpers/CurlHelper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function headers(array $headers) {
27 27
         $newHeaders = [];
28
-        foreach($headers as $key=>$val) {
28
+        foreach ($headers as $key=>$val) {
29 29
             $newHeaders[] = $key.": ".$val;
30 30
         }
31 31
         $this->headers = $newHeaders;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
         $err = curl_error($ch);
48 48
         curl_close($ch);
49 49
 
50
-        if($err) {
50
+        if ($err) {
51 51
             return $err;
52
-        }else {
52
+        } else {
53 53
             return $response;
54 54
         }
55 55
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 
50 50
         if($err) {
51 51
             return $err;
52
-        }else {
52
+        } else {
53 53
             return $response;
54 54
         }
55 55
     }
Please login to merge, or discard this patch.