<?php

class Redirect extends Controller {

	function Redirect()
	{
		parent::Controller();
		$this->load->model('Functions');
		$this->config->load('katalog_config');
		$this->data = $this->config->item('data');
	}
	
	function sort()
	{
		if((isSet($_POST['s1']) or isSet($_POST['s2'])) and isSet($_POST['url']))
		{
			$uri = 'http://'.$this->data['domeny']['firmy'].'.'.$this->data['domena'].'/'.$this->data['catcontroller'];
      if(!empty($_POST['kategoria']))$uri .= '/'.$_POST['kategoria'];
      if(!empty($_POST['lokalita']))$uri .= '/'.$_POST['lokalita'];
      if((int)$_POST['s1'] > 0 or (int)$_POST['s2'] > 0)
      {
        $uri .= '/0-'.(int)$_POST['s1'].'-'.(int)$_POST['s2'];
      }
			if($uri != '')
			{
				$this->Functions->Redirect($uri);
			}
		}
		return 0;
	}
	
	function search()
	{
    $_POST = $this->Functions->htmlarrayspecialchars($_POST);
    if(empty($_POST['w']) or (int)$_POST['w'] == 0)$_POST['w'] = '0';	
		if(!empty($_POST['q']))header('Location: /'.$this->data['searchcontroller'].'/'.$this->Functions->MakeCool($_POST['q']).'-'.$_POST['w'].'-'.$this->Functions->AsciiToHex($_POST['q']));
		else header('Location: /'.$this->data['searchcontroller']);
		exit;
	}


}
?>
