Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
e639e706
Commit
e639e706
authored
Nov 10, 2020
by
Davide Aprea
Browse files
added full settings link to key page
parent
ee700786
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/KeyController.php
View file @
e639e706
...
...
@@ -5,15 +5,15 @@ namespace App\Http\Controllers;
use
Cookie
;
use
Illuminate\Http\Request
;
use
LaravelLocalization
;
use
\
App\Models\Key
;
class
KeyController
extends
Controller
{
public
function
index
(
Request
$request
)
{
$redirUrl
=
$request
->
input
(
'redirUrl'
,
""
);
$cookie
=
Cookie
::
get
(
'key'
);
$key
=
$request
->
input
(
'key'
,
''
);
$key
=
$request
->
input
(
'key
ToSet
'
,
''
);
if
(
empty
(
$key
)
&&
empty
(
$cookie
)){
$key
=
'enter_key_here'
;
...
...
@@ -23,42 +23,40 @@ class KeyController extends Controller
$key
=
$request
->
input
(
'key'
);
}
$cookieLink
=
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
route
(
'loadSettings'
,
Cookie
::
get
()));
return
view
(
'key'
)
->
with
(
'title'
,
trans
(
'titles.key'
))
->
with
(
'cookie'
,
$key
);
->
with
(
'cookie'
,
$key
)
->
with
(
'cookieLink'
,
$cookieLink
);
}
public
function
setKey
(
Request
$request
)
{
$redirUrl
=
$request
->
input
(
'redirUrl'
,
""
);
$key
=
$request
->
input
(
'key'
,
''
);
$keyToSet
=
$request
->
input
(
'keyToSet'
);
$key
=
new
Key
(
$request
->
input
(
'keyToSet'
,
''
));
if
(
app
(
'App\Models\Key'
)
->
getStatus
())
{
if
(
$key
->
getStatus
())
{
# Valid Key
$host
=
$request
->
header
(
"X_Forwarded_Host"
,
""
);
if
(
empty
(
$host
))
{
$host
=
$request
->
header
(
"Host"
,
""
);
}
$cookie
=
Cookie
::
get
(
'key'
);
if
(
empty
(
$key
)
&&
empty
(
$cookie
)){
$key
=
'enter_key_here'
;
}
elseif
(
empty
(
$key
)
&&
!
empty
(
$cookie
)){
$key
=
$cookie
;
}
elseif
(
!
empty
(
$key
)){
$key
=
$request
->
input
(
'key'
);
Cookie
::
queue
(
'key'
,
$key
,
0
,
'/'
,
null
,
false
,
false
);
}
Cookie
::
queue
(
'key'
,
$keyToSet
,
0
,
'/'
,
null
,
false
,
false
);
$settings
=
Cookie
::
get
();
$settings
[
'key'
]
=
$keyToSet
;
$cookieLink
=
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
route
(
'loadSettings'
,
$settings
));
return
view
(
'key'
)
->
with
(
'title'
,
trans
(
'titles.key'
))
->
with
(
'cookie'
,
$key
);
->
with
(
'title'
,
trans
(
'titles.key'
))
->
with
(
'cookie'
,
$keyToSet
)
->
with
(
'cookieLink'
,
$cookieLink
);
}
else
{
$cookieLink
=
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
route
(
'loadSettings'
,
Cookie
::
get
()));
return
view
(
'key'
)
->
with
(
'title'
,
trans
(
'titles.key'
))
->
with
(
'keyValid'
,
false
)
->
with
(
'cookie'
,
'enter_key_here'
);
->
with
(
'cookie'
,
'enter_key_here'
)
->
with
(
'cookieLink'
,
$cookieLink
);
}
}
...
...
resources/views/key.blade.php
View file @
e639e706
...
...
@@ -24,7 +24,7 @@
<
li
>
@
lang
(
'key.li1'
)
<
div
class
=
"copyLink"
>
<
input
id
=
"loadSettings"
class
=
"loadSettings"
type
=
"text"
value
=
"{{
route('loadSettings', ["
key
" =>
$cookie
])
}}"
>
<
input
id
=
"loadSettings"
class
=
"loadSettings"
type
=
"text"
value
=
"
{
{$cookie
Link
}
}
"
>
<
button
class
=
"js-only btn btn-default"
onclick
=
"var copyText = document.getElementById('loadSettings');copyText.select();copyText.setSelectionRange(0, 99999);document.execCommand('copy');"
>@
lang
(
'settings.copy'
)
</
button
>
</
div
>
</
li
>
...
...
@@ -42,7 +42,7 @@
<
div
id
=
"form-wrapper"
>
<
form
method
=
"post"
>
<
input
type
=
"hidden"
name
=
"redirUrl"
value
=
"{{ Request::input('redirUrl', '') }}"
/>
<
input
type
=
"text"
name
=
"key"
value
=
"{{$cookie === 'enter_key_here' ? '' :
$cookie
}}"
placeholder
=
"@lang('key.placeholder1')"
autofocus
>
<
input
type
=
"text"
name
=
"key
ToSet
"
value
=
"{{$cookie === 'enter_key_here' ? '' :
$cookie
}}"
placeholder
=
"@lang('key.placeholder1')"
autofocus
>
<
button
type
=
"submit"
class
=
"btn btn-success"
>
OK
</
button
>
</
form
>
@
if
(
$cookie
!==
'enter_key_here'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment