Skip to content

Instantly share code, notes, and snippets.

@motebaya
Last active August 1, 2022 10:45
Show Gist options
  • Save motebaya/b0299c1714081b444f36cfbe41237f9b to your computer and use it in GitHub Desktop.
Save motebaya/b0299c1714081b444f36cfbe41237f9b to your computer and use it in GitHub Desktop.
for change /replace unreadable ascii variable to readable .
<?php
/*
this to replace all php ascii variable to human readable
author: motebaya
gihtub.com/motebaya
*/
function utf8($utf){
return iconv('UTF-8', 'ISO-8859-1', $utf);
}
function clearvar($fn, $out){
$file = utf8_encode(file_get_contents($fn));
if (preg_match_all('/(?:\\$[\\x{0080}-\\x{FFFF}]+)(?=\\W)/u', $file, $code)) {
$vars = array_unique($code[0]);
$word = preg_split("/\r\n|\n|\r/", file_get_contents("word.txt"));
foreach ($vars as $i => $cd) {
$vm = "\${$word[$i]}";
$file = str_replace($cd, $vm, $file);
}
if (file_put_contents($out, utf8($file))) {
die(" - saved in {$out}");
}
}
}
if (count($argv) < 3){
die("usage: php main.php <file/php> <out/php>");
} else {
clearvar($argv[1], $argv[2]);
}
?>
@motebaya
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment