<?php
/****************************************************************************
** Knjižnica, kjer so zbrane funkcije za operiranje http		**
** Author: DC @ zabec.net	 												 			**
** Date: 2008 						 												 			**
****************************************************************************/

/* funkcija, ki skrbi za preusmerjanje */
/**********************************************************************************/
	function redirect_url($link)
	{	
		//header("Location: " . $link);
		print '
		<script type="text/javascript">
			<!--
			window.location = "'. $link .'"
			//-->
		</script>';
		
	}
	
	# vrne array url podatkov, 
	#ce je podan argument[protocol, host, scrupt, params, currentUrl, currentHost] izpise le tega kot (string)
	function getUrl($get = false,$http=false)
	{
		
		$arr['protocol'] = $_SERVER['HTTPS'] != 'on' ?
			'http'
		:
			'https'
		;
		
		$arr['host']     = $_SERVER['HTTP_HOST'];
		$arr['script']   = $_SERVER['SCRIPT_NAME'];
		$arr['params']   = $_SERVER['QUERY_STRING'];
		
		if($http)
			$arr['protocol']='http';
		 
		$arr['currentUrl'] = $arr['protocol'] . '://' . $arr['host'] . $arr['script'] . '?' . $arr['params'];
		
		$arr['currentHost'] = $arr['protocol'] . '://' . $arr['host'];
		
		if($get) return $arr[$get];
		
		return $arr;
	}
	
	# Preusmeri na https
	function goSecure()
	{
		if($_SERVER['HTTPS']!='on')
		{
			header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
			exit;
		}
	}

?>