Skip to content

Commit 8350373

Browse files
committed
Updated config editor
1 parent 8614339 commit 8350373

20 files changed

+2365
-1160
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
use Illuminate\Support\Facades\Schema;
99
use Illuminate\Support\Facades\File;
1010

11+
use GeoSot\EnvEditor\Controllers\EnvController;
12+
use GeoSot\EnvEditor\Exceptions\EnvException;
13+
use GeoSot\EnvEditor\Helpers\EnvFileContentManager;
14+
use GeoSot\EnvEditor\Helpers\EnvFilesManager;
15+
use GeoSot\EnvEditor\Helpers\EnvKeysManager;
16+
use GeoSot\EnvEditor\Facades\EnvEditor;
17+
use GeoSot\EnvEditor\ServiceProvider;
18+
1119
use Auth;
1220
use Exception;
1321
use ZipArchive;
@@ -289,11 +297,11 @@ public function editAC(request $request)
289297
//Saves .env config
290298
public function editENV(request $request)
291299
{
292-
$AdvancedConfig = $request->AdvancedConfig;
300+
$config = $request->altConfig;
293301

294-
file_put_contents('.env', $AdvancedConfig);
302+
file_put_contents('.env', $config);
295303

296-
return view('/panel/config');
304+
return Redirect('/panel/config');
297305
}
298306

299307
//Shows config file editor page
@@ -458,6 +466,64 @@ public function updateThemes()
458466
}
459467

460468
//Shows config file editor page
469+
public function showConfig(request $request)
470+
{
471+
return view('/panel/config-editor');
472+
}
473+
474+
//Shows config file editor page
475+
public function editConfig(request $request)
476+
{
477+
478+
$type = $request->type;
479+
$entry = $request->entry;
480+
$value = $request->value;
481+
482+
if($type === "toggle"){
483+
if($request->toggle != ''){$value = "auth";}else{$value = "false";}
484+
if(EnvEditor::keyExists($entry)){EnvEditor::editKey($entry, $value);}
485+
} elseif($type === "toggle2") {
486+
if($request->toggle != ''){$value = "verified";}else{$value = "auth";}
487+
if(EnvEditor::keyExists($entry)){EnvEditor::editKey($entry, $value);}
488+
} elseif($type === "text") {
489+
if(EnvEditor::keyExists($entry)){EnvEditor::editKey($entry, '"' . $value . '"');}
490+
} elseif($type === "debug") {
491+
if($request->toggle != ''){
492+
if(EnvEditor::keyExists('APP_DEBUG')){EnvEditor::editKey('APP_DEBUG', 'true');}
493+
if(EnvEditor::keyExists('APP_ENV')){EnvEditor::editKey('APP_ENV', 'local');}
494+
if(EnvEditor::keyExists('LOG_LEVEL')){EnvEditor::editKey('LOG_LEVEL', 'debug');}
495+
} else {
496+
if(EnvEditor::keyExists('APP_DEBUG')){EnvEditor::editKey('APP_DEBUG', 'false');}
497+
if(EnvEditor::keyExists('APP_ENV')){EnvEditor::editKey('APP_ENV', 'production');}
498+
if(EnvEditor::keyExists('LOG_LEVEL')){EnvEditor::editKey('LOG_LEVEL', 'error');}
499+
}
500+
} elseif($type === "register") {
501+
if($request->toggle != ''){$register = "true";}else{$register = "false";}
502+
Page::first()->update(['register' => $register]);
503+
} elseif($type === "smtp") {
504+
if($request->toggle != ''){$value = "built-in";}else{$value = "smtp";}
505+
if(EnvEditor::keyExists('MAIL_MAILER')){EnvEditor::editKey('MAIL_MAILER', $value);}
506+
507+
if(EnvEditor::keyExists('MAIL_HOST')){EnvEditor::editKey('MAIL_HOST', $request->MAIL_HOST);}
508+
if(EnvEditor::keyExists('MAIL_PORT')){EnvEditor::editKey('MAIL_PORT', $request->MAIL_PORT);}
509+
if(EnvEditor::keyExists('MAIL_USERNAME')){EnvEditor::editKey('MAIL_USERNAME', $request->MAIL_USERNAME);}
510+
if(EnvEditor::keyExists('MAIL_PASSWORD')){EnvEditor::editKey('MAIL_PASSWORD', $request->MAIL_PASSWORD);}
511+
if(EnvEditor::keyExists('MAIL_ENCRYPTION')){EnvEditor::editKey('MAIL_ENCRYPTION', $request->MAIL_ENCRYPTION);}
512+
if(EnvEditor::keyExists('MAIL_FROM_ADDRESS')){EnvEditor::editKey('MAIL_FROM_ADDRESS', $request->MAIL_FROM_ADDRESS);}
513+
} elseif($type === "homeurl") {
514+
if($request->value == 'default'){$value = "";}else{$value = '"' . $request->value . '"';}
515+
if(EnvEditor::keyExists($entry)){EnvEditor::editKey($entry, $value);}
516+
} else {
517+
if(EnvEditor::keyExists($entry)){EnvEditor::editKey($entry, $value);}
518+
}
519+
520+
521+
522+
523+
return Redirect('/panel/config');
524+
}
525+
526+
//Shows theme editor page
461527
public function showThemes(request $request)
462528
{
463529
return view('/panel/theme');

backups/CANUPDATE

Whitespace-only changes.
21.7 MB
Binary file not shown.
21.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)