1<?PHP2 functionEncode_file_contents ($filename) { 3 4 $type=Strtolower(substr(STRRCHR($filename, '. '), 1)); 5 if(' php ' = =$type&&Is_file($filename) &&is_writable($filename)) {//compressed code if PHP file is writable6 $contents=file_get_contents($filename);//determine if the file has been encoded7 $contents=Php_strip_whitespace($filename); 8 9 //Remove PHP header and tail markingsTen $headerPos=Strpos($contents, ' <?php '); One $footerPos=Strrpos($contents, '?> '); A $contents=substr($contents,$headerPos+ 5,$footerPos-$headerPos); - $encode=Base64_encode(gzdeflate($contents));//Start Coding - $encode= ' <?php '. " \ n Eval (gzinflate (Base64_decode ("." ").$encode."‘".")));\ N\n?> "; the - return file_put_contents($filename,$encode); - } - return false; + } - + //calling Functions A $filename= './test.php '; atEncode_file_contents ($filename); - Echo"OK, encryption done!" "; -?>
PHP Code encryption