<?php
class verify extends connection
{
function __construct($root,$verify)
{
parent::__construct($root);
$id=round($_GET['id']);
$lastdate=time()-2*24*60*60;
@mysql_query("DELETE FROM ".$this->prefix."tmpuser WHERE date < $lastdate");
@mysql_query("DELETE FROM ".$this->prefix."user WHERE level = 7 AND date < $lastdate");
$query=sprintf("SELECT* FROM ".$this->prefix."tmpuser WHERE id = %u",$id);
$result=@mysql_query($query);
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
if(empty($row)||(md5($row['verify'])!==$verify)){$this->bad_request();}
$email=$row['email'];
$query=sprintf("SELECT id, email, level FROM ".$this->prefix."user WHERE id = %u",$row['uid']);
$result=@mysql_query($query);
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
if(($row['level']==7)&&($row['email']==$email)){$this->verify_registraton($row['id']);}
if(($row['level']==6)&&($row['email']==$email)){$this->reset_password($row['id'],$id,$verify);}
if(($row['level']==6)&&($row['email']!==$email)){$this->change_email($row['id'],$email);}
$this->bad_request();
}
private function bad_request()
{
$title='Bad request url';
$img='bad_request.gif';
$text='Your requested page is not found. Probable reason may be,<ul><li>This URL has been expired.</li><li>You have typed wrong URL;<br />Please copy the link text and pase on your browser address bar to avoid typing mistake.</li></ul>';
include 'include/message.php';
}
private function system_error()
{
$title='System error';
$img='error.gif';
$text='We are really very sory that the system experience an error! Probable reason may be,<ul><li>Error in network connection.</li><li>Bad handling of the system.<br />Please contact site administrator for further action.</li></ul>';
include 'include/message.php';
}
private function verify_registraton($id)
{
@mysql_query("UPDATE ".$this->prefix."user set level = 6 WHERE id = $id");
if(mysql_affected_rows()>0){
@mysql_query("DELETE FROM ".$this->prefix."tmpuser WHERE uid = $id");
$title='Confirm registration';
$img='verified.gif';
$text='Congratulation! This email address has been verified. Now you can login and post your message.<br />If you have any suggestion or if you experience any problem please do not heisted to contact us.<br />-- Site administrator.';
include 'include/message.php';
}
else{$this->system_error();}
}
private function reset_password($uid,$id,$verify)
{
$pw=fw_strip_slashes($_POST['pw']);
$rpw=fw_strip_slashes($_POST['rpw']);
if((empty($pw))||(empty($rpw))||($pw!==$rpw)||(!fw_validate_password($pw))){
$title='Enter new password';
$img='new_password.gif';
$script=true;
$text='Please enter your new password in the form below.<form name="password" style="margin-top:5px;" action="index.php?id='.$id.'&verify='.$verify.'" method="post" onsubmit="return validateForm()"><table cellspacing="6"><tr><td width="100px">Password:</td><td><input name="pw" class="text" type="password" onmouseover="this.className=\'hovertext\'" onmouseout="this.className=\'text\'" /></td></tr>';
$text.='<tr><td>Re-type password:</td><td><input name="rpw" class="text" type="password" onmouseover="this.className=\'hovertext\'" onmouseout="this.className=\'text\'" /></td></tr><tr><td colspan="2"><button type="submit">Go</button></td></tr></table></form>';
include 'include/message.php';}
$pw=mysql_real_escape_string(md5($pw));
@mysql_query("UPDATE ".$this->prefix."user set password = '$pw' WHERE id = $uid");
if(mysql_affected_rows()>0){
@mysql_query("DELETE FROM ".$this->prefix."tmpuser WHERE id = $id");
@header("Location: index.php");}
else{$this->system_error();}
}
private function change_email($id,$email)
{
$query=sprintf("UPDATE ".$this->prefix."user set email = '%s' WHERE id = $id",mysql_real_escape_string($email));
@mysql_query($query);
if(mysql_affected_rows()>0){
@mysql_query("DELETE FROM ".$this->prefix."tmpuser WHERE uid = $id");
$title='Email address verified';
$img='verified.gif';
$text='Congratulation! This email address has been verified. Now you can login to UserCP with your new email address.<br />If you have any suggestion or if you experience any problem please do not heisted to contact us.<br />-- Site administrator.';
include 'include/message.php';
}
else{$this->system_error();}
}
}
?>