2021-04-16 01:00:00 +02:00
< ? php
use Illuminate\Support\Facades\Route ;
use App\Http\Controllers\AdminController ;
use App\Http\Controllers\UserController ;
2022-11-08 16:11:59 +01:00
use App\Http\Controllers\Auth\SocialLoginController ;
use App\Http\Controllers\LinkTypeViewController ;
use App\Http\Controllers\PagesController ;
2022-11-23 15:52:33 +01:00
use App\Http\Controllers\InstallerController ;
2021-04-16 01:00:00 +02:00
/*
|--------------------------------------------------------------------------
| 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-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-11-23 15:52:33 +01:00
// generates new APP KEY if no one is set
2023-05-25 20:28:48 +02:00
if ( EnvEditor :: getKey ( 'APP_KEY' ) == '' ){ try { Artisan :: call ( 'key:generate' );} catch ( exception $e ) {}}
2022-11-23 15:52:33 +01:00
// copies template meta config if none is present
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-07 23:15:39 +02:00
2022-11-23 15:52:33 +01:00
// Installer
2023-02-13 13:41:30 +01:00
if ( file_exists ( base_path ( 'INSTALLING' )) or file_exists ( base_path ( 'INSTALLERLOCK' ))){
2022-11-23 15:52:33 +01:00
Route :: get ( '/' , [ InstallerController :: class , 'showInstaller' ]) -> name ( 'showInstaller' );
Route :: post ( '/create-admin' , [ InstallerController :: class , 'createAdmin' ]) -> name ( 'createAdmin' );
Route :: post ( '/db' , [ InstallerController :: class , 'db' ]) -> name ( 'db' );
Route :: post ( '/mysql' , [ InstallerController :: class , 'mysql' ]) -> name ( 'mysql' );
Route :: post ( '/options' , [ InstallerController :: class , 'options' ]) -> name ( 'options' );
Route :: get ( '/mysql-test' , [ InstallerController :: class , 'mysqlTest' ]) -> name ( 'mysqlTest' );
2023-01-19 21:12:08 +01:00
Route :: get ( '/skip' , function () { Artisan :: call ( 'db:seed' , [ '--class' => 'AdminSeeder' ,]); return redirect ( url ( '' ));});
2023-06-13 15:19:39 +02:00
Route :: post ( '/editConfigInstaller' , [ InstallerController :: class , 'editConfigInstaller' ]) -> name ( 'editConfigInstaller' );
2022-11-23 15:52:33 +01:00
2022-12-02 16:30:10 +01:00
Route :: get ( '{any}' , function () {
if ( ! DB :: table ( 'users' ) -> get () -> isEmpty ()){
2023-02-13 13:22:49 +01:00
if ( file_exists ( base_path ( " INSTALLING " )) and ! file_exists ( base_path ( 'INSTALLERLOCK' ))){ unlink ( base_path ( " INSTALLING " )); header ( " Refresh:0 " );}
2022-12-02 16:30:10 +01:00
} else {
return redirect ( url ( '' ));
}
}) -> where ( 'any' , '.*' );
2022-11-23 15:52:33 +01:00
} else {
2022-06-08 18:51:14 +02:00
2022-08-08 15:50:40 +02:00
// Disables routes if in Maintenance Mode
2023-05-26 00:58:13 +02:00
if ( env ( 'MAINTENANCE_MODE' ) != 'true' ){
2022-08-08 15:50:40 +02:00
2023-04-26 15:44:39 +02:00
//Changes the homepage to a LinkStack 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' ) != '' ) {
2023-03-21 20:24:23 +01:00
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' );
2022-11-25 16:50:11 +01:00
Route :: get ( '/going/{id?}' , [ UserController :: class , 'clickNumber' ]) -> where ( 'link' , '.*' ) -> name ( 'clickNumber' );
2023-10-18 23:45:43 +02:00
Route :: get ( '/info/{id?}' , [ AdminController :: class , 'redirectInfo' ]) -> name ( 'redirectInfo' );
2023-10-10 16:20:04 +02:00
if ( $custom_prefix != " " ){ 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' );
2023-06-24 15:39:16 +02:00
Route :: get ( '/pages/' . strtolower ( footer ( 'Terms' )), [ AdminController :: class , 'pagesTerms' ]) -> name ( 'pagesTerms' );
Route :: get ( '/pages/' . strtolower ( footer ( 'Privacy' )), [ AdminController :: class , 'pagesPrivacy' ]) -> name ( 'pagesPrivacy' );
Route :: get ( '/pages/' . strtolower ( footer ( 'Contact' )), [ AdminController :: class , 'pagesContact' ]) -> name ( 'pagesContact' );
2022-05-31 14:11:26 +02:00
Route :: get ( '/theme/@{littlelink}' , [ UserController :: class , 'theme' ]) -> name ( 'theme' );
2023-03-27 19:04:41 +02:00
Route :: get ( '/vcard/{id?}' , [ UserController :: class , 'vcard' ]) -> name ( 'vcard' );
2023-10-08 17:45:49 +02:00
Route :: get ( '/u/{id?}' , [ UserController :: class , 'userRedirect' ]) -> name ( 'userRedirect' );
2021-04-16 01:00:00 +02:00
2023-04-26 15:44:39 +02:00
Route :: get ( '/demo-page' , [ App\Http\Controllers\HomeController :: class , 'demo' ]) -> name ( 'demo' );
2023-10-10 16:20:04 +02:00
}
2023-07-22 13:16:28 +02:00
Route :: middleware ([ 'auth' , 'blocked' , 'impersonate' ]) -> group ( function () {
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-11-20 14:10:49 +01:00
if ( env ( 'FORCE_ROUTE_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
2023-04-26 15:44:39 +02:00
Route :: get ( '/dashboard' , [ AdminController :: class , 'index' ]) -> name ( 'panelIndex' );
Route :: get ( '/studio/index' , function (){ return redirect ( url ( 'dashboard' ));});
2022-11-08 16:11:59 +01:00
Route :: get ( '/studio/add-link' , [ UserController :: class , 'AddUpdateLink' ]) -> name ( 'showButtons' );
Route :: post ( '/studio/edit-link' , [ UserController :: class , 'saveLink' ]) -> name ( 'addLink' );
2023-11-02 22:02:20 +01:00
Route :: get ( '/studio/edit-link/{id}' , [ UserController :: class , 'AddUpdateLink' ]) -> name ( 'showLink' ) -> middleware ( 'link-id' );
2022-08-14 21:05:26 +02:00
Route :: post ( '/studio/sort-link' , [ UserController :: class , 'sortLinks' ]) -> name ( 'sortLinks' );
2022-08-05 17:29:49 +02:00
Route :: get ( '/studio/links' , [ UserController :: class , $LinkPage ]) -> name ( $LinkPage );
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' );
2023-11-02 22:02:20 +01:00
Route :: get ( '/deleteLink/{id}' , [ UserController :: class , 'deleteLink' ]) -> name ( 'deleteLink' ) -> middleware ( 'link-id' );
Route :: get ( '/upLink/{up}/{id}' , [ UserController :: class , 'upLink' ]) -> name ( 'upLink' ) -> middleware ( 'link-id' );
Route :: post ( '/studio/edit-link/{id}' , [ UserController :: class , 'editLink' ]) -> name ( 'editLink' ) -> middleware ( 'link-id' );
Route :: get ( '/studio/button-editor/{id}' , [ UserController :: class , 'showCSS' ]) -> name ( 'showCSS' ) -> middleware ( 'link-id' );
Route :: post ( '/studio/button-editor/{id}' , [ UserController :: class , 'editCSS' ]) -> name ( 'editCSS' ) -> middleware ( 'link-id' );
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' );
2023-02-13 16:22:11 +01:00
Route :: post ( '/studio/background' , [ UserController :: class , 'themeBackground' ]) -> name ( 'themeBackground' );
2023-02-13 18:40:18 +01:00
Route :: get ( '/studio/rem-background' , [ UserController :: class , 'removeBackground' ]) -> name ( 'removeBackground' );
2021-04-16 01:00:00 +02:00
Route :: get ( '/studio/profile' , [ UserController :: class , 'showProfile' ]) -> name ( 'showProfile' );
Route :: post ( '/studio/profile' , [ UserController :: class , 'editProfile' ]) -> name ( 'editProfile' );
2022-12-05 20:00:16 +01:00
Route :: post ( '/edit-icons' , [ UserController :: class , 'editIcons' ]) -> name ( 'editIcons' );
2022-12-06 16:21:33 +01:00
Route :: get ( '/clearIcon/{id}' , [ UserController :: class , 'clearIcon' ]) -> name ( 'clearIcon' );
2023-01-23 17:19:09 +01:00
Route :: get ( '/studio/page/delprofilepicture' , [ UserController :: class , 'delProfilePicture' ]) -> name ( 'delProfilePicture' );
2022-11-08 16:11:59 +01:00
Route :: get ( '/studio/delete-user/{id}' , [ UserController :: class , 'deleteUser' ]) -> name ( 'deleteUser' ) -> middleware ( 'verified' );
2023-07-13 18:22:50 +02:00
Route :: post ( '/auth-as' , [ AdminController :: class , 'authAs' ]) -> name ( 'authAs' );
2023-10-18 15:35:27 +02:00
// Catch all redirects
2023-11-02 22:14:25 +01:00
Route :: get ( '/admin/users/all' , fn () => redirect ( route ( 'showUsers' )));
2023-10-18 15:35:27 +02:00
Route :: get ( '/studio' , fn () => redirect ( url ( 'dashboard' )));
Route :: get ( '/studio/edit-link' , fn () => redirect ( url ( 'dashboard' )));
2023-03-08 17:46:40 +01:00
if ( env ( 'ALLOW_USER_EXPORT' ) != false ){
Route :: get ( '/export-links' , [ UserController :: class , 'exportLinks' ]) -> name ( 'exportLinks' );
Route :: get ( '/export-all' , [ UserController :: class , 'exportAll' ]) -> name ( 'exportAll' );
}
if ( env ( 'ALLOW_USER_IMPORT' ) != false ){
Route :: post ( '/import-data' , [ UserController :: class , 'importData' ]) -> name ( 'importData' );
}
2022-11-08 16:11:59 +01:00
Route :: get ( '/studio/linkparamform_part/{typeid}/{linkid}' , [ LinkTypeViewController :: class , 'getParamForm' ]) -> name ( 'linkparamform.part' );
2021-04-16 01:00:00 +02:00
});
2023-04-26 15:44:39 +02:00
});
2022-08-08 14:55:54 +02:00
}
2022-11-08 16:11:59 +01:00
//Social login route
Route :: get ( '/social-auth/{provider}/callback' , [ SocialLoginController :: class , 'providerCallback' ]);
Route :: get ( '/social-auth/{provider}' , [ SocialLoginController :: class , 'redirectToProvider' ]) -> name ( 'social.redirect' );
2023-07-22 13:16:28 +02:00
Route :: middleware ([ 'auth' , 'blocked' , 'impersonate' ]) -> group ( function () {
2021-04-16 01:00:00 +02:00
//Admin route
Route :: group ([
'middleware' => 'admin' ,
], function () {
2022-11-20 14:10:49 +01:00
if ( env ( 'FORCE_ROUTE_HTTPS' ) == 'true' ){ URL :: forceScheme ( 'https' );}
2023-04-26 15:44:39 +02:00
Route :: get ( '/panel/index' , function (){ return redirect ( url ( 'dashboard' ));});
2023-11-02 22:14:25 +01:00
Route :: get ( '/admin/users' , [ AdminController :: class , 'users' ]) -> name ( 'showUsers' );
2023-04-26 15:44:39 +02:00
Route :: get ( '/admin/links/{id}' , [ AdminController :: class , 'showLinksUser' ]) -> name ( 'showLinksUser' );
Route :: get ( '/admin/deleteLink/{id}' , [ AdminController :: class , 'deleteLinkUser' ]) -> name ( 'deleteLinkUser' );
Route :: get ( '/admin/users/block/{block}/{id}' , [ AdminController :: class , 'blockUser' ]) -> name ( 'blockUser' );
Route :: get ( '/admin/users/verify/-{verify}/{id}' , [ AdminController :: class , 'verifyUser' ]) -> name ( 'verifyUser' );
Route :: get ( '/admin/edit-user/{id}' , [ AdminController :: class , 'showUser' ]) -> name ( 'showUser' );
Route :: post ( '/admin/edit-user/{id}' , [ AdminController :: class , 'editUser' ]) -> name ( 'editUser' );
Route :: get ( '/admin/new-user' , [ AdminController :: class , 'createNewUser' ]) -> name ( 'createNewUser' ) -> middleware ( 'max.users' );
Route :: get ( '/admin/delete-user/{id}' , [ AdminController :: class , 'deleteUser' ]) -> name ( 'deleteUser' );
2023-10-24 01:04:17 +02:00
Route :: post ( '/admin/delete-table-user/{id}' , [ AdminController :: class , 'deleteTableUser' ]) -> name ( 'deleteTableUser' );
2023-04-26 15:44:39 +02:00
Route :: get ( '/admin/pages' , [ AdminController :: class , 'showSitePage' ]) -> name ( 'showSitePage' );
Route :: post ( '/admin/pages' , [ AdminController :: class , 'editSitePage' ]) -> name ( 'editSitePage' );
Route :: get ( '/admin/advanced-config' , [ AdminController :: class , 'showFileEditor' ]) -> name ( 'showFileEditor' );
Route :: post ( '/admin/advanced-config' , [ AdminController :: class , 'editAC' ]) -> name ( 'editAC' );
Route :: get ( '/admin/env' , [ AdminController :: class , 'showFileEditor' ]) -> name ( 'showFileEditor' );
Route :: post ( '/admin/env' , [ AdminController :: class , 'editENV' ]) -> name ( 'editENV' );
Route :: get ( '/admin/site' , [ AdminController :: class , 'showSite' ]) -> name ( 'showSite' );
Route :: post ( '/admin/site' , [ AdminController :: class , 'editSite' ]) -> name ( 'editSite' );
Route :: get ( '/admin/site/delavatar' , [ AdminController :: class , 'delAvatar' ]) -> name ( 'delAvatar' );
Route :: get ( '/admin/site/delfavicon' , [ AdminController :: class , 'delFavicon' ]) -> name ( 'delFavicon' );
Route :: get ( '/admin/phpinfo' , [ AdminController :: class , 'phpinfo' ]) -> name ( 'phpinfo' );
Route :: get ( '/admin/backups' , [ AdminController :: class , 'showBackups' ]) -> name ( 'showBackups' );
Route :: post ( '/admin/theme' , [ AdminController :: class , 'deleteTheme' ]) -> name ( 'deleteTheme' );
Route :: get ( '/admin/theme' , [ AdminController :: class , 'showThemes' ]) -> name ( 'showThemes' );
2022-11-08 16:11:59 +01:00
Route :: get ( '/update/theme' , [ AdminController :: class , 'updateThemes' ]) -> name ( 'updateThemes' );
2023-04-26 15:44:39 +02:00
Route :: get ( '/admin/config' , [ AdminController :: class , 'showConfig' ]) -> name ( 'showConfig' );
Route :: post ( '/admin/config' , [ AdminController :: class , 'editConfig' ]) -> name ( 'editConfig' );
2023-03-13 19:49:30 +01:00
Route :: get ( '/send-test-email' , [ AdminController :: class , 'SendTestMail' ]) -> name ( 'SendTestMail' );
2023-07-13 18:22:50 +02:00
Route :: get ( '/auth-as/{id}' , [ AdminController :: class , 'authAsID' ]) -> name ( 'authAsID' );
2023-03-07 19:43:05 +01:00
Route :: get ( '/theme-updater' , function () { return view ( 'studio/theme-updater' , []);});
2022-11-08 16:11:59 +01:00
Route :: get ( '/update' , function () { return view ( 'update' , []);});
Route :: get ( '/backup' , function () { return view ( 'backup' , []);});
Route :: group ([ 'namespace' => 'App\Http\Controllers\Admin' , 'prefix' => 'admin' , 'as' => 'admin' ], function () {
//Route::resource('/admin/linktype', LinkTypeController::class);
Route :: resources ([
'linktype' => LinkTypeController :: class
]);
});
2023-04-26 15:44:39 +02:00
2022-11-08 16:11:59 +01:00
Route :: get ( '/updating' , function ( \Codedge\Updater\UpdaterManager $updater ) {
2022-05-25 16:20:05 +02:00
// 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
2023-05-26 00:58:13 +02:00
EnvEditor :: editKey ( 'MAINTENANCE_MODE' , true );
2022-08-08 14:09:11 +02:00
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
}
});
2022-11-08 16:11:59 +01:00
}); // ENd Admin authenticated routes
2023-04-26 15:44:39 +02:00
});
2021-04-16 01:00:00 +02:00
2022-08-08 15:30:28 +02:00
// Displays Maintenance Mode page
2023-05-28 18:13:02 +02:00
if ( env ( 'MAINTENANCE_MODE' ) == 'true' ){
2022-08-08 15:30:28 +02:00
Route :: get ( '/{any}' , function () {
return view ( 'maintenance' );
}) -> where ( 'any' , '.*' );
}
2021-04-16 01:00:00 +02:00
require __DIR__ . '/auth.php' ;
2023-05-25 21:47:36 +02:00
if ( config ( 'advanced-config.custom_url_prefix' ) == " " ){
Route :: get ( '/{littlelink}' , [ UserController :: class , 'littlelink' ]) -> name ( 'littlelink' );
}