<?php
include("config.php3");
include($BIB."bib_generic.php3");
include($BIB."bib_tables.php3");
include($BIB."bib_mailing.php3");
include($BIB."bib_check_members.php3");

$sess = open_page($sessid, 1);

$member = getmember($sess->memberid);

$title = C_PARISTITLE;

	if (isset($modif))
	{
		if ($Email != $member[Email])
		{
			$onceId = isEmailExists($Email,$ORIGINE);			
			if ($onceId[0]>0)
				$error = $error . "Cet email est déjà inscrit !<br>";
		}
		else
			$error = $error . "Vous n'avez pas modifié l'email !<br>";
		if( empty($error))
		{
			$member[Email] = $Email;
			main_db_query("UPDATE `Members` SET `Email`='".$member['Email']."' WHERE `Id`=".$member['Id']);

			#ici on envoie un mail de confirmation d'inscription
			$subject="Bienvenue sur ".$GAME_NAME." !";
			$msg = loadTemplate("Mailing/template_confirm_registration2.html");
			
			$url_confirm = $REGISTRATION_CONFIRM_PAGE."?l=".$member['Login']."&k=".encryptePassword($ORIGINE."_".$member['Login']);
			
			$msg = replaceTag("__LOGIN__", $member['Login'], $msg);
			$msg = replaceTag("__URL_CONFIRM__", $url_confirm, $msg);
			$msg = replaceTag("__GAMEURL__", $SERVER_URL, $msg);
		
			generic_mail($Email, $subject, $msg,
					"From: ".$GAME_NAME." <".$FROM_FIELD.">\n" . 
					"Reply-To: $FROM_FIELD\n" . 
					"X-Mailer: PHP/" . phpversion()."\n".
					"MIME-Version: 1.0\n".
					"Content-Type: text/html; charset=iso-8859-1"."\n"
			);		
			
			$info = $info . "Un message vient de vous être envoyé à ".$member['Email']."<br>";
		}
	}

?>
<html>
<head>
<title><?php echo $GAME_NAME ?></title>
<META CONTENT="kestufoot, kestufoot.com, football, sport, pronostics sportifs, parier, mise, jeux, pronostics, matchs, championnat de France, équipes, L1" NAME="Keywords">
<link rel="stylesheet" href="<?php echo $SERVER_URL?>common.css">
<link rel="stylesheet" href="<?php echo $SERVER_URL?>links.css">
<link rel="stylesheet" href="<?php echo $SERVER_URL?>tables.css">
</head>
<body LEFTMARGIN="0" TOPMARGIN="0" rightmargin=0 bottommargin=0 bgcolor=white>

<br style=font-size:1px>
<center>
<?php 

if ($sess->memberid != -1)
{
	$form_action = $sess->action($INSCRIPTION_RELANCE);
	$form_name = "modif";
	include("registration_form_header.inc"); 

table_ktf_up("Modification Email et confirmation d'inscription", "100%", 'green',1,'','','#FFFFFF' ); 

?>
<script language="Javascript">
<!--
function checkApos(a)
{
	if (a.indexOf("'",0)!=-1) return true;
	return false;
}
function wrongemail(email) { 
	
	if (email == '') return false;
	
	var atpl = email.indexOf("@",0)
		
	if (atpl < 1 ) return true;
	if (atpl == email.length - 1) return true;
	if (email.indexOf(".",atpl) < atpl + 2) return true;
	
	return false;
}
function check(doc_this)
{		
	var error="";
	if ( doc_this.Email.value =='' )
		error +=  "<?php echo C_ERREURMAIL?>\n";
	if (checkApos(doc_this.Email.value))
		error +=  "<?php echo C_ERREURAPOS3?>\n";
	if (wrongemail(doc_this.Email.value))
		error = error + "<?php echo C_ERREURMAIL?>\n";
	if (error != '')
	{
		alert(error);
		return false;
	}
	else
		return true;
}
//-->
</script>

<?php
if ($error != "")
	echo "<div align=center class=smallboldRed>".$error."</div>";
if ($info != "")
	echo "<div align=center class=smallBoldBlue style='font-size:10px;'>".$info."</div>";
?>

<table cellpadding=5 align=center width=450 border=0>
<tr>
	<td class=smallDark align=left colspan=3>
		Veuilez renseigner ci-dessous une adresse email valide afin que nous puissions vous renvoyer un message de confirmation d'inscription :
	</td>
</tr>
<tr>
	<td valign=top>
		<input type=text class=inputbg2 style="width:250px" name=Email value="<?php echo $member[Email]; ?>">
	</td>
	<td>
		<input src="<?php echo $IMAGES_DIR; ?>boutons/bouton_valider.gif" type=image>
	</td>
</tr>
</table>

<?php 
include("form_footer.inc");  
table_ktf_down("",1);

}

?>
 
<div class=std align=right><img src="<?php echo $IMAGES_DIR?>triangleorange.gif" border=0> <a class=smallDarkLink href="javascript:window.close()">Fermer la popup</a><font size=1>&nbsp;&nbsp;</font></div>
</body>
</html>
