Search code examples
phpuudecode

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!


Solution

  • 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);