chore: migrate to unified payment system & fix disposable gmail and outlook
This commit is contained in:
@@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Livewire\Dashboard\Mailbox;
|
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\ColorPicker;
|
||||||
use App\Models\Log;
|
use App\Models\Log;
|
||||||
use App\Models\Premium;
|
use App\Models\Premium;
|
||||||
@@ -13,7 +9,11 @@ use App\Models\PremiumEmail;
|
|||||||
use App\Models\UsageLog;
|
use App\Models\UsageLog;
|
||||||
use App\Models\ZEmail;
|
use App\Models\ZEmail;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Date;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class Inbox extends Component
|
class Inbox extends Component
|
||||||
@@ -82,7 +82,7 @@ class Inbox extends Component
|
|||||||
|
|
||||||
$this->emailsHistory = array_reverse(PremiumEmail::parseEmail(\auth()->user()->id)['data']) ?? [];
|
$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);
|
Session::put('isSubscribed', $subscriptionCheck);
|
||||||
if ($subscriptionCheck) {
|
if ($subscriptionCheck) {
|
||||||
try {
|
try {
|
||||||
@@ -245,6 +245,7 @@ class Inbox extends Component
|
|||||||
private function checkEmailLimit(): bool
|
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();
|
$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;
|
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) {
|
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();
|
$check = Log::query()->where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
|
||||||
|
|
||||||
return $check <= 0;
|
return $check <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,6 +432,7 @@ class Inbox extends Component
|
|||||||
if (Session::get('isSubscribed')) {
|
if (Session::get('isSubscribed')) {
|
||||||
return view('livewire.dashboard.mailbox.inbox')->layout('components.layouts.dashboard');
|
return view('livewire.dashboard.mailbox.inbox')->layout('components.layouts.dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use App\ColorPicker;
|
use App\ColorPicker;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use DateTimeImmutable;
|
||||||
use Ddeboer\Imap\ConnectionInterface;
|
use Ddeboer\Imap\ConnectionInterface;
|
||||||
use Ddeboer\Imap\Search\Email\Cc;
|
use Ddeboer\Imap\Search\Email\Cc;
|
||||||
use Ddeboer\Imap\Search\Email\To;
|
use Ddeboer\Imap\Search\Email\To;
|
||||||
@@ -19,8 +17,6 @@ use Illuminate\Support\Facades\Cookie;
|
|||||||
|
|
||||||
class Premium extends Model
|
class Premium extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
|
||||||
use HasFactory;
|
|
||||||
use ColorPicker;
|
use ColorPicker;
|
||||||
|
|
||||||
public static function connectMailBox($imap = null): ConnectionInterface
|
public static function connectMailBox($imap = null): ConnectionInterface
|
||||||
@@ -54,7 +50,7 @@ class Premium extends Model
|
|||||||
|
|
||||||
$mailbox = $connection->getMailbox('INBOX');
|
$mailbox = $connection->getMailbox('INBOX');
|
||||||
$search = new SearchExpression;
|
$search = new SearchExpression;
|
||||||
if ($type == 'cc') {
|
if ($type === 'cc') {
|
||||||
$search->addCondition(new Cc($email));
|
$search->addCondition(new Cc($email));
|
||||||
} else {
|
} else {
|
||||||
$search->addCondition(new To($email));
|
$search->addCondition(new To($email));
|
||||||
@@ -75,7 +71,7 @@ class Premium extends Model
|
|||||||
$blocked = false;
|
$blocked = false;
|
||||||
$sender = $message->getFrom();
|
$sender = $message->getFrom();
|
||||||
$date = $message->getDate();
|
$date = $message->getDate();
|
||||||
if (!$date instanceof DateTimeImmutable) {
|
if (! $date instanceof DateTimeImmutable) {
|
||||||
$date = new DateTime;
|
$date = new DateTime;
|
||||||
if ($message->getHeaders()->get('udate')) {
|
if ($message->getHeaders()->get('udate')) {
|
||||||
$date->setTimestamp($message->getHeaders()->get('udate'));
|
$date->setTimestamp($message->getHeaders()->get('udate'));
|
||||||
@@ -87,12 +83,12 @@ class Premium extends Model
|
|||||||
$html = $message->getBodyHtml();
|
$html = $message->getBodyHtml();
|
||||||
$text = $message->getBodyText();
|
$text = $message->getBodyText();
|
||||||
if ($text) {
|
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) {
|
if ($html) {
|
||||||
$content = str_replace('<a', '<a target="blank"', $html);
|
$content = str_replace('<a', '<a target="blank"', $html);
|
||||||
} else {
|
} 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) {
|
if (json_decode((string) config('app.settings.configuration_settings'))->enable_masking_external_link) {
|
||||||
$content = str_replace('href="', 'href="http://href.li/?', $content);
|
$content = str_replace('href="', 'href="http://href.li/?', $content);
|
||||||
@@ -124,8 +120,10 @@ class Premium extends Model
|
|||||||
if ($message->hasAttachments() && ! $blocked) {
|
if ($message->hasAttachments() && ! $blocked) {
|
||||||
$attachments = $message->getAttachments();
|
$attachments = $message->getAttachments();
|
||||||
$directory = './tmp/premium/attachments/'.$obj['id'].'/';
|
$directory = './tmp/premium/attachments/'.$obj['id'].'/';
|
||||||
if (!is_dir($directory)) {
|
if (! is_dir($directory)) {
|
||||||
mkdir($directory, 0777, true);
|
if (! mkdir($directory, 0777, true) && ! is_dir($directory)) {
|
||||||
|
\Illuminate\Support\Facades\Log::error('Unable to create temporary directory \''.$directory.'\'');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
$filenameArray = explode('.', (string) $attachment->getFilename());
|
$filenameArray = explode('.', (string) $attachment->getFilename());
|
||||||
@@ -196,6 +194,7 @@ class Premium extends Model
|
|||||||
if (Cookie::has('p_email')) {
|
if (Cookie::has('p_email')) {
|
||||||
return Cookie::get('p_email');
|
return Cookie::get('p_email');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $generate ? self::generateRandomEmail() : null;
|
return $generate ? self::generateRandomEmail() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +203,7 @@ class Premium extends Model
|
|||||||
if (Cookie::has('p_emails')) {
|
if (Cookie::has('p_emails')) {
|
||||||
return unserialize(Cookie::get('p_emails'));
|
return unserialize(Cookie::get('p_emails'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,26 +374,27 @@ class Premium extends Model
|
|||||||
$zemail = new Premium;
|
$zemail = new Premium;
|
||||||
$uname = $zemail->getRandomGmailUser();
|
$uname = $zemail->getRandomGmailUser();
|
||||||
$uname_len = strlen((string) $uname);
|
$uname_len = strlen((string) $uname);
|
||||||
$len_power = $uname_len - 1;
|
$len_power = max(1, $uname_len - 1); // Ensure minimum of 1
|
||||||
$combination = 2 ** $len_power;
|
|
||||||
mt_rand(1, $combination);
|
|
||||||
$formatted = implode(' ', str_split((string) $uname));
|
$formatted = implode(' ', str_split((string) $uname));
|
||||||
$uname_exp = explode(' ', $formatted);
|
$uname_exp = explode(' ', $formatted);
|
||||||
|
|
||||||
$bin = intval('');
|
$bin = '';
|
||||||
for ($i = 0; $i < $len_power; $i++) {
|
for ($i = 0; $i < $len_power; $i++) {
|
||||||
$bin .= mt_rand(0, 1);
|
$bin .= mt_rand(0, 1);
|
||||||
}
|
}
|
||||||
$bin = explode(' ', implode(' ', str_split(strval($bin))));
|
$bin_array = str_split($bin);
|
||||||
|
|
||||||
$email = '';
|
$email = '';
|
||||||
for ($i = 0; $i < $len_power; $i++) {
|
for ($i = 0; $i < $len_power && $i < count($uname_exp); $i++) {
|
||||||
$email .= $uname_exp[$i];
|
$email .= $uname_exp[$i];
|
||||||
if ($bin[$i] !== '' && $bin[$i] !== '0') {
|
if (isset($bin_array[$i]) && $bin_array[$i] === '1') {
|
||||||
$email .= '.';
|
$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);
|
$gmail_rand = mt_rand(1, 10);
|
||||||
if ($gmail_rand > 5) {
|
if ($gmail_rand > 5) {
|
||||||
$email .= '@gmail.com';
|
$email .= '@gmail.com';
|
||||||
@@ -480,7 +481,12 @@ class Premium extends Model
|
|||||||
$gmailusername = json_decode((string) config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
$gmailusername = json_decode((string) config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
||||||
$count = count($gmailusername);
|
$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()
|
private function getRandomOutlookUser()
|
||||||
@@ -488,7 +494,12 @@ class Premium extends Model
|
|||||||
$outlook_username = json_decode((string) config('app.settings.configuration_settings'))->premium_outlookUsernames ?? [];
|
$outlook_username = json_decode((string) config('app.settings.configuration_settings'))->premium_outlookUsernames ?? [];
|
||||||
$count = count($outlook_username);
|
$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
|
private function generatePronounceableWord(): string
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
</article>
|
</article>
|
||||||
|
|
||||||
</div>
|
</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]">
|
<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>
|
<div>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
|
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
<div class="w-1/2">
|
<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>
|
||||||
<div class="w-1/2">
|
<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>
|
<flux:button wire:click="gmail()" class="cursor-pointer w-full ml-2 btn-gmail" type="submit" variant="filled">Disposable Gmail</flux:button>
|
||||||
|
|||||||
Reference in New Issue
Block a user