Code: Select all
<?php
$file=fopen("hi.7bx","r") or exit("Unable to open file!");
$tag;
$char;
$inTag;
$skip;
while (!feof($file))
{
$char .= fgets($file);
if (strpos($char, "<body"))
break;
}
echo $char;
while (!feof($file))
{
$char = fgetc($file);
if ($char == "<")
$inTag = true;
else if ($char == ">"){
$inTag = false;
echo $char;
$skip = true;
}
if ($char == "\n" || $char == "\r")
$skip = true;
if(!$skip){
if ($inTag)
echo $char;
else
colorizeChar($char);
}else
$skip = false;
}
function colorizeChar($char2){
$num = mt_rand(0, 16777215);
$num = dechex($num);
echo "<font color = " . $num . ">" . $char2 . "</font>\n";
}
fclose($file);
?>
I made 2 versions of the page, with \n and without \n.
http://xyzcrew.info/test.php is exactly the code above and
http://xyzcrew.info/test2.php is exactly the code above with removed \n from the echo line in the colorizeChar function.
--MALON
P.S. If you're wondering about what a 7bx file is (because that's the file I'm opening), it's just a regular old text file with a renamed extension so that I could upload it in binary rather than ASCII. FileZilla automatically uploads recognized file extensions as ASCII. I didn't want the server OS (or my OS for some reason) to add in some strange characters, so I made it a crazy extension.
P.P.S. I'm using PHP 5.2.5