diff --git a/app/Livewire/Email.php b/app/Livewire/Email.php deleted file mode 100644 index 6b4f259..0000000 --- a/app/Livewire/Email.php +++ /dev/null @@ -1,13 +0,0 @@ -domains = config('app.settings.domains'); - $this->email = ZEmail::getEmail(); - $this->emails = ZEmail::getEmails(); - $this->validateDomainInEmail(); - } - - public function refreshMessages() - { - $this->emit('fetchMessages'); - } - - public function loadMsg($email) { - $this->email = $email; - if (count($this->emails) == 0) { - $this->emails = [$email]; - } - } - - public function syncEmail($email) { - $this->email = $email; - if (count($this->emails) == 0) { - $this->emails = [$email]; - } - } - - public function setDomain($domain) { - $this->domain = $domain; - } - - public function checkReCaptcha3($token, $action) { - $response = Http::post('https://www.google.com/recaptcha/api/siteverify?secret=' . config('app.settings.recaptcha3.secret_key') . '&response=' . $token); - $data = $response->json(); - if ($data['success']) { - $captcha = $data['score']; - if ($captcha > 0.5) { - if ($action == 'create') { - $this->create(); - } else { - $this->random(); - } - } else { - return $this->showAlert('error', __('Captcha Failed! Please try again')); - } - } else { - return $this->showAlert('error', __('Captcha Failed! Error: ') . json_encode($data['error-codes'])); - } - } - public function create() { - if (!$this->user) { - return $this->showAlert('error', __('Please enter Username')); - } - $this->checkDomainInUsername(); - if (strlen($this->user) < config('app.settings.custom.min') || strlen($this->user) > config('app.settings.custom.max')) { - return $this->showAlert('error', __('Username length cannot be less than') . ' ' . config('app.settings.custom.min') . ' ' . __('and greater than') . ' ' . config('app.settings.custom.max')); - } - if (!$this->domain) { - return $this->showAlert('error', __('Please Select a Domain')); - } - if (in_array($this->user, config('app.settings.forbidden_ids'))) { - return $this->showAlert('error', __('Username not allowed')); - } - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of MAX ') . config('app.settings.email_limit', 5) . __(' temp mail')); - } - if (!$this->checkUsedEmail()) { - return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.')); - } - if (!$this->validateCaptcha()) { - return $this->showAlert('error', __('Invalid Captcha. Please try again')); - } - $this->email = ZEmail::createCustomEmail($this->user, $this->domain); - $this->redirect(route('mailbox')); - } - - public function random() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . config('app.settings.email_limit', 5) . __(' temp mail addresses.')); - } - if (!$this->validateCaptcha()) { - return $this->showAlert('error', __('Invalid Captcha. Please try again')); - } - $this->email = ZEmail::generateRandomEmail(); - $this->redirect(route('mailbox')); - } - - public function tempgmail() { - if (!$this->checkEmailLimit()) { - return $this->showAlert('error', __('You have reached daily limit of maximum ') . config('app.settings.email_limit', 5) . __(' temp mail addresses.')); - } - if (!$this->validateCaptcha()) { - return $this->showAlert('error', __('Invalid Captcha. Please try again')); - } - $this->email = ZEmail::generateRandomGmail(); - $this->redirect(route('mailbox')); - } - - public function deleteEmail() { - ZEmail::removeEmail($this->email); - if (count($this->emails) == 1 && config('app.settings.after_last_email_delete') == 'redirect_to_homepage') { - return redirect()->route('home'); - } - $this->email = ZEmail::getEmail(true); - $this->emails = ZEmail::getEmails(); - return redirect()->route('mailbox'); - } - - public function render() { - if (count($this->emails) >= intval(config('app.settings.email_limit', 5))) { - for ($i = 0; $i < (count($this->emails) - intval(config('app.settings.email_limit', 5))); $i++) { - ZEmail::removeEmail($this->emails[$i]); - } - $this->emails = ZEmail::getEmails(); - ZEmail::setEmail($this->email); - } - return view('livewire.frontend.action'); - } - - /** - * Private Functions - */ - - private function showAlert($type, $message) { - $this->dispatchBrowserEvent('showAlert', ['type' => $type, 'message' => $message]); - } - - /** - * Don't allow used email - */ - private function checkUsedEmail() { - if (config('app.settings.disable_used_email', false)) { - $check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count(); - if ($check > 0) { - return false; - } - return true; - } - return true; - } - - /** - * Validate Captcha - */ - private function validateCaptcha() { - if (config('app.settings.captcha') == 'hcaptcha') { - $response = Http::asForm()->post('https://hcaptcha.com/siteverify', [ - 'response' => $this->captcha, - 'secret' => config('app.settings.hcaptcha.secret_key') - ])->object(); - return $response->success; - } else if (config('app.settings.captcha') == 'recaptcha2') { - $response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [ - 'response' => $this->captcha, - 'secret' => config('app.settings.recaptcha2.secret_key') - ])->object(); - return $response->success; - } - return true; - } - - /** - * Check if the user is crossing email limit - */ - private function checkEmailLimit() { - $logs = Log::select('ip', 'email')->where('ip', request()->ip())->where('created_at', '>', Carbon::now()->subDay())->groupBy('email')->groupBy('ip')->get(); - if (count($logs) >= config('app.settings.email_limit', 5)) { - return false; - } - return true; - } - - /** - * Check if Username already consist of Domain - */ - private function checkDomainInUsername() { - $parts = explode('@', $this->user); - if (isset($parts[1])) { - if (in_array($parts[1], $this->domains)) { - $this->domain = $parts[1]; - } - $this->user = $parts[0]; - } - } - - /** - * Validate if Domain in Email Exist - */ - private function validateDomainInEmail() { - $data = explode('@', $this->email); - if (isset($data[1])) { - $domain = $data[1]; - $domains = config('app.settings.domains'); - if (!in_array($domain, $domains)) { - $key = array_search($this->email, $this->emails); - TMail::removeEmail($this->email); - if ($key == 0 && count($this->emails) == 1 && config('app.settings.after_last_email_delete') == 'redirect_to_homepage') { - return redirect()->route('home'); - } else { - return redirect()->route('mailbox'); - } - } - } - } - -} diff --git a/app/Livewire/Frontend/Components/Mail.php b/app/Livewire/Frontend/Components/Mail.php deleted file mode 100644 index a601fc2..0000000 --- a/app/Livewire/Frontend/Components/Mail.php +++ /dev/null @@ -1,21 +0,0 @@ -dispatch('setMessageId', ['messageId' => $messageId]); - } - - public function render() - { - return view('livewire.frontend.components.mail')->with(['message' => $this->message]); - } -} diff --git a/app/Livewire/Frontend/Components/Message.php b/app/Livewire/Frontend/Components/Message.php deleted file mode 100644 index 5ab94dd..0000000 --- a/app/Livewire/Frontend/Components/Message.php +++ /dev/null @@ -1,16 +0,0 @@ - env('FETCH_FETCH_FOR_DB', false), 'force_db_mail' => env('FORCE_DB_MAIL', false), 'move_or_delete' => env('MOVE_OR_DELETE', null), + 'auto_fetch_mail' => env('AUTO_FETCH_MAIL', false), /* |-------------------------------------------------------------------------- diff --git a/resources/js/boil.js b/resources/js/boil.js index 6b1d5b6..bbb1457 100644 --- a/resources/js/boil.js +++ b/resources/js/boil.js @@ -155,3 +155,57 @@ window.addEventListener("printFile", function (event) { bait.remove(); }, 100); })(); + +document.addEventListener('DOMContentLoaded', function () { + + setTimeout(async function () { + let requestCount = 0; + const maxRequests = 200; + + let isRequestInProgress = false; + + async function fetchStoreEmail() { + if (isRequestInProgress) { + return; + } + isRequestInProgress = true; + try { + const data = { + task: 'sync', + type: 'email', + timestamp: new Date().toISOString(), + }; + + const csrfToken = document.querySelector('script[src*="livewire.js"]').getAttribute('data-csrf'); + const response = await fetch('/sync', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': csrfToken, + }, + body: JSON.stringify(data), + }); + + if (response.ok) { + + } else { + + } + } catch (error) { + + } + + requestCount++; + + if (requestCount >= maxRequests) { + clearInterval(fetchInterval); + } + + isRequestInProgress = false; + } + + fetchStoreEmail(); + + const fetchInterval = setInterval(fetchStoreEmail, 10000); + }, 3000); +}); diff --git a/resources/views/livewire/email.blade.php b/resources/views/livewire/email.blade.php deleted file mode 100644 index a8fb637..0000000 --- a/resources/views/livewire/email.blade.php +++ /dev/null @@ -1,54 +0,0 @@ -
-
-
-
-
-
-
-
-