added bulk gmail generator
This commit is contained in:
118
app/Livewire/Dashboard/BulkGmail.php
Normal file
118
app/Livewire/Dashboard/BulkGmail.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
use function Pest\Laravel\withoutMockingConsoleOutput;
|
||||
|
||||
class BulkGmail extends Component
|
||||
{
|
||||
public $email;
|
||||
public int $quantity = 10;
|
||||
public $bulkEmails = [];
|
||||
|
||||
public function mount() {
|
||||
$subscriptionCheck = auth()->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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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'],
|
||||
];
|
||||
|
||||
|
||||
67
resources/views/livewire/dashboard/bulk-gmail.blade.php
Normal file
67
resources/views/livewire/dashboard/bulk-gmail.blade.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<span>
|
||||
<div class="flex-1 overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700 dark:bg-white/[0.03] sm:px-8 sm:py-8 lg:p-12 p-2">
|
||||
<div class="text-center">
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-400 py-2">Bulk Gmail Generator</h2>
|
||||
<!-- Upper Part: Input + Button -->
|
||||
<div class="w-full max-w-xl mx-auto mb-2">
|
||||
<div class="flex rounded-lg overflow-hidden border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-zinc-800">
|
||||
<input
|
||||
type="email"
|
||||
max="500"
|
||||
wire:model="email"
|
||||
class="w-full px-4 py-2 bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 placeholder-zinc-500 focus:outline-none"
|
||||
placeholder="Enter your real gmail address"
|
||||
/>
|
||||
<button
|
||||
wire:click="generateBulk"
|
||||
class="cursor-pointer px-5 py-2 bg-[#4361EE] text-white transition-colors dark:bg-[#4361EE] "
|
||||
>
|
||||
Generate
|
||||
</button>
|
||||
@if (!empty($bulkEmails))
|
||||
<button
|
||||
type="button"
|
||||
wire:click="downloadBulk"
|
||||
class="cursor-pointer px-5 py-2 bg-[#00AB55] text-white transition-colors dark:bg-[#00AB55] "
|
||||
>
|
||||
<flux:icon.download />
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div x-data="{ quantity: @entangle('quantity') }" class="my-2 flex flex-col sm:flex-row sm:items-center justify-between mt-3 space-y-1 sm:space-y-0">
|
||||
<label class="text-sm text-gray-700 dark:text-gray-300">Quantity: <span x-text="quantity"></span></label>
|
||||
<input
|
||||
type="range"
|
||||
min="10"
|
||||
max="500"
|
||||
step="1"
|
||||
x-model="quantity"
|
||||
wire:model.debounce.150ms="quantity"
|
||||
class="w-full sm:w-2/3"
|
||||
/>
|
||||
</div>
|
||||
@error('quantity')
|
||||
<span class="text-sm text-red-600 dark:text-red-400">{{ $message }}</span>
|
||||
@enderror
|
||||
@error('email')
|
||||
<span class="text-sm text-red-600 dark:text-red-400">{{ $message }}</span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
|
||||
@if(count($bulkEmails) > 0)
|
||||
<div class="w-full flex justify-center my-3 mt-12">
|
||||
<span class="text-shadow-yellow-200">UNIQUE GMAIL GENERATED</span> : {{ count($bulkEmails)}}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
||||
@foreach($bulkEmails as $email)
|
||||
<div class="truncate px-4 py-2 bg-white dark:bg-zinc-800 rounded shadow text-zinc-900 dark:text-zinc-100">
|
||||
{{ $email }}
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user