403Webshell
Server IP : 138.197.107.151  /  Your IP : 216.73.217.10
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux BloxBy-Builder 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User : wpbetasites_mrakzqskir ( 1022)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/silversharkadmindev/app/Services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/silversharkadmindev/app/Services/EmailValidatorService.php
<?php

namespace App\Services;

use Illuminate\Support\Facades\Http;

class EmailValidatorService
{
    protected string $apiBase = "https://rapid-email-verifier.fly.dev/api";

    /**
     * Local list of known disposable domains
     */
    protected array $disposableDomains = [
        'mailinator.com',
        'tempmail.com',
        '10minutemail.com',
        'guerrillamail.com',
        'yopmail.com',
        'trashmail.com',
        'getnada.com',
        'dispostable.com',
        'fakeinbox.com',
        'sharklasers.com',
        // 👉 add more if you want
    ];

    /**
     * Validate email via local + API
     */
    public function validate(string $email): array
    {
        $domain = strtolower(substr(strrchr($email, "@"), 1));

        // ✅ Local check first
        if (in_array($domain, $this->disposableDomains)) {
            return [
                'valid' => true,
                'disposable' => true,
                'source' => 'local'
            ];
        }

        // 🌍 Fallback to external API
        try {
            $response = Http::acceptJson()->get("{$this->apiBase}/validate", [
                'email' => $email
            ]);

            if ($response->successful()) {
                $data = $response->json();
                $data['source'] = 'api';

                                        $data["valid"] = true;

                        $data["disposable"] = false;

                if(isset($data["validations"])){

                    if($data["validations"]["is_disposable"]){
                        $data["valid"] = true;

                        $data["disposable"] = true;
                    }
                    if(!$data["validations"]["domain_exists"]){
                        $data["valid"] = false;

                        $data["disposable"] = false;
                    }
                }
                return $data;
            }
        } catch (\Exception $e) {
            \Log::error("Email validation failed: " . $e->getMessage());
        }

        // If API fails, assume invalid
        return [
            'valid' => false,
            'disposable' => false,
            'source' => 'fallback'
        ];
    }

    /**
     * Quick helper: only return disposable check
     */
    public function isDisposable(string $email): bool
    {
        $result = $this->validate($email);
        return $result['disposable'] ?? false;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit