2021-04-16 01:00:00 +02:00
< ? php
use Illuminate\Support\Facades\Route ;
use App\Http\Controllers\AdminController ;
use App\Http\Controllers\UserController ;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application . These
| routes are loaded by the RouteServiceProvider within a group which
| contains the " web " middleware group . Now create something great !
|
*/
2022-08-08 14:09:11 +02:00
// Displays Maintenance Mode page
if ( env ( 'MAINTENANCE_MODE' ) == 'true' or file_exists ( base_path ( " storage/MAINTENANCE " ))){
Route :: get ( '/{any}' , function () {
return view ( 'maintenance' );
}) -> where ( 'any' , '.*' );
} else {
2022-06-14 23:45:11 +02:00
// Prevents section below from being run by 'composer update'
if ( file_exists ( base_path ( 'storage/app/ISINSTALLED' ))){
2022-06-07 23:15:39 +02:00
// generates new APP KEY if no one is set
if ( EnvEditor :: getKey ( 'APP_KEY' ) == '' ){ Artisan :: call ( 'key:generate' );}
2022-06-08 18:51:14 +02:00
// copies template meta config if none is present
2022-06-09 22:35:59 +02:00
if ( ! file_exists ( base_path ( " config/advanced-config.php " ))){ copy ( base_path ( 'storage/templates/advanced-config.php' ), base_path ( 'config/advanced-config.php' ));}
2022-06-14 23:45:11 +02:00
}
2022-06-08 18:51:14 +02:00
2022-03-24 14:44:33 +01:00
//Changes the homepage to a LittleLink Custom profile if set in the config
2022-06-09 22:51:16 +02:00
if ( config ( 'advanced-config.custom_home_url' ) != '' ) {
$custom_home_page_url = config ( 'advanced-config.custom_home_url' );
2022-06-09 16:45:05 +02:00
} else {
$custom_home_page_url = " /home " ;
}
2022-03-24 14:44:33 +01:00
if ( env ( 'HOME_URL' ) != '' ) {
Route :: get ( '/' , [ UserController :: class , 'littlelinkhome' ]) -> name ( 'littlelink' );
2022-06-09 22:51:16 +02:00
if ( config ( 'advanced-config.disable_home_page' ) == 'redirect' ) {
Route :: get ( $custom_home_page_url , function () { return redirect ( config ( 'advanced-config.redirect_home_page' ));});
} elseif ( config ( 'advanced-config.disable_home_page' ) != 'true' ) {
2022-06-09 17:07:45 +02:00
Route :: get ( $custom_home_page_url , [ App\Http\Controllers\HomeController :: class , 'home' ]) -> name ( 'home' );}
2022-03-24 14:44:33 +01:00
} else {
2022-06-09 22:51:16 +02:00
if ( config ( 'advanced-config.disable_home_page' ) == 'redirect' ) {
Route :: get ( '/' , function () { return redirect ( config ( 'advanced-config.redirect_home_page' ));});
} elseif ( config ( 'advanced-config.disable_home_page' ) != 'true' ) {
2022-06-09 16:45:05 +02:00
Route :: get ( '/' , [ App\Http\Controllers\HomeController :: class , 'home' ]) -> name ( 'home' );}
2022-03-24 14:44:33 +01:00
}
2022-03-19 18:34:43 +01:00
//Redirect if no page URL is set
Route :: get ( '/@' , function () {
return redirect ( '/studio/no_page_name' );
});
2022-04-20 17:31:38 +02:00
//Show diagnose page
Route :: get ( '/panel/diagnose' , function () {
return view ( 'panel/diagnose' , []);
});
2021-04-16 01:00:00 +02:00
//Public route
2022-06-09 22:51:16 +02:00
$custom_prefix = config ( 'advanced-config.custom_url_prefix' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/going/{id?}/{link?}' , [ UserController :: class , 'clickNumber' ]) -> where ( 'link' , '.*' ) -> name ( 'clickNumber' );
2022-06-09 16:45:05 +02:00
Route :: get ( '/' . $custom_prefix . '{littlelink}' , [ UserController :: class , 'littlelink' ]) -> name ( 'littlelink' );
2021-07-06 10:56:05 +02:00
Route :: get ( '/@{littlelink}' , [ UserController :: class , 'littlelink' ]) -> name ( 'littlelink' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/pages/{name}' , [ AdminController :: class , 'pages' ]) -> name ( 'pages' );
2022-05-31 14:11:26 +02:00
Route :: get ( '/theme/@{littlelink}' , [ UserController :: class , 'theme' ]) -> name ( 'theme' );
2021-04-16 01:00:00 +02:00
//User route
Route :: group ([
2022-03-19 16:48:21 +01:00
'middleware' => env ( 'REGISTER_AUTH' ),
2021-04-16 01:00:00 +02:00
], function () {
2022-06-30 10:39:40 +02:00
if ( env ( 'FORCE_HTTPS' ) == 'true' ){ URL :: forceScheme ( 'https' );}
2022-08-05 17:29:49 +02:00
if ( isset ( $_COOKIE [ 'LinkCount' ])){ if ( $_COOKIE [ 'LinkCount' ] == '20' ){ $LinkPage = 'showLinks20' ;} elseif ( $_COOKIE [ 'LinkCount' ] == '30' ){ $LinkPage = 'showLinks30' ;} elseif ( $_COOKIE [ 'LinkCount' ] == 'all' ){ $LinkPage = 'showLinksAll' ;} else { $LinkPage = 'showLinks' ;}} else { $LinkPage = 'showLinks' ;} //Shows correct link number
2021-04-16 01:00:00 +02:00
Route :: get ( '/studio/index' , [ UserController :: class , 'index' ]) -> name ( 'studioIndex' );
Route :: get ( '/studio/add-link' , [ UserController :: class , 'showButtons' ]) -> name ( 'showButtons' );
Route :: post ( '/studio/add-link' , [ UserController :: class , 'addLink' ]) -> name ( 'addLink' );
2022-08-05 17:29:49 +02:00
Route :: get ( '/studio/links' , [ UserController :: class , $LinkPage ]) -> name ( $LinkPage );
Route :: get ( '/studio/links/10' , [ UserController :: class , 'showLinks' ]) -> name ( 'showLinks' );
Route :: get ( '/studio/links/20' , [ UserController :: class , 'showLinks20' ]) -> name ( 'showLinks20' );
Route :: get ( '/studio/links/30' , [ UserController :: class , 'showLinks30' ]) -> name ( 'showLinks30' );
Route :: get ( '/studio/links/all' , [ UserController :: class , 'showLinksAll' ]) -> name ( 'showLinksAll' );
2022-05-18 21:08:58 +02:00
Route :: get ( '/studio/theme' , [ UserController :: class , 'showTheme' ]) -> name ( 'showTheme' );
Route :: post ( '/studio/theme' , [ UserController :: class , 'editTheme' ]) -> name ( 'editTheme' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/deleteLink/{id}' , [ UserController :: class , 'deleteLink' ]) -> name ( 'deleteLink' );
Route :: get ( '/upLink/{up}/{id}' , [ UserController :: class , 'upLink' ]) -> name ( 'upLink' );
Route :: get ( '/studio/edit-link/{id}' , [ UserController :: class , 'showLink' ]) -> name ( 'showLink' );
Route :: post ( '/studio/edit-link/{id}' , [ UserController :: class , 'editLink' ]) -> name ( 'editLink' );
2022-04-27 20:55:19 +02:00
Route :: get ( '/studio/button-editor/{id}' , [ UserController :: class , 'showCSS' ]) -> name ( 'showCSS' );
Route :: post ( '/studio/button-editor/{id}' , [ UserController :: class , 'editCSS' ]) -> name ( 'editCSS' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/studio/page' , [ UserController :: class , 'showPage' ]) -> name ( 'showPage' );
2022-03-19 18:34:43 +01:00
Route :: get ( '/studio/no_page_name' , [ UserController :: class , 'showPage' ]) -> name ( 'showPage' );
2021-04-16 01:00:00 +02:00
Route :: post ( '/studio/page' , [ UserController :: class , 'editPage' ]) -> name ( 'editPage' );
Route :: get ( '/studio/profile' , [ UserController :: class , 'showProfile' ]) -> name ( 'showProfile' );
Route :: post ( '/studio/profile' , [ UserController :: class , 'editProfile' ]) -> name ( 'editProfile' );
});
//Admin route
Route :: group ([
'middleware' => 'admin' ,
], function () {
2022-06-30 10:39:40 +02:00
if ( env ( 'FORCE_HTTPS' ) == 'true' ){ URL :: forceScheme ( 'https' );}
2021-04-16 01:00:00 +02:00
Route :: get ( '/panel/index' , [ AdminController :: class , 'index' ]) -> name ( 'panelIndex' );
Route :: get ( '/panel/users/{type}' , [ AdminController :: class , 'users' ]) -> name ( 'showUsers' );
Route :: post ( '/panel/users/{name?}' , [ AdminController :: class , 'searchUser' ]) -> name ( 'searchUser' );
2022-05-30 15:02:27 +02:00
Route :: get ( '/panel/links/{id}' , [ AdminController :: class , 'showLinksUser' ]) -> name ( 'showLinksUser' );
Route :: get ( '/panel/deleteLink/{id}' , [ AdminController :: class , 'deleteLinkUser' ]) -> name ( 'deleteLinkUser' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/panel/users/block/{block}/{id}' , [ AdminController :: class , 'blockUser' ]) -> name ( 'blockUser' );
2022-07-11 14:51:24 +02:00
Route :: get ( '/panel/users/verify/-{verify}/{id}' , [ AdminController :: class , 'verifyUser' ]) -> name ( 'verifyUser' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/panel/edit-user/{id}' , [ AdminController :: class , 'showUser' ]) -> name ( 'showUser' );
Route :: post ( '/panel/edit-user/{id}' , [ AdminController :: class , 'editUser' ]) -> name ( 'editUser' );
2022-07-11 16:05:28 +02:00
Route :: get ( '/panel/new-user' , [ AdminController :: class , 'createNewUser' ]) -> name ( 'createNewUser' );
2022-07-11 16:25:26 +02:00
Route :: get ( '/panel/delete-user/{id}' , [ AdminController :: class , 'deleteUser' ]) -> name ( 'deleteUser' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/panel/pages' , [ AdminController :: class , 'showSitePage' ]) -> name ( 'showSitePage' );
Route :: post ( '/panel/pages' , [ AdminController :: class , 'editSitePage' ]) -> name ( 'editSitePage' );
2022-06-13 17:47:24 +02:00
Route :: get ( '/panel/advanced-config' , [ AdminController :: class , 'showFileEditor' ]) -> name ( 'showFileEditor' );
Route :: post ( '/panel/advanced-config' , [ AdminController :: class , 'editAC' ]) -> name ( 'editAC' );
Route :: get ( '/panel/env' , [ AdminController :: class , 'showFileEditor' ]) -> name ( 'showFileEditor' );
Route :: post ( '/panel/env' , [ AdminController :: class , 'editENV' ]) -> name ( 'editENV' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/panel/site' , [ AdminController :: class , 'showSite' ]) -> name ( 'showSite' );
Route :: post ( '/panel/site' , [ AdminController :: class , 'editSite' ]) -> name ( 'editSite' );
2022-03-28 12:20:47 +02:00
Route :: get ( '/panel/phpinfo' , [ AdminController :: class , 'phpinfo' ]) -> name ( 'phpinfo' );
2022-06-16 13:35:39 +02:00
Route :: get ( '/panel/backups' , [ AdminController :: class , 'showBackups' ]) -> name ( 'showBackups' );
2022-07-04 23:41:28 +02:00
Route :: post ( '/panel/theme' , [ AdminController :: class , 'deleteTheme' ]) -> name ( 'deleteTheme' );
Route :: get ( '/panel/theme' , [ AdminController :: class , 'showThemes' ]) -> name ( 'showThemes' );
2022-05-24 15:23:10 +02:00
Route :: get ( '/update' , function () { return view ( 'update' , []);});
2022-08-06 12:20:28 +02:00
Route :: get ( '/backup' , function () { return view ( 'backup' , []);});
2022-05-25 16:20:05 +02:00
Route :: get ( '/updating' , function ( \Codedge\Updater\UpdaterManager $updater ) {
// Check if new version is available
2022-05-30 11:39:39 +02:00
if ( $updater -> source () -> isNewVersionAvailable () and ( file_exists ( base_path ( " backups/CANUPDATE " )) or env ( 'SKIP_UPDATE_BACKUP' ) == true )) {
2022-05-25 16:20:05 +02:00
2022-08-08 14:09:11 +02:00
$tst = base_path ( 'storage/' );
file_put_contents ( $tst . 'MAINTENANCE' , '' );
2022-05-25 16:20:05 +02:00
// Get the current installed version
echo $updater -> source () -> getVersionInstalled ();
// Get the new version available
$versionAvailable = $updater -> source () -> getVersionAvailable ();
// Create a release
$release = $updater -> source () -> fetch ( $versionAvailable );
// Run the update process
$updater -> source () -> update ( $release );
2022-05-30 11:39:39 +02:00
if ( env ( 'SKIP_UPDATE_BACKUP' ) != true ) { unlink ( base_path ( " backups/CANUPDATE " ));}
2022-05-25 16:20:05 +02:00
2022-05-26 12:12:09 +02:00
echo " <meta http-equiv= \" refresh \" content= \" 0; " . url () -> current () . " /../update?finishing \" /> " ;
2022-05-25 16:20:05 +02:00
} else {
2022-05-26 12:12:09 +02:00
echo " <meta http-equiv= \" refresh \" content= \" 0; " . url () -> current () . " /../update?error \" /> " ;
2022-05-25 16:20:05 +02:00
}
});
2021-04-16 01:00:00 +02:00
});
2022-08-08 14:09:11 +02:00
}
2021-04-16 01:00:00 +02:00
require __DIR__ . '/auth.php' ;