<?php

$array = db_request(db_execute("SELECT ID,TITLE,PHP_SELF,SEARCH_PHP_SELF,SEARCH_VARS FROM SAVED_INFO WHERE ID='".$_REQUEST['id']."'"));
$array = $array[1];
$array['PHP_SELF'] = str_replace('&amp;','?',substr($array['PHP_SELF'],20));

if(strpos($array['PHP_SELF'],'?search_servicefunction=list')!==false)
	unset($_SYSTEM['modules_search']);

if(strpos($array['PHP_SELF'],'?')!==false)
{
	$vars = substr($array['PHP_SELF'],(strpos($array['PHP_SELF'],'?')+1));
	$servicemod = substr($array['PHP_SELF'],0,strpos($array['PHP_SELF'],'?'));

	$vars = explode('?',$vars);
	
	//print_r($vars);die;	

	foreach($vars as $code)
	{
    	//print_r($code);die;
		$equals = strpos($code,'=');
    
    	$request_arrays[] = substr($code,0,$equals);
		
    	//print_r($equals);die;
    	
		// if(strpos($code,'[')!==false)
		// {
		// 	$req_var = "\$request_arrays[".preg_replace('([^]])\[','\1][',substr($code,0,$equals));
		// 	$req_var = str_replace('[',"['",str_replace(']',"']",$req_var));
		// 	$continue = false;
		// 	eval("if(isset($req_var)) \$continue=true;");
		// 	if($continue==true)
		// 		continue;
		// 	if(urldecode(substr($code,$equals+1))=='')
		// 		continue;
		// 	$code = $req_var . "='".urldecode(substr($code,$equals+1))."';";
		// 	eval($code);
		// }
		// else
        if(!$_REQUEST[substr($code,0,$equals)])
			$_REQUEST[substr($code,0,$equals)] = urldecode(substr($code,$equals+1));
		elseif(substr($code,0,$equals)=='search_servicefunction')
			unset($_SYSTEM['modules_search']);
	}
}
else
	$servicemod = $array['PHP_SELF'];

if($servicemod=='mod_users/UsrAdvancedReport.php')
	$_SYSTEM['user_search'] = true;

foreach($request_arrays as $key=>$value)
	$_REQUEST[$key] = $value;

$_SESSION['Search_PHP_SELF'] = $array['SEARCH_PHP_SELF'];
$_SESSION['Search_vars'] = unserialize($array['SEARCH_VARS']);

$run_report_require_request_vars = $_REQUEST;

if (strpos($servicemod,'=') > 0)
    $servicemod = substr($servicemod,strpos($servicemod,'=')+1,strlen($servicemod));
require($staticpath.'modules/'.$servicemod);
?>
