⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.23
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
/
Admin
/
View File Name :
ForgetController.php
<?php namespace App\Http\Controllers\Admin; use App\Models\Admin; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\Language; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; use Mail; use Session; class ForgetController extends Controller { public function mailForm() { return view('admin.forget'); } public function sendmail(Request $request) { // check whether the mail exists in database $request->validate([ 'email' => [ 'required', function ($attribute, $value, $fail) { $count = Admin::where('email', $value)->count(); if ($count == 0) { $fail("The email address doesn't exist"); } } ] ]); // change the password with newly created random password $pass = uniqid(); $admin = Admin::where('email', $request->email)->first(); $admin->password = bcrypt($pass); $admin->save(); // send the random (newly created) & username to the mail if (session()->has('lang')) { $currentLang = Language::where('code', session()->get('lang'))->first(); } else { $currentLang = Language::where('is_default', 1)->first(); } $be = $currentLang->basic_extended; $from = $be->from_mail; $to = $request->email; $subject = "Restore Password & Username"; $username = $admin->username; // Send Mail $mail = new PHPMailer(true); if ($be->is_smtp == 1) { try { $mail->isSMTP(); $mail->Host = $be->smtp_host; $mail->SMTPAuth = true; $mail->Username = $be->smtp_username; $mail->Password = $be->smtp_password; $mail->SMTPSecure = $be->encryption; $mail->Port = $be->smtp_port; //Recipients $mail->setFrom($from, $be->from_name); $mail->addAddress($to); // Content $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = "<h4>Hello $username,</h4><div><p><strong>Your current username:</strong> $username</p><p><strong>Your new password:</strong>$pass</p></div>"; $mail->send(); } catch (Exception $e) { } } else { try { //Recipients $mail->setFrom($from, $be->from_name); $mail->addAddress($to); // Content $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = "<h4>Hello $username,</h4><div><p><strong>Your current username:</strong> $username</p><p><strong>Your new password:</strong>$pass</p></div>"; $mail->send(); } catch (Exception $e) { } } Session::flash('success', __('New password & current username sent successfully via mail')); return back(); } }