Skip to content

Commit 0df539c

Browse files
committed
Added HTTPS redirection to env config
1 parent 64c1faf commit 0df539c

File tree

7 files changed

+49
-43
lines changed

7 files changed

+49
-43
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ SKIP_UPDATE_BACKUP=false
7474

7575
#=CUSTOM_META_TAGS either true or false. Used to enable setting in advanced config file (config/advanced-config.php).
7676
#=You can read more about this config at https://llc.bio/advanced-config.
77-
CUSTOM_META_TAGS=false
77+
CUSTOM_META_TAGS=false
78+
79+
FORCE_HTTPS=true
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
//run before finishing:
4+
if(EnvEditor::keyExists('JOIN_BETA')){ /* Do nothing if key already exists */
5+
} else { EnvEditor::addKey('JOIN_BETA', 'false');} // Adds key to .env file
6+
7+
if(EnvEditor::keyExists('SKIP_UPDATE_BACKUP')){ /* Do nothing if key already exists */
8+
} else { EnvEditor::addKey('SKIP_UPDATE_BACKUP', 'false');} // Adds key to .env file
9+
10+
if(EnvEditor::keyExists('CUSTOM_META_TAGS')){ /* Do nothing if key already exists */
11+
} else {EnvEditor::addKey('CUSTOM_META_TAGS', 'false');}
12+
13+
if (!config()->has('advanced-config.expand_panel_admin_menu_permanently') and !config()->has('disable_default_password_notice')) {
14+
15+
function getStringBetween($string, $start, $end) {
16+
$lastStartIndex = strrpos($string, $start);
17+
$lastEndIndex = strrpos($string, $end);
18+
19+
$substringStartIndex = $lastStartIndex + strlen($start);
20+
$substringSize = $lastStartIndex - $lastEndIndex - 1;
21+
22+
return substr($string, $substringStartIndex, $substringSize);
23+
}
24+
25+
$subject = file_get_contents('config/advanced-config.php');
26+
$search = ")";
27+
$replace = "),";
28+
29+
file_put_contents('config/advanced-config.php', str_replace('),,', '),', strrev(implode(strrev($replace), explode(strrev($search), strrev($subject), 2)))));
30+
31+
$replace = "];";
32+
file_put_contents('config/advanced-config.php', str_replace($replace, file_get_contents('storage/templates/advanced-config-update-1.php'), file_get_contents('config/advanced-config.php')));
33+
}
34+
35+
if(EnvEditor::keyExists('FORCE_HTTPS')){ /* Do nothing if key already exists */
36+
} else {EnvEditor::addKey('FORCE_HTTPS', 'false');}
37+
38+
echo "<meta http-equiv=\"refresh\" content=\"0; " . url()->current() . "?success\" />";
39+
?>

resources/views/layouts/lang.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
{{-- Redirects to https if enabled in the advanced-config --}}
9-
@if(config('advanced-config.redirect_https') == 'true')
9+
@if(env('FORCE_HTTPS') == 'true')
1010
@php
1111
if (! isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off' ) {
1212
$redirect_url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

resources/views/update.blade.php

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -99,42 +99,7 @@
9999
</div>
100100
<h1 class="loadingtxt">Finishing up</h1>
101101

102-
<?php
103-
104-
//run before finishing:
105-
if(EnvEditor::keyExists('JOIN_BETA')){ /* Do nothing if key already exists */
106-
} else { EnvEditor::addKey('JOIN_BETA', 'false');} // Adds key to .env file
107-
108-
if(EnvEditor::keyExists('SKIP_UPDATE_BACKUP')){ /* Do nothing if key already exists */
109-
} else { EnvEditor::addKey('SKIP_UPDATE_BACKUP', 'false');} // Adds key to .env file
110-
111-
if(EnvEditor::keyExists('CUSTOM_META_TAGS')){ /* Do nothing if key already exists */
112-
} else {EnvEditor::addKey('CUSTOM_META_TAGS', 'false');}
113-
114-
if (!config()->has('advanced-config.expand_panel_admin_menu_permanently') and !config()->has('advanced-config.redirect_https')) {
115-
116-
function getStringBetween($string, $start, $end) {
117-
$lastStartIndex = strrpos($string, $start);
118-
$lastEndIndex = strrpos($string, $end);
119-
120-
$substringStartIndex = $lastStartIndex + strlen($start);
121-
$substringSize = $lastStartIndex - $lastEndIndex - 1;
122-
123-
return substr($string, $substringStartIndex, $substringSize);
124-
}
125-
126-
$subject = file_get_contents('config/advanced-config.php');
127-
$search = ")";
128-
$replace = "),";
129-
130-
file_put_contents('config/advanced-config.php', str_replace('),,', '),', strrev(implode(strrev($replace), explode(strrev($search), strrev($subject), 2)))));
131-
132-
$replace = "];";
133-
file_put_contents('config/advanced-config.php', str_replace($replace, file_get_contents('storage/templates/advanced-config-update-1.php'), file_get_contents('config/advanced-config.php')));
134-
}
135-
136-
echo "<meta http-equiv=\"refresh\" content=\"0; " . url()->current() . "?success\" />";
137-
?>
102+
@include('components.finishing')
138103
@endif
139104

140105
@if($_SERVER['QUERY_STRING'] === 'success')

routes/web.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
Route::group([
6868
'middleware' => env('REGISTER_AUTH'),
6969
], function () {
70-
if(config('advanced-config.redirect_https') == 'true'){URL::forceScheme('https');}
70+
if(env('FORCE_HTTPS') == 'true'){URL::forceScheme('https');}
7171
Route::get('/studio/index', [UserController::class, 'index'])->name('studioIndex');
7272
Route::get('/studio/add-link', [UserController::class, 'showButtons'])->name('showButtons');
7373
Route::post('/studio/add-link', [UserController::class, 'addLink'])->name('addLink');
@@ -91,7 +91,7 @@
9191
Route::group([
9292
'middleware' => 'admin',
9393
], function () {
94-
if(config('advanced-config.redirect_https') == 'true'){URL::forceScheme('https');}
94+
if(env('FORCE_HTTPS') == 'true'){URL::forceScheme('https');}
9595
Route::get('/panel/index', [AdminController::class, 'index'])->name('panelIndex');
9696
Route::get('/panel/users/{type}', [AdminController::class, 'users'])->name('showUsers');
9797
Route::post('/panel/users/{name?}', [AdminController::class, 'searchUser'])->name('searchUser');

storage/backups/default_settings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,6 @@ SKIP_UPDATE_BACKUP=false
7474

7575
#=CUSTOM_META_TAGS either true or false. Used to enable setting in advanced config file (config/advanced-config.php).
7676
#=You can read more about this config at https://llc.bio/advanced-config.
77-
CUSTOM_META_TAGS=false
77+
CUSTOM_META_TAGS=false
78+
79+
FORCE_HTTPS=false

storage/templates/advanced-config-update-1.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
'expand_panel_admin_menu_permanently' => 'false',
1111

12-
'redirect_https' => 'false',
13-
1412
'disable_default_password_notice' => 'false',
1513

1614
];

0 commit comments

Comments
 (0)