diff --git a/app/Livewire/Dashboard/BulkGmail.php b/app/Livewire/Dashboard/BulkGmail.php new file mode 100644 index 0000000..0debfe3 --- /dev/null +++ b/app/Livewire/Dashboard/BulkGmail.php @@ -0,0 +1,118 @@ +user()->subscribedToProduct(config('app.plans')[0]['product_id']); + Session::put('isSubscribed', $subscriptionCheck); + } + + public function generateBulk(): void + { + $this->validate([ + 'email' => [ + 'required', + 'email', + 'regex:/^[^@\s]+@gmail\.com$/i', + ], + 'quantity' => 'required|integer|min:10|max:500', + ]); + + if (count($this->bulkEmails) > 0) { + $this->bulkEmails = []; + } + + $this->bulkEmails = $this->generateDotVariants(explode("@", $this->email)[0], $this->quantity); + } + + public function downloadBulk() + { + // Ensure there's something to download + if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) { + return; + } + + $filename = 'bulk_gmails_' . now()->format('Ymd_His') . '.txt'; + $content = implode(PHP_EOL, $this->bulkEmails); + + return response()->streamDownload(function () use ($content) { + echo $content; + }, $filename); + } + + private function generateDotVariants($uname, $quantity) + { + $length = strlen($uname); + $positions = range(1, $length - 1); + $results = []; + + // From 1 dot up to max possible + for ($dotCount = 1; $dotCount < $length; $dotCount++) { + $combinations = $this->combinations($positions, $dotCount); + + // Reverse each combination for right-to-left priority + foreach (array_reverse($combinations) as $combo) { + $dotted = ''; + $lastPos = 0; + + foreach ($combo as $pos) { + $dotted .= substr($uname, $lastPos, $pos - $lastPos) . '.'; + $lastPos = $pos; + } + $dotted .= substr($uname, $lastPos); + $results[] = $dotted . '@gmail.com'; + + if (count($results) >= $quantity) { + return $results; + } + } + } + + return $results; + } + + private function combinations(array $items, int $size): array + { + if ($size === 0) { + return [[]]; + } + + if (empty($items)) { + return []; + } + + $combinations = []; + $head = $items[0]; + $tail = array_slice($items, 1); + + foreach ($this->combinations($tail, $size - 1) as $c) { + array_unshift($c, $head); + $combinations[] = $c; + } + + foreach ($this->combinations($tail, $size) as $c) { + $combinations[] = $c; + } + + return $combinations; + } + + public function render() + { + if (Session::get('isSubscribed')) { + return view('livewire.dashboard.bulk-gmail')->layout('components.layouts.dashboard'); + } else { + return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard'); + } + } +} diff --git a/resources/views/components/layouts/dashboard.blade.php b/resources/views/components/layouts/dashboard.blade.php index 4342076..7735743 100644 --- a/resources/views/components/layouts/dashboard.blade.php +++ b/resources/views/components/layouts/dashboard.blade.php @@ -39,6 +39,7 @@ ['label' => 'Generate Premium Email', 'route' => 'dashboard.premium'], //['label' => '10 Minute Mail', 'route' => 'dashboard.10minute'], ['label' => 'Bulk Email Generator', 'route' => 'dashboard.bulk'], + ['label' => 'Bulk Gmail Generator', 'route' => 'dashboard.bulkGmail'], //['label' => 'Compose Email', 'route' => 'dashboard.compose'], ]; diff --git a/resources/views/livewire/dashboard/bulk-gmail.blade.php b/resources/views/livewire/dashboard/bulk-gmail.blade.php new file mode 100644 index 0000000..cafa318 --- /dev/null +++ b/resources/views/livewire/dashboard/bulk-gmail.blade.php @@ -0,0 +1,67 @@ + +
+
+

Bulk Gmail Generator

+ +
+
+ + + @if (!empty($bulkEmails)) + + @endif +
+ +
+ + +
+ @error('quantity') + {{ $message }} + @enderror + @error('email') + {{ $message }} + @enderror +
+ + + @if(count($bulkEmails) > 0) +
+ UNIQUE GMAIL GENERATED : {{ count($bulkEmails)}} +
+
+ @foreach($bulkEmails as $email) +
+ {{ $email }} +
+ @endforeach +
+ @endif +
+
+
diff --git a/routes/web.php b/routes/web.php index afc0580..05753d4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Http\Controllers\AppController; use App\Http\Middleware\CheckPageSlug; use App\Livewire\Blog; use App\Livewire\Dashboard\Bulk; +use App\Livewire\Dashboard\BulkGmail; use App\Livewire\Dashboard\Dashboard; use App\Livewire\Dashboard\Mailbox\Inbox; use App\Livewire\Frontend\Mailbox; @@ -49,6 +50,7 @@ Route::middleware(['auth', 'verified'])->group(function () { Route::get('dashboard/generate-premium-email', Inbox::class)->name('dashboard.premium'); Route::get('dashboard/generate-10minute-email', Dashboard::class)->name('dashboard.10minute'); Route::get('dashboard/bulk-email-generator', Bulk::class)->name('dashboard.bulk'); + Route::get('dashboard/bulk-gmail-generator', BulkGmail::class)->name('dashboard.bulkGmail'); Route::get('dashboard/compose-email', Dashboard::class)->name('dashboard.compose'); // Checkout Routes