<?php
class rewrite{	
  function parameter(){
	 if(!config::get("rewrite")) return false;
	 if(!isset($_GET['parameter'])) return false;
	 $parameter = explode("/",$_GET['parameter']);
	 unset($_GET['parameter']);
	 foreach($parameter as $key=>$val){
		$arr = explode('-',$val);
		if($arr[0]){
           $_GET[$arr[0]] = $arr[1];		
		}
	 }
	 $request = geturl();
	 $posnum = strpos($request,'?');
     if($posnum){
	    $request = substr($request,$posnum+1);
	    $request = explode("&",$request);
	    foreach($request as $key=>$val){
		  $arr = explode('=',$val);
		  if($arr[0]){
			 if($arr[0]=='notify_time') $arr[1]=str_replace("+"," ",$arr[1]);
             $_GET[$arr[0]] = rawurldecode($arr[1]);		
		  }
	    }
	 }
  }
  
  function request($request=''){
	 $request = strpos($request,'?')===false ? $request : config::get('siteurl').'index.php'.$request;
	 if(!config::get("rewrite")) return $request;
	 $pos = strpos($request,'?');
	 $request = substr($request,$pos+1);
	 $arr = explode("&",$request);
	 unset($request);
	 foreach($arr as $key=>$val){
	   if($val!=''){
	     $array = explode("=",$val);
		 if(in_array($array[0],array('mod','act'))){
		 	 $request.='/'.$array[1];
	 	 }else{
			 $request.='/'.$array[0].'-'.$array[1];
		 }
	   }
	 }
	 return $request;
  } 
}
?>