Location: PHPKode > projects > MyOrgBook > myorgbook/ChangeEmail.php
<?php
/*
Purpose: Change users own e-mail address

$Header: /cvsroot/myorgbook/unstable/ChangeEmail.php,v 1.7 2003/08/17 14:52:48 mik3 Exp $
$Log: ChangeEmail.php,v $
Revision 1.7  2003/08/17 14:52:48  mik3
- made mail both text and html
- Changed the way feedback works

Revision 1.6  2003/08/07 06:09:41  mik3
Changed redirection on succes

Revision 1.5  2003/08/07 05:45:17  mik3
Changed language path

Revision 1.4  2003/06/20 22:04:22  mik3
Changed how language works, fixed bugs, made small other enhancements.......

*/

include( 'inc/conf.inc.php');
include ('lang/' . $_REQUEST['Lang'] . '/lang.php');
include ('inc/functions.inc');
include ('inc/template.inc');

if ($_REQUEST['old'] == "true") {
	// Set a new random cookie id that can be used to identify the user
	$Timestamp = strtotime ("now");
	$result = $db->Execute("UPDATE myorgbook_users SET last_login = '$Timestamp' where uemail = '" . $_REQUEST['mail_old'] . "' and last_login =" . $_REQUEST['id']);
	if ($result == false) die(msg('Query Failed'));
	$ChangeURL = "http://".$_SERVER['SERVER_NAME']."/".substr($_SERVER['PHP_SELF'], 1, strrpos($_SERVER['PHP_SELF'],"/")) . "ChangeEmail.php?id=" . $Timestamp  . "&old=false&mail_old=" . $_REQUEST['mail_old'] . "&mail_new=" . $_REQUEST['mail_new'] . "&Lang=" . $_REQUEST['Lang'];
	
	include ('mail/htmlMimeMail.php');
	$mail = new htmlMimeMail();
	$HTMLBody = "<a href='$ChangeURL'>" . msg('Myorgbook request: Email change') . "</a><br><br>" . nl2br(msg("Above URL will complete the e-mail change. After you have confirmed the request by visiting the URL your e-mail address wil be changed.\n\nRegards,\n")) . $MyName;
	$TextBody = msg('Myorgbook request: Email change') . " - " . $ChangeURL . "\n\n" . msg("Above URL will complete the e-mail change. After you have confirmed the request by visiting the URL your e-mail address wil be changed.\n\nRegards,\n") . $MyName;
	$mail->setHTML($HTMLBody,$TextBody);
	$mail->setSubject(msg('Myorgbook request: Email change'));
	$mail->setFrom($MyName . '<' . $MyEmail . '>');
	$result = $mail->send(array($_REQUEST['mail_new']));
	if ($result) {
		header("Location: http://".$_SERVER['SERVER_NAME']."/".substr($_SERVER['PHP_SELF'], 1, strrpos($_SERVER['PHP_SELF'],"/")) . "login.php?Neg_Lang=" . $_REQUEST['Lang'] . "&Info=" . msg('The confirmation e-mail has been sent'));
		exit;
	}
}
if ($_REQUEST['old'] == "false") {
	$result = $db->Execute("UPDATE myorgbook_users SET uemail = '" . $_REQUEST['mail_new'] . "' where uemail = '" . $_REQUEST['mail_old'] . "' and last_login =" . $_REQUEST['id']);
	if ($result == false) die(msg('Query Failed'));
	if ($result) {
		header("Location: http://".$_SERVER['SERVER_NAME']."/".substr($_SERVER['PHP_SELF'], 1, strrpos($_SERVER['PHP_SELF'],"/")) . "login.php?Neg_Lang=" . $_REQUEST['Lang'] . "&Info=" . msg('E-mail address is changed!'));
		exit;
	}
}

echo "What?";

?>
Return current item: MyOrgBook