⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
public_html
/
app
/
Http
/
Controllers
/
User
/
View File Name :
ForgotController.php
<?php namespace App\Http\Controllers\User; use App\Models\User; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use App\Models\Language; use Validator; use Mail; use Session; use DB; use App; use Str; class ForgotController extends Controller { public function __construct() { $this->middleware('web'); $this->middleware('setlang'); } public function showForgotForm() { return view('user.forgot'); } public function forgot(Request $request) { $request->validate([ 'email' => 'required' ]); // Validation Starts if (session()->has('lang')) { $currentLang = Language::where('code', session()->get('lang'))->first(); } else { $currentLang = Language::where('is_default', 1)->first(); } $input = $request->all(); $be = $currentLang->basic_extended; if (User::where('email', '=', $request->email)->count() > 0) { // user found $admin = User::where('email', '=', $request->email)->firstOrFail(); $autopass = Str::random(8); $input['password'] = bcrypt($autopass); $admin->update($input); $subject = __("Reset Password Request"); $msg = __("Your New Password is : ") . $autopass; $mail = new PHPMailer(true); $be->is_smtp = 0; if ($be->is_smtp == 1) { try { //Server settings $mail->isSMTP(); // Send using SMTP $mail->Host = $be->smtp_host; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $be->smtp_username; // SMTP username $mail->Password = $be->smtp_password; // SMTP password $mail->SMTPSecure = $be->encryption; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = $be->smtp_port; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above //Recipients $mail->setFrom($be->from_mail, $be->from_name); $mail->addAddress($request->email); // Add a recipient // Content $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $msg; $mail->send(); } catch (Exception $e) { } } else { try { //Recipients $mail->setFrom($be->from_mail, $be->from_name); $mail->addAddress($request->email); // Add a recipient // Content $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $msg; $mail->send(); } catch (Exception $e) { die($e->getMessage()); } } Session::flash('success', toastrMsg('Your_Password_Reseted_Successfully_Please_Check_your_email_for_new_Password.')); return back(); } else { // user not found Session::flash('err', 'No_Account_Found_With_This_Email.'); return back(); } } }