From b799ac3f9a97ab6d281fb4ef94766218c07af925 Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 23 Apr 2025 17:52:22 +0530 Subject: [PATCH] Added Setting.php, [Logs, Messages] Model --- app/Filament/Pages/Settings.php | 230 +++++++- app/Models/Log.php | 21 + app/Models/Message.php | 108 ++++ app/Models/Meta.php | 52 ++ app/Models/Setting.php | 4 + app/Models/ZEmail.php | 516 ++++++++++++++++++ app/Providers/AppServiceProvider.php | 9 +- composer.json | 2 + composer.lock | 233 +++++++- config/app.php | 5 + config/debugbar.php | 333 +++++++++++ ...nfiguration_settings_to_settings_table.php | 28 + ...834_add_ads_settings_to_settings_table.php | 28 + .../2025_04_23_101602_create_metas_table.php | 29 + .../2025_04_23_104947_create_logs_table.php | 29 + ...025_04_23_120910_create_messages_table.php | 33 ++ database/seeders/DatabaseSeeder.php | 6 +- database/seeders/MetaSeeder.php | 28 + routes/web.php | 18 + storage/debugbar/.gitignore | 2 + 20 files changed, 1704 insertions(+), 10 deletions(-) create mode 100644 app/Models/Log.php create mode 100644 app/Models/Message.php create mode 100644 app/Models/Meta.php create mode 100644 app/Models/ZEmail.php create mode 100644 config/debugbar.php create mode 100644 database/migrations/2025_04_22_231534_add_configuration_settings_to_settings_table.php create mode 100644 database/migrations/2025_04_23_004834_add_ads_settings_to_settings_table.php create mode 100644 database/migrations/2025_04_23_101602_create_metas_table.php create mode 100644 database/migrations/2025_04_23_104947_create_logs_table.php create mode 100644 database/migrations/2025_04_23_120910_create_messages_table.php create mode 100644 database/seeders/MetaSeeder.php create mode 100644 storage/debugbar/.gitignore diff --git a/app/Filament/Pages/Settings.php b/app/Filament/Pages/Settings.php index c44fd78..ee5202f 100644 --- a/app/Filament/Pages/Settings.php +++ b/app/Filament/Pages/Settings.php @@ -3,6 +3,8 @@ namespace App\Filament\Pages; use App\Models\Setting; +use App\Models\ZEmail; +use Ddeboer\Imap\Server; use Filament\Actions\Action; use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\KeyValue; @@ -37,6 +39,34 @@ class Settings extends Page implements HasForms if ($setting) { $imapSettings = $setting->imap_settings ?? []; + $configurationSettings = $setting->configuration_settings ?? []; + $adsSettings = $setting->ads_settings ?? []; + + $this->applyDefaults($imapSettings, [ + 'protocol' => 'imap', + 'default_account' => 'default', + ]); + + $this->applyDefaults($configurationSettings, [ + 'cron_password' => fn() => $this->generateRandomString(20), + 'date_format' => 'd M Y h:i A', + 'after_last_email_delete' => 'redirect_to_homepage', + ]); + + $transformMap = [ + 'domains' => 'domain', + 'gmailUsernames' => 'gmailUsername', + 'forbidden_ids' => 'forbidden_id', + 'blocked_domains' => 'blocked_domain', + ]; + + foreach ($transformMap as $key => $subKey) { + if (isset($configurationSettings[$key])) { + $configurationSettings[$key] = array_map(function ($value) use ($subKey) { + return [$subKey => $value]; + }, $configurationSettings[$key]); + } + } $this->form->fill([ 'app_name' => $setting->app_name, 'app_version' => $setting->app_version, @@ -51,6 +81,8 @@ class Settings extends Page implements HasForms 'app_header' => $setting->app_header, 'app_footer' => $setting->app_footer, 'imap_settings' => $imapSettings, + 'configuration_settings' => $configurationSettings, + 'ads_settings' => $adsSettings, ]); @@ -117,7 +149,7 @@ class Settings extends Page implements HasForms ->description('Enter your imap server') ->collapsed() ->schema([ - TextInput::make('imap_settings.hostname')->label('Hostname')->required(), + TextInput::make('imap_settings.host')->label('Hostname')->required(), TextInput::make('imap_settings.port')->label('Port')->required(), Select::make('imap_settings.encryption')->options([ 'none' => 'None', @@ -127,10 +159,137 @@ class Settings extends Page implements HasForms Checkbox::make('imap_settings.validate_cert')->label('Validate Encryption Certificate')->default(false), TextInput::make('imap_settings.username')->label('Username')->required(), TextInput::make('imap_settings.password')->label('Password')->required(), - TextInput::make('imap_settings.default_account')->label('Default Account')->default('default')->placeholder('default'), - TextInput::make('imap_settings.protocol')->label('Protocol')->default('imap')->placeholder('imap'), + TextInput::make('imap_settings.default_account')->label('Default Account')->placeholder('default'), + TextInput::make('imap_settings.protocol')->label('Protocol')->placeholder('imap'), Checkbox::make('imap_settings.cc_check')->label('Check CC Field')->default(false)->helperText('If enabled, we will check the CC field as well while fetching mails.'), - ]) + ]), + + Section::make('Configuration') + ->description('Enter your configuration') + ->collapsed() + ->schema([ + Section::make('General Configuration') + ->columns(2) + ->schema([ + Checkbox::make('configuration_settings.enable_masking_external_link') + ->label('Enable URL Masking of External URL') + ->default(false) + ->columnSpan(1) + ->helperText('If you enable this, then we will use href.li to remove your site footprint being passed-on to external link.'), + Checkbox::make('configuration_settings.disable_mailbox_slug') + ->label('Disable Mailbox Slug') + ->default(false) + ->columnSpan(1) + ->helperText('If you enable this, then we will disable mailbox slug.'), + Checkbox::make('configuration_settings.enable_create_from_url') + ->label('Enable Mail ID Creation from URL') + ->default(true) + ->columnSpan(1) + ->helperText('If you enable this, then users will be able to create email ID from URL.'), + Checkbox::make('configuration_settings.enable_ad_block_detector') + ->label('Enable Ad Block Detector') + ->default(true) + ->columnSpan(1) + ->helperText('If you enable this, then we block all the users from using when that have Ad Blocker enabled.'), + KeyValue::make('configuration_settings.font_family') + ->label('Font Family') + ->columnSpan(2) + ->helperText('Use Google Fonts with exact name.') + ]), + + Select::make('configuration_settings.default_language')->options([ + 'ar' => 'Arabic', + 'de' => 'German', + 'en' => 'English', + 'fr' => 'French', + 'hi' => 'Hindi', + 'pl' => 'Polish', + 'ru' => 'Russian', + 'es' => 'Spanish', + 'vi' => 'Viet', + 'tr' => 'Turkish', + 'no' => 'Norwegian', + 'id' => 'Indonesian', + ]), + + Section::make('Domains & Gmail Usernames') + ->collapsed() + ->columns(2) + ->schema([ + Repeater::make('configuration_settings.domains') + ->statePath('configuration_settings.domains') + ->columnSpan(1) + ->schema([ + TextInput::make('domain')->label('Domain')->required()->maxLength(30), + ]), + Repeater::make('configuration_settings.gmailUsernames') + ->statePath('configuration_settings.gmailUsernames') + ->columnSpan(1) + ->schema([ + TextInput::make('gmailUsername')->label('Gmail Username')->required()->maxLength(30), + ]), + ]), + + Section::make('Mailbox Configuration') + ->collapsed() + ->schema([ + Checkbox::make('configuration_settings.add_mail_in_title')->label('Add Mail In Title')->default(false)->required()->helperText('If you enable this, then we will automatically add the created temp mail to the page title.'), + Checkbox::make('configuration_settings.disable_used_email')->label('Disable Used Email')->default(false)->required()->helperText('If you enable this, same email address cannot be created by user from different IP for one week.'), + TextInput::make('configuration_settings.fetch_seconds')->label('Fetch Seconds')->numeric()->required(), + TextInput::make('configuration_settings.email_limit')->label('Email Limit')->numeric()->required()->helperText('Limit on number of email ids that can be created per IP address in 24 hours. Recommended - 5.'), + TextInput::make('configuration_settings.fetch_messages_limit')->label('Fetch Messages Limit')->numeric()->required()->helperText('Limit of messages retrieved at a time. Keep it to as low as possible. Default - 15.'), + TextInput::make('configuration_settings.cron_password')->label('Cron Password')->required(), + TextInput::make('configuration_settings.date_format')->label('Date Format')->placeholder('d M Y h:i A')->required(), + Section::make('Custom Username Lengths') + ->description('Username length for custom input') + ->columns(2) + ->schema([ + TextInput::make('configuration_settings.custom_username_length_min')->numeric()->minValue(3)->label('Custom Username Min Length')->required(), + TextInput::make('configuration_settings.custom_username_length_max')->numeric()->minValue(3)->label('Custom Username Max Length')->required(), + ]), + Section::make('Random Username Lengths') + ->description('Username length for random username') + ->columns(2) + ->schema([ + TextInput::make('configuration_settings.random_username_length_min')->numeric()->minValue(0)->label('Random Username Min Length')->required(), + TextInput::make('configuration_settings.random_username_length_max')->numeric()->minValue(0)->label('Random Username Max Length')->required(), + ]), + Select::make('configuration_settings.after_last_email_delete')->options([ + 'redirect_to_homepage' => 'Redirect to homepage', + 'create_new_email' => 'Create new Email', + ])->required(), + ]), + Section::make('Forbidden Username & Blocked Domains') + ->columns(2) + ->collapsed() + ->schema([ + Repeater::make('configuration_settings.forbidden_ids') + ->statePath('configuration_settings.forbidden_ids') + ->columnSpan(1) + ->schema([ + TextInput::make('forbidden_id')->label('Forbidden IDs')->required()->maxLength(30), + ]), + Repeater::make('configuration_settings.blocked_domains') + ->statePath('configuration_settings.blocked_domains') + ->columnSpan(1) + ->schema([ + TextInput::make('blocked_domain')->label('Blocked Domain')->required()->maxLength(30), + ]), + ]), + + ]), + + Section::make('Ad Spaces') + ->description('You can setup your Ad Codes here for various Ad Spaces') + ->collapsed() + ->schema([ + Textarea::make('ads_settings.one')->label('Ad Space 1')->rows(4), + Textarea::make('ads_settings.two')->label('Ad Space 2')->rows(4), + Textarea::make('ads_settings.three')->label('Ad Space 3')->rows(4), + Textarea::make('ads_settings.four')->label('Ad Space 4')->rows(4), + Textarea::make('ads_settings.five')->label('Ad Space 5')->rows(4), + ]), + ]) ->statePath('data'); } @@ -149,6 +308,36 @@ class Settings extends Page implements HasForms try { $data = $this->form->getState(); + if (!$this->testIMAP($data['imap_settings'])) { + return; + } else { + Notification::make() + ->title('IMAP Connection Successful') + ->success() + ->send(); + } + foreach ([ + 'protocol' => 'imap', + 'default_account' => 'default' + ] as $key => $default) { + $data['imap_settings'][$key] ??= $default; + } + + $pluckMap = [ + 'domains' => 'domain', + 'gmailUsernames' => 'gmailUsername', + 'forbidden_ids' => 'forbidden_id', + 'blocked_domains' => 'blocked_domain' + ]; + + foreach ($pluckMap as $key => $subKey) { + if (isset($data['configuration_settings'][$key])) { + $data['configuration_settings'][$key] = collect($data['configuration_settings'][$key]) + ->pluck($subKey) + ->toArray(); + } + } + $setting = Setting::where('id', 1)->first(); $user = auth()->user(); @@ -183,6 +372,8 @@ class Settings extends Page implements HasForms 'app_keyword' => $data['app_keyword'], 'app_social' => $data['app_social'], 'imap_settings' => $data['imap_settings'], + 'configuration_settings' => $data['configuration_settings'], + 'ads_settings' => $data['ads_settings'], ]; $create_res = Setting::create(array_merge($data)); @@ -200,4 +391,35 @@ class Settings extends Page implements HasForms ->send(); } } + + private function generateRandomString($length = 10): string + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + + private function applyDefaults(array &$target, array $defaults): void { + foreach ($defaults as $key => $value) { + $target[$key] ??= is_callable($value) ? $value() : $value; + } + } + + private function testIMAP($imap): bool + { + try { + ZEmail::connectMailBox($imap); + return true; + } catch (\Exception $exception) { + Notification::make() + ->title('Imap Error : '.$exception->getMessage()) + ->danger() + ->send(); + return false; + } + } } diff --git a/app/Models/Log.php b/app/Models/Log.php new file mode 100644 index 0000000..58518ae --- /dev/null +++ b/app/Models/Log.php @@ -0,0 +1,21 @@ +subject = $request->subject; + $message->from = $request->from; + $message->to = $request->to; + if ($request->has('html')) { + $message->body = $request->html; + } else { + $message->body = $request->text; + } + $message->save(); + if ($request->has('content-ids')) { + $message->attachments = $request->get('attachment-info'); + $message->save(); + $directory = './attachments/' . $message->id; + is_dir($directory) || mkdir($directory, 0777, true); + $attachment_ids = json_decode($request->get('attachment-info')); + foreach ($attachment_ids as $attachment_id => $attachment_info) { + $allowed = explode(',', 'csv,doc,docx,xls,xlsx,ppt,pptx,xps,pdf,dxf,ai,psd,eps,ps,svg,ttf,zip,rar,tar,gzip,mp3,mpeg,wav,ogg,jpeg,jpg,png,gif,bmp,tif,webm,mpeg4,3gpp,mov,avi,mpegs,wmv,flx,txt'); + $file = explode('.', $attachment_info->filename); + if (in_array($file[count($file) - 1], $allowed)) { + Storage::disk('tmp')->putFileAs($directory, $request->file($attachment_id), $attachment_info->filename); + } + } + } + } + + public static function getMessages($email): array + { + $limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15; + $messages = Message::where('to', $email)->orWhere('to', 'like', '%<' . $email . '>%')->limit($limit)->get(); + $response = [ + 'data' => [], + 'notifications' => [] + ]; + foreach ($messages as $message) { + $content = str_replace('body); + if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) { + $content = str_replace('href="', 'href="https://href.li/?', $content); + } + $obj = []; + $obj['subject'] = $message->subject; + $sender = explode('<', $message->from); + $obj['sender_name'] = $sender[0]; + if (isset($sender[1])) { + $obj['sender_email'] = str_replace('>', '', $sender[1]); + } else { + $obj['sender_email'] = $obj['sender_name']; + } + $obj['timestamp'] = $message->created_at; + $obj['date'] = $message->created_at->format(json_decode(config('app.settings.configuration_settings'))->date_format, 'd M Y h:i A'); + $obj['datediff'] = $message->created_at->diffForHumans(); + $obj['id'] = $message->id; + $obj['content'] = $content; + $obj['attachments'] = []; + $domain = explode('@', $obj['sender_email'])[1]; + $blocked = in_array($domain, json_decode(config('app.settings.configuration_settings'))->blocked_domains); + if ($blocked) { + $obj['subject'] = __('Blocked'); + $obj['content'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin'); + } + if ($message->attachments && !$blocked) { + $attachments = json_decode($message->attachments); + foreach ($attachments as $id => $attachment) { + $url = config('app.settings.app_base_url') . '/tmp/attachments/' . $message->id . '/' . $attachment->filename; + if (str_contains($obj['content'], $id)) { + $obj['content'] = str_replace('cid:' . $id, $url, $obj['content']); + } else { + if (Storage::disk('tmp')->exists('attachments/' . $message->id . '/' . $attachment->filename)) { + $obj['attachments'][] = [ + 'file' => $attachment->filename, + 'url' => $url + ]; + } + } + } + } + $response['data'][] = $obj; + if (!$message->is_seen) { + $response['notifications'][] = [ + 'subject' => $obj['subject'], + 'sender_name' => $obj['sender_name'], + 'sender_email' => $obj['sender_email'] + ]; + if (config('app.zemail_log')) { + file_put_contents(storage_path('logs/zemail.csv'), request()->ip() . "," . date("Y-m-d h:i:s a") . "," . $obj['sender_email'] . "," . $email . PHP_EOL, FILE_APPEND); + } + $message->is_seen = true; + $message->save(); + } + } + return $response; + } +} diff --git a/app/Models/Meta.php b/app/Models/Meta.php new file mode 100644 index 0000000..b94ae15 --- /dev/null +++ b/app/Models/Meta.php @@ -0,0 +1,52 @@ +value = $this->value + $value; + $this->save(); + return true; + } + + public static function incrementEmailIdsCreated($value = 1): bool + { + $meta = Meta::where('key', 'email_ids_created')->first(); + if ($meta) { + $meta->incrementMeta($value); + return true; + } + return false; + } + + public static function incrementMessagesReceived($value = 1): bool + { + $meta = Meta::where('key', 'messages_received')->first(); + if ($meta) { + $meta->incrementMeta($value); + return true; + } + return false; + } + + public static function getEmailIdsCreated() { + $meta = Meta::where('key', 'email_ids_created')->first(); + if ($meta) { + return $meta->value; + } + return "NaN"; + } + + public static function getMessagesReceived() { + $meta = Meta::where('key', 'messages_received')->first(); + if ($meta) { + return $meta->value; + } + return "NaN"; + } +} diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 459e0a4..06a1609 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -25,11 +25,15 @@ class Setting extends Model 'app_header', 'app_footer', 'imap_settings', + 'configuration_settings', + 'ads_settings', ]; protected $casts = [ 'app_meta' => 'json', 'app_social' => 'json', 'imap_settings' => 'json', + 'configuration_settings' => 'json', + 'ads_settings' => 'json', ]; } diff --git a/app/Models/ZEmail.php b/app/Models/ZEmail.php new file mode 100644 index 0000000..a971124 --- /dev/null +++ b/app/Models/ZEmail.php @@ -0,0 +1,516 @@ +authenticate($imap['username'], $imap['password']); + } + + public static function getMessages($email, $type = 'to', $deleted = []): array + { + if (config('app.beta_feature')) { + return Message::getMessages($email); + } + $allowed = explode(',', 'doc,docx,xls,xlsx,ppt,pptx,xps,pdf,dxf,ai,psd,eps,ps,svg,ttf,zip,rar,tar,gzip,mp3,mpeg,wav,ogg,jpeg,jpg,png,gif,bmp,tif,webm,mpeg4,3gpp,mov,avi,mpegs,wmv,flx,txt'); + $connection = ZEmail::connectMailBox(); + $mailbox = $connection->getMailbox('INBOX'); + $search = new SearchExpression(); + if ($type == 'cc') { + $search->addCondition(new Cc($email)); + } else { + $search->addCondition(new To($email)); + } + $messages = $mailbox->getMessages($search, \SORTDATE, true); + $limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15; + $count = 1; + $response = [ + 'data' => [], + 'notifications' => [] + ]; + foreach ($messages as $message) { + if (in_array($message->getNumber(), $deleted)) { + $message->delete(); + continue; + } + $blocked = false; + $sender = $message->getFrom(); + $date = $message->getDate(); + if (!$date) { + $date = new \DateTime(); + if ($message->getHeaders()->get('udate')) { + $date->setTimestamp($message->getHeaders()->get('udate')); + } + } + $datediff = new Carbon($date); + $content = ''; + $html = $message->getBodyHtml(); + if ($html) { + $content = str_replace('getBodyText(); + $content = str_replace('', $text)); + } + if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) { + $content = str_replace('href="', 'href="http://href.li/?', $content); + } + $obj = []; + $obj['subject'] = $message->getSubject(); + $obj['sender_name'] = $sender->getName(); + $obj['sender_email'] = $sender->getAddress(); + $obj['timestamp'] = $message->getDate(); + $obj['date'] = $date->format(json_decode(config('app.settings.configuration_settings'))->date_format, 'd M Y h:i A'); + $obj['datediff'] = $datediff->diffForHumans(); + $obj['id'] = $message->getNumber(); + $obj['content'] = $content; + $obj['attachments'] = []; + //Checking if Sender is Blocked + $domain = explode('@', $obj['sender_email'])[1]; + $blocked = in_array($domain, json_decode(config('app.settings.configuration_settings'))->blocked_domains); + if ($blocked) { + $obj['subject'] = __('Blocked'); + $obj['content'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin'); + } + if ($message->hasAttachments() && !$blocked) { + $attachments = $message->getAttachments(); + $directory = './tmp/attachments/' . $obj['id'] . '/'; + is_dir($directory) || mkdir($directory, 0777, true); + foreach ($attachments as $attachment) { + $filenameArray = explode('.', $attachment->getFilename()); + $extension = $filenameArray[count($filenameArray) - 1]; + if (in_array($extension, $allowed)) { + if (!file_exists($directory . $attachment->getFilename())) { + file_put_contents( + $directory . $attachment->getFilename(), + $attachment->getDecodedContent() + ); + } + if ($attachment->getFilename() !== 'undefined') { + $url = config('app.settings.app_base_url') . str_replace('./', '/', $directory . $attachment->getFilename()); + $structure = $attachment->getStructure(); + if (isset($structure->id) && str_contains($obj['content'], trim($structure->id, '<>'))) { + $obj['content'] = str_replace('cid:' . trim($structure->id, '<>'), $url, $obj['content']); + } + $obj['attachments'][] = [ + 'file' => $attachment->getFilename(), + 'url' => $url + ]; + } + } + } + } + $response['data'][] = $obj; + if (!$message->isSeen()) { + $response['notifications'][] = [ + 'subject' => $obj['subject'], + 'sender_name' => $obj['sender_name'], + 'sender_email' => $obj['sender_email'] + ]; + if (config('app.zemail_log')) { + file_put_contents(storage_path('logs/zemail.csv'), request()->ip() . "," . date("Y-m-d h:i:s a") . "," . $obj['sender_email'] . "," . $email . PHP_EOL, FILE_APPEND); + } + } + $message->markAsSeen(); + if (++$count > $limit) { + break; + } + } + $response['data'] = array_reverse($response['data']); + $connection->expunge(); + return $response; + } + + public static function deleteMessage($id): void + { + $connection = ZEmail::connectMailBox(); + $mailbox = $connection->getMailbox('INBOX'); + $mailbox->getMessage($id)->delete(); + $connection->expunge(); + } + + public static function getEmail($generate = false) { + if (Cookie::has('email')) { + return Cookie::get('email'); + } else { + return $generate ? ZEmail::generateRandomEmail() : null; + } + } + + public static function getEmails() { + if (Cookie::has('emails')) { + return unserialize(Cookie::get('emails')); + } else { + return []; + } + } + + public static function setEmail($email): void + { + $emails = unserialize(Cookie::get('emails')); + if (is_array($emails) && in_array($email, $emails)) { + Cookie::queue('email', $email, 43800); + } + } + + public static function removeEmail($email): void + { + $emails = ZEmail::getEmails(); + $key = array_search($email, $emails); + if ($key !== false) { + array_splice($emails, $key, 1); + } + if (count($emails) > 0) { + ZEmail::setEmail($emails[0]); + Cookie::queue('emails', serialize($emails), 43800); + } else { + Cookie::queue('email', '', -1); + Cookie::queue('emails', serialize([]), -1); + } + } + + public static function createCustomEmailFull($email): string + { + $data = explode('@', $email); + $username = $data[0]; + if (strlen($username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) { + $zemail = new ZEmail(); + $username = $zemail->generateRandomUsername(); + } + $domain = $data[1]; + return ZEmail::createCustomEmail($username, $domain); + } + + public static function createCustomEmail($username, $domain): string + { + $username = preg_replace('/[^a-zA-Z0-9+.]/', '', strtolower($username)); + + $settings = json_decode(config('app.settings.configuration_settings'), true); + $forbidden_ids = $settings['forbidden_ids'] ?? []; + $gmail_usernames = $settings['gmailUsernames'] ?? []; + $domains = $settings['domains'] ?? []; + + if (in_array($username, $forbidden_ids)) { + return ZEmail::generateRandomEmail(true); + } + + if ($username === '' && in_array($domain, ['gmail.com', 'googlemail.com'])) { + return ZEmail::generateRandomGmail(true); + } + + $zemail = new ZEmail(); + + if ($username === '' && in_array($domain, $domains)) { + return $zemail->generateRandomUsername().'@'.$domain; + } + + + + if (in_array($domain, ['gmail.com', 'googlemail.com'])) { + if (str_contains($username, '+')) { + [$check_username, $post_username] = explode('+', $username, 2); + + if (in_array($check_username, $gmail_usernames)) { + $email = $username . '@' . $domain; + } else { + $email = $zemail->getRandomGmailUser() . '+' . $post_username . '@' . $domain; + } + + } elseif (str_contains($username, '.')) { + $check_username = str_replace('.', '', $username); + + if (in_array($check_username, $gmail_usernames)) { + $email = $username . '@' . $domain; + } else { + $email = $zemail->generateRandomGmail() . '@' . $domain; + } + + } else { + $email = $zemail->getRandomGmailUser() . '+' . $username . '@' . $domain; + } + + ZEmail::storeEmail($email); + return $email; + } + + // Handle other custom domains + if (!in_array($domain, $domains)) { + return ZEmail::generateRandomEmail(true); + } + + $finalDomain = in_array($domain, $domains) ? $domain : ($domains[0] ?? 'example.com'); + $email = $username . '@' . $finalDomain; + + ZEmail::storeEmail($email); + return $email; + } + + + public static function generateRandomEmail($store = true): string + { + $zemail = new ZEmail(); + $domain = $zemail->getRandomDomain(); + if ($domain == "gmail.com") { + $rd = mt_rand(0,1); + if ($rd == 0) { + $email = $zemail->generateRandomGmail(); + } else { + $email = $zemail->getRandomGmailUser().'+'.$zemail->generateRandomUsername().'@gmail.com'; + } + } elseif ($domain == "googlemail.com") { + $rd = mt_rand(0,1); + if ($rd == 0) { + $email = $zemail->generateRandomGmail(); + } else { + $email = $zemail->getRandomGmailUser().'+'.$zemail->generateRandomUsername().'@googlemail.com'; + } + } else { + $email = $zemail->generateRandomUsername() . '@' . $domain; + } + if ($store) { + ZEmail::storeEmail($email); + } + return $email; + } + public static function generateRandomGmail($store = true): string + { + $zemail = new ZEmail(); + $uname = $zemail->getRandomGmailUser(); + $uname_len = strlen($uname); + $len_power = $uname_len - 1; + $combination = pow(2,$len_power); + $rand_comb = mt_rand(1,$combination); + $formatted = implode(' ',str_split($uname)); + $uname_exp = explode(' ', $formatted); + + $bin = intval(""); + for($i=0; $i<$len_power; $i++) { + $bin .= mt_rand(0,1); + } + $bin = explode(' ', implode(' ',str_split(strval($bin)))); + + $email = ""; + for($i=0; $i<$len_power; $i++) { + $email .= $uname_exp[$i]; + if($bin[$i]) { + $email .= "."; + } + } + $email .= $uname_exp[$i]; + $gmail_rand = mt_rand(1,10); + if($gmail_rand > 5) { + $email .= "@gmail.com"; + } else { + $email .= "@googlemail.com"; + } + if ($store) { + ZEmail::storeEmail($email); + } + return $email; + } + + private static function storeEmail($email): void + { + Log::create([ + 'ip' => request()->ip(), + 'email' => $email + ]); + Cookie::queue('email', $email, 43800); + $emails = Cookie::has('emails') ? unserialize(Cookie::get('emails')) : []; + if (!in_array($email, $emails)) { + ZEmail::incrementEmailStats(); + $emails[] = $email; + Cookie::queue('emails', serialize($emails), 43800); + } + } + + /** + * Stats Handling Functions + */ + public static function incrementEmailStats($count = 1): void + { + Meta::incrementEmailIdsCreated($count); + } + + public static function incrementMessagesStats($count = 1): void + { + Meta::incrementMessagesReceived($count); + } + + + + private function generateRandomUsername(): string + { + $start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0; + $end = json_decode(config('app.settings.configuration_settings'))->random_username_length_max ?? 0; + if ($start == 0 && $end == 0) { + return $this->generatePronounceableWord(); + } + return $this->generatedRandomBetweenLength($start, $end); + } + + protected function generatedRandomBetweenLength($start, $end): string + { + $length = rand($start, $end); + return $this->generateRandomString($length); + } + private function getRandomDomain() { + $domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; + $count = count($domains); + return $count > 0 ? $domains[rand(1, $count) - 1] : ''; + } + + private function getRandomGmailUser() { + $gmailusername = json_decode(config('app.settings.configuration_settings'))->gmailUsernames ?? []; + + $count = count($gmailusername); + return $count > 0 ? $gmailusername[rand(1, $count) - 1] : ''; + } + + private function generatePronounceableWord(): string + { + $c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones + $v = 'aeiou'; //vowels + $a = $c . $v; //both + $random = ''; + for ($j = 0; $j < 2; $j++) { + $random .= $c[rand(0, strlen($c) - 1)]; + $random .= $v[rand(0, strlen($v) - 1)]; + $random .= $a[rand(0, strlen($a) - 1)]; + } + return $random; + } + private function generateRandomString($length = 10): string + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + +} + + +// public static function createCustomEmail($username, $domain): string +// { +// $username = str_replace('[^a-zA-Z0-9]', '', strtolower($username)); +// $forbidden_ids = json_decode(config('app.settings.configuration_settings'))->forbidden_ids ?? []; +// $gmail_usernames = json_decode(config('app.settings.configuration_settings'))->gmailUsernames ?? []; +// if (in_array($username, $forbidden_ids)) { +// return ZEmail::generateRandomEmail(true); +// } +// $zemail = new ZEmail(); +// if($domain == "gmail.com") { +// +// if(str_contains($username, "+")){ +// $check_username = explode("+", $username)[0]; +// $post_username = explode("+", $username)[1]; +// if (in_array($check_username, $gmail_usernames)) { +// $email = $username . '@gmail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } else { +// +// $email = $zemail->getRandomGmailUser().'+'.$post_username.'@gmail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } +// } +// elseif(str_contains($username, ".")){ +// $check_username = str_replace(".","",$username); +// +// if (in_array($check_username, $gmail_usernames)) { +// $email = $username . '@gmail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } else { +// +// $email = $zemail->generateRandomGmail(); +// ZEmail::storeEmail($email); +// return $email; +// } +// +// } +// else { +// +// $email = $zemail->getRandomGmailUser().'+'.$username.'@gmail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } +// } elseif($domain == "googlemail.com") { +// if(str_contains($username, "+")){ +// $check_username = explode("+", $username)[0]; +// $post_username = explode("+", $username)[1]; +// +// if (in_array($check_username, $gmail_usernames)) { +// $email = $username . '@googlemail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } else { +// +// $email = $zemail->getRandomGmailUser().'+'.$post_username.'@googlemail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } +// } +// elseif(str_contains($username, ".")){ +// $check_username = str_replace(".","",$username); +// +// if (in_array($check_username, $gmail_usernames)) { +// $email = $username . '@googlemail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } else { +// +// $email = $zemail->generateRandomGmail(); +// ZEmail::storeEmail($email); +// return $email; +// } +// } +// else { +// $email = $zemail->getRandomGmailUser().'+'.$username.'@googlemail.com'; +// ZEmail::storeEmail($email); +// return $email; +// } +// } else { +// $domains = json_decode(config('app.settings.configuration_settings'))->domains ?? []; +// if (in_array($domain, $domains)) { +// $email = $username . '@' . $domain; +// ZEmail::storeEmail($email); +// return $email; +// } else { +// $email = $username . '@' . $domains[0]; +// ZEmail::storeEmail($email); +// return $email; +// } +// +// } +// } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..d4653cb 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use DB; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -19,6 +20,12 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + $settings = cache()->remember('app_settings', now()->addMinutes(1), function () { + return (array) DB::table('settings')->find(1); + }); + if ($settings) { + config(['app.settings' => (array) $settings]); + } + } } diff --git a/composer.json b/composer.json index 93ef155..03b7421 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,14 @@ "license": "MIT", "require": { "php": "^8.2", + "ddeboer/imap": "^1.14", "filament/filament": "3.3", "laravel/framework": "^12.0", "laravel/tinker": "^2.10.1", "livewire/livewire": "^3.6" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.15", "fakerphp/faker": "^1.23", "laravel/pail": "^1.2.2", "laravel/pint": "^1.13", diff --git a/composer.lock b/composer.lock index 41044a9..c7f2dd0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e94c40ed9395f89fa0d1acf8500fe2b3", + "content-hash": "3c178f04aa87a34364e767ad999d5889", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -456,6 +456,82 @@ ], "time": "2025-02-21T08:52:11+00:00" }, + { + "name": "ddeboer/imap", + "version": "1.19.0", + "source": { + "type": "git", + "url": "https://github.com/ddeboer/imap.git", + "reference": "30800b1cfeacc4add5bb418e40a8b6e95a8a04ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ddeboer/imap/zipball/30800b1cfeacc4add5bb418e40a8b6e95a8a04ac", + "reference": "30800b1cfeacc4add5bb418e40a8b6e95a8a04ac", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-iconv": "*", + "ext-imap": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "php": "~8.2.0 || ~8.3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.38.2", + "laminas/laminas-mail": "^2.25.1", + "phpstan/phpstan": "^1.10.43", + "phpstan/phpstan-phpunit": "^1.3.15", + "phpstan/phpstan-strict-rules": "^1.5.2", + "phpunit/phpunit": "^10.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ddeboer\\Imap\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David de Boer", + "email": "david@ddeboer.nl" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com" + }, + { + "name": "Community contributors", + "homepage": "https://github.com/ddeboer/imap/graphs/contributors" + } + ], + "description": "Object-oriented IMAP for PHP", + "keywords": [ + "email", + "imap", + "mail" + ], + "support": { + "issues": "https://github.com/ddeboer/imap/issues", + "source": "https://github.com/ddeboer/imap/tree/1.19.0" + }, + "funding": [ + { + "url": "https://github.com/Slamdunk", + "type": "github" + }, + { + "url": "https://github.com/ddeboer", + "type": "github" + } + ], + "time": "2023-11-20T14:41:54+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -7459,6 +7535,91 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.15.4", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/c0667ea91f7185f1e074402c5788195e96bf8106", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11|^12", + "illuminate/session": "^9|^10|^11|^12", + "illuminate/support": "^9|^10|^11|^12", + "php": "^8.1", + "php-debugbar/php-debugbar": "~2.1.1", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^7|^8|^9|^10", + "phpunit/phpunit": "^9.5.10|^10|^11", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + }, + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.15-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "dev", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.15.4" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-04-16T06:32:06+00:00" + }, { "name": "brianium/paratest", "version": "v7.8.3", @@ -8823,6 +8984,76 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-debugbar/php-debugbar", + "version": "v2.1.6", + "source": { + "type": "git", + "url": "https://github.com/php-debugbar/php-debugbar.git", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/16fa68da5617220594aa5e33fa9de415f94784a0", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0", + "shasum": "" + }, + "require": { + "php": "^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/php-debugbar/php-debugbar", + "keywords": [ + "debug", + "debug bar", + "debugbar", + "dev" + ], + "support": { + "issues": "https://github.com/php-debugbar/php-debugbar/issues", + "source": "https://github.com/php-debugbar/php-debugbar/tree/v2.1.6" + }, + "time": "2025-02-21T17:47:03+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", diff --git a/config/app.php b/config/app.php index 324b513..d7bc011 100644 --- a/config/app.php +++ b/config/app.php @@ -28,6 +28,9 @@ return [ 'env' => env('APP_ENV', 'production'), + 'zemail_log' => env('ENABLE_ZEMAIL_LOGS', false), + 'beta_feature' => env('APP_BETA_FEATURE', false), + /* |-------------------------------------------------------------------------- | Application Debug Mode @@ -79,6 +82,8 @@ return [ */ 'locale' => env('APP_LOCALE', 'en'), + 'locales' => ['ar', 'de', 'en', 'fr', 'hi', 'pl', 'ru', 'es', 'vi', 'tr', 'no', 'id'], + 'locales_text' => ['Arabic', 'German', 'English', 'French', 'Hindi', 'Polish', 'Russian', 'Spanish', 'Vietnamese', 'Turkish', 'Norwegian', 'Indonesian'], 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), diff --git a/config/debugbar.php b/config/debugbar.php new file mode 100644 index 0000000..c6f8d77 --- /dev/null +++ b/config/debugbar.php @@ -0,0 +1,333 @@ + env('DEBUGBAR_ENABLED', null), + 'hide_empty_tabs' => true, // Hide tabs until they have content + 'except' => [ + 'telescope*', + 'horizon*', + ], + + /* + |-------------------------------------------------------------------------- + | Storage settings + |-------------------------------------------------------------------------- + | + | Debugbar stores data for session/ajax requests. + | You can disable this, so the debugbar stores data in headers/session, + | but this can cause problems with large data collectors. + | By default, file storage (in the storage folder) is used. Redis and PDO + | can also be used. For PDO, run the package migrations first. + | + | Warning: Enabling storage.open will allow everyone to access previous + | request, do not enable open storage in publicly available environments! + | Specify a callback if you want to limit based on IP or authentication. + | Leaving it to null will allow localhost only. + */ + 'storage' => [ + 'enabled' => true, + 'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback. + 'driver' => 'file', // redis, file, pdo, socket, custom + 'path' => storage_path('debugbar'), // For file driver + 'connection' => null, // Leave null for default connection (Redis/PDO) + 'provider' => '', // Instance of StorageInterface for custom driver + 'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver + 'port' => 2304, // Port to use with the "socket" driver + ], + + /* + |-------------------------------------------------------------------------- + | Editor + |-------------------------------------------------------------------------- + | + | Choose your preferred editor to use when clicking file name. + | + | Supported: "phpstorm", "vscode", "vscode-insiders", "vscode-remote", + | "vscode-insiders-remote", "vscodium", "textmate", "emacs", + | "sublime", "atom", "nova", "macvim", "idea", "netbeans", + | "xdebug", "espresso" + | + */ + + 'editor' => env('DEBUGBAR_EDITOR') ?: env('IGNITION_EDITOR', 'phpstorm'), + + /* + |-------------------------------------------------------------------------- + | Remote Path Mapping + |-------------------------------------------------------------------------- + | + | If you are using a remote dev server, like Laravel Homestead, Docker, or + | even a remote VPS, it will be necessary to specify your path mapping. + | + | Leaving one, or both of these, empty or null will not trigger the remote + | URL changes and Debugbar will treat your editor links as local files. + | + | "remote_sites_path" is an absolute base path for your sites or projects + | in Homestead, Vagrant, Docker, or another remote development server. + | + | Example value: "/home/vagrant/Code" + | + | "local_sites_path" is an absolute base path for your sites or projects + | on your local computer where your IDE or code editor is running on. + | + | Example values: "/Users//Code", "C:\Users\\Documents\Code" + | + */ + + 'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH'), + 'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', env('IGNITION_LOCAL_SITES_PATH')), + + /* + |-------------------------------------------------------------------------- + | Vendors + |-------------------------------------------------------------------------- + | + | Vendor files are included by default, but can be set to false. + | This can also be set to 'js' or 'css', to only include javascript or css vendor files. + | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) + | and for js: jquery and highlight.js + | So if you want syntax highlighting, set it to true. + | jQuery is set to not conflict with existing jQuery scripts. + | + */ + + 'include_vendors' => true, + + /* + |-------------------------------------------------------------------------- + | Capture Ajax Requests + |-------------------------------------------------------------------------- + | + | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), + | you can use this option to disable sending the data through the headers. + | + | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. + | + | Note for your request to be identified as ajax requests they must either send the header + | X-Requested-With with the value XMLHttpRequest (most JS libraries send this), or have application/json as a Accept header. + | + | By default `ajax_handler_auto_show` is set to true allowing ajax requests to be shown automatically in the Debugbar. + | Changing `ajax_handler_auto_show` to false will prevent the Debugbar from reloading. + | + | You can defer loading the dataset, so it will be loaded with ajax after the request is done. (Experimental) + */ + + 'capture_ajax' => true, + 'add_ajax_timing' => false, + 'ajax_handler_auto_show' => true, + 'ajax_handler_enable_tab' => true, + 'defer_datasets' => false, + /* + |-------------------------------------------------------------------------- + | Custom Error Handler for Deprecated warnings + |-------------------------------------------------------------------------- + | + | When enabled, the Debugbar shows deprecated warnings for Symfony components + | in the Messages tab. + | + */ + 'error_handler' => false, + + /* + |-------------------------------------------------------------------------- + | Clockwork integration + |-------------------------------------------------------------------------- + | + | The Debugbar can emulate the Clockwork headers, so you can use the Chrome + | Extension, without the server-side code. It uses Debugbar collectors instead. + | + */ + 'clockwork' => false, + + /* + |-------------------------------------------------------------------------- + | DataCollectors + |-------------------------------------------------------------------------- + | + | Enable/disable DataCollectors + | + */ + + 'collectors' => [ + 'phpinfo' => false, // Php version + 'messages' => true, // Messages + 'time' => true, // Time Datalogger + 'memory' => true, // Memory usage + 'exceptions' => true, // Exception displayer + 'log' => true, // Logs from Monolog (merged in messages if enabled) + 'db' => true, // Show database (PDO) queries and bindings + 'views' => true, // Views with their data + 'route' => false, // Current route information + 'auth' => false, // Display Laravel authentication status + 'gate' => true, // Display Laravel Gate checks + 'session' => false, // Display session data + 'symfony_request' => true, // Only one can be enabled.. + 'mail' => true, // Catch mail messages + 'laravel' => true, // Laravel version and environment + 'events' => false, // All events fired + 'default_request' => false, // Regular or special Symfony request logger + 'logs' => false, // Add the latest log messages + 'files' => false, // Show the included files + 'config' => false, // Display config settings + 'cache' => false, // Display cache events + 'models' => true, // Display models + 'livewire' => true, // Display Livewire (when available) + 'jobs' => false, // Display dispatched jobs + 'pennant' => false, // Display Pennant feature flags + ], + + /* + |-------------------------------------------------------------------------- + | Extra options + |-------------------------------------------------------------------------- + | + | Configure some DataCollectors + | + */ + + 'options' => [ + 'time' => [ + 'memory_usage' => false, // Calculated by subtracting memory start and end, it may be inaccurate + ], + 'messages' => [ + 'trace' => true, // Trace the origin of the debug message + 'capture_dumps' => false, // Capture laravel `dump();` as message + ], + 'memory' => [ + 'reset_peak' => false, // run memory_reset_peak_usage before collecting + 'with_baseline' => false, // Set boot memory usage as memory peak baseline + 'precision' => 0, // Memory rounding precision + ], + 'auth' => [ + 'show_name' => true, // Also show the users name/email in the debugbar + 'show_guards' => true, // Show the guards that are used + ], + 'db' => [ + 'with_params' => true, // Render SQL with the parameters substituted + 'exclude_paths' => [ // Paths to exclude entirely from the collector +// 'vendor/laravel/framework/src/Illuminate/Session', // Exclude sessions queries + ], + 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. + 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) + 'timeline' => false, // Add the queries to the timeline + 'duration_background' => true, // Show shaded background on each query relative to how long it took to execute. + 'explain' => [ // Show EXPLAIN output on queries + 'enabled' => false, + ], + 'hints' => false, // Show hints for common mistakes + 'show_copy' => true, // Show copy button next to the query, + 'slow_threshold' => false, // Only track queries that last longer than this time in ms + 'memory_usage' => false, // Show queries memory usage + 'soft_limit' => 100, // After the soft limit, no parameters/backtrace are captured + 'hard_limit' => 500, // After the hard limit, queries are ignored + ], + 'mail' => [ + 'timeline' => true, // Add mails to the timeline + 'show_body' => true, + ], + 'views' => [ + 'timeline' => true, // Add the views to the timeline + 'data' => false, // True for all data, 'keys' for only names, false for no parameters. + 'group' => 50, // Group duplicate views. Pass value to auto-group, or true/false to force + 'exclude_paths' => [ // Add the paths which you don't want to appear in the views + 'vendor/filament' // Exclude Filament components by default + ], + ], + 'route' => [ + 'label' => true, // Show complete route on bar + ], + 'session' => [ + 'hiddens' => [], // Hides sensitive values using array paths + ], + 'symfony_request' => [ + 'label' => true, // Show route on bar + 'hiddens' => [], // Hides sensitive values using array paths, example: request_request.password + ], + 'events' => [ + 'data' => false, // Collect events data, listeners + ], + 'logs' => [ + 'file' => null, + ], + 'cache' => [ + 'values' => true, // Collect cache values + ], + ], + + /* + |-------------------------------------------------------------------------- + | Inject Debugbar in Response + |-------------------------------------------------------------------------- + | + | Usually, the debugbar is added just before , by listening to the + | Response after the App is done. If you disable this, you have to add them + | in your template yourself. See http://phpdebugbar.com/docs/rendering.html + | + */ + + 'inject' => true, + + /* + |-------------------------------------------------------------------------- + | Debugbar route prefix + |-------------------------------------------------------------------------- + | + | Sometimes you want to set route prefix to be used by Debugbar to load + | its resources from. Usually the need comes from misconfigured web server or + | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97 + | + */ + 'route_prefix' => '_debugbar', + + /* + |-------------------------------------------------------------------------- + | Debugbar route middleware + |-------------------------------------------------------------------------- + | + | Additional middleware to run on the Debugbar routes + */ + 'route_middleware' => [], + + /* + |-------------------------------------------------------------------------- + | Debugbar route domain + |-------------------------------------------------------------------------- + | + | By default Debugbar route served from the same domain that request served. + | To override default domain, specify it as a non-empty value. + */ + 'route_domain' => null, + + /* + |-------------------------------------------------------------------------- + | Debugbar theme + |-------------------------------------------------------------------------- + | + | Switches between light and dark theme. If set to auto it will respect system preferences + | Possible values: auto, light, dark + */ + 'theme' => env('DEBUGBAR_THEME', 'auto'), + + /* + |-------------------------------------------------------------------------- + | Backtrace stack limit + |-------------------------------------------------------------------------- + | + | By default, the Debugbar limits the number of frames returned by the 'debug_backtrace()' function. + | If you need larger stacktraces, you can increase this number. Setting it to 0 will result in no limit. + */ + 'debug_backtrace_limit' => 50, +]; diff --git a/database/migrations/2025_04_22_231534_add_configuration_settings_to_settings_table.php b/database/migrations/2025_04_22_231534_add_configuration_settings_to_settings_table.php new file mode 100644 index 0000000..d8df9b4 --- /dev/null +++ b/database/migrations/2025_04_22_231534_add_configuration_settings_to_settings_table.php @@ -0,0 +1,28 @@ +json('configuration_settings')->default('[]')->after('imap_settings'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('configuration_settings'); + }); + } +}; diff --git a/database/migrations/2025_04_23_004834_add_ads_settings_to_settings_table.php b/database/migrations/2025_04_23_004834_add_ads_settings_to_settings_table.php new file mode 100644 index 0000000..2008a57 --- /dev/null +++ b/database/migrations/2025_04_23_004834_add_ads_settings_to_settings_table.php @@ -0,0 +1,28 @@ +json('ads_settings')->default('[]')->after('configuration_settings'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('ads_settings'); + }); + } +}; diff --git a/database/migrations/2025_04_23_101602_create_metas_table.php b/database/migrations/2025_04_23_101602_create_metas_table.php new file mode 100644 index 0000000..59d9c8f --- /dev/null +++ b/database/migrations/2025_04_23_101602_create_metas_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('key'); + $table->text('value')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('metas'); + } +}; diff --git a/database/migrations/2025_04_23_104947_create_logs_table.php b/database/migrations/2025_04_23_104947_create_logs_table.php new file mode 100644 index 0000000..560d9d1 --- /dev/null +++ b/database/migrations/2025_04_23_104947_create_logs_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('ip'); + $table->string('email'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('logs'); + } +}; diff --git a/database/migrations/2025_04_23_120910_create_messages_table.php b/database/migrations/2025_04_23_120910_create_messages_table.php new file mode 100644 index 0000000..e571c8e --- /dev/null +++ b/database/migrations/2025_04_23_120910_create_messages_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('subject'); + $table->string('from'); + $table->string('to'); + $table->text('body'); + $table->text('attachments')->nullable()->default(null); + $table->boolean('is_seen')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('messages'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index d01a0ef..8761330 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -14,10 +14,8 @@ class DatabaseSeeder extends Seeder public function run(): void { // User::factory(10)->create(); - - User::factory()->create([ - 'name' => 'Test User', - 'email' => 'test@example.com', + $this->call([ + MetaSeeder::class, ]); } } diff --git a/database/seeders/MetaSeeder.php b/database/seeders/MetaSeeder.php new file mode 100644 index 0000000..7863f32 --- /dev/null +++ b/database/seeders/MetaSeeder.php @@ -0,0 +1,28 @@ +email_ids_created = 0; + $metas->messages_received = 0; + foreach ($metas as $key => $meta) { + if (!Meta::where('key', $key)->exists()) { + Meta::create([ + 'key' => $key, + 'value' => $meta + ]); + } + } + } +} diff --git a/routes/web.php b/routes/web.php index 86a06c5..f524a90 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,25 @@ random_username_length_max ?? 0; + //return json_decode(config('app.settings.configuration_settings')) ?? []; +}); + +Route::get('bc', function (){ + return ZEmail::check(); +}); + +Route::get('zz', function (){ + try { + ZEmail::connectMailBox(); + } catch (Exception $ex) { + return $ex->getMessage(); + } +}); diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore