Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/Console.tar
Ðазад
Kernel.php 0000755 00000005377 15060130161 0006505 0 ustar 00 <?php /* * JobClass - Job Board Web Application * Copyright (c) BeDigit. All Rights Reserved * * Website: https://laraclassifier.com/jobclass * Author: Mayeul Akpovi (BeDigit - https://bedigit.com) * * LICENSE * ------- * This software is provided under a license agreement and may only be used or copied * in accordance with its terms, including the inclusion of the above copyright notice. * As this software is sold exclusively on CodeCanyon, * please review the full license details here: https://codecanyon.net/licenses/standard */ namespace App\Console; use App\Helpers\Common\Date; use Illuminate\Console\Scheduling\Schedule; use Throwable; class Kernel { public function __invoke(Schedule $schedule): void { $tz = Date::getAppTimeZone(); // Pruning Batches // Doc: https://laravel.com/docs/11.x/queues#pruning-batches // Delete all batches that finished over 48 hours ago try { $schedule->command('queue:prune-batches --hours=48 --unfinished=72')->daily(); } catch (Throwable $e) { } // Deleting Expired Tokens (Resetting Password) // Doc: https://laravel.com/docs/11.x/passwords $schedule->command('auth:clear-resets')->timezone($tz)->everyFifteenMinutes(); // Clear Listings $schedule->command('listings:purge')->timezone($tz)->hourly(); // Backups setBackupConfig(); $disableNotifications = (config('settings.backup.disable_notifications')) ? ' --disable-notifications' : ''; // Taking Backups $takingBackup = config('settings.backup.taking_backup'); if ($takingBackup != 'none') { $takingBackupAt = config('settings.backup.taking_backup_at'); $takingBackupAt = ($takingBackupAt != '') ? $takingBackupAt : '00:00'; if ($takingBackup == 'daily') { $schedule->command('backup:run' . $disableNotifications)->timezone($tz)->dailyAt($takingBackupAt); } if ($takingBackup == 'weekly') { $schedule->command('backup:run' . $disableNotifications)->timezone($tz)->weeklyOn(1, $takingBackupAt); } if ($takingBackup == 'monthly') { $schedule->command('backup:run' . $disableNotifications)->timezone($tz)->monthlyOn(1, $takingBackupAt); } if ($takingBackup == 'yearly') { $schedule->command('backup:run' . $disableNotifications)->timezone($tz)->yearlyOn(1, 1, $takingBackupAt); } // Cleaning Up Old Backups $schedule->command('backup:clean' . $disableNotifications)->timezone($tz)->daily(); } // Clear Cache & Views if (!env('DISABLE_CACHE_AUTO_CLEAR') || (int)env('DISABLE_CACHE_AUTO_CLEAR', 0) != 1) { $schedule->command('cache:clear')->timezone($tz)->weeklyOn(7, '6:00'); $schedule->command('cache:clear')->timezone($tz)->weeklyOn(7, '6:05'); // To prevent file lock issues (Optional) $schedule->command('view:clear')->timezone($tz)->weeklyOn(7, '6:00'); } } } TinkerCommand.php 0000644 00000010674 15060475772 0010035 0 ustar 00 <?php namespace Laravel\Tinker\Console; use Illuminate\Console\Command; use Illuminate\Support\Env; use Laravel\Tinker\ClassAliasAutoloader; use Psy\Configuration; use Psy\Shell; use Psy\VersionUpdater\Checker; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; class TinkerCommand extends Command { /** * Artisan commands to include in the tinker shell. * * @var array */ protected $commandWhitelist = [ 'clear-compiled', 'down', 'env', 'inspire', 'migrate', 'migrate:install', 'optimize', 'up', ]; /** * The console command name. * * @var string */ protected $name = 'tinker'; /** * The console command description. * * @var string */ protected $description = 'Interact with your application'; /** * Execute the console command. * * @return int */ public function handle() { $this->getApplication()->setCatchExceptions(false); $config = Configuration::fromInput($this->input); $config->setUpdateCheck(Checker::NEVER); $config->getPresenter()->addCasters( $this->getCasters() ); if ($this->option('execute')) { $config->setRawOutput(true); } $shell = new Shell($config); $shell->addCommands($this->getCommands()); $shell->setIncludes($this->argument('include')); $path = Env::get('COMPOSER_VENDOR_DIR', $this->getLaravel()->basePath().DIRECTORY_SEPARATOR.'vendor'); $path .= '/composer/autoload_classmap.php'; $config = $this->getLaravel()->make('config'); $loader = ClassAliasAutoloader::register( $shell, $path, $config->get('tinker.alias', []), $config->get('tinker.dont_alias', []) ); if ($code = $this->option('execute')) { try { $shell->setOutput($this->output); $shell->execute($code); } finally { $loader->unregister(); } return 0; } try { return $shell->run(); } finally { $loader->unregister(); } } /** * Get artisan commands to pass through to PsySH. * * @return array */ protected function getCommands() { $commands = []; foreach ($this->getApplication()->all() as $name => $command) { if (in_array($name, $this->commandWhitelist)) { $commands[] = $command; } } $config = $this->getLaravel()->make('config'); foreach ($config->get('tinker.commands', []) as $command) { $commands[] = $this->getApplication()->add( $this->getLaravel()->make($command) ); } return $commands; } /** * Get an array of Laravel tailored casters. * * @return array */ protected function getCasters() { $casters = [ 'Illuminate\Support\Collection' => 'Laravel\Tinker\TinkerCaster::castCollection', 'Illuminate\Support\HtmlString' => 'Laravel\Tinker\TinkerCaster::castHtmlString', 'Illuminate\Support\Stringable' => 'Laravel\Tinker\TinkerCaster::castStringable', ]; if (class_exists('Illuminate\Database\Eloquent\Model')) { $casters['Illuminate\Database\Eloquent\Model'] = 'Laravel\Tinker\TinkerCaster::castModel'; } if (class_exists('Illuminate\Process\ProcessResult')) { $casters['Illuminate\Process\ProcessResult'] = 'Laravel\Tinker\TinkerCaster::castProcessResult'; } if (class_exists('Illuminate\Foundation\Application')) { $casters['Illuminate\Foundation\Application'] = 'Laravel\Tinker\TinkerCaster::castApplication'; } $config = $this->getLaravel()->make('config'); return array_merge($casters, (array) $config->get('tinker.casters', [])); } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'], ]; } /** * Get the console command options. * * @return array */ protected function getOptions() { return [ ['execute', null, InputOption::VALUE_OPTIONAL, 'Execute the given code using Tinker'], ]; } } Commands/InstallFreshData.php 0000644 00000012305 15060612615 0012211 0 ustar 00 <?php /* * JobClass - Job Board Web Application * Copyright (c) BeDigit. All Rights Reserved * * Website: https://laraclassifier.com/jobclass * Author: Mayeul Akpovi (BeDigit - https://bedigit.com) * * LICENSE * ------- * This software is provided under a license agreement and may only be used or copied * in accordance with its terms, including the inclusion of the above copyright notice. * As this software is sold exclusively on CodeCanyon, * please review the full license details here: https://codecanyon.net/licenses/standard */ namespace App\Console\Commands; // Increase the server resources $iniConfigFile = __DIR__ . '/../../Helpers/Common/Functions/ini.php'; if (file_exists($iniConfigFile)) { include_once $iniConfigFile; } use Database\Seeders\SiteInfoSeeder; use Illuminate\Console\Command; use Illuminate\Support\Facades\Artisan; /* * This command run migrations and seeders (including the site info seeder) * WARNING: Never run this command on production! * NOTE: To run this command, the application must already be installed * * USAGE: * php artisan app:install-fresh-data --purchaseCode=ABC123 --email=admin@domain.tld --country=US * Artisan::call('app:install-fresh-data', ['--purchaseCode' => 'ABC123', ..., '--confirm' => true]); */ class InstallFreshData extends Command { private ?string $countryCode; private ?string $purchaseCode; private ?string $email; private ?string $password; /** * The name and signature of the console command. * * @var string */ protected $signature = 'app:install-fresh-data {--country= : The default country code} {--purchaseCode= : The purchase code} {--email= : The admin user\'s email address} {--password= : The admin user\'s email address} {--confirm : Automatically confirm the action}'; /** * The console command description. * * @var string */ protected $description = 'Run the fresh install seeder with array data.'; /** * Execute the console command. * * @throws \App\Exceptions\Custom\CustomException */ public function handle() { // Allow only local & demo env if (!isLocalEnv() && !isDemoEnv()) { $this->error('This command can only be executed on local environments.'); return; } // Exclude production env if (app()->isProduction()) { $this->error('This command can not be executed on production environments.'); return; } // Make sure that APP_DEBUG is set to true in the .env file if (!config('app.debug')) { $this->error('Debug needs to be enabled to execute this command.'); return; } // Make sure the app is installed if (!appIsInstalled()) { $this->error('The app is not installed yet. Make sure the app is installed to continue.'); return; } // Get the command arguments values $countryCode = $this->option('country'); $purchaseCode = $this->option('purchaseCode'); $email = $this->option('email'); $password = $this->option('password'); $autoConfirm = $this->option('confirm'); // Ask for confirmation if not auto-confirmed if (!$autoConfirm && !$this->confirm('Do you wish to continue?')) { $this->info('Action cancelled.'); return; } // Get the site info minimum data $this->countryCode = $countryCode ?? 'US'; $this->purchaseCode = $purchaseCode ?? env('PURCHASE_CODE'); $this->email = $email ?? 'admin@domain.tld'; $this->password = $password ?? '123456'; // Display the values to the user $this->info('The app will be installed using these information:'); $this->warn('Default Country Code: ' . ($this->countryCode ?? 'Not provided')); $this->warn('Purchase Code: ' . ($this->purchaseCode ?? 'Not provided')); $this->warn('Admin Email: ' . ($this->email ?? 'Not provided')); $this->warn('Admin Password: ' . ($this->password ?? 'Not provided')); // Ensure the testing environment is set up correctly Artisan::call('cache:clear'); Artisan::call('config:clear'); // Run migrations Artisan::call('migrate:fresh', ['--path' => '/database/migrations', '--force' => true]); $output = Artisan::output(); $this->info($output); // Seed default data Artisan::call('db:seed', ['--force' => true]); $output = Artisan::output(); $this->info($output); // Seed site info data $siteInfoSeeder = new SiteInfoSeeder(); $siteInfoSeeder->run($this->getSiteInfoData()); } /** * Get site info data * * @return array */ private function getSiteInfoData(): array { $data = []; // settings.app $app = [ 'name' => 'Site Name', 'slogan' => 'Your website\'s slogan', 'purchase_code' => $this->purchaseCode, 'email' => $this->email, ]; // settings.localization $localization = [ 'default_country_code' => $this->countryCode, ]; // settings.mail $mail = []; // settings $data['settings']['app'] = $app; $data['settings']['localization'] = $localization; $data['settings']['mail'] = $mail; // user $data['user'] = [ 'name' => 'Admin User', 'email' => $this->email, 'password' => $this->password, 'country_code' => $this->countryCode, ]; return $data; } } Commands/ListingsPurge.php 0000644 00000026672 15060612615 0011634 0 ustar 00 <?php /* * JobClass - Job Board Web Application * Copyright (c) BeDigit. All Rights Reserved * * Website: https://laraclassifier.com/jobclass * Author: Mayeul Akpovi (BeDigit - https://bedigit.com) * * LICENSE * ------- * This software is provided under a license agreement and may only be used or copied * in accordance with its terms, including the inclusion of the above copyright notice. * As this software is sold exclusively on CodeCanyon, * please review the full license details here: https://codecanyon.net/licenses/standard */ namespace App\Console\Commands; // Increase the server resources $iniConfigFile = __DIR__ . '/../../Helpers/Common/Functions/ini.php'; if (file_exists($iniConfigFile)) { include_once $iniConfigFile; } use App\Models\Country; use App\Models\Post; use App\Models\Scopes\ActiveScope; use App\Models\Scopes\ReviewedScope; use App\Models\Scopes\VerifiedScope; use App\Notifications\PostArchived; use App\Notifications\PostDeleted; use App\Notifications\PostWilBeDeleted; use Illuminate\Console\Command; use Illuminate\Support\Carbon; use Throwable; class ListingsPurge extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'listings:purge'; /** * The console command description. * * @var string */ protected $description = 'Delete all old Listings.'; /** * Default Ads Expiration Duration * * @var int */ private int $unactivatedPostsExpiration = 30; // Delete the unactivated Posts after this expiration private int $activatedPostsExpiration = 30; // Archive the activated Posts after this expiration private int $archivedPostsExpiration = 7; // Delete the archived Posts after this expiration private int $manuallyArchivedPostsExpiration = 90; // Delete the manually archived Posts after this expiration public function __construct() { parent::__construct(); $this->applyRequiredSettings(); } /** * Execute the console command. */ public function handle() { if (isDemoDomain(config('app.url'))) { $msg = t('demo_mode_message'); $this->cmdLogger($msg); exit(); } // Get all countries $countries = Country::query()->withoutAppends()->withoutGlobalScope(ActiveScope::class); if ($countries->doesntExist()) { $msg = 'No country found.'; $this->cmdLogger($msg); exit(); } // Get the default/current locale $defaultLocale = app()->getLocale(); // Browse countries foreach ($countries->lazy() as $country) { // Get the country locale $countryLocale = getCountryMainLangCode(collect($country)); if (empty($countryLocale) || !is_string($countryLocale)) { $countryLocale = $defaultLocale; } // Set the country locale app()->setLocale($countryLocale); // Get country's items $posts = Post::query() ->withoutAppends() ->withoutGlobalScopes([VerifiedScope::class, ReviewedScope::class]) ->inCountry($country->code); if ($posts->doesntExist()) { $msg = 'No listings in "' . $country->name . '" (' . strtoupper($country->code) . ') website.'; $this->cmdLogger($msg); continue; } /* * Items Processing (Using Eloquent Cursor Method) * The cursor method allows you to iterate through your database records using a cursor, which will only execute a single query. * When processing large amounts of data, the cursor method may be used to greatly reduce your memory usage */ foreach ($posts->lazy() as $post) { $this->itemProcessing($post, $country); } } $msg = 'END.'; $this->cmdLogger($msg); } /** * @param \App\Models\Post $post * @param \App\Models\Country $country * @return void */ private function itemProcessing(Post $post, Country $country): void { // Debug // if ($country->code != 'US') return; // Get the Country's TimeZone $timeZone = (!empty($country->time_zone)) ? $country->time_zone : config('app.timezone'); // Get the current Datetime $today = now($timeZone); // Ensure that the date columns are not null and are Carbon objects $createdAt = $post->created_at ?? now($timeZone); if (!$createdAt instanceof Carbon) { $createdAt = (new Carbon($createdAt))->timezone($timeZone); } $archivedAt = $post->archived_at ?? now($timeZone); if (!$archivedAt instanceof Carbon) { $archivedAt = (new Carbon($archivedAt))->timezone($timeZone); } $archivedManuallyAt = $post->archived_manually_at ?? now($timeZone); if (!$archivedManuallyAt instanceof Carbon) { $archivedManuallyAt = (new Carbon($archivedManuallyAt))->timezone($timeZone); } $deletionMailSentAt = $post->deletion_mail_sent_at ?? now($timeZone); if (!$deletionMailSentAt instanceof Carbon) { $deletionMailSentAt = (new Carbon($deletionMailSentAt))->timezone($timeZone); } // Debug // dd($createdAt->diffInDays($today)); /* For non-activated items */ if (!isVerifiedPost($post)) { // Delete non-active items after '$this->unactivatedPostsExpiration' days if ($createdAt->diffInDays($today) >= $this->unactivatedPostsExpiration) { $post->delete(); } /* * IMPORTANT * Exit: Non-activated item expected treatment applied */ return; } /* For activated items */ /* Is it a website with premium options enabled? */ /* * Important: * The basic packages can be saved as paid in the "payments" table by the OfflinePayment plugin * So, don't apply the fake basic features, so we have to exclude packages whose price is 0. */ $isNotBasic = fn ($q) => $q->where('price', '>', 0); // Subscription ============================================================ // Load the post's user's subscription payment $post->loadMissing([ 'user' => function ($query) use ($isNotBasic) { $query->with(['payment' => fn ($q) => $q->withWhereHas('package', $isNotBasic)]); }, ]); $hasValidSubscription = ( !empty($post->user) && !empty($post->user->payment) && !empty($post->user->payment->package) && !empty($post->user->payment->package->expiration_time) ); if ($hasValidSubscription) { $this->activatedPostsExpiration = $post->user->payment->package->expiration_time ?? 0; } /* Check if the item's user is premium|featured */ if (!empty($post->user) && $post->user->featured == 1) { // Un-featured the item's user when its payment expires du to the validity period if (empty($post->user->payment)) { $post->user->featured = 0; $post->push(); } } // Promotion ============================================================ // Load the post's promotion payment $post->loadMissing(['payment' => fn ($q) => $q->withWhereHas('package', $isNotBasic)]); if (!empty($post->payment) && !empty($post->payment->package)) { if (!empty($post->payment->package->expiration_time)) { $this->activatedPostsExpiration = $post->payment->package->expiration_time; } } /* Check if the item is premium|featured */ if ($post->featured == 1) { // Un-featured the item when its payment expires du to the validity period if (!empty($post->payment)) { /* * IMPORTANT * Exit: Premium|featured item expected treatment applied */ return; } // Un-featured $post->featured = 0; $post->save(); /* * Payment is not found: * Continue to apply non-premium|non-featured treatment */ } /* For non-archived items (Not to be confused with "non-activated items") */ // Auto-archive if (empty($post->archived_at)) { // Archive all activated Ads after '$this->activatedPostsExpiration' days if ($createdAt->diffInDays($today) >= $this->activatedPostsExpiration) { // Archive $post->archived_at = $today; $post->save(); if ($country->active == 1) { try { // Send Notification Email to the Author $post->notify(new PostArchived($post, $this->archivedPostsExpiration)); } catch (Throwable $e) { $msg = $e->getMessage() . PHP_EOL; $this->cmdLogger($msg); } } } /* * IMPORTANT * Exit: Non-archived item expected treatment applied */ return; } /* For archived items (Not to be confused with "activated items") */ // Auto-delete // $today = $today->addDays(4); // Debug // Count days since the item has been archived $daysSinceListingHasBeenArchived = $archivedAt->diffInDays($today); // Send one alert email each X day started from Y days before the final deletion until the item deletion (using 'archived_at') // Start alert email sending from 7 days earlier (for example) $daysEarlier = 7; // In days (Y) $intervalOfSending = 2; // In days (X) if (empty($post->archived_manually_at)) { $archivedPostsExpirationSomeDaysEarlier = $this->archivedPostsExpiration - $daysEarlier; } else { $archivedPostsExpirationSomeDaysEarlier = $this->manuallyArchivedPostsExpiration - $daysEarlier; } if ($daysSinceListingHasBeenArchived >= $archivedPostsExpirationSomeDaysEarlier) { // Update the '$daysEarlier' to show in the mail $daysEarlier = $daysEarlier - $daysSinceListingHasBeenArchived; if ($daysEarlier > 0) { // Count days since the item's deletion mail has been sent (Using the 'deletion_mail_sent_at' column) $daysSinceListingDeletionMailHasBeenSent = $deletionMailSentAt->diffInDays($today); /* * ============================================================= * Send a deletion mail when: * - deletion mails are never sent before * - the latest sending is earlier than the interval of sending * ============================================================= */ if (empty($post->deletion_mail_sent_at) || $daysSinceListingDeletionMailHasBeenSent >= $intervalOfSending) { try { $post->notify(new PostWilBeDeleted($post, $daysEarlier)); } catch (Throwable $e) { $msg = $e->getMessage() . PHP_EOL; $this->cmdLogger($msg); } // Update the field 'deletion_mail_sent_at' with today timestamp $post->deletion_mail_sent_at = $today; $post->save(); } } } // Delete all archived items '$this->archivedPostsExpiration' days later (using 'archived_at') if ($daysSinceListingHasBeenArchived >= $this->archivedPostsExpiration) { if ($country->active == 1) { try { // Send Notification Email to the Author $post->notify(new PostDeleted($post)); } catch (Throwable $e) { $msg = $e->getMessage() . PHP_EOL; $this->cmdLogger($msg); } } // Delete $post->delete(); } /* * IMPORTANT * Exit: Archived item expected treatment applied */ } // PRIVATE private function applyRequiredSettings(): void { $this->unactivatedPostsExpiration = (int)config( 'settings.cron.unactivated_listings_expiration', $this->unactivatedPostsExpiration ); $this->activatedPostsExpiration = (int)config( 'settings.cron.activated_listings_expiration', $this->activatedPostsExpiration ); $this->archivedPostsExpiration = (int)config( 'settings.cron.archived_listings_expiration', $this->archivedPostsExpiration ); $this->manuallyArchivedPostsExpiration = (int)config( 'settings.cron.manually_archived_listings_expiration', $this->manuallyArchivedPostsExpiration ); } /** * @param $msg * @return void */ private function cmdLogger($msg): void { if (isCli()) { $this->warn($msg); } else { $this->printWeb($msg); } } /** * @param $var */ private function printWeb($var) { // Only for Debug ! // echo '<pre>'; print_r($var); echo '</pre>'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка