Passed
Push — master ( 1d59b2...95e7d1 )
by Ferry
03:47
created
src/helpers/Helper.php 2 patches
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!function_exists("isConfigCached")) {
2
+if (!function_exists("isConfigCached")) {
3 3
     function isConfigCached()
4 4
     {
5
-        if(env("APP_NAME")=="" || env("APP_NAME")==null) return true;
5
+        if (env("APP_NAME") == "" || env("APP_NAME") == null) return true;
6 6
         else return false;
7 7
     }
8 8
 }
9 9
 
10
-if(!function_exists("miscellanousSingleton")) {
10
+if (!function_exists("miscellanousSingleton")) {
11 11
     /**
12 12
      * @return \crocodicstudio\crudbooster\helpers\MiscellanousSingleton
13 13
      */
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
     }
17 17
 }
18 18
 
19
-if(!function_exists("makeReferalUrl")) {
19
+if (!function_exists("makeReferalUrl")) {
20 20
     function makeReferalUrl($name = null) {
21 21
         $ref = [];
22 22
         $ref['url'] = request()->fullUrl();
23 23
         $ref['name'] = $name;
24 24
         $md5Hash = md5(serialize($ref));
25 25
 
26
-        if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
26
+        if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) {
27 27
             return $exist['id'];
28 28
         }
29 29
 
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
     }
36 36
 }
37 37
 
38
-if(!function_exists("getReferalUrl")) {
38
+if (!function_exists("getReferalUrl")) {
39 39
     function getReferalUrl($key = null) {
40
-        if(verifyReferalUrl()) {
40
+        if (verifyReferalUrl()) {
41 41
             $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"));
42 42
             $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
43
-            if($key) {
43
+            if ($key) {
44 44
                 return @$ref[$key];
45 45
             } else {
46 46
                 return $ref;
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
     }
51 51
 }
52 52
 
53
-if(!function_exists("verifyReferalUrl")) {
53
+if (!function_exists("verifyReferalUrl")) {
54 54
     function verifyReferalUrl()
55 55
     {
56
-        if(request("ref")) {
57
-            if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
56
+        if (request("ref")) {
57
+            if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) {
58 58
                 $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash);
59
-                if(filter_var($ref['url'], FILTER_VALIDATE_URL)) {
59
+                if (filter_var($ref['url'], FILTER_VALIDATE_URL)) {
60 60
                     return true;
61 61
                 }
62 62
             }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
 }
67 67
 
68
-if(!function_exists("putHtaccess")) {
68
+if (!function_exists("putHtaccess")) {
69 69
     function putHtaccess($stringToPut)
70 70
     {
71 71
         file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND);
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
     }
74 74
 }
75 75
 
76
-if(!function_exists("checkHtaccess")) {
76
+if (!function_exists("checkHtaccess")) {
77 77
     function checkHtaccess($stringToCheck)
78 78
     {
79
-        if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
79
+        if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) {
80 80
             $htaccess = file_get_contents(base_path(".htaccess"));
81
-            $htaccess2= file_get_contents(public_path(".htaccess"));
82
-            if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
81
+            $htaccess2 = file_get_contents(public_path(".htaccess"));
82
+            if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) {
83 83
                 return true;
84 84
             }
85 85
         }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     }
89 89
 }
90 90
 
91
-if(!function_exists("setEnvironmentValue")) {
91
+if (!function_exists("setEnvironmentValue")) {
92 92
     function setEnvironmentValue(array $values)
93 93
     {
94 94
         $envFile = app()->environmentFilePath();
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 }
120 120
 
121 121
 
122
-if(!function_exists("cbLang")) {
122
+if (!function_exists("cbLang")) {
123 123
     /**
124 124
      * @param string $key
125 125
      * @param array $replace
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
     }
132 132
 }
133 133
 
134
-if(!function_exists('rglob')) {
134
+if (!function_exists('rglob')) {
135 135
     function rglob($pattern, $flags = 0) {
136 136
         $files = glob($pattern, $flags);
137
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
137
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
138 138
             $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags));
139 139
         }
140 140
         return $files;
141 141
     }
142 142
 }
143 143
 
144
-if(!function_exists('convertPHPToMomentFormat')) {
144
+if (!function_exists('convertPHPToMomentFormat')) {
145 145
     function convertPHPToMomentFormat($format)
146 146
     {
147 147
         $replacements = [
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     }
189 189
 }
190 190
 
191
-if(!function_exists('slug')) {
191
+if (!function_exists('slug')) {
192 192
     function slug($string, $separator = '-') {
193 193
         return \Illuminate\Support\Str::slug($string, $separator);
194 194
     }
195 195
 }
196 196
 
197
-if(!function_exists('columnSingleton')) {
197
+if (!function_exists('columnSingleton')) {
198 198
     /**
199 199
      * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton
200 200
      */
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     }
204 204
 }
205 205
 
206
-if(!function_exists('cbHook'))
206
+if (!function_exists('cbHook'))
207 207
 {
208 208
     /**
209 209
      * @return crocodicstudio\crudbooster\hooks\CBHook
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     }
216 216
 }
217 217
 
218
-if(!function_exists('getTypeHook'))
218
+if (!function_exists('getTypeHook'))
219 219
 {
220 220
     /**
221 221
      * @param string $type
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     }
229 229
 }
230 230
 
231
-if(!function_exists('getPrimaryKey'))
231
+if (!function_exists('getPrimaryKey'))
232 232
 {
233 233
     function getPrimaryKey($table_name)
234 234
     {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     }
237 237
 }
238 238
 
239
-if(!function_exists('cb'))
239
+if (!function_exists('cb'))
240 240
 {
241 241
     function cb()
242 242
     {
@@ -244,25 +244,25 @@  discard block
 block discarded – undo
244 244
     }
245 245
 }
246 246
 
247
-if(!function_exists('cbAsset')) {
247
+if (!function_exists('cbAsset')) {
248 248
     function cbAsset($path, $secure = null) {
249 249
         return asset("cb_asset/".$path, $secure);
250 250
     }
251 251
 }
252 252
 
253
-if(!function_exists("cbConfig")) {
253
+if (!function_exists("cbConfig")) {
254 254
     function cbConfig($name, $default = null) {
255 255
         return config("crudbooster.".$name, $default);
256 256
     }
257 257
 }
258 258
 
259
-if(!function_exists("strRandom")) {
259
+if (!function_exists("strRandom")) {
260 260
     function strRandom($length = 5) {
261 261
         return \Illuminate\Support\Str::random($length);
262 262
     }
263 263
 }
264 264
 
265
-if(!function_exists('module')) {
265
+if (!function_exists('module')) {
266 266
     function module()
267 267
     {
268 268
         $module = new \crocodicstudio\crudbooster\helpers\Module();
@@ -270,21 +270,21 @@  discard block
 block discarded – undo
270 270
     }
271 271
 }
272 272
 
273
-if(!function_exists('getAdminLoginURL')) {
273
+if (!function_exists('getAdminLoginURL')) {
274 274
     function getAdminLoginURL()
275 275
     {
276 276
         return cb()->getAdminUrl("login");
277 277
     }
278 278
 }
279 279
 
280
-if(!function_exists('dummyPhoto')) {
280
+if (!function_exists('dummyPhoto')) {
281 281
     function dummyPhoto()
282 282
     {
283 283
         return cbConfig("DUMMY_PHOTO");
284 284
     }
285 285
 }
286 286
 
287
-if(!function_exists('extract_unit')) {	
287
+if (!function_exists('extract_unit')) {	
288 288
 	/*
289 289
 	Credits: Bit Repository
290 290
 	URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
 |
310 310
 */
311 311
 
312
-if(!function_exists('putSetting')) {
312
+if (!function_exists('putSetting')) {
313 313
     function putSetting($key, $value)
314 314
     {
315
-        if(file_exists(storage_path('.cbconfig'))) {
315
+        if (file_exists(storage_path('.cbconfig'))) {
316 316
             $settings = file_get_contents(storage_path('.cbconfig'));
317 317
             $settings = decrypt($settings);
318 318
             $settings = unserialize($settings);
319
-        }else{
319
+        } else {
320 320
             $settings = [];
321 321
         }
322 322
 
@@ -330,31 +330,31 @@  discard block
 block discarded – undo
330 330
     }
331 331
 }
332 332
 
333
-if(!function_exists('getSetting')) {
333
+if (!function_exists('getSetting')) {
334 334
     function getSetting($key, $default = null)
335 335
     {
336
-        if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
336
+        if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) {
337 337
             return $cache;
338 338
         }
339 339
 
340
-        if(file_exists(storage_path('.cbconfig'))) {
340
+        if (file_exists(storage_path('.cbconfig'))) {
341 341
             $settings = file_get_contents(storage_path('.cbconfig'));
342 342
             $settings = decrypt($settings);
343 343
             $settings = unserialize($settings);
344
-        }else{
344
+        } else {
345 345
             $settings = [];
346 346
         }
347 347
 
348
-        if(isset($settings[$key])) {
348
+        if (isset($settings[$key])) {
349 349
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
350
-            return $settings[$key]?:$default;
351
-        }else{
350
+            return $settings[$key] ?: $default;
351
+        } else {
352 352
             return $default;
353 353
         }
354 354
     }
355 355
 }
356 356
 
357
-if(!function_exists('timeAgo')) {
357
+if (!function_exists('timeAgo')) {
358 358
     function timeAgo($datetime_to, $datetime_from = null, $full = false)
359 359
     {
360 360
         $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             }
386 386
         }
387 387
 
388
-        if (! $full) {
388
+        if (!$full) {
389 389
             $string = array_slice($string, 0, 1);
390 390
         }
391 391
 
@@ -393,22 +393,22 @@  discard block
 block discarded – undo
393 393
     }
394 394
 }
395 395
 
396
-if(!function_exists("array_map_r")) {
397
-    function array_map_r( $func, $arr )
396
+if (!function_exists("array_map_r")) {
397
+    function array_map_r($func, $arr)
398 398
     {
399 399
         $newArr = array();
400 400
 
401
-        foreach( $arr as $key => $value )
401
+        foreach ($arr as $key => $value)
402 402
         {
403 403
             $key = $func($key);
404
-            $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) );
404
+            $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value)));
405 405
         }
406 406
 
407 407
         return $newArr;
408 408
     }
409 409
 }
410 410
 
411
-if(!function_exists("sanitizeXSS"))
411
+if (!function_exists("sanitizeXSS"))
412 412
 {
413 413
     function sanitizeXSS($value)
414 414
     {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     }
421 421
 }
422 422
 
423
-if(!function_exists("requestAll")) {
423
+if (!function_exists("requestAll")) {
424 424
     function requestAll() {
425 425
         $all = array_map_r("sanitizeXSS", request()->all());
426 426
         return $all;
@@ -429,22 +429,22 @@  discard block
 block discarded – undo
429 429
 
430 430
 
431 431
 
432
-if(!function_exists('getURLFormat')) {
432
+if (!function_exists('getURLFormat')) {
433 433
     function getURLFormat($name) {
434 434
         $url = request($name);
435
-        if(filter_var($url, FILTER_VALIDATE_URL)) {
435
+        if (filter_var($url, FILTER_VALIDATE_URL)) {
436 436
             return $url;
437
-        }else{
437
+        } else {
438 438
             return request()->url();
439 439
         }
440 440
     }
441 441
 }
442 442
 
443
-if(!function_exists('g')) {
443
+if (!function_exists('g')) {
444 444
     function g($name, $safe = true) {
445
-        if($safe == true) {
445
+        if ($safe == true) {
446 446
             $response = request($name);
447
-            if(is_string($response)) {
447
+            if (is_string($response)) {
448 448
                 $response = sanitizeXSS($response);
449 449
             }elseif (is_array($response)) {
450 450
                 array_walk_recursive($response, function(&$response) {
@@ -453,25 +453,25 @@  discard block
 block discarded – undo
453 453
             }
454 454
 
455 455
             return $response;
456
-        }else{
456
+        } else {
457 457
             return Request::get($name);
458 458
         }
459 459
     }
460 460
 }
461 461
 
462
-if(!function_exists('min_var_export')) {
462
+if (!function_exists('min_var_export')) {
463 463
     function min_var_export($input) {
464
-        if(is_array($input)) {
464
+        if (is_array($input)) {
465 465
             $buffer = [];
466
-            foreach($input as $key => $value)
466
+            foreach ($input as $key => $value)
467 467
                 $buffer[] = var_export($key, true)."=>".min_var_export($value);
468
-            return "[".implode(",",$buffer)."]";
468
+            return "[".implode(",", $buffer)."]";
469 469
         } else
470 470
             return var_export($input, true);
471 471
     }
472 472
 }
473 473
 
474
-if(!function_exists('rrmdir')) {
474
+if (!function_exists('rrmdir')) {
475 475
 	/*
476 476
 	* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
477 477
 	*/
Please login to merge, or discard this patch.
Braces   +25 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,8 +2,11 @@  discard block
 block discarded – undo
2 2
 if(!function_exists("isConfigCached")) {
3 3
     function isConfigCached()
4 4
     {
5
-        if(env("APP_NAME")=="" || env("APP_NAME")==null) return true;
6
-        else return false;
5
+        if(env("APP_NAME")=="" || env("APP_NAME")==null) {
6
+            return true;
7
+        } else {
8
+            return false;
9
+        }
7 10
     }
8 11
 }
9 12
 
@@ -113,7 +116,9 @@  discard block
 block discarded – undo
113 116
         }
114 117
 
115 118
         $str = substr($str, 0, -1);
116
-        if (!file_put_contents($envFile, $str)) return false;
119
+        if (!file_put_contents($envFile, $str)) {
120
+            return false;
121
+        }
117 122
         return true;
118 123
     }
119 124
 }
@@ -316,7 +321,7 @@  discard block
 block discarded – undo
316 321
             $settings = file_get_contents(storage_path('.cbconfig'));
317 322
             $settings = decrypt($settings);
318 323
             $settings = unserialize($settings);
319
-        }else{
324
+        } else{
320 325
             $settings = [];
321 326
         }
322 327
 
@@ -341,14 +346,14 @@  discard block
 block discarded – undo
341 346
             $settings = file_get_contents(storage_path('.cbconfig'));
342 347
             $settings = decrypt($settings);
343 348
             $settings = unserialize($settings);
344
-        }else{
349
+        } else{
345 350
             $settings = [];
346 351
         }
347 352
 
348 353
         if(isset($settings[$key])) {
349 354
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
350 355
             return $settings[$key]?:$default;
351
-        }else{
356
+        } else{
352 357
             return $default;
353 358
         }
354 359
     }
@@ -434,7 +439,7 @@  discard block
 block discarded – undo
434 439
         $url = request($name);
435 440
         if(filter_var($url, FILTER_VALIDATE_URL)) {
436 441
             return $url;
437
-        }else{
442
+        } else{
438 443
             return request()->url();
439 444
         }
440 445
     }
@@ -446,14 +451,14 @@  discard block
 block discarded – undo
446 451
             $response = request($name);
447 452
             if(is_string($response)) {
448 453
                 $response = sanitizeXSS($response);
449
-            }elseif (is_array($response)) {
454
+            } elseif (is_array($response)) {
450 455
                 array_walk_recursive($response, function(&$response) {
451 456
                     $response = sanitizeXSS($response);
452 457
                 });
453 458
             }
454 459
 
455 460
             return $response;
456
-        }else{
461
+        } else{
457 462
             return Request::get($name);
458 463
         }
459 464
     }
@@ -463,11 +468,13 @@  discard block
 block discarded – undo
463 468
     function min_var_export($input) {
464 469
         if(is_array($input)) {
465 470
             $buffer = [];
466
-            foreach($input as $key => $value)
467
-                $buffer[] = var_export($key, true)."=>".min_var_export($value);
471
+            foreach($input as $key => $value) {
472
+                            $buffer[] = var_export($key, true)."=>".min_var_export($value);
473
+            }
468 474
             return "[".implode(",",$buffer)."]";
469
-        } else
470
-            return var_export($input, true);
475
+        } else {
476
+                    return var_export($input, true);
477
+        }
471 478
     }
472 479
 }
473 480
 
@@ -480,10 +487,11 @@  discard block
 block discarded – undo
480 487
 	     $objects = scandir($dir); 
481 488
 	     foreach ($objects as $object) { 
482 489
 	       if ($object != "." && $object != "..") { 
483
-	         if (is_dir($dir."/".$object))
484
-	           rrmdir($dir."/".$object);
485
-	         else
486
-	           unlink($dir."/".$object); 
490
+	         if (is_dir($dir."/".$object)) {
491
+	         	           rrmdir($dir."/".$object);
492
+	         } else {
493
+	         	           unlink($dir."/".$object);
494
+	         }
487 495
 	       } 
488 496
 	     }
489 497
 	     rmdir($dir); 
Please login to merge, or discard this patch.
src/controllers/DeveloperSecurityController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@  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()
31 31
     {
32
-        if(!isConfigCached()) {
32
+        if (!isConfigCached()) {
33 33
             setEnvironmentValue([
34 34
                 "APP_DEBUG"=>request("APP_DEBUG")
35 35
             ]);
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
         putSetting("AUTO_REDIRECT_TO_LOGIN", request("AUTO_REDIRECT_TO_LOGIN"));
42 42
         putSetting("LOGIN_NOTIFICATION", request("LOGIN_NOTIFICATION"));
43 43
 
44
-        if(request("htaccess_ServerSignature")) {
44
+        if (request("htaccess_ServerSignature")) {
45 45
             putHtaccess("ServerSignature Off");
46 46
         }
47 47
 
48
-        if(request("htaccess_IndexIgnore")) {
48
+        if (request("htaccess_IndexIgnore")) {
49 49
             putHtaccess("IndexIgnore *");
50 50
         }
51 51
 
52
-        if(request("htaccess_dotAccess")) {
52
+        if (request("htaccess_dotAccess")) {
53 53
 putHtaccess("
54 54
 <FilesMatch \"^\.\">
55 55
 Order allow,deny
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 </FilesMatch>");
58 58
         }
59 59
 
60
-        if(request("htaccess_preventVendor")) {
60
+        if (request("htaccess_preventVendor")) {
61 61
             putHtaccess("RewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]");
62 62
         }
63 63
 
64 64
 
65
-        return cb()->redirectBack("Security has been updated!","success");
65
+        return cb()->redirectBack("Security has been updated!", "success");
66 66
     }
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.