chore: migrate to unified payment system & fix disposable gmail and outlook

This commit is contained in:
idevakk
2025-11-21 12:11:52 -08:00
parent 72b8109a3a
commit 7ca3d44d59
4 changed files with 42 additions and 28 deletions

View File

@@ -2,10 +2,6 @@
namespace App\Livewire\Dashboard\Mailbox;
use Illuminate\Support\Facades\Session;
use Illuminate\Routing\Redirector;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Date;
use App\ColorPicker;
use App\Models\Log;
use App\Models\Premium;
@@ -13,7 +9,11 @@ use App\Models\PremiumEmail;
use App\Models\UsageLog;
use App\Models\ZEmail;
use Exception;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Session;
use Livewire\Component;
class Inbox extends Component
@@ -82,7 +82,7 @@ class Inbox extends Component
$this->emailsHistory = array_reverse(PremiumEmail::parseEmail(\auth()->user()->id)['data']) ?? [];
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
$subscriptionCheck = auth()->user()->hasActiveSubscription();
Session::put('isSubscribed', $subscriptionCheck);
if ($subscriptionCheck) {
try {
@@ -245,6 +245,7 @@ class Inbox extends Component
private function checkEmailLimit(): bool
{
$logs = Log::query()->select('ip', 'email')->where('user_id', auth()->user()->id)->where('created_at', '>', Date::now()->subDay())->groupBy('email')->groupBy('ip')->get();
return count($logs) < $this->email_limit;
}
@@ -252,6 +253,7 @@ class Inbox extends Component
{
if (json_decode((string) config('app.settings.configuration_settings'))->disable_used_email) {
$check = Log::query()->where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
return $check <= 0;
}
@@ -430,6 +432,7 @@ class Inbox extends Component
if (Session::get('isSubscribed')) {
return view('livewire.dashboard.mailbox.inbox')->layout('components.layouts.dashboard');
}
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
}

View File

@@ -2,12 +2,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use DateTimeImmutable;
use Illuminate\Support\Facades\Log;
use App\ColorPicker;
use Carbon\Carbon;
use DateTime;
use DateTimeImmutable;
use Ddeboer\Imap\ConnectionInterface;
use Ddeboer\Imap\Search\Email\Cc;
use Ddeboer\Imap\Search\Email\To;
@@ -19,8 +17,6 @@ use Illuminate\Support\Facades\Cookie;
class Premium extends Model
{
use HasFactory;
use HasFactory;
use ColorPicker;
public static function connectMailBox($imap = null): ConnectionInterface
@@ -54,7 +50,7 @@ class Premium extends Model
$mailbox = $connection->getMailbox('INBOX');
$search = new SearchExpression;
if ($type == 'cc') {
if ($type === 'cc') {
$search->addCondition(new Cc($email));
} else {
$search->addCondition(new To($email));
@@ -75,7 +71,7 @@ class Premium extends Model
$blocked = false;
$sender = $message->getFrom();
$date = $message->getDate();
if (!$date instanceof DateTimeImmutable) {
if (! $date instanceof DateTimeImmutable) {
$date = new DateTime;
if ($message->getHeaders()->get('udate')) {
$date->setTimestamp($message->getHeaders()->get('udate'));
@@ -87,12 +83,12 @@ class Premium extends Model
$html = $message->getBodyHtml();
$text = $message->getBodyText();
if ($text) {
$contentText = str_replace('<a', '<a target="blank"', str_replace(["\r\n", "\n"], '', $text));
$contentText = str_replace(["\r\n", "\n", '<a'], ['', '', '<a target="blank"'], $text);
}
if ($html) {
$content = str_replace('<a', '<a target="blank"', $html);
} else {
$content = str_replace('<a', '<a target="blank"', str_replace(["\r\n", "\n"], '<br/>', $text));
$content = str_replace(["\r\n", "\n", '<a'], ['<br/>', '<br/>', '<a target="blank"'], $text);
}
if (json_decode((string) config('app.settings.configuration_settings'))->enable_masking_external_link) {
$content = str_replace('href="', 'href="http://href.li/?', $content);
@@ -124,8 +120,10 @@ class Premium extends Model
if ($message->hasAttachments() && ! $blocked) {
$attachments = $message->getAttachments();
$directory = './tmp/premium/attachments/'.$obj['id'].'/';
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
if (! is_dir($directory)) {
if (! mkdir($directory, 0777, true) && ! is_dir($directory)) {
\Illuminate\Support\Facades\Log::error('Unable to create temporary directory \''.$directory.'\'');
}
}
foreach ($attachments as $attachment) {
$filenameArray = explode('.', (string) $attachment->getFilename());
@@ -196,6 +194,7 @@ class Premium extends Model
if (Cookie::has('p_email')) {
return Cookie::get('p_email');
}
return $generate ? self::generateRandomEmail() : null;
}
@@ -204,6 +203,7 @@ class Premium extends Model
if (Cookie::has('p_emails')) {
return unserialize(Cookie::get('p_emails'));
}
return [];
}
@@ -374,26 +374,27 @@ class Premium extends Model
$zemail = new Premium;
$uname = $zemail->getRandomGmailUser();
$uname_len = strlen((string) $uname);
$len_power = $uname_len - 1;
$combination = 2 ** $len_power;
mt_rand(1, $combination);
$len_power = max(1, $uname_len - 1); // Ensure minimum of 1
$formatted = implode(' ', str_split((string) $uname));
$uname_exp = explode(' ', $formatted);
$bin = intval('');
$bin = '';
for ($i = 0; $i < $len_power; $i++) {
$bin .= mt_rand(0, 1);
}
$bin = explode(' ', implode(' ', str_split(strval($bin))));
$bin_array = str_split($bin);
$email = '';
for ($i = 0; $i < $len_power; $i++) {
for ($i = 0; $i < $len_power && $i < count($uname_exp); $i++) {
$email .= $uname_exp[$i];
if ($bin[$i] !== '' && $bin[$i] !== '0') {
if (isset($bin_array[$i]) && $bin_array[$i] === '1') {
$email .= '.';
}
}
$email .= $uname_exp[$i];
// Add the last character if it exists
if (isset($uname_exp[$len_power])) {
$email .= $uname_exp[$len_power];
}
$gmail_rand = mt_rand(1, 10);
if ($gmail_rand > 5) {
$email .= '@gmail.com';
@@ -480,7 +481,12 @@ class Premium extends Model
$gmailusername = json_decode((string) config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
$count = count($gmailusername);
return $count > 0 ? $gmailusername[random_int(1, $count) - 1] : '';
if ($count > 0) {
return $gmailusername[random_int(1, $count) - 1];
}
// Fallback to a default username if none configured
return 'user'.random_int(1000, 9999);
}
private function getRandomOutlookUser()
@@ -488,7 +494,12 @@ class Premium extends Model
$outlook_username = json_decode((string) config('app.settings.configuration_settings'))->premium_outlookUsernames ?? [];
$count = count($outlook_username);
return $count > 0 ? $outlook_username[random_int(1, $count) - 1] : '';
if ($count > 0) {
return $outlook_username[random_int(1, $count) - 1];
}
// Fallback to a default username if none configured
return 'user'.random_int(1000, 9999);
}
private function generatePronounceableWord(): string

View File

@@ -23,7 +23,7 @@
</article>
</div>
@if(auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']))
@if(auth()->user()->hasActiveSubscription())
<article class="flex items-center gap-4 rounded-lg border border-gray-100 bg-white p-6 dark:border-gray-800 dark:bg-white/[0.03]">
<div>

View File

@@ -76,7 +76,7 @@
<div class="flex w-full">
<div class="w-1/2">
<flux:button wire:click="outlook()" class="cursor-pointer w-full btn-outlook" type="submit" variant="filled">Disposable Gmail</flux:button>
<flux:button wire:click="outlook()" class="cursor-pointer w-full btn-outlook" type="submit" variant="filled">Disposable Outlook</flux:button>
</div>
<div class="w-1/2">
<flux:button wire:click="gmail()" class="cursor-pointer w-full ml-2 btn-gmail" type="submit" variant="filled">Disposable Gmail</flux:button>