<?php
// URL::forceRootUrl("http://doxbin.com");
// URL::forceScheme("https");
$routes = function(){
    Route::get('/', 'PasteController@main');
    Route::get('/dataleak', 'PasteController@dataleakshow');
    // Route::get('/meowbahh', 'CustomController@meowbahh');
    Route::get('/meowbah', 'CustomController@meowbahh');
    Route::get('/yuri', 'CustomController@yuri');
	Route::get('/jahzuko', 'CustomController@jahzuko');
    Route::get('/paste/{link}', 'CustomController@iplogger');

    Route::post('/', 'AdminController@action');


    Route::get('/hoa', 'PasteController@hoa');
    Route::any('/privacy', 'PasteController@privacy');
    Route::get('/tos', 'PasteController@tos');
    Route::get('/history', 'PasteController@history');


    // 2fa
    Route::any('/verify/new', 'TwoFactorController@verify_new');
    Route::any('/verify', 'TwoFactorController@verify');
    Route::any('/account/disable-2fa', 'TwoFactorController@disable2FA');
    Route::any('/account/enable-2fa', 'TwoFactorController@enable2FA');
    // ---


    // upgrades
    Route::any('/upgrade', 'UpgradeController@upgrade');
    Route::any('/btcpay/webhook', 'UpgradeController@webhook');
    Route::any('/api/purchase', 'UpgradeController@create_invoice')->middleware('captcha');
    // --------

    Route::get('/upload', 'PasteController@index');

    Route::post('/upload', 'PasteController@submit')->middleware(['throttle:5,1', 'captcha']);
    Route::get('/upload/{link}', 'PasteController@view')->where('link', '[a-zA-Z0-9]+');
    Route::post('/upload/{link}', 'PasteController@view')->where('link', '[a-zA-Z0-9]+');
    Route::get('/upload/{link}/raw', 'PasteController@raw')->where('link', '[a-zA-Z0-9]+');
    // Route::get('/upload/{link}/hide', 'PasteController@hide')->where('link', '[a-zA-Z0-9]+');
    Route::post('/upload/{link}/manage', 'PasteController@manage')->where('link', '[a-zA-Z0-9]+');
    Route::post('/upload/{link}/password-verify', 'PasteController@verify_password')->where('link', '[a-zA-Z0-9]+')->middleware('captcha');;


    Route::post('/comment', 'PasteController@comment')->middleware(['throttle:6,1', 'captcha']);
    Route::get('/loadcomments', 'PasteController@load_more_comments')->middleware('throttle:60,1');


    Route::any('/search', 'PasteController@search');
    Route::any('/search/{search}', 'PasteController@search')->where('search', '[a-zA-Z0-9 \_]+');

    Route::get('/login', 'UserController@login');
    Route::post('/login', 'UserController@submitlogin')->middleware('captcha');
    Route::get('/register', 'UserController@register');
    Route::post('/register', 'UserController@submitregister')->middleware('captcha');



    Route::get('/edit/{paste}', 'PasteController@edit')->where('paste', '[a-zA-Z0-9]+');
    Route::post('/edit/{paste}', 'PasteController@editsubmit')->where('paste', '[a-zA-Z0-9]+')->middleware('captcha');

    Route::get('/user/{username}', 'UserController@profile')->where('username', '[a-zA-Z0-9_]+');
    Route::get('/user/{username}/pastes', 'UserController@pastes')->where('username', '[a-zA-Z0-9_]+');
    Route::get('/user/{username}/followers', 'UserController@followers')->where('username', '[a-zA-Z0-9_]+');
    Route::get('/user/{username}/following', 'UserController@following')->where('username', '[a-zA-Z0-9_]+');
    Route::any('/user/{username}/comment', 'UserController@comment')->middleware('captcha');
    Route::any('/logout', 'UserController@logout');
    Route::any('/settings', 'UserController@settings');
    Route::get('/password-reset/{token}', 'UserController@passwordreset')->where('token', '[a-zA-Z0-9]+');
    Route::post('/password-reset/{token}', 'UserController@passwordreset')->where('token', '[a-zA-Z0-9]+');

    Route::get('/users', 'UserController@users');
    Route::get('/users/search/{query}', 'UserController@search')->where('query', '[a-zA-Z0-9_]+');
    Route::get('/notifications', 'UserController@notifications');

    Route::any('/settings/change-color', 'UpgradeController@change_color')->middleware('throttle:20,1');

    Route::prefix('api')->group(function () {
        Route::any('clear-notifications', 'ApiController@clear_notifications')->middleware('throttle:30,1');
        Route::any('paste/cancel-edit-request', 'ApiController@cancel_edit_request');
        Route::any('flag-paste', 'ApiController@flag');
        Route::any('rate-paste', 'PasteController@rate')->middleware('throttle:10,1');
        Route::any('follow-user', 'ApiController@follow')->middleware('throttle:30,1');
        Route::any('pastes/visibility', 'ApiController@change_paste_visibility')->middleware('throttle:5,1');
        Route::any('next-paste', 'PasteController@next_paste')->middleware('throttle:35,1'); // Staff have been having issues with such a low limit 
        Route::any('previous-paste', 'PasteController@previous_paste')->middleware('throttle:35,1'); // Same reason as above for change
    });


    Route::get('/user/{username}/edit', 'AdminController@edituser');
    Route::post('/user/{username}/edit', 'AdminController@edituser');

    Route::prefix('admin')->group(function () {
        Route::get('', 'AdminController@main_admin');
        Route::get('users', 'AdminController@users');
        Route::get('flags', 'AdminController@flags');
        Route::get('edits', 'AdminController@edits');
        Route::get('blacklist', 'AdminController@blacklist');
        Route::get('edits/{link}', 'AdminController@editshow')->where('link', '[a-zA-Z0-9]+');
        Route::get('flag/{link}', 'AdminController@showflag')->where('link', '[a-zA-Z0-9]+');
        Route::get('/logs/orders', 'AdminController@orderlogs');
        Route::get('/logs/flags', 'AdminController@flaglogs');
        Route::get('/logs/usernames', 'AdminController@usernamelogs');
        Route::get('/logs/staff', 'AdminController@stafflogs');
        Route::get('/logs/errors', 'AdminController@errorlogs');
		Route::get('/logs/hiddenlogs', 'AdminController@hiddenlogs');
		Route::get('/spam-system', 'AdminController@spamsystem');
    });

    Route::prefix('admin/api')->group(function () {
        Route::any('switch-maintenance', 'AdminApiController@switch_maintenance');
        Route::any('blacklist', 'AdminApiController@blacklist');
        Route::any('edits', 'AdminApiController@edits');
        Route::any('create-role', 'AdminApiController@addNewRank');
        Route::any('delete-role', 'AdminApiController@delRank');
        Route::any('delete-comment', 'AdminApiController@hide_comment')->middleware('throttle:30,1');
        Route::any('delete-profile-comment', 'AdminApiController@hide_profile_comment')->middleware('throttle:30,1');
        Route::any('add-redirect', 'AdminApiController@add_redirect');
        Route::any('remove-redirect', 'AdminApiController@remove_redirect');
        Route::any('flag-action', 'AdminApiController@flag_action');
        Route::any('ban', 'AdminApiController@blacklist_fingerprint');
        Route::any('add-to-blacklist', 'AdminApiController@add_to_blacklist');
        Route::any('flagger-add', 'AdminApiController@add_to_flagger');
        Route::any('flagger-remove', 'AdminApiController@remove_from_flagger');

        Route::any('staff-comment', 'AdminApiController@staff_note')->middleware('throttle:10,1');
        Route::any('count', 'AdminApiController@count');
        Route::any('announcements', 'AdminApiController@announcements');
        Route::any('update-views', 'AdminApiController@change_views')->middleware('throttle:3,1');
        Route::any('change-owner', 'AdminApiController@change_owner')->middleware('throttle:10,1');
        Route::any('edit-ban', 'AdminApiController@editBan')->middleware('throttle:10,1');
        Route::any('blacklist/delete', 'AdminApiController@remove_from_blacklist')->middleware('throttle:10,1');
        Route::any('paste/hide', 'PasteController@hide');
        Route::any('paste/pin', 'PasteController@pin');

        Route::any('/clear-error-log', 'AdminApiController@clearerrorlogs');
        Route::any('/download-error-log', 'AdminApiController@downloaderrorlogs');
		
        Route::any('accept-all-flags', 'AdminApiController@acceptAllFlags');
		
		Route::any('switch-paste-detection', 'AdminApiController@switch_paste_detection');
        Route::any('switch-no-anon', 'AdminApiController@switch_no_anon');
        Route::any('switch-register-toggle', 'AdminApiController@switch_register_toggle');
    });
};

// Bind routes for all app domains.
foreach (appDomains() as $domain) {
    Route::group(['domain' => $domain], $routes);
}
