Created
April 28, 2020 12:11
-
-
Save Cvar1984/95b2b9332f38fa19c484561caea8be0b to your computer and use it in GitHub Desktop.
Php quick encode file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Copyright (c) 2020 Ramdhan Firmansyah | |
| * File : encode.php | |
| * @author : Cvar1984 <[email protected]> | |
| * Date : 28.04.2020 | |
| * Last Modified Date: 28.04.2020 | |
| * Last Modified By : Cvar1984 <[email protected]> | |
| */ | |
| while (!file_exists($fileName)) { | |
| $fileName = readline('File Name : '); | |
| $fileName = trim($fileName); | |
| } | |
| $outputName = readline('Output Name : '); | |
| $outputName = trim($outputName); | |
| $fileContents = file_get_contents($fileName); | |
| $fileContents = base64_encode(gzdeflate($fileContents)); | |
| $fileContents = '<?php eval(\'?>\' . gzinflate(base64_decode(\'' . $fileContents . '\')));'; | |
| if (file_put_contents($outputName, $fileContents)) { | |
| echo 'Original Size : ' . filesize($fileName) . ' Bytes' . PHP_EOL; | |
| echo 'Encoded Size : ' . filesize($outputName) . ' Bytes' . PHP_EOL; | |
| } else { | |
| echo 'Can\'t write output permission denied' . PHP_EOL; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment