SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/usr/bin/env php | |
| 2 | <?php | |
| 3 | ||
| 4 | $file = [ | |
| 5 | 'name' => @$argv[2] ?? '', | |
| 6 | 'data' => @file_get_contents($argv[2]) | |
| 7 | ]; | |
| 8 | ||
| 9 | $argv[1] = @$argv[1] ?? ''; | |
| 10 | ||
| 11 | switch ($argv[1]) {
| |
| 12 | case 'i': | |
| 13 | if(empty($file['name'])) | |
| 14 | die("[ERROR] no input file specified\n");
| |
| 15 | ||
| 16 | if(!file_exists($file['name'])) | |
| 17 | die("[ERROR] file `{$file['name']}` does not exist\n");
| |
| 18 | file_put_contents($file['name'], gzinflate($file['data'])); | |
| 19 | break; | |
| 20 | case 'd': | |
| 21 | if(empty($file['name'])) | |
| 22 | die("[ERROR] no input file specified\n");
| |
| 23 | ||
| 24 | if(!file_exists($file['name'])) | |
| 25 | die("[ERROR] file `{$file['name']}` does not exist\n");
| |
| 26 | file_put_contents($file['name'], gzdeflate($file['data'])); | |
| 27 | break; | |
| 28 | case '': | |
| 29 | die("[ERROR] no action specified\n");
| |
| 30 | break; | |
| 31 | default: | |
| 32 | die("[ERROR] unknown action `{$argv[1]}`\n");
| |
| 33 | break; | |
| 34 | } |