<?php
//error_reporting(0);
ini_set('session.cookie_domain', '.wowdoyou.com');
session_start();
include("includes/site_info.php");
include('session_handler.inc');
include('functions.php');
//include_once('lib/lib.Functions.php');
include_once __INCLUDE_CLASS_PATH."/class.ItemManager.php";
$option_manager = new OptionManager();
$email_confirm=$option_manager->GetValue('email_confirm');
$CONST_MAIL = $option_manager->GetValue('mail'); 
$CONST_SUPPMAIL = $option_manager->GetValue('suppmail'); 

$Sess_UserId = $_SESSION['Sess_UserId'];
$result=mysql_query("SELECT * FROM members WHERE mem_userid=$Sess_UserId",$link);
$sql_user=mysql_fetch_object($result);

		$activityText ="joined Wauhaha.";
		$checkAct = mysql_query("SELECT * FROM activities_user WHERE userID='$sql_user->mem_userid' and activityID='10'",$link);
		$checkActTotal = mysql_num_rows($checkAct);
		if ($checkActTotal==0) {
		$query2="INSERT INTO activities_user (userID, activityID, activityText) values ('$sql_user->mem_userid', '10', '$activityText')";
		$result2=mysql_query($query2,$link) or die(mysql_error());

# final stage of registration
    $confirm_url = $CONST_LINK_ROOT."/confirm.php?reg_confirm_id=".md5($sql_user->mem_userid);

    $data['UserName'] = $sql_user->mem_username;
    $data['Password'] = $sql_user->mem_password;
    $data['ConfirmUrl'] = $confirm_url;
    $data['CompanyName'] = $CONST_COMPANY;
    $data['Url'] = $CONST_URL;
    $data['SupportEmail'] = $CONST_SUPPMAIL;
    $data['ProfileLink'] = $CONST_URL."/".$sql_user->mem_username;
   //echo $m_template = 'Welcome_Mail_Activate';
    //$m_template = ($email_confirm == 'Y') ? 'Welcome_Mail_Activate' : 'Welcome_Mail';
    //list($type,$message) = getTemplateByName($m_template,$data,getDefaultLanguage($sql_user->mem_userid));


	//send_mail ("$sql_user->mem_email", "$CONST_MAIL", PRGPROFILE_WELCOME." $CONST_COMPANY!", "$message", $type, "ON");
	//if (!send_mail) echo"failed";

# Add the message to the database and mail the user
$query="INSERT INTO messages (msg_senderid, msg_receiverid, msg_senderhandle, msg_title, msg_text, msg_dateadded, msg_read) VALUES ('4', '$Sess_UserId','WauHH Admin' ,'".PRGPROFILE_WELCOME." $CONST_COMPANY!', '".htmlentities($message, ENT_QUOTES)."', NOW(), 'U' )";
mysql_query($query);

	if($email_confirm == 'N'){
echo "<script> location.href='$CONST_LINK_ROOT/hahaperParks.php'</script>";
		}else{
	echo "<script> location.href='$CONST_LINK_ROOT/logoff.php'</script>";
		}
} else {
echo "<script> location.href='$CONST_LINK_ROOT/profile_update.php#add_photo'</script>";
/*	echo "<script> location.href='$CONST_LINK_ROOT/home.php'</script>";
*/}
	?>
