2021-04-16 01:00:00 +02:00
<! doctype html >
2022-06-08 15:43:51 +02:00
@ include ( 'layouts.lang' )
2021-04-16 01:00:00 +02:00
< head >
< title > Studio ⚙️ {{ config ( 'app.name' ) }} </ title >
< meta charset = " utf-8 " >
2022-06-08 15:58:04 +02:00
2023-02-16 13:02:05 +01:00
@ php
// Update the 'updated_at' timestamp for the currently authenticated user
if ( auth () -> check ()) {
$user = auth () -> user ();
$user -> touch ();
}
@ endphp
2022-06-08 15:58:04 +02:00
@ include ( 'layouts.analytics' )
2022-11-08 16:11:59 +01:00
< base href = " { { url()->current()}} " />
2021-04-16 01:00:00 +02:00
< meta name = " viewport " content = " width=device-width, initial-scale=1, shrink-to-fit=no " >
2022-08-14 21:05:26 +02:00
< meta name = " csrf-token " content = " { { csrf_token() }} " >
2022-03-21 23:11:49 +01:00
< link rel = " stylesheet " href = " { { asset('littlelink/css/hover-min.css') }} " >
< link rel = " stylesheet " href = " { { asset('littlelink/css/animate.css') }} " >
2021-04-16 01:00:00 +02:00
2022-08-16 17:50:13 +02:00
< link href = " //fonts.bunny.net/css?family=Poppins:300,400,500,600,700,800,900 " rel = " stylesheet " >
2022-11-23 16:37:30 +01:00
< link rel = " stylesheet " href = " { { asset('studio/external-dependencies/bootstrap-icons.css') }} " >
2022-02-20 22:56:09 +01:00
<!-- begin dark mode detection -->
< script src = " { { asset('littlelink/js/js.cookie.min.js') }} " ></ script >
< script >
// code to set the `color_scheme` cookie
var $color_scheme = Cookies . get ( " color_scheme " );
function get_color_scheme () {
return ( window . matchMedia && window . matchMedia ( " (prefers-color-scheme: dark) " ) . matches ) ? " dark " : " light " ;
}
function update_color_scheme () {
Cookies . set ( " color_scheme " , get_color_scheme ());
}
// read & compare cookie `color-scheme`
if (( typeof $color_scheme === " undefined " ) || ( get_color_scheme () != $color_scheme ))
update_color_scheme ();
// detect changes and change the cookie
if ( window . matchMedia )
window . matchMedia ( " (prefers-color-scheme: dark) " ) . addListener ( update_color_scheme );
Fixed dark mode not applying on first visit
This 'bug' was caused due to the way the dark mode was applied. The dark mode detection detects the preferred theme style from the client and then saves the preferred type with a cookie, all with JavaScript. Then a simple PHP if-else statement loads either the dark or light mode CSS theme, depending on the cookie.
The problem here was that the cookie would only be detected if the page was refreshed, so once the cookie was set, the dark mode was applied every time without a problem. But the first time a user visited the site and the preferred theme was set to dark mode, the page would still display the white version until the page was refreshed.
Now, I could have changed how the page applies the dark mode, however I decided against that and went with this commit instead.
Now I'm not really experienced with JavaScript at all, so this definitely could have been solved in a more elegant way, but this is what I did:
I added a bit to the JavaScript that sets and reads the cookie. When the page finished loading, a simple if statement is run that requires the following conditions:
The URL contains a '#' and the color scheme equals 'dark' and the cookie isn't set yet.
After these conditions are met, '#dark' is added to the URL and the page will be refreshed.
This refresh is only performed without the cookie, thus only refreshing the page on the first visit if the dark mode would be applied.
The '#dark' is only added to the URL to fail the first requirement of the if statement, preventing the page from being reloaded in an infinite loop. Otherwise, the '#dark' part of the URL fulfills no purpose and only the '#' part is required, so it doesn't even matter what comes after the hash. I just chose this for clarification.
If the dark mode cookie is blocked by the user, the page will be set to light mode and refreshed every time they visit but the '#dark' will still be added to the URL, preventing the infinite refresh-loop.
2022-03-03 10:49:10 +01:00
// reloads page to apply the dark mode cookie
window . onload = function () {
if ( ! window . location . hash && get_color_scheme () == " dark " && ( get_color_scheme () != $color_scheme )) {
window . location = window . location + '#dark' ;
window . location . reload ();
}
}
2022-02-20 22:56:09 +01:00
</ script >
< ? php // loads dark mode CSS if dark mode detected
2022-05-13 13:03:10 +02:00
$color_scheme = isset ( $_COOKIE [ " color_scheme " ]) ? $_COOKIE [ " color_scheme " ] : false ;
$color_scheme_override = isset ( $_COOKIE [ " color_scheme_override " ]) ? $_COOKIE [ " color_scheme_override " ] : false ; ?>
2022-06-09 22:26:35 +02:00
@ if ( $color_scheme == 'dark' and config ( 'advanced-config.theme' ) != 'light' and $color_scheme_override != 'light' or $color_scheme_override == 'dark' )
2022-03-20 17:15:16 +01:00
<!-- switch the two < link > Tags below to default to dark mode if cookie detection fails -->
2022-02-20 22:56:09 +01:00
< link rel = " stylesheet " href = " { { asset('/studio/css/bootstrap.min-dark.css') }} " >
< link rel = " stylesheet " href = " { { asset('/studio/css/style-dashboard-dark.css') }} " >
2022-06-09 22:26:35 +02:00
@ elseif ( config ( 'advanced-config.theme' ) == 'dark' )
2022-06-08 17:09:24 +02:00
< link rel = " stylesheet " href = " { { asset('/studio/css/bootstrap.min-dark.css') }} " >
< link rel = " stylesheet " href = " { { asset('/studio/css/style-dashboard-dark.css') }} " >
2022-02-20 22:56:09 +01:00
@ else
< link rel = " stylesheet " href = " { { asset('/studio/css/bootstrap.min.css') }} " >
< link rel = " stylesheet " href = " { { asset('/studio/css/style-dashboard.css') }} " >
@ endif
<!-- end dark mode detection -->
2021-04-16 01:00:00 +02:00
2022-04-20 18:18:41 +02:00
< ? php //security check, checks if config files got compromised
if ( auth () -> user () -> role == 'admin' ){
$serversb = $_SERVER [ 'SERVER_NAME' ];
$urisb = $_SERVER [ 'REQUEST_URI' ];
// Tests if a URL has a valid SSL certificate
function has_sslsb ( $domain ) {
$ssl_check = @ fsockopen ( 'ssl://' . $domain , 443 , $errno , $errstr , 30 );
$res = !! $ssl_check ;
if ( $ssl_check ) { fclose ( $ssl_check ); }
return $res ;
}
// Changes probed URL to HTTP if no valid SSL certificate is present, otherwise an error would be thrown
if ( has_sslsb ( $serversb )) {
$actual_linksb = " https:// $_SERVER[HTTP_HOST] $_SERVER[REQUEST_URI] " ;
} else {
$actual_linksb = " http:// $_SERVER[HTTP_HOST] $_SERVER[REQUEST_URI] " ;
}
2022-06-16 09:56:36 +02:00
function getUrlSatusCodesb ( $urlsb , $timeoutsb = 3 )
{
$chsb = curl_init ();
$optssb = array ( CURLOPT_RETURNTRANSFER => true , // do not output to browser
CURLOPT_URL => $urlsb ,
CURLOPT_NOBODY => true , // do a HEAD request only
CURLOPT_TIMEOUT => $timeoutsb );
curl_setopt_array ( $chsb , $optssb );
curl_exec ( $chsb );
$status = curl_getinfo ( $chsb , CURLINFO_HTTP_CODE );
curl_close ( $chsb );
return $status ;
}
2022-04-20 18:18:41 +02:00
// Files or directories to test if accessible externally
2022-06-16 09:56:36 +02:00
$url1sb = getUrlSatusCodesb ( $actual_linksb . '/../../.env' );
$url2sb = getUrlSatusCodesb ( $actual_linksb . '/../../database/database.sqlite' );
2022-04-20 18:18:41 +02:00
// sets compromised to true if config files got compromised
2022-06-16 09:56:36 +02:00
if ( $url1sb == '200' or $url2sb == '200' ) {
2022-04-20 18:18:41 +02:00
$compromised = " true " ;
} else {
$compromised = " false " ;
}
}
// end security check ?>
2022-12-04 23:15:40 +01:00
@ if ( file_exists ( base_path ( " littlelink/images/ " ) . findFile ( 'favicon' )))
< link rel = " icon " type = " image/png " href = " { { asset('littlelink/images/'.findFile('favicon')) }} " >
2022-02-20 13:12:25 +01:00
@ else
2022-02-20 13:20:21 +01:00
< link rel = " icon " type = " image/svg+xml " href = " { { asset('littlelink/images/logo.svg') }} " >
2022-02-20 13:12:25 +01:00
@ endif
2022-05-03 23:27:37 +02:00
2022-05-07 16:23:25 +02:00
@ stack ( 'sidebar-stylesheets' )
2022-11-08 16:11:59 +01:00
< style >
. segmented - button {
display : flex ;
margin - right : 0.75 rem ;
margin - top : 0.1 rem ;
}
. segmented - button . dropdown - button {
padding : 0 1 rem ;
margin - left : 1 px ;
}
. btn - seg , . btn - seg - large {
text - decoration : none ;
color : #fff;
background - color : #f8b739;
text - align : center ;
letter - spacing : . 5 px ;
transition : . 2 s ease - out ;
cursor : pointer ;
}
. btn - seg : hover {
color : #fff;
}
. btn - seg , . btn - seg - large , . btn - seg - floating , . btn - seg - large , . btn - seg - flat {
outline : 0 ;
}
. btn - seg , . btn - seg - large , . btn - seg - flat {
border : none ;
border - radius : 0.25 rem ;
display : inline - block ;
height : 36 px ;
line - height : 36 px ;
padding : 0 2 rem ;
text - transform : uppercase ;
vertical - align : middle ;
- webkit - tap - highlight - color : transparent ;
}
. z - depth - 1 , nav , . card - panel , . card , . toast , . btn - seg , . btn - seg - large , . btn - seg - floating , . dropdown - content , . collapsible , . side - nav {
box - shadow : 0 2 px 2 px 0 rgb ( 0 0 0 / 14 % ), 0 1 px 5 px 0 rgb ( 0 0 0 / 12 % ), 0 3 px 1 px - 2 px rgb ( 0 0 0 / 20 % );
}
</ style >
{{ -- Couldn ' t get this fixed so I did this : -- }}
@ if ( request () -> route () -> getName () == 'env-editor.index' )
< style >
. btn - seg - ico {
position : relative ;
top : 10 px ;
left : 1 px ;
}
</ style >
@ endif
2021-04-16 01:00:00 +02:00
</ head >
< body >
< div class = " wrapper d-flex align-items-stretch " >
< nav id = " sidebar " >
< div class = " p-4 pt-5 " >
2021-07-06 10:48:50 +02:00
@ if ( auth () -> user () -> role == 'user' || auth () -> user () -> role == 'vip' )
2021-04-16 01:00:00 +02:00
< a href = " { { url('/studio/index') }} " >
@ elseif ( auth () -> user () -> role == 'admin' )
< a href = " { { url('/panel/index') }} " >
@ endif
2022-12-04 23:15:40 +01:00
@ if ( file_exists ( base_path ( " littlelink/images/ " ) . findFile ( 'avatar' )))
< img class = " img logo " src = " { { asset('littlelink/images/'.findFile('avatar')) }} " style = " width:150px;height:auto; " >
2022-02-20 14:09:08 +01:00
@ else
2022-02-21 20:22:21 +01:00
< img class = " img logo " type = " image/svg+xml " src = " { { asset('littlelink/images/logo.svg') }} " style = " width:100px; " >
2022-02-20 14:09:08 +01:00
@ endif
2021-04-16 01:00:00 +02:00
</ a >
2022-12-15 22:53:19 +01:00
< ul class = " list-unstyled " >
2021-04-16 01:00:00 +02:00
@ if ( auth () -> user () -> role == 'admin' )
2022-12-14 12:07:46 +01:00
< li class = " active " >
< a href = " #adminSubmenu " data - toggle = " collapse " @ if ( Request :: segment ( 1 ) == 'panel' ) class = " dropdown-toggle " aria - expanded = " true " @ else class = " dropdown-toggle collapsed " aria - expanded = " false " @ endif > Admin </ a >
< ul class = " collapse list-unstyled @if(Request::segment(1) == 'panel' ) show @endif " id = " adminSubmenu " >
< li class = " { { Request::segment(2) == 'config' ? 'active' : ''}} " >
< a href = " { { url('panel/config') }} " > Config </ a >
</ li >
2022-12-13 11:56:37 +01:00
< li class = " { { Request::segment(2) == 'users' ? 'active' : ''}} " >
2022-12-14 12:07:46 +01:00
< a href = " { { url('panel/users/all') }} " > Manage Users </ a >
</ li >
< li class = " { { Request::segment(2) == 'pages' ? 'active' : ''}} " >
< a href = " { { url('panel/pages') }} " > Footer Pages </ a >
</ li >
< li class = " { { Request::segment(2) == 'site' ? 'active' : ''}} " >
< a href = " { { url('panel/site') }} " > Home Page </ a >
</ li >
</ ul >
</ li >
@ endif
2022-12-13 11:56:37 +01:00
< li class = " { { Request::segment(2) == 'add-link' ? 'active' : ''}} " >
2022-11-08 16:11:59 +01:00
< a href = " { { url('/studio/add-link') }} " > Add Page Item </ a >
2022-12-13 11:56:37 +01:00
</ li >
< li class = " { { Request::segment(2) == 'links' ? 'active' : ''}} " >
2022-11-08 16:11:59 +01:00
< a href = " { { url('/studio/links') }} " > Your Links </ a >
2022-12-13 11:56:37 +01:00
</ li >
< li class = " { { Request::segment(2) == 'page' ? 'active' : ''}} " >
2022-11-08 16:11:59 +01:00
< a href = " { { url('/studio/page') }} " > Your Page </ a >
2022-12-13 11:56:37 +01:00
</ li >
< li class = " { { Request::segment(2) == 'theme' ? 'active' : ''}} " >
2022-11-08 16:11:59 +01:00
< a href = " { { url('/studio/theme') }} " > Your Themes </ a >
2022-12-13 11:56:37 +01:00
</ li >
< li class = " { { Request::segment(2) == 'profile' ? 'active' : ''}} " >
2022-11-08 16:11:59 +01:00
< a href = " { { url('/studio/profile') }} " > Account Settings </ a >
2022-12-13 11:56:37 +01:00
</ li >
2021-04-16 01:00:00 +02:00
< form action = " { { route('logout') }} " method = " post " >
< input type = " hidden " name = " _token " value = " { { csrf_token() }} " >
2021-07-06 10:48:50 +02:00
< button type = " submit " class = " buttonLogout " > Logout </ button >
2021-04-16 01:00:00 +02:00
</ form >
</ ul >
2022-03-17 17:33:37 +01:00
< div class = " footer " >
2022-03-21 23:11:49 +01:00
@ if ( env ( 'DISPLAY_FOOTER' ) === true )
2021-04-16 01:00:00 +02:00
< p >
2022-03-17 17:33:37 +01:00
Copyright & copy ; @ php echo date ( 'Y' ); @ endphp {{ config ( 'app.name' ) }} < i class = " icon-heart " aria - hidden = " true " ></ i > </ br >
2023-01-09 18:07:30 +01:00
@ php if ( env ( 'DISPLAY_FOOTER_HOME' ) != false and env ( 'DISPLAY_FOOTER_TERMS' ) != false and env ( 'DISPLAY_FOOTER_PRIVACY' ) != false and env ( 'DISPLAY_FOOTER_CONTACT' ) != false ){ $dot = " . " ; } else { $dot = "   " ;} @ endphp
@ if ( env ( 'DISPLAY_FOOTER_HOME' ) === true ) < a class = " footer-hover spacing " href = " @if(str_replace(' " ', "", EnvEditor::getKey(' HOME_FOOTER_LINK ')) === "" ){{ url(' ') }}@else{{ str_replace(' " ', " " , EnvEditor::getKey('HOME_FOOTER_LINK')) }}@endif " > {{ str_replace ( '"' , " " , EnvEditor :: getKey ( 'TITLE_FOOTER_HOME' ))}} </ a > { !! $dot !! } @ endif
2023-02-06 20:13:11 +01:00
@ if ( env ( 'DISPLAY_FOOTER_TERMS' ) === true ) < a class = " footer-hover spacing " href = " { { url('') }}/pages/ { { strtolower(env('TITLE_FOOTER_TERMS')) }} " > {{ str_replace ( '"' , " " , EnvEditor :: getKey ( 'TITLE_FOOTER_TERMS' ))}} </ a > { !! $dot !! } @ endif
@ if ( env ( 'DISPLAY_FOOTER_PRIVACY' ) === true ) < a class = " footer-hover spacing " href = " { { url('') }}/pages/ { { strtolower(env('TITLE_FOOTER_PRIVACY')) }} " > {{ str_replace ( '"' , " " , EnvEditor :: getKey ( 'TITLE_FOOTER_PRIVACY' ))}} </ a > { !! $dot !! } @ endif
@ if ( env ( 'DISPLAY_FOOTER_CONTACT' ) === true ) < a class = " footer-hover spacing " href = " { { url('') }}/pages/ { { strtolower(env('TITLE_FOOTER_CONTACT')) }} " > {{ str_replace ( '"' , " " , EnvEditor :: getKey ( 'TITLE_FOOTER_CONTACT' ))}} </ a >@ endif
2021-04-16 01:00:00 +02:00
</ p >
2022-03-21 23:11:49 +01:00
@ endif
@ if ( env ( 'DISPLAY_CREDIT' ) === true )
< a href = " https://littlelink-custom.com " target = " _blank " title = " Learn more " >
< section class = " hvr-grow fadein sections " >
< div class = " parent-footers " >
< img id = " footer_spin " class = " footer_spin image-footers1 " src = " { { asset('littlelink/images/just-gear.svg') }} " alt = " LittleLink Custom " ></ img >
< img class = " image-footers2 " src = " { { asset('littlelink/images/just-ll.svg') }} " alt = " LittleLink Custom " ></ img >
</ div >
2022-03-21 23:29:42 +01:00
< a href = " https://littlelink-custom.com " class = " text-footers " style = " color: #FFFFFF; font-weight: 700; font-size: 15px; " >& nbsp ; & nbsp ; Powered by </ a >< br >
< a href = " https://littlelink-custom.com " class = " text-footers " style = " color: #FFFFFF; font-weight: 700; font-size: 15px; " > LittleLink Custom </ a >
2022-03-21 23:11:49 +01:00
</ section >
</ a >
@ endif
2021-04-16 01:00:00 +02:00
</ div >
</ div >
</ nav >
<!-- Page Content -->
< div id = " content " class = " p-4 p-md-5 " >
< nav class = " navbar navbar-expand-lg navbar-light bg-light " >
< div class = " container-fluid " >
< button type = " button " id = " sidebarCollapse " class = " btn btn-primary " >
2022-02-20 15:20:57 +01:00
< i class = " bi bi-list " ></ i >
2021-04-16 01:00:00 +02:00
< span class = " sr-only " > Toggle Menu </ span >
</ button >
< button class = " btn btn-dark d-inline-block d-lg-none ml-auto " type = " button " data - toggle = " collapse " data - target = " #navbarSupportedContent " aria - controls = " navbarSupportedContent " aria - expanded = " false " aria - label = " Toggle navigation " >
2022-02-20 15:20:57 +01:00
< i class = " bi bi-list " ></ i >
2021-04-16 01:00:00 +02:00
</ button >
< div class = " collapse navbar-collapse " id = " navbarSupportedContent " >
< ul class = " nav navbar-nav ml-auto " >
< li class = " nav-item " >
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
< div class = " row " >
<! – – #### begin update detection #### – – >
2022-05-28 16:07:19 +02:00
@ if ( env ( 'NOTIFY_UPDATES' ) === 'old' )
2022-04-04 17:46:32 +02:00
<! – – Checks if file version . json exists to continue ( without this PHP will throw ErrorException ) – – >
@ if ( file_exists ( base_path ( " version.json " )))
< ? php // Requests newest version from server and sets it as variable
ini_set ( 'user_agent' , 'Mozilla/4.0 (compatible; MSIE 6.0)' );
2023-01-31 16:01:00 +01:00
$json = external_file_get_contents ( " https://api.github.com/repos/julianprieber/littlelink-custom/releases/latest " );
2022-04-04 17:46:32 +02:00
$myObj = json_decode ( $json );
2022-05-28 15:49:29 +02:00
$Vgit = $myObj -> tag_name ;
2022-04-04 17:46:32 +02:00
// Requests current version from the local version file and sets it as variable
2022-05-28 15:49:29 +02:00
$Vlocal = 'v' . file_get_contents ( base_path ( " version.json " ));
2022-04-04 17:46:32 +02:00
?>
<! – – If user has role admin AND newest GitHub release version is higher than the local one an update notice will be displayed – – >
@ if ( auth () -> user () -> role == 'admin' and $Vgit > $Vlocal )
2022-05-25 23:19:29 +02:00
< a style = " color:#007bff " class = " nav-link " href = " { { url('update') }} " title = " Click here to learn more about how to update " > An update is available </ a >
2022-04-04 17:46:32 +02:00
@ endif
@ endif
2022-05-28 16:32:53 +02:00
@ elseif ( env ( 'NOTIFY_UPDATES' ) == 'true' or env ( 'NOTIFY_UPDATES' ) === 'major' or env ( 'NOTIFY_UPDATES' ) === 'all' )
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
<! – – Checks if file version . json exists AND if version . json exists on server to continue ( without this PHP will throw ErrorException ) – – >
2022-11-10 13:46:10 +01:00
@ if ( file_exists ( base_path ( " version.json " )))
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
< ? php // Requests newest version from server and sets it as variable
2022-11-10 13:46:10 +01:00
try {
2023-01-31 16:01:00 +01:00
$Vgit = external_file_get_contents ( " https://version.littlelink-custom.com/ " );
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
// Requests current version from the local version file and sets it as variable
2022-11-10 13:46:10 +01:00
$Vlocal = file_get_contents ( base_path ( " version.json " ));
}
catch ( Exception $e ){
$Vgit = " 0 " ;
$Vlocal = " 0 " ;
}
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
?>
<! – – If user has role admin AND newest GitHub release version is higher than the local one an update notice will be displayed – – >
@ if ( auth () -> user () -> role == 'admin' and $Vgit > $Vlocal )
2022-12-04 23:15:26 +01:00
< button style = " margin-left:5px; " class = " update-notification " >< a class = " update-link nav-link " href = " { { url('update') }} " title = " Click here to learn more about how to update " > Update </ a ></ button >
2022-11-08 16:11:59 +01:00
< ? php
$version1 = $Vlocal ;
$version2 = $Vgit ;
$version1_steps = explode ( " . " , $version1 );
$version2_steps = explode ( " . " , $version2 );
$count = 0 ;
// first digit
if ( $version2_steps [ 0 ] - $version1_steps [ 0 ] == 1 ) {
$count += 10 ;
}
// second digit
if ( $version2_steps [ 1 ] - $version1_steps [ 1 ] == 1 ) {
$count += 10 ;
}
for ( $i = 2 ; $i < count ( $version1_steps ); $i ++ ) {
$count += $version2_steps [ $i ] - $version1_steps [ $i ];
}
$count = abs ( $count );
?>
< style >
: root {
@ if ( $count < 4 )
-- bg - color : rgba ( 63 , 144 , 90 , 0.2 );
-- bo - color : rgb ( 63 , 144 , 90 );
@ elseif ( $count > 3 and $count < 6 )
-- bg - color : rgb ( 213 , 184 , 95 , 0.2 );
-- bo - color : rgba ( 213 , 183 , 95 );
@ else
-- bg - color : rgb ( 255 , 99 , 71 , 0.2 );
-- bo - color : rgb ( 255 , 99 , 71 );
@ endif
}
. update - link {
color : var ( -- bo - color ) ! important ;
}
. update - notification {
display : inline - block ;
margin - bottom : 0 ;
font - size : 14 px ;
height : 2.5 rem ;
line - height : 1 rem ;
width : auto ;
font - weight : 500 ;
text - align : center ;
white - space : nowrap ;
vertical - align : middle ;
cursor : pointer ;
- webkit - user - select : none ;
- moz - user - select : none ;
- ms - user - select : none ;
user - select : none ;
background - color : var ( -- bg - color );
border : 1 px solid var ( -- bo - color );
border - radius : 25 px ;
}
</ style >
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
@ endif
@ endif
2022-03-20 17:15:16 +01:00
@ endif
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
<! – – #### end update detection #### – – >
2022-04-20 18:18:41 +02:00
@ if ( auth () -> user () -> role == 'admin' and $compromised === " true " )
2022-11-19 12:21:44 +01:00
< a style = " color:tomato; " class = " nav-link " href = " { { url('panel/config#5') }} " title = " Your security is at risk. Some files can be accessed by everyone. Immediate action is required! Click this message to learn more. " > Your security is at risk !</ a >
2022-04-20 18:18:41 +02:00
@ endif
2022-12-04 20:30:49 +01:00
@ if ( env ( 'JOIN_BETA' ) === true and auth () -> user () -> role == 'admin' )
2022-12-04 23:07:21 +01:00
< style >. beta - mobile { display : none ; margin : 0 auto ; font - size : 200 % ; padding - left : 15 px ; margin - right : - 15 px ; position : relative ; bottom : 3 px ;} @ media only screen and ( max - width : 1300 px ) { . beta { display : none ;} . beta - mobile { display : inline - block ! important ;}} </ style >
2023-01-31 16:01:00 +01:00
< a style = " color:tomato; " class = " nav-link beta " href = " { { url('update') }} " > You are in BETA mode ! < img src = " https://img.llc.ovh/static/v1?label=installed:&message=<?php if(file_exists(base_path( " vbeta . json " ))) { echo file_get_contents(base_path( " vbeta . json " ));} else { echo " none " ;} ?>&color=FFFFFF " > < img src = " https://img.llc.ovh/static/v1?label=server:&message=<?php echo external_file_get_contents( " https :// update . littlelink - custom . com / beta / vbeta . json " ); ?>&color=FFFFFF " ></ a >
2022-12-04 23:07:21 +01:00
< a style = " color:tomato; " class = " beta-mobile " href = " { { url('update') }} " >< i class = " bi bi-file-code-fill " ></ i ></ a >
2022-06-01 18:36:53 +02:00
@ endif
2022-11-23 22:59:05 +01:00
@ if ( Route :: currentRouteName () === " showConfig " ) < style > #toggle-switch{margin-left: -24px !important;}</style>@endif
2022-06-09 22:26:35 +02:00
@ if ( config ( 'advanced-config.theme' ) == 'light' and $color_scheme_override != 'dark' )
2022-06-08 17:52:21 +02:00
< div id = " myBtn " class = " toggle " >< span > 🌙 </ span >< input type = " checkbox " id = " toggle-switch " checked />< label for = " toggle-switch " ></ label >< span > ☀️ </ span ></ div >
< script > function ColorOverrride (){ document . cookie = " color_scheme_override=dark; path=/ " , location . reload ()} var btn = document . getElementById ( " myBtn " ); btn . addEventListener ( " click " , ColorOverrride ); </ script >
@ elseif ( $color_scheme_override == 'dark' or ( $color_scheme == 'dark' and $color_scheme_override != 'dark' and $color_scheme_override != 'light' ))
2022-05-13 13:03:10 +02:00
< div id = " myBtn " class = " toggle " >< span > 🌙 </ span >< input type = " checkbox " id = " toggle-switch " />< label for = " toggle-switch " ></ label >< span > ☀️ </ span ></ div >
< script > function ColorOverrride (){ document . cookie = " color_scheme_override=light; path=/ " , location . reload ()} var btn = document . getElementById ( " myBtn " ); btn . addEventListener ( " click " , ColorOverrride ); </ script >
@ elseif ( $color_scheme_override == 'light' or ( $color_scheme == 'light' and $color_scheme_override != 'dark' and $color_scheme_override != 'light' ))
< div id = " myBtn " class = " toggle " >< span > 🌙 </ span >< input type = " checkbox " id = " toggle-switch " checked />< label for = " toggle-switch " ></ label >< span > ☀️ </ span ></ div >
< script > function ColorOverrride (){ document . cookie = " color_scheme_override=dark; path=/ " , location . reload ()} var btn = document . getElementById ( " myBtn " ); btn . addEventListener ( " click " , ColorOverrride ); </ script >
@ endif
2022-11-08 16:11:59 +01:00
< div class = " segmented-button " >
< a style = " font-weight: 130% " href = " { { url('') }}/@<?= Auth::user()->littlelink_name ?> " target = " _blank " class = " btn-seg " > View Page </ a >
< a onclick = " copyText(' { { url('') }}/@<?= Auth::user()->littlelink_name ?>') " style = " color:#fff " class = " btn-seg dropdown-button " >< i class = " btn-seg-ico bi bi-share-fill " ></ i ></ a >
</ div >
< div id = 'dropdown1' class = 'dropdown-content' >
</ div >
< script >
function copyText ( text ) {
var dummy = document . createElement ( " textarea " );
document . body . appendChild ( dummy );
dummy . value = text ;
dummy . select ();
document . execCommand ( " copy " );
document . body . removeChild ( dummy );
alert ( 'URL has been copied to your clipboard!' )
}
</ script >
Added automatic update detection
This displays an update notice if a new version of LittleLink Custom has been released.
This one is definitely a messy one. Everything I added is commented, but I'm going to try explaining it here one more time.
General outcome:
• This feature checks the local version against the newest version stored on a separate server.
Error prevention:
• I used 'file_get_contents' to get the version number from a JSON file. If 'file_get_contents' cant find the file, PHP will throw an Error Exception.
• To prevent this, I put the update section in an if-statement that only applies if the following conditions are met.
Check if files exist:
• To test whether the file on the server exists (remember, if the server can't be reached, you will get an Error Exception) I used a function that checks if the URL to the file on the server successfully returns a '200 OK' response (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200).
• If this condition is met, it sets the variable '$ServerExists' to true, if not to false.
• Now, the previous mentioned if-statement simply checks if the local file exists and the '$ServerExists' variable equals 'true' to proceed.
Get version number:
• If all previous conditions are met, two variables get defined via 'file_get_contents' '$Vgit' and '$Vlocal'.
• Both the file on the server and the local file simply contain the version number.
• The variable '$Vgit' is the newest version number retrieved from the server.
• The variable '$Vlocal' is the local version number.
Display update notice:
• To finally display the version number (added with HTML) one last check via an if-statement is performed. This simply checks if the current user is an admin AND if the version retrieved from the server is higher than the local one.
• If both conditions are met, the notice is displayed.
In addition, I should mention that I put the existing 'Watch Page' link as well as the update notice in a div with the class 'row' to display both links next to another instead of them being stacked.
2022-02-23 13:38:15 +01:00
</ div >
2021-04-16 01:00:00 +02:00
</ li >
</ ul >
2022-03-20 17:15:16 +01:00
</ div
2021-04-16 01:00:00 +02:00
</ div >
</ nav >
2022-06-28 12:13:39 +02:00
2022-06-28 18:10:39 +02:00
@ if ( config ( 'advanced-config.disable_default_password_notice' ) != 'true' )
2022-06-28 12:13:39 +02:00
{{ -- Displays a warning message if default password is still set -- }}
2022-07-05 22:35:20 +02:00
@ php
$littlelink_current = Auth :: user () -> id ;
$userdbs = DB :: table ( 'users' ) -> where ( 'id' , $littlelink_current ) -> get ();
@ endphp
2022-06-28 12:13:39 +02:00
@ foreach ( $userdbs as $userdb )
@ if ( Hash :: check ( '12345678' , $userdb -> password ))
2022-11-08 16:11:59 +01:00
< nav class = " shadow navbar navbar-expand-lg navbar-light bg-light " >
2022-06-28 12:13:39 +02:00
< div class = " container-fluid " >
< a style = " background-color:tomato;color:#fff;border-radius:5px; " class = " nav-link " href = " { { url('/studio/profile') }} " target = " " >< i class = " bi bi-exclamation-circle-fill " ></ i > < strong > You are still using the default password ! Click here to change this .</ strong ></ a >
</ div >
</ nav >
@ endif
@ endforeach
2022-06-28 18:10:39 +02:00
@ endif
2022-06-28 12:13:39 +02:00
2022-03-20 17:15:16 +01:00
<! – – #### begin event detection #### – – >
2022-11-10 13:46:10 +01:00
@ if ( env ( 'NOTIFY_EVENTS' ) === true )
2022-03-20 17:15:16 +01:00
< ? php
2022-11-10 13:46:10 +01:00
try {
2023-01-31 16:01:00 +01:00
$GetEventJson = external_file_get_contents ( " https://event.littlelink-custom.com/ " );
2022-03-20 17:15:16 +01:00
$EventJson = json_decode ( $GetEventJson , true );
2022-03-20 23:43:27 +01:00
if ( isset ( $_COOKIE [ 'HideEvent' ]) == NULL ) {
setcookie ( " HideEvent " , $_COOKIE [ 'ID' ] = " 0 " , time () + 60 * 60 * 24 * 5 , " / " );
header ( 'Location: ' . url ( '/panel/index' ));
exit ();
}
2022-03-20 17:15:16 +01:00
?>
@ if ( auth () -> user () -> role == 'admin' and strtotime ( date ( " d-m-Y " )) < strtotime ( $EventJson [ 'enddate' ]))
2022-03-20 23:43:27 +01:00
@ if ( isset ( $_COOKIE [ 'HideEvent' ]) and $_COOKIE [ 'HideEvent' ] != $EventJson [ 'id' ])
2022-03-20 17:15:16 +01:00
< nav class = " navbar navbar-expand-lg navbar-light bg-light " >
< div class = " container-fluid " >
2022-03-20 23:43:27 +01:00
< a class = " nav-link " href = " { { $EventJson['link'] }} " target = " { { $EventJson['target'] }} " >< mark onMouseOver = " { { $EventJson['hoveron'] }} " onMouseOut = " { { $EventJson['hoveroff'] }} " style = " { { $EventJson['style'] }} " title = " { { $EventJson['hover'] }} " > {{ $EventJson [ 'title' ] }} </ mark ></ a > < a href = " ?hide_event " title = " Click to hide this message " > ❌ </ a >
2022-03-21 09:13:10 +01:00
< ? php
if ( strpos ( $_SERVER [ 'REQUEST_URI' ], " hide_event " ) !== false ){
setcookie ( " HideEvent " , $_COOKIE [ 'ID' ] = $EventJson [ 'id' ], time () + 60 * 60 * 24 * 5 , " / " );
header ( 'Location: ' . url ( '/panel/index' ));
exit ();
}
?>
2022-03-20 17:15:16 +01:00
</ div >
</ nav >
@ endif
@ endif
2022-03-21 15:37:55 +01:00
@ if ( env ( 'NOTIFY_EVENTS' ) === false and auth () -> user () -> role == 'admin' )
2022-03-20 17:15:16 +01:00
< a href = " { { url('env-editor') }} " id = " notify " style = " color:#F75D59; font-weight:600; font-size:120%; background-color:#F5FFFA; " ></ a >
< script >
if ( localStorage . getItem ( " firstTime " ) == null ){
document . getElementById ( " notify " ) . innerHTML = " ➡️ Click here to get notified about important events or security vulnerabilities " ;
localStorage . setItem ( " firstTime " , " done " );
}
</ script >
@ endif
2022-11-10 13:46:10 +01:00
< ? php } catch ( Exception $e ){} ?>
2022-03-20 23:43:27 +01:00
@ endif
2022-03-20 17:15:16 +01:00
<! – – #### end event detection #### – – >
2021-04-16 01:00:00 +02:00
@ yield ( 'content' )
</ div >
</ div >
< script src = " { { asset('/studio/js/jquery.min.js') }} " ></ script >
< script src = " { { asset('/studio/js/popper.js') }} " ></ script >
< script src = " { { asset('/studio/js/bootstrap.min.js') }} " ></ script >
2022-08-14 21:05:26 +02:00
< script src = " { { asset('/studio/js/Sortable.min.js') }} " ></ script >
< script src = " { { asset('/studio/js/jquery-block-ui.js') }} " ></ script >
2021-04-16 01:00:00 +02:00
< script src = " { { asset('/studio/js/main-dashboard.js') }} " ></ script >
2022-05-03 23:27:37 +02:00
2022-05-07 16:23:25 +02:00
@ stack ( 'sidebar-scripts' )
2021-04-16 01:00:00 +02:00
</ body >
2022-03-20 23:43:27 +01:00
</ html >