@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | if ($this->confirm('Do you have setting the database configuration at .env ?')) { |
41 | 41 | |
42 | - if (! file_exists(public_path('vendor')) ) { |
|
42 | + if (!file_exists(public_path('vendor'))) { |
|
43 | 43 | mkdir(public_path('vendor')); |
44 | 44 | } |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /* |
53 | 53 | * Create CBPlugins |
54 | 54 | */ |
55 | - if(!file_exists(app_path("CBPlugins"))) { |
|
55 | + if (!file_exists(app_path("CBPlugins"))) { |
|
56 | 56 | mkdir(app_path("CBPlugins")); |
57 | 57 | } |
58 | 58 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * We need it to change default laravel local filesystem from storage to public |
62 | 62 | * We won't use symlink because of a security issue in many server |
63 | 63 | */ |
64 | - if(!file_exists(public_path("storage"))) { |
|
64 | + if (!file_exists(public_path("storage"))) { |
|
65 | 65 | $this->info("Create storage directory on /public"); |
66 | 66 | mkdir(public_path("storage")); |
67 | - file_put_contents(public_path("storage/.gitignore"),"!.gitignore"); |
|
68 | - file_put_contents(public_path("storage/index.html")," "); |
|
67 | + file_put_contents(public_path("storage/.gitignore"), "!.gitignore"); |
|
68 | + file_put_contents(public_path("storage/index.html"), " "); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /* |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * Disable php execution on /vendor/* |
75 | 75 | */ |
76 | 76 | $this->info("Tweak some security for your laravel"); |
77 | - file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
|
78 | - file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
|
77 | + file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND); |
|
78 | + file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>", FILE_APPEND); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | $this->info('Dumping the autoloaded files and reloading all new files...'); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getRoleByName($roleName) { |
27 | - return $this->find("cb_roles",['name'=>$roleName]); |
|
27 | + return $this->find("cb_roles", ['name'=>$roleName]); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function fcm() { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getDeveloperUrl($path = null) { |
43 | - $path = ($path)?"/".trim($path,"/"):null; |
|
43 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
44 | 44 | return url("developer/".getSetting("developer_path")).$path; |
45 | 45 | } |
46 | 46 | |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getAdminPath() { |
60 | - return getSetting("ADMIN_PATH","admin"); |
|
60 | + return getSetting("ADMIN_PATH", "admin"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function getAdminUrl($path = null) { |
64 | - $path = ($path)?"/".trim($path,"/"):null; |
|
64 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
65 | 65 | return url($this->getAdminPath()).$path; |
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getAppName() { |
69 | - return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER")); |
|
69 | + return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER")); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null) |
82 | 82 | { |
83 | - if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
83 | + if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
84 | 84 | $file_path = cbConfig("UPLOAD_PATH_FORMAT"); |
85 | - $file_path = str_replace("{Y}",date('Y'), $file_path); |
|
85 | + $file_path = str_replace("{Y}", date('Y'), $file_path); |
|
86 | 86 | $file_path = str_replace("{m}", date('m'), $file_path); |
87 | 87 | $file_path = str_replace("{d}", date("d"), $file_path); |
88 | 88 | |
89 | 89 | //Create Directory Base On Template |
90 | 90 | Storage::makeDirectory($file_path); |
91 | - Storage::put($file_path."/index.html"," ","public"); |
|
92 | - Storage::put($file_path."/.gitignore","!.gitignore","public"); |
|
91 | + Storage::put($file_path."/index.html", " ", "public"); |
|
92 | + Storage::put($file_path."/.gitignore", "!.gitignore", "public"); |
|
93 | 93 | |
94 | 94 | if ($encrypt == true) { |
95 | 95 | $filename = md5(strRandom(5)).'.'.$extension; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | $filename = slug($filename, '_').'.'.$extension; |
98 | 98 | } |
99 | 99 | |
100 | - if($resize_width || $resize_height) { |
|
100 | + if ($resize_width || $resize_height) { |
|
101 | 101 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
102 | 102 | return $file_path.'/'.$filename; |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | if (Storage::putFileAs($file_path, $file, $filename, 'public')) { |
105 | 105 | return $file_path.'/'.$filename; |
106 | 106 | } else { |
107 | 107 | throw new \Exception("Something went wrong, file can't upload!"); |
108 | 108 | } |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else { |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | } |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | { |
124 | 124 | $fileData = base64_decode($base64_value); |
125 | 125 | $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE); |
126 | - if($mime_type) { |
|
127 | - if($mime_type = explode('/', $mime_type)) { |
|
126 | + if ($mime_type) { |
|
127 | + if ($mime_type = explode('/', $mime_type)) { |
|
128 | 128 | $ext = $mime_type[1]; |
129 | - if($filename && $ext) { |
|
129 | + if ($filename && $ext) { |
|
130 | 130 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
131 | 131 | } |
132 | - }else { |
|
132 | + } else { |
|
133 | 133 | throw new \Exception("Mime type not found"); |
134 | 134 | } |
135 | - }else{ |
|
135 | + } else { |
|
136 | 136 | throw new \Exception("Mime type not found"); |
137 | 137 | } |
138 | 138 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $filename = $file->getClientOriginalName(); |
153 | 153 | $ext = strtolower($file->getClientOriginalExtension()); |
154 | 154 | |
155 | - if($filename && $ext) { |
|
155 | + if ($filename && $ext) { |
|
156 | 156 | return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height); |
157 | 157 | } |
158 | 158 | |
@@ -187,29 +187,29 @@ discard block |
||
187 | 187 | if ($resize_width && $resize_height) { |
188 | 188 | $img->fit($resize_width, $resize_height); |
189 | 189 | |
190 | - } elseif ($resize_width && ! $resize_height) { |
|
190 | + } elseif ($resize_width && !$resize_height) { |
|
191 | 191 | |
192 | - $img->resize($resize_width, null, function ($constraint) { |
|
192 | + $img->resize($resize_width, null, function($constraint) { |
|
193 | 193 | $constraint->aspectRatio(); |
194 | 194 | }); |
195 | 195 | |
196 | - } elseif (! $resize_width && $resize_height) { |
|
196 | + } elseif (!$resize_width && $resize_height) { |
|
197 | 197 | |
198 | - $img->resize(null, $resize_height, function ($constraint) { |
|
198 | + $img->resize(null, $resize_height, function($constraint) { |
|
199 | 199 | $constraint->aspectRatio(); |
200 | 200 | }); |
201 | 201 | |
202 | 202 | } else { |
203 | 203 | |
204 | 204 | if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) { |
205 | - $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) { |
|
205 | + $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) { |
|
206 | 206 | $constraint->aspectRatio(); |
207 | 207 | }); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | Storage::put($fullFilePath, $img, 'public'); |
212 | - }else{ |
|
212 | + } else { |
|
213 | 213 | throw new \Exception("The file format is not allowed!"); |
214 | 214 | } |
215 | 215 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $validator = Validator::make($input_arr, $rules, $messages); |
323 | 323 | if ($validator->fails()) { |
324 | 324 | $message = $validator->errors()->all(); |
325 | - throw new CBValidationException(implode("; ",$message)); |
|
325 | + throw new CBValidationException(implode("; ", $message)); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function findPrimaryKey($table) |
335 | 335 | { |
336 | 336 | $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey(); |
337 | - if(!$pk) { |
|
337 | + if (!$pk) { |
|
338 | 338 | return null; |
339 | 339 | } |
340 | 340 | return $pk->getColumns()[0]; |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $string_parameters_array = explode('&', $string_parameters); |
384 | 384 | foreach ($string_parameters_array as $s) { |
385 | 385 | $part = explode('=', $s); |
386 | - if(isset($part[0]) && isset($part[1])) { |
|
386 | + if (isset($part[0]) && isset($part[1])) { |
|
387 | 387 | $name = htmlspecialchars(urldecode($part[0])); |
388 | 388 | $name = strip_tags($name); |
389 | 389 | $value = htmlspecialchars(urldecode($part[1])); |
@@ -400,16 +400,16 @@ discard block |
||
400 | 400 | |
401 | 401 | |
402 | 402 | public function routeGet($prefix, $controller) { |
403 | - $alias = str_replace("@"," ", $controller); |
|
403 | + $alias = str_replace("@", " ", $controller); |
|
404 | 404 | $alias = ucwords($alias); |
405 | - $alias = str_replace(" ","",$alias); |
|
405 | + $alias = str_replace(" ", "", $alias); |
|
406 | 406 | Route::get($prefix, ['uses' => $controller, 'as' => $alias]); |
407 | 407 | } |
408 | 408 | |
409 | 409 | public function routePost($prefix, $controller) { |
410 | - $alias = str_replace("@"," ", $controller); |
|
410 | + $alias = str_replace("@", " ", $controller); |
|
411 | 411 | $alias = ucwords($alias); |
412 | - $alias = str_replace(" ","",$alias); |
|
412 | + $alias = str_replace(" ", "", $alias); |
|
413 | 413 | Route::post($prefix, ['uses' => $controller, 'as' => $alias]); |
414 | 414 | } |
415 | 415 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | |
443 | 443 | $prefix = trim($prefix, '/').'/'; |
444 | 444 | |
445 | - if(substr($controller,0,1) != "\\") { |
|
445 | + if (substr($controller, 0, 1) != "\\") { |
|
446 | 446 | $controller = "\App\Http\Controllers\\".$controller; |
447 | 447 | } |
448 | 448 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $data['name'] = $name; |
26 | 26 | $data['label'] = $label; |
27 | 27 | $data['required'] = $required; |
28 | - $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true; |
|
28 | + $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true; |
|
29 | 29 | return view("crudbooster::html_helper.file_uploader.index", $data); |
30 | 30 | } |
31 | 31 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $data['name'] = $name; |
43 | 43 | $data['label'] = $label; |
44 | 44 | $data['required'] = $required; |
45 | - $data['encrypt'] = isset($options['encrypt'])?$options['encrypt']:true; |
|
45 | + $data['encrypt'] = isset($options['encrypt']) ? $options['encrypt'] : true; |
|
46 | 46 | @$data['resizeWidth'] = $options['resize_width']; |
47 | 47 | @$data['resizeHeight'] = $options['resize_height']; |
48 | 48 | return view("crudbooster::html_helper.image_uploader.index", $data); |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -cb()->routeGroupBackend(function () { |
|
4 | - cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
3 | +cb()->routeGroupBackend(function() { |
|
4 | + cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
5 | 5 | }); |
6 | 6 | |
7 | -cb()->routeGroupDeveloper(function () { |
|
8 | - cb()->routePost("upload-file",'\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
7 | +cb()->routeGroupDeveloper(function() { |
|
8 | + cb()->routePost("upload-file", '\crocodicstudio\crudbooster\types\file\FileController@postUploadFile'); |
|
9 | 9 | }); |
10 | 10 | \ No newline at end of file |
@@ -19,15 +19,15 @@ |
||
19 | 19 | try { |
20 | 20 | |
21 | 21 | cb()->validation([ |
22 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
22 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_FILE_EXTENSION_ALLOWED')) |
|
23 | 23 | ]); |
24 | 24 | |
25 | 25 | $file = cb()->uploadFile('userfile', request("encrypt")); |
26 | 26 | |
27 | 27 | } catch (CBValidationException $e) { |
28 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
28 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
29 | 29 | } catch (\Exception $e) { |
30 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
30 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | return response()->json([ |
@@ -18,15 +18,15 @@ |
||
18 | 18 | try { |
19 | 19 | |
20 | 20 | cb()->validation([ |
21 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
21 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
22 | 22 | ]); |
23 | 23 | |
24 | - $file = cb()->uploadFile('userfile', request("encrypt")?true:false, request("resize_width"), request("resize_height")); |
|
24 | + $file = cb()->uploadFile('userfile', request("encrypt") ?true:false, request("resize_width"), request("resize_height")); |
|
25 | 25 | |
26 | 26 | } catch (CBValidationException $e) { |
27 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
27 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
28 | 28 | } catch (\Exception $e) { |
29 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
29 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | return response()->json([ |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -cb()->routeGroupBackend(function () { |
|
4 | - cb()->routePost("upload-image",'\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
3 | +cb()->routeGroupBackend(function() { |
|
4 | + cb()->routePost("upload-image", '\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
5 | 5 | }); |
6 | 6 | |
7 | -cb()->routeGroupDeveloper(function () { |
|
8 | - cb()->routePost("upload-image",'\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
7 | +cb()->routeGroupDeveloper(function() { |
|
8 | + cb()->routePost("upload-image", '\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
9 | 9 | }); |
@@ -24,21 +24,21 @@ |
||
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 | - if(request("login_background_cover")) { |
|
36 | + if (request("login_background_cover")) { |
|
37 | 37 | putSetting("login_background_cover", "on"); |
38 | 38 | } else { |
39 | 39 | putSetting("login_background_cover", ""); |
40 | 40 | } |
41 | 41 | |
42 | - return cb()->redirectBack("Appearance has been updated!","success"); |
|
42 | + return cb()->redirectBack("Appearance has been updated!", "success"); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -20,29 +20,29 @@ discard block |
||
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 |
||
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 |