<?php

// -------------------------------------------------
include_once("lang.inc.php");

function getmicrotime()
{ 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
} 

// -------------------------------------------------

function write2_file_new( $path, $data )
{
	if ( $data != '' ) 
	{
		$filenum = fopen( $path, "w+" );
		flock( $filenum,LOCK_EX);
		fwrite( $filenum, $data);
		fclose( $filenum);
	}
}

// -----------------------------------------------

function get_ext_name($in)
{
	$name = explode('.',$in);
	$c = count($name);
	$out = $name[$c-1];	
	return ($out);
}

// ---------------------------------------------

function get_base_name($in)
{
	$name = explode('.',$in);
	$c = count($name);
	for ( $i = 0 ; $i < ($C-1) ; $i++ )
	{
		$out .= $name[$i];
	}
	return ($out);
}

// ------------------------------------------

function long($in_str,$length)
{
	while( strlen($in_str)<$length )
	{
		$in_str='0'.$in_str;
	}
	return ($in_str);
}

function get_sys_date()
{
	$today = getdate(); 
	
$month = $today['mon'];

	$mday = $today['mday']; 

	$year = $today['year'];
	
	$month = long($month,2);
	$mday = long($mday,2);
	$year = long($year,4);

	$date= "$year-$month-$mday";
	return($date);
}

//////////////////////////////////////////////////////
//  session function
///////////////////////////////////////////////////////
function check( $in )
{
	session_start();
	if ( !session_is_registered( $in ) ) 
	{ 	
		$con = '<a href="login.php" >'.$txt[1].'</a><p>'.$txt[2].'<p>';
		tpl_show( $con,$txt[3]);
		exit;
	}
}

function add_session( $in )
{
	$is_ok = session_start();
	$iis_ok = session_register( $in );
	if ( !$is_ok || !$iis_ok )
	{
		$con = $txt[4].'<p>'.$txt[5].'<p>';
		tpl_show( $con,$txt[6]);
		exit;
	}
}

function del_session($in)
{
	$is_ok = session_unregister($in);
	$iis_ok = session_destroy();
	if ( $is_ok || $iis_ok )
	{
		$con = $aw_txt[7].'<p>';

		tpl_show( $con,$txt[7]);
		exit;
		
	}
	else
	{
		$con = $aw_txt[8].'<p>';
		tpl_show( $con,$txt[8]);
		exit;
	}
}

function tpl_show( $text,$title)
{
		$tmp1 = new tpl( "admin_center.htm" );
		$tmp1->assign( "content", $text );
		$tmp1->assign( "page_title", $title.'-'.$site_name );
		$tmp1->printe();
		unset($tmp1);
}

?>