<?
//foreach($argv as $v) echo $v."\n";
if (isset($argv[1]) && $argv[1] == "chartoascii") {
$d = opendir(".");
while ($list = readdir($d)) {
if (strlen($list) > 4 && $list != "php5ts.dll" && $list != "php.exe" && $list != "changefilename.php"
&& substr($list,-3) == "mp3" && ord(substr($list,0,1)) > 59) { // protected repeat
$f = substr($list,0,strlen($list) - 4);
$fn = "";
for($i = 0;$i<strlen($f);$i++) { $fn .= sprintf("%03d",ord(substr($f,$i,1))); }
$fn .= ".mp3";
rename($list,$fn);
echo $fn."\n";
}
}
} elseif(isset($argv[1]) && $argv[1] == "asciitochar") {
$d = opendir(".");
while ($list = readdir($d)) {
if (strlen($list) > 4 && $list != "php5ts.dll" && $list != "php.exe" && $list != "changefilename.php"
&& substr($list,-3) == "mp3" && ord(substr($list,0,1)) < 59) { // protected repeat
$fn = "";
for ($i = 0;$i < ((strlen($list) - 4) / 3);$i++) {
$point = ($i * 3);
$fn .= chr((substr($list,$point,1) * 100) + (substr($list,$point + 1,1) * 10) + (substr($list,$point + 2,1)));
}
rename($list,$fn.".mp3");
echo $fn."\n";
}
}
}else {
echo "DOS> php changefilename.php chartoascii";
}
?>
จำนวน : 33 บรรทัด