All pastes #765678 Raw Edit

DbuG

public text v1 · immutable
·published 2007-11-08 07:49 UTC
rendered paste body
<?php
#define BZ_OK                0
#define BZ_RUN_OK            1
#define BZ_FLUSH_OK          2
#define BZ_FINISH_OK         3
#define BZ_STREAM_END        4
#define BZ_SEQUENCE_ERROR    (-1)
#define BZ_PARAM_ERROR       (-2)
#define BZ_MEM_ERROR         (-3)
#define BZ_DATA_ERROR        (-4)
#define BZ_DATA_ERROR_MAGIC  (-5)
#define BZ_IO_ERROR          (-6)
#define BZ_UNEXPECTED_EOF    (-7)
#define BZ_OUTBUFF_FULL      (-8)
#define BZ_CONFIG_ERROR      (-9)

$file = "corrupted.png.bz2";
/*$image = "corrupted.png";
$bz = bzopen($file, "r");
$ecd_cont = bzread($bz);

$fp = fopen($image,"wb");
$ecd_cont = bzdecompress($ecd_cont); 
fwrite($fp, $ecd_cont);
fclose($fp);
echo $ecd_cont;
bzclose($bz);
echo "<img src=\"./corrupted.png\">";
*/

$contents = file_get_contents($file);
$j = strlen($contents);

$arrCRLF = null;
$counter = 0;
$carr = 0;
$a = 0;

while ($a<$j) 
{
	if ((($contents[$a]) == "\r") && (($contents[$a+1]) == "\n")) {
		$counter = $counter+1;
		$arrCRLF[$carr] = $a;
		$carr = $carr + 1;
	}
	$a = $a+1;
}

$a = 0;

$ecd_cont = 0;

while ($a < $carr)
{
	//$bz = bzopen($file, "w");
	//$ecd_cont = bzread($bz);
	//$ecd_cont = bzdecompress($ecd_cont);
		//while ($ecd_cont != 1) {
			$str = $contents[$arrCRLF[$a]].$contents[$arrCRLF[$a]+1];
			echo bin2hex($str);
			//$lol = str_replace("\r\n","\n",$str);
			//$bz = bzopen($file, "w");
			//$ecd_cont = bzread($bz);
			//bzwrite($bz,$lol);
		//}
	//bzclose($bz);
	$a = $a+1;
}
echo "Counts of CRLFs: ".$counter;
?>