fjffk简单的咖啡店科开发2方法2 环滁皆山也。其西南诸峰,林壑尤美,望之蔚然而深秀者,琅琊也。山行六七里,渐闻水声潺潺,而泻出于两峰之间者,酿泉也 ??????????????????????????????? ??????????????/????????????????? ............/................... .........................../... ??????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dsdfREADME.md000064400000005540152665617510006045 0ustar00# Magic ai updater [![Latest Version on Packagist](https://img.shields.io/packagist/v/magicai/magicai-updater.svg?style=flat-square)](https://packagist.org/packages/magicai/magicai-updater) [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/magicai/magicai-updater/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/magicai/magicai-updater/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/magicai/magicai-updater/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/magicai/magicai-updater/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/magicai/magicai-updater.svg?style=flat-square)](https://packagist.org/packages/magicai/magicai-updater) This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. ## Support us [](https://spatie.be/github-ad-click/magicai-updater) We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). ## Installation You can install the package via composer: ```bash composer require magicai/magicai-updater ``` You can publish and run the migrations with: ```bash php artisan vendor:publish --tag="magicai-updater-migrations" php artisan migrate ``` You can publish the config file with: ```bash php artisan vendor:publish --tag="magicai-updater-config" ``` This is the contents of the published config file: ```php return [ ]; ``` Optionally, you can publish the views using ```bash php artisan vendor:publish --tag="magicai-updater-views" ``` ## Usage ```php $updater = new MagicAI\Updater(); echo $updater->echoPhrase('Hello, MagicAI!'); ``` ## Testing ```bash composer test ``` ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Security Vulnerabilities Please review [our security policy](../../security/policy) on how to report security vulnerabilities. ## Credits - [Rauf Abbaszade](https://github.com/rafoabbas) - [All Contributors](../../contributors) ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. src/Services/ExtensionReportService.php000064400000003774152665617510014351 0ustar00extensionRepository->checkSelectedExtensions($extensions); $report = [ 'total_extensions' => count($checkResults), 'valid_licenses' => 0, 'invalid_licenses' => 0, 'errors' => 0, 'extensions' => $checkResults, 'generated_at' => time(), ]; foreach ($checkResults as $result) { switch ($result['status']) { case 'valid': $report['valid_licenses']++; break; case 'invalid': $report['invalid_licenses']++; break; case 'error': $report['errors']++; break; } } return $report; } public function generateLicenseReport(): array { $checkResults = $this->extensionRepository->checkAllRegisteredExtensions(); $report = [ 'total_extensions' => count($checkResults), 'valid_licenses' => 0, 'invalid_licenses' => 0, 'errors' => 0, 'extensions' => $checkResults, 'generated_at' => time(), ]; foreach ($checkResults as $result) { switch ($result['status']) { case 'valid': $report['valid_licenses']++; break; case 'invalid': $report['invalid_licenses']++; break; case 'error': $report['errors']++; break; } } return $report; } } src/Services/ExtensionCacheService.php000064400000002664152665617510014076 0ustar00getCacheKey($registerKey); return Cache::get($cacheKey); } public function put(string $registerKey, bool $value): void { $cacheKey = $this->getCacheKey($registerKey); Cache::put($cacheKey, $value, $this->cacheInterval); } public function forget(string $registerKey): void { $cacheKey = $this->getCacheKey($registerKey); Cache::forget($cacheKey); } public function clearAll(string $registerKey): void { $cacheKey = $this->getCacheKey($registerKey); $lastCheckKey = $this->getLastCheckCacheKey($registerKey); Cache::forget($cacheKey); Cache::forget($lastCheckKey); } private function getCacheKey(string $registerKey): string { return $this->cachePrefix . $this->obfuscationHelper->obfuscateKey($registerKey); } private function getLastCheckCacheKey(string $registerKey): string { return $this->cachePrefix . 'last_check_' . $this->obfuscationHelper->obfuscateKey($registerKey); } } src/Services/ExtensionCleanupService.php000064400000011426152665617510014456 0ustar00extensionRepository->checkAllRegisteredExtensions(); $uninstalledExtensions = []; foreach ($checkResults as $result) { if ($result['status'] === 'invalid') { try { // Extension'ı uninstall et app(ExtensionUninstallService::class)->uninstall($result['slug']); // Lisans dosyasını sil $this->removeSecurityFile($result['slug']); // Cache'i temizle $this->cacheService->clearAll($result['slug']); $uninstalledExtensions[] = $result['slug']; Log::info('Extension removed due to security violation', [ 'extension' => $result['slug'], ]); } catch (Exception $e) { Log::error('Failed to remove invalid extension', [ 'extension' => $result['slug'], 'error' => $e->getMessage(), ]); } } } return $uninstalledExtensions; } public function removeSecurityFile(string $extensionSlug): bool { try { $hashedKey = $this->obfuscationHelper->obfuscateKey($extensionSlug); $securityFile = "{$this->managerFolder}/{$hashedKey}.lic"; if (Storage::disk('local')->exists($securityFile)) { Storage::disk('local')->delete($securityFile); Log::info('Security file removed', [ 'extension' => $extensionSlug, ]); return true; } return false; } catch (Exception $e) { Log::error('Failed to remove security file', [ 'extension' => $extensionSlug, 'error' => $e->getMessage(), ]); return false; } } public function fullCleanup(string $extensionSlug): bool { try { // 1. Extension'ı uninstall et app(ExtensionUninstallService::class)->uninstall($extensionSlug); // 2. Security dosyasını sil $this->removeSecurityFile($extensionSlug); // 3. Cache'i temizle $this->cacheService->clearAll($extensionSlug); Log::info('Full cleanup completed', [ 'extension' => $extensionSlug, ]); return true; } catch (Exception $e) { Log::error('Full cleanup failed', [ 'extension' => $extensionSlug, 'error' => $e->getMessage(), ]); return false; } } public function cleanupOrphanedFiles(): array { $cleanedFiles = []; try { $registeredExtensions = $this->extensionRepository->getRegisteredExtensions(); $allSecurityFiles = Storage::disk('local')->files($this->managerFolder); foreach ($allSecurityFiles as $file) { if (! str_ends_with($file, '.lic')) { continue; } $fileName = basename($file, '.lic'); $isOrphaned = true; // Kayıtlı extension'larla karşılaştır foreach (array_keys($registeredExtensions) as $extensionSlug) { $hashedKey = $this->obfuscationHelper->obfuscateKey($extensionSlug); if ($fileName === $hashedKey) { $isOrphaned = false; break; } } if ($isOrphaned) { Storage::disk('local')->delete($file); $cleanedFiles[] = $file; Log::info('Orphaned security file removed', [ 'file' => $file, ]); } } } catch (Exception $e) { Log::error('Failed to cleanup orphaned files', [ 'error' => $e->getMessage(), ]); } return $cleanedFiles; } } src/Services/ExtensionValidationService.php000064400000001401152665617510015151 0ustar00 $extensionSlug, 'status' => 'valid', 'source' => 'bypass', 'message' => 'License validation bypassed (always valid)', ]; } public function performValidation(string $registerKey): bool { return true; // Always valid } public function removeSecurityFile(string $extensionSlug): bool { // No-op (do nothing) Log::info("Bypassed security removal for extension: {$extensionSlug}"); return true; } } src/Helpers/ObfuscationHelper.php000064400000001527152665617510013105 0ustar00 'x7k9m2n5', 'salt2' => 'p3q8r1t6', 'salt3' => 'z4w7j0v9', ]; public function obfuscateKey(string $key): string { $combined = $key . $this->obfuscationKeys['salt3']; return hash('sha256', $combined); } public function getCacheKey(string $registerKey): string { return $this->cachePrefix . $this->obfuscateKey($registerKey); } public function getLastCheckCacheKey(string $registerKey): string { return $this->cachePrefix . 'last_check_' . $this->obfuscateKey($registerKey); } public function getSalt(string $key): string { return $this->obfuscationKeys[$key] ?? ''; } } src/Helpers/LicenseHelper.php000064400000004555152665617510012217 0ustar00get("{$this->managerFolder}/{$hashedKey}.lic") ); return unserialize($content); } public function validateLicenseContent(array $content): bool { $requiredFields = ['domain', 'domain_key', 'extension']; foreach ($requiredFields as $field) { if (! isset($content[$field])) { return false; } } if (! isset($content['checksum'])) { return false; } $expectedChecksum = $this->generateChecksum($content); return hash_equals($content['checksum'], $expectedChecksum); } public function generateChecksum(array $content): string { $data = $content['domain'] . $content['domain_key'] . $content['extension'] . $this->obfuscationHelper->getSalt('salt1'); return hash_hmac('sha256', $data, $this->obfuscationHelper->getSalt('salt2')); } public function getCurrentDomain(): string { return request()->getHost(); } public function getCurrentDomainKey(): string { return app(ExtensionRepositoryInterface::class)->domainKey(); } public function saveLicenseData(string $registerKey, array $data): void { $data['checksum'] = $this->generateChecksum($data); $encrypt = $this->encrypt($data); $hashedKey = $this->obfuscationHelper->obfuscateKey($registerKey); $this->save($hashedKey, $encrypt); } public function makeRemoteRequest(string $registerKey) { return app(ExtensionRepositoryInterface::class)->request( 'post', "extension/{$registerKey}/license", ); } private function encrypt(array $content): string { return encrypt(serialize($content)); } private function save(string $hashedKey, string $content): void { Storage::disk('local')->put("{$this->managerFolder}/{$hashedKey}.lic", $content); } } src/Exceptions/InvalidLicenseException.php000064400000000171152665617510014752 0ustar00getRegisteredExtensions(); $results = []; foreach ($extensions as $slug) { if (Helper::appIsDemo()) { $results[$slug] = [ 'status' => 'success', 'message' => 'Demo mode: License validation is not applicable.', ]; continue; } if (array_key_exists($slug, $regExtensions)) { $results[$slug] = $this->validationService->validateSingle($slug); } else { $results[$slug] = [ 'status' => 'error', 'message' => "Extension '$slug' is not registered.", ]; } } return $results; } public function checkAllRegisteredExtensions(): array { $registeredExtensions = $this->getRegisteredExtensions(); $results = []; foreach ($registeredExtensions as $slug => $providerClass) { if (Helper::appIsDemo()) { $results[$slug] = [ 'status' => 'success', 'message' => 'Demo mode: License validation is not applicable.', ]; continue; } $results[$slug] = $this->validationService->validateSingle($slug); } return $results; } public function getRegisteredExtensions(): array { $providers = MarketplaceServiceProvider::getExtensionProviders(); $loadedProviders = app()->getLoadedProviders(); return array_filter($providers, function ($provider) use ($loadedProviders) { return array_key_exists($provider, $loadedProviders); }); } } src/Commands/HealthyCommand.php000064400000000475152665617510012526 0ustar00comment('All done'); return self::SUCCESS; } } src/Http/Controllers/HealthyController.php000064400000001543152665617510014754 0ustar00get('extensions')) { $extensions = explode(',', $request->get('extensions')); } else { return response()->json(['error' => 'No extensions provided'], 400); } return response()->json($this->service->generateLicenseReportSelected($extensions)); } public function checkAll(): JsonResponse { return response()->json($this->service->generateLicenseReport()); } } src/Http/Middleware/HealthyMiddleware.php000064400000003205152665617510014452 0ustar00verify($k); return $n($r); } catch (InvalidLicenseException $e) { Log::warning('Access violation', [ 'id' => $this->s3->obfuscateKey($k), 'msg' => $e->getMessage(), 'addr' => $r->ip(), 'agent' => $r->userAgent(), ]); $this->s2->clearAll($k); abort(403); } } private function verify(string $k): void { $c = $this->s2->get($k); if ($c !== null) { if (! $c) { throw new InvalidLicenseException('Verification failed from cache.'); } return; } $v = $this->s1->performValidation($k); $this->s2->put($k, $v); if (! $v) { throw new InvalidLicenseException('Access denied.'); } } } src/HealthyServiceProvider.php000064400000003007152665617510012514 0ustar00name('magicai-healthy') ->hasConfigFile() ->hasViews() ->hasViewComponents('healthy', Permission::class, Li::class, Button::class) ->hasCommand(HealthyCommand::class); } public function bootingPackage() { $this->app->make(Router::class)->aliasMiddleware( 'healthy', HealthyMiddleware::class ); } public function packageRegistered(): void { Route::prefix('healthy') ->as('healthy.') ->middleware(['api']) ->group(function (Router $router) { $router->get('check/selected', [\MagicAI\Healthy\Http\Controllers\HealthyController::class, 'checkSelected']) ->name('check.selected'); $router->get('check/all', [\MagicAI\Healthy\Http\Controllers\HealthyController::class, 'checkAll']) ->name('check.all'); }); } } CHANGELOG.md000064400000000127152665617510006373 0ustar00# Changelog All notable changes to `magicai-updater` will be documented in this file. composer.json000064400000004606152665617510007312 0ustar00{ "name": "magicai/magicai-healthy", "description": "Magic ai healthy", "keywords": [ "MagicAI", "laravel", "magicai-healthy" ], "homepage": "https://github.com/magicai/magicai-healthy", "license": "MIT", "authors": [ { "name": "MagicAI Team", "email": "info@liquid-themes.com", "role": "Developer" } ], "require": { "php": "^8.2", "ext-zip": "*", "illuminate/contracts": "^10.0||^11.0", "spatie/laravel-package-tools": "^1.16" }, "require-dev": { "laravel/pint": "^1.14", "nunomaduro/collision": "^8.1.1||^7.10.0", "larastan/larastan": "^2.9", "orchestra/testbench": "^9.0.0||^8.22.0", "pestphp/pest": "^2.34", "pestphp/pest-plugin-arch": "^2.7", "pestphp/pest-plugin-laravel": "^2.3", "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^1.1", "phpstan/phpstan-phpunit": "^1.3", "spatie/laravel-ray": "^1.35" }, "autoload": { "psr-4": { "MagicAI\\Healthy\\": "src/", "MagicAI\\Healthy\\Database\\Factories\\": "database/factories/" } }, "autoload-dev": { "psr-4": { "MagicAI\\Healthy\\Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": "@composer run prepare", "clear": "@php vendor/bin/testbench package:purge-magicai-updater --ansi", "prepare": "@php vendor/bin/testbench package:discover --ansi", "build": [ "@composer run prepare" ], "start": [ "Composer\\Config::disableProcessTimeout", "@composer run build", "@php vendor/bin/testbench serve" ], "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", "format": "vendor/bin/pint" }, "config": { "sort-packages": true, "allow-plugins": { "pestphp/pest-plugin": true, "phpstan/extension-installer": true } }, "extra": { "laravel": { "providers": [ "MagicAI\\Healthy\\HealthyServiceProvider" ], "aliases": { } } }, "minimum-stability": "dev", "prefer-stable": true } config/magicai-checker.php000064400000000604152665617510011534 0ustar00 'https://api.liquid-themes.com/magicai/' . $path, 'updater_download_url' => 'https://api.liquid-themes.com/magicai/' . $path . 'updater.php.zip', 'version_url' => 'https://api.liquid-themes.com/magicai/' . $path . 'magicaiupdater.json', ];