forked from metin2/web
Added website Docker image, bumped PHP version, added mall authentication, added experimental patcher support, improved migrations, added teasers
This commit is contained in:
@ -3,8 +3,9 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
@ -22,8 +23,6 @@ class VerificationController extends Controller
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
@ -46,8 +45,8 @@ class VerificationController extends Controller
|
||||
/**
|
||||
* Show the email verification notice.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse|View
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function show(Request $request): View|RedirectResponse
|
||||
{
|
||||
@ -56,14 +55,73 @@ class VerificationController extends Controller
|
||||
: view('user/registration/verification-notice');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function verify(Request $request)
|
||||
{
|
||||
if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) {
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) {
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 204)
|
||||
: redirect($this->redirectPath());
|
||||
}
|
||||
|
||||
if ($request->user()->markEmailAsVerified()) {
|
||||
event(new Verified($request->user()));
|
||||
}
|
||||
|
||||
if ($response = $this->verified($request)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 204)
|
||||
: redirect($this->redirectPath())->with('verified', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has been verified.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return View
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
protected function verified(Request $request): View
|
||||
protected function verified(Request $request): mixed
|
||||
{
|
||||
return view('user/registration/registration-success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resend the email verification notification.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function resend(Request $request)
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 204)
|
||||
: redirect($this->redirectPath());
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse([], 202)
|
||||
: back()->with('resent', true);
|
||||
}
|
||||
}
|
||||
|
39
app/Http/Controllers/Mall/AuthController.php
Normal file
39
app/Http/Controllers/Mall/AuthController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mall;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Game\Player\Player;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function auth(Request $request): RedirectResponse
|
||||
{
|
||||
if (!$request->hasValidSignature()) {
|
||||
abort(401);
|
||||
}
|
||||
|
||||
// Validate the request data
|
||||
$validated = $request->validate([
|
||||
'pid' => 'required|exists:player.player,id',
|
||||
'sid' => 'required|int',
|
||||
]);
|
||||
|
||||
// Fetch the player's account
|
||||
$player = Player::findOrFail($validated['pid']);
|
||||
$account = $player->account;
|
||||
|
||||
// Authenticate user
|
||||
Auth::login($account);
|
||||
$request->session()->regenerate();
|
||||
|
||||
// Save user's IP address
|
||||
$account->ip = $request->ip();
|
||||
$account->saveOrFail();
|
||||
|
||||
return redirect(route('mall'));
|
||||
}
|
||||
}
|
77
app/Http/Controllers/Patch/PatchConfigController.php
Normal file
77
app/Http/Controllers/Patch/PatchConfigController.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Patch;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class PatchConfigController extends Controller
|
||||
{
|
||||
public function config(): \Illuminate\Http\Response
|
||||
{
|
||||
$patchMethod = 'TORRENT';
|
||||
$currentVersion = 'nightly-d19dc772db';
|
||||
$config = [];
|
||||
|
||||
if ($patchMethod == 'TORRENT') {
|
||||
$torrentConfig = [
|
||||
'port_range' => '6881~6891',
|
||||
'bandwidth_range' => '5:10:25:50:75:100:150:200:250:500:1000',
|
||||
'foreground_speed' => 0,
|
||||
'background_speed' => 10,
|
||||
'max_uploads_per_session' => 16,
|
||||
'max_connections_per_session' => 200,
|
||||
'max_uploads_per_torrent' => 4,
|
||||
'max_connections_per_torrent' => 50,
|
||||
'seeding_duration' => 21600,
|
||||
'web_seed_enable' => 1
|
||||
];
|
||||
$config = array_merge($config, $torrentConfig);
|
||||
}
|
||||
|
||||
$noticeConfig = [
|
||||
'notice_ver' => 1,
|
||||
'notice_url' => route('patch.notice'),
|
||||
'notice_width' => 680,
|
||||
'notice_height' => 500,
|
||||
];
|
||||
$config = array_merge($config, $noticeConfig);
|
||||
|
||||
$patcherConfig = [
|
||||
'cur_patcher_path' => 'TorrentPatch.exe',
|
||||
'new_patcher_path' => 'TorrentPatch.bin',
|
||||
'new_patcher_crc32' => '0x414EEA07',
|
||||
];
|
||||
$config = array_merge($config, $patcherConfig);
|
||||
|
||||
$clientConfig = [
|
||||
'run_path' => 'metin2client.bin',
|
||||
];
|
||||
$config = array_merge($config, $clientConfig);
|
||||
|
||||
// Build the XML file
|
||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><torrent_config/>');
|
||||
foreach ($config as $item => $value)
|
||||
$xml->addAttribute($item, $value);
|
||||
|
||||
if ($patchMethod == 'CRC') {
|
||||
$patchItem = $xml->addChild('foreground_patch');
|
||||
$patchItem->addAttribute('crcpatch_url', asset('patch-data/crc'));
|
||||
$patchItem->addAttribute('crcversion', $currentVersion);
|
||||
}
|
||||
elseif ($patchMethod == 'TORRENT') {
|
||||
$patchItem = $xml->addChild('foreground_patch');
|
||||
$patchItem->addAttribute('torrent_url', asset("patch-data/torrent/{$currentVersion}.torrent"));
|
||||
|
||||
if (!empty($torrentConfig['web_seed_enable']) && $torrentConfig['web_seed_enable'] == 1)
|
||||
$patchItem->addAttribute('webseed_url', asset("patch-data/torrent/"));
|
||||
}
|
||||
|
||||
$xmlData = $xml->asXML();
|
||||
|
||||
return response($xmlData, 200, [
|
||||
'Content-Type' => 'application/xml',
|
||||
'Content-Length' => strlen($xmlData),
|
||||
]);
|
||||
}
|
||||
}
|
19
app/Http/Controllers/Patch/PatchLandingController.php
Normal file
19
app/Http/Controllers/Patch/PatchLandingController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Patch;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PatchLandingController extends Controller
|
||||
{
|
||||
public function home(): View
|
||||
{
|
||||
return view('patch/home');
|
||||
}
|
||||
|
||||
public function notice(): View
|
||||
{
|
||||
return view('patch/notice');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user