<?php
/************************************************************************
	UebiMiau is a GPL'ed software developed by 
	 - Aldoir Ventura - aldoir@users.sourceforge.net
	 - http://uebimiau.sourceforge.net SåÐ Paulo - Brasil
   		
	***********************************************************************
	Version 3.2.0 Upgrades and templates developed by
	 - Todd Henderson - Lead Developer - http://tdah.us 
	 - Dave Rodgers - Developer - http://www.manvel.net 
	 - Laurent (AdNovea) - Developer - http://adnovea.free.fr
	 
	***********************************************************************
	 - Special thanks to the developers at 
	codeworxtech.com, tinymce.moxiecode.com
	telaen.org, phptoys.com, winged.info, ngcoders.com
	without help this project wouldn't be possible 
	
	***********************************************************************
	- File:			loginchat.php
	- Developer: 	Todd Henderson / Mods by Laurent (AdNovea)
	- Date:			November 4, 2008
	- version:		(3.2.0) 1.0
	- Description:  Login procedure to connect to the chat

*************************************************************************/
 
	require('./inc/inc.php');
	require(PATH_LANGS."$chat_language.php");
  $chat_data_file	= DB_CHAT_DATA;
  $chat_online_file = DB_CHAT_ONLINE;
  $chat_upload_dir = DB_CHAT_UPLOAD;
	$nick = ($nick) ? $nick : CHAT_HIDDEN;

// start the session
	session_start();
	$_SESSION['nickname'] = $nick;
	$date = date($chat_date_format);

	$line = "<p><span class=\"main\">$nick</span> <span class=\"login\"> ".CHAT_JOIN."</span><span class=\"date\"> - $date</span></p>";
	$file = fopen($temporary_directory.DB_CHAT_DATA, 'a+');
	fwrite($file, $line);
	fclose($file);





// Update user list	
	$data = "<a href=\"newmsg.php?nameto=$nick&mailto=$f_user\" title=\"".CHAT_ONLINE." ($f_user) - ".CHAT_CLICK2PM."\" target=\"blank\">$nick</a>";
	$pic = "pic_online";
	if ( !$file_handle = fopen($temporary_directory.DB_CHAT_ONLINE ,"a") ) echo CHAT_CANNOT_OPENFILE; 
	if ( !fwrite($file_handle, "<div class=\"user_online $pic\"> $data</div>\n") )  echo CHAT_CANNOT_WRITEFILE; 
	fclose($file_handle);  

	$fp = fopen($temporary_directory.DB_CHAT_ONLINE,"a");
	if(!$fp) {
		echo CHAT_CANNOT_OPENUSER;
		exit;
	}
	fclose($fp);

	header("Cache-control: private");
	echo "
		<link rel='stylesheet' type='text/css' href='./themes/$selected_theme/$chat_default_theme'>
		<script type='text/javascript'>
			<!--
			function delayer(){
				document.location = './startchat.php?lid=$lid&tid=$tid';
			}
			//-->
		</script>
	
	<body onLoad=\"setTimeout('delayer()', 0)\">
	";	
	echo "<br><center><b>$nick</b> ".CHAT_LOGGING."</center>";

?>
