150 lines
6.5 KiB
PHP
150 lines
6.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Application Routes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here is where you can register all of the routes for an application.
|
|
| It's a breeze. Simply tell Laravel the URIs it should respond to
|
|
| and give it the controller to call when that URI is requested.
|
|
|
|
|
*/
|
|
|
|
Route::get('/', ['as' => 'home', function () {
|
|
Session::reflash();
|
|
// Dummy query to calculate rows
|
|
$video = \App\Models\Video::getRandom()->first();
|
|
|
|
return redirect($video->id);
|
|
|
|
}])->middleware('auth');
|
|
|
|
|
|
Route::post('filter', 'UserController@filter');
|
|
|
|
// /api
|
|
Route::group(['prefix' => 'api'], function() {
|
|
|
|
// /api/messages
|
|
Route::group(['prefix' => 'messages'], function() {
|
|
Route::get('', 'MessageController@index');
|
|
Route::post('read', 'MessageController@read');
|
|
Route::get('readall', 'MessageController@readall');
|
|
});
|
|
|
|
// /api/comments
|
|
Route::group(['prefix' => 'comments'], function() {
|
|
Route::get('/', 'CommentController@index');
|
|
Route::get('/{id}', 'CommentController@show')->where('id', '[0-9]+');
|
|
Route::post('{id}/edit', 'CommentController@update')->where('id', '[0-9]+');
|
|
Route::post('{id}/delete', 'CommentController@destroy')->where('id', '[0-9]+');
|
|
Route::post('{id}/restore', 'CommentController@restore')->where('id', '[0-9]+');
|
|
});
|
|
|
|
// /api/user
|
|
Route::group(['prefix' => 'user'], function() {
|
|
Route::post('{username}/ban', 'UserController@ban');
|
|
Route::get('/layout', 'UserController@setLayout');
|
|
});
|
|
|
|
// /api/video
|
|
Route::group(['prefix' => 'video'], function() {
|
|
Route::get('random', function() {
|
|
return \App\Models\Video::getRandom()->with(['category', 'user' => function($query) {
|
|
$query->addSelect('username', 'id');
|
|
}])->first();
|
|
});
|
|
|
|
|
|
Route::get('latest', function(\Illuminate\Http\Request $req) {
|
|
if ($req->has('filtered') && $req->get('filtered')) {
|
|
return \App\Models\Video::filtered()->orderBy('id', 'DESC')->first();
|
|
}
|
|
return \App\Models\Video::orderBy('id', 'DESC')->first();
|
|
});
|
|
|
|
Route::get('{id}', function($id) {
|
|
$res = \App\Models\Video::with(['category', 'user' => function($query) {
|
|
$query->addSelect('username', 'id');
|
|
}])->find($id);
|
|
if(!$res) {
|
|
return response(['message' => 'Video not found'], 404);
|
|
}
|
|
return $res;
|
|
})->where('id', '[0-9]+');
|
|
Route::post('{id}/delete', 'VideoController@destroy')->where('id', '[0-9]+');
|
|
Route::post('{id}/tag', 'VideoController@tag')->where('id', '[0-9]+');
|
|
Route::post('{id}/untag', 'VideoController@untag')->where('id', '[0-9]+');
|
|
Route::post('upload', 'VideoController@store')->middleware('auth.basic');
|
|
});
|
|
|
|
Route::post('upload', 'VideoController@store');
|
|
});
|
|
|
|
Route::group(["middleware" => "theme"], function() {
|
|
Route::post('report/{id}', 'ReportController@report'); // added by klee
|
|
Route::get('messages', 'MessageController@page');
|
|
Route::get('user/{username}', 'UserController@show')->middleware('auth');
|
|
Route::get('user/{username}/uploads', 'UserController@random')->middleware('auth');
|
|
Route::get('user/{username}/uploads/{id}', 'UserController@play')->where('id', '[0-9]+')->middleware('auth');
|
|
Route::get('user/{username}/favs', 'UserController@random_fav')->middleware('auth');
|
|
Route::get('user/{username}/favs/{id}', 'UserController@play_fav')->where('id', '[0-9]+')->middleware('auth');
|
|
Route::get('user/{username}/favs/index', 'UserController@show_favs')->middleware('auth');
|
|
Route::get('user/{username}/comments', 'UserController@show_comments')->middleware('auth');
|
|
Route::get('logout', 'UserController@logout');
|
|
Route::post('login', 'UserController@login');
|
|
Route::get('register', 'UserController@create');
|
|
Route::post('register', 'UserController@store');
|
|
Route::get('activate/{token}', 'UserController@activate');
|
|
Route::get('index', 'VideoController@index')->middleware('auth');
|
|
Route::post('index/{id}', 'VideoController@update')->middleware('auth');
|
|
Route::get('upload', 'VideoController@create')->middleware('auth');
|
|
Route::get('categories', 'CategoryController@index')->middleware('auth');
|
|
Route::get('webm', function() { return view('webm'); });
|
|
Route::get('about', function() { return view('about'); });
|
|
Route::get('irc', function() { return view('irc'); });
|
|
Route::get('rules', function() { return view('rules'); });
|
|
Route::get('contact', function() { return view('contact'); });
|
|
Route::get('privacy', function() { return view('privacy'); });
|
|
Route::get('teamspeak', function() { return view('teamspeak'); });
|
|
Route::get('news', function() { return view('news'); });
|
|
Route::get('0x40', function() { return view('0x40'); });
|
|
Route::get('stats', function() {
|
|
return view('stats', [
|
|
'user_count' => \App\Models\User::count(),
|
|
'upload_count' => \App\Models\Video::count(),
|
|
'comment_count' => \App\Models\Comment::count(),
|
|
//'fav_count' => \App\Models\UserFavorite::count(),
|
|
'latest_video' => \App\Models\Video::getLastId(),
|
|
'newest_user' => \App\Models\User::orderBy('id', 'DESC')->first()->username,
|
|
'dirsize' => shell_exec("(du -sh " . public_path() . "/b | cut -f1)")
|
|
]);
|
|
});
|
|
Route::get('/latest', function () {
|
|
Session::reflash();
|
|
|
|
$video = \App\Models\Video::orderBy('id', 'DESC')->first();
|
|
|
|
return redirect($video->id);
|
|
});
|
|
#Route::get('help', function() { return view('help'); });
|
|
#Route::get('announcement', function() { return view('announcement'); });
|
|
#Route::get('map', function() { return view('map'); });
|
|
#Route::get('donate', function() {
|
|
# return view('donate', [
|
|
# 'donations' => \App\Models\Donation::orderBy('timestamp', 'DESC')->get()
|
|
# ]);
|
|
#});
|
|
Route::get('transparency', function() { return view('transparency'); });
|
|
Route::get('login', function() { return view('login'); });
|
|
#Route::get('counter-strike', function() { return view('counter-strike'); });
|
|
|
|
Route::get('{id}', 'VideoController@show')->where('id', '[0-9]+');
|
|
Route::get('{id}/fav', 'VideoController@favorite')->where('id', '[0-9]+');
|
|
Route::post('{id}', 'CommentController@store')->where('id', '[0-9]+');
|
|
|
|
Route::get('{shortname}', 'CategoryController@showVideo')->where('shortname', '[a-z][a-z0-9]+')->middleware('auth');
|
|
Route::get('{shortname}/{id}', 'CategoryController@showVideo')->where(['shortname' => '[a-z][a-z0-9]+', 'id' => '[0-9]+'])->middleware('auth');
|
|
});
|