Location: PHPKode > scripts > Voodoo chat > voc/data/engine/files/registration_add.php
<?php
if (!defined("_COMMON_")) {echo "stop";exit;}
$users = "";
$t_id = 0;
$canon_view = to_canon_nick($new_user_name);
//if it's not from registration_mail;
if (!isset($new_user_mail)) $new_user_mail = "";
$already_on_mail = 0;
$fp = fopen($user_data_file, "a+");
flock($fp, LOCK_EX);
fseek($fp,0);
//for the first user -- to avoid empty line at the start or users.dat
$last_record = " \n";
while($user = fgets($fp, 4096)) {
	$last_record = $user;
	$u_data = explode("\t",str_replace("\r","",str_replace("\n","",($user))));
	if ($u_data[4] == $canon_view) {
		$error_text = str_replace("~", $new_user_name, $w_already_registered)."<br><a href=\"registration_form.php?session=$session\">$w_try_again</a>";
		include($file_path."designes/".$design."/error_page.php");
		flock($fp, LOCK_UN);
		fclose($fp);
		exit;
	}
	if (strcmp(strtolower($u_data[5]),strtolower($new_user_mail)) == 0)
		$already_on_mail++;
	if ($u_data[0]>$t_id)$t_id = $u_data[0];
	#$users .= implode("\t",$u_data) . "\n";
}
if ($registration_mailconfirm && ($already_on_mail >= $max_per_mail)) {
	$error_text = $w_mail_used."<br>".str_replace("~", $max_per_mail, $w_max_per_mail)."<br><a href=\"registration_form.php?session=$session\">$w_try_again</a>";
	include($file_path."designes/".$design."/error_page.php");
	exit;
}

$t_id=intval($t_id);
$t_id++;
$u_data = array($t_id,$new_user_name,$passwd1,"user",$canon_view, $new_user_mail);
$users = (substr($last_record,-1) == "\n" ) ? implode("\t",$u_data) : "\n".implode("\t",$u_data); 
//$users[count($users)] = "".$t_id."\t".$new_user_name."\t".$passwd1."\tuser\t".$canon_view."\n";
#ftruncate($fp,0);
fwrite($fp,$users);
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
unset($users);

include($file_path."inc_user_class.php");
$user = new User;
$user->nickname = $new_user_name;
$user->password = $passwd1;
$user->show_group_1 = 1;
$user->show_group_2 = 1;
$user->registered_at = my_time();
$user->last_visit = my_time();

if(!@is_dir($data_path."users/".floor($t_id/2000)))
	if (ini_get('safe_mode'))
		trigger_error("Your PHP works in SAFE MODE, please create directory data/users/".floor($t_id/2000),E_USER_ERROR);
	else
		mkdir($data_path."users/".floor($t_id/2000),0777);
$fp = fopen ($data_path."users/".floor($t_id/2000)."/".$t_id.".user", "w");
if (!$fp) trigger_error("Cannot open user-data file users/".floor($t_id/2000)."/".$t_id.".msg for writing. Please, check permissions", E_USER_ERROR);
if (!flock($fp, LOCK_EX)) trigger_error("Cannot LOCK user-data file. Do you use Win 95/98/Me?", E_USER_WARNING);
flock($fp, LOCK_EX);
fwrite($fp,serialize($user));
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);

if(!@is_dir($data_path."board/".floor($t_id/2000)))
	if (ini_get('safe_mode'))
		trigger_error("Your PHP works in SAFE MODE, please create directory data/board/".floor($t_id/2000),E_USER_ERROR);
	else
		mkdir($data_path."board/".floor($t_id/2000),0777);
$fp = fopen($data_path."board/".floor($t_id/2000)."/".$t_id.".msg","w");
if (!$fp) trigger_error("Cannot open mail-file board/".floor($t_id/2000)."/".$t_id.".msg for writing. Please, check permissions", E_USER_ERROR);
if (!flock($fp, LOCK_EX)) trigger_error("Cannot LOCK mail-file. Do you use Win 95/98/Me?", E_USER_WARNING);
fwrite($fp,"0\t\n");
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);

if(!@is_dir($file_path."photos/".floor($t_id/2000)))
	if (ini_get('safe_mode'))
		trigger_error("Your PHP works in SAFE MODE, please create directory chat/photos/".floor($t_id/2000),E_USER_ERROR);
	else
		mkdir($file_path."photos/".floor($t_id/2000),0777);

$out_message =  str_replace("~", $new_user_name, $w_succesfull_reg);
if (strtolower($user_name) == strtolower($new_user_name)) {
	$fields_to_update[0][0] = 5;
	$fields_to_update[0][1] = $t_id;
	include($engine_path."user_din_data_update.php");
	$out_message .= "<br><a href=\"user_info.php?session=$session\">$w_about_me</a>";
}
?>
Return current item: Voodoo chat