Skip to content

Instantly share code, notes, and snippets.

@moksamedia
Created July 30, 2015 23:13
Show Gist options
  • Save moksamedia/d2a36ab16a32cc601043 to your computer and use it in GitHub Desktop.
Save moksamedia/d2a36ab16a32cc601043 to your computer and use it in GitHub Desktop.
Replaces escaped octal char codes in php with char
<?php
/**
* Created by PhpStorm.
* User: cantgetnosleep
* Date: 7/30/15
* Time: 4:50 PM
*/
$chars = array();
$i = 33;
for ($i=33; $i < 123; $i++ ) {
$oct = decoct($i);
if (strlen($oct) == 2) {
$oct = "0".$oct;
}
$char = chr($i);
echo $char." = ".$oct."\n";
$chars[$oct] = $char;
}
$fileText = file_get_contents('_admin.php');
$newText = $fileText;
foreach ($chars as $octCode => $charVal) {
$newText = str_replace("\\$octCode", $charVal, $newText, $count);
echo "\\$octCode - ".$count."\n";
}
echo $newText;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment