简体   繁体   中英

convert_uuencode a php file

I want to encode a php file with uuencode to use it with

eval(gzuncompress(convert_uudecode("somedata");

I only found a way to encode a string, but no way to encode a complete php file (or php code).

Thanks!

Read the file first

http://php.net/manual/en/function.file-get-contents.php

Encode the content and then do whatever you want with it.

You can simply read data of your file

$contentString = file_get_contents(PATH_TO_PHP/some.php)

adn then do same eval(gzuncompress(convert_uudecode($contentString)));

UPDATE

if you need to have as result this string

<?php eval(gzuncompress(convert_uudecode("M>)S=6PEOVTBR_BL90,\\x5c2(9D0;W+\\x5c%.Q@UKL;O,7,K. ............. a")));

you have to do following

// Reading file content
$phpFileContent = file_get_content("PATH/some.php");

// Remove <?php and ?> from your content
$phpFileContent = str_replace(array('<?php', '?>'), '', $phpFileContent);

// Encoding and compressing
$phpFileContent = convert_uuencode(  gzcompress($phpFileContent) );

// Your result string
$result = '<?php eval(gzuncompress(convert_uudecode("' . $phpFileContent . '")));';

//which you can write to some other php file with file_put_contensts
file_put_contents ( 'PATH_TO_RESULT_FILE/result.php' , $result);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM