Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/install/functions.php
<?
defined( '_VALID_DA_' ) or die( 'Direct Access to this location is not allowed.' );

//*****************************************************************************
/* These functions are used to keep track of generation time */
//*****************************************************************************
function t_getmicrotime(){
	list($usec, $sec) = explode(" ",microtime());
	return ((float)$usec + (float)$sec);
}

//*****************************************************************************
function t_pagetime($type){
	static $orig_time;
	if($type=="init")$orig_time=t_getmicrotime();
	if($type=="print")return sprintf("%2.4f",t_getmicrotime()-$orig_time);
}

//*****************************************************************************
function PrintSessionVar(){
	print_r($_SESSION);
	echo "<br>";
}

//*****************************************************************************
function Message($messageid){
	echo "Mid:$messageid";
}

//*****************************************************************************
function ReDirection($url){
	echo "<meta http-equiv='Refresh' content='0; url=$url'>";	
}

//*****************************************************************************
function IsLogin(){
	$login_ok = false;
	if (session_is_registered(signed_in)){
		if ($_SESSION['signed_in']=="indeed")
			$login_ok = true;
	}
	return $login_ok;
}

//*****************************************************************************
function SetLanguage() {
	global $defaultlanguage;

	if (!$_REQUEST['lang']){
		// No change request of language
		if (!session_is_registered("lang")){
			//No Registered
			$lang = $defaultlanguage;
			session_register("lang");
			$_SESSION['lang'] = $lang;
		}
		else{
			//Registered
		}
	}
	else{
		//Change request of language
		$lang = $_REQUEST['lang'];
		if (session_is_registered("lang")){
			$_SESSION['lang'] = $lang;
		}
		else{
			if ($lang =="")
				$lang = $defaultlanguage;
			session_register("lang");
		}
	}

	$lang = $_SESSION['lang'];

	switch (strtolower($lang)){
	default:
		$charset = "iso-8859-9";
	break;
	case "tr":
		$charset = "iso-8859-9";
	break;
	case "en":
		$charset = "iso-8859-1";
	break;
	case "de":
		$charset = "iso-8859-1";
	break;
	}

	if (session_is_registered("charset")){
		$_SESSION['charset'] = $charset;
	}
	else{
		if ($charset =="")
			$charset = "iso-8859-9";
		session_register("charset");
	}

	//Include Language File
	include("languages/".strtolower($_SESSION['lang'])."/language.php");
}


//*****************************************************************************
function ActiveLanguage() {
	$lang = $_SESSION['lang'];
	return $lang;
}

//*****************************************************************************
function SetMode () {

	if (!$_REQUEST['mode']){
		// No change request of mode
		if (!session_is_registered("mode")){
			//No Registered
			$mode = "user";
			session_register("mode");
			$_SESSION['mode'] = $mode;
		}
		else{
			//Registered
		}
	}
	else{
		//Change request of mode
		$mode = $_REQUEST['mode'];
		if (session_is_registered("mode")){
			$_SESSION['mode'] = $mode;
		}
		else{
			if ($mode =="")
				$mode = "user";
			session_register("mode");
		}
	}

	$mode = $_SESSION['mode'];

}

//*****************************************************************************
/* The following function transforms the IP number of the 
visitor to a decimal number */
//*****************************************************************************
function f_ip2dec($a){
$d = 0.0;
$b = explode(".", $a,4);
for ($i = 0; $i < 4; $i++) {
       $d *= 256.0;
       $d += $b[$i];
   };
return $d;
}

//*****************************************************************************
function go_back(){
	return "
	<form>
	<input type=button value=\""._CMN_BACK_."\" onClick=\"history.go(-1)\">
	</form>";
}

//*****************************************************************************
function get_datetime(){
	$now = mktime();
	$today = date("Y-m-j, H:i:s", $now); //01/2/2006, 13:08
	return $today;
}

?>
Return current item: ChiCoMaS - Chilek CMS