Location: PHPKode > projects > Spam free PHP GuestBook > guestbook/gb/verify.php
<?php
header('Content-Type: text/html; charset=ISO-8859-1');
header("Cache-Control: no-cache, must-revalidate");
include "include/functions.php";
include "include/connection.php";
class clsverify extends connection
{
private function verify_email()
{
        $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");
        @mysql_query("UPDATE ".$this->prefix."user set level = 6 WHERE level = 8 AND date < $lastdate");
        $email=fw_strip_slashes($_GET['email']);
        if(!fw_validate_email($email)){return false;}
        $confirm=fw_strip_slashes($_GET['confirm']);
        $query=sprintf("SELECT id, uid, verify FROM ".$this->prefix."tmpuser WHERE email = '%s'",mysql_real_escape_string($email));
        $result=@mysql_query($query);
        if(@mysql_num_rows($result)!==1){return false;}
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
        if(md5($row['verify'])!==$confirm){return false;}
        $query=sprintf("UPDATE ".$this->prefix."user set level = 6 WHERE email = '%s'",mysql_real_escape_string($email));
		if(!empty($row['uid'])){$query=sprintf("UPDATE ".$this->prefix."user set level = 6 WHERE id = %d",$row['uid']);}
        @mysql_query($query);
        if(mysql_affected_rows()<>1){return false;}
        $query=sprintf("DELETE FROM ".$this->prefix."tmpuser WHERE email = '%s'",mysql_real_escape_string($email));
        @mysql_query($query);
        return true;
}
public function verify()
{
        $b=$this->verify_email();
?>
<html>
<head>
<title><?php echo ($b? 'Confirmed user' : 'Invalid request');?></title>
<style>
<!--
h1 { font-family: Tahoma; font-size: 14pt; color: #333333; padding-bottom:2px; text-align:center; }
ul { list-style-type: square;text-align:left;margin:0;padding:5px 15px; }
p { line-height: 100%; margin-top: 0; margin-bottom: 5px; padding:0; }
-->
</style>
</head>
<body>
<center>
<div style="margin: 100px; padding: 0; width: 520px; text-align: left;">
<?php
if($b){echo '
<h1>Confirmed user</h1>
<p>Your email address has been confirmed. Please follow the link to login your control panel.</p>
<p style="text-align:center;"><a href="http://'.getenv('HTTP_HOST').fw_get_docroot().'gb/user/index.php">Login</a> | <a href="http://'.getenv('HTTP_HOST').fw_get_docroot().'index.php">Index</a></p>
';}
else{echo '
<h1>Invalid request!</h1>
<p>This url does not exist! <a href="http://'.getenv('HTTP_HOST').fw_get_docroot().'index.php">Click here</a> to go back to Index page. Probable reasons may be</p>
<ul>
<li>You have typed wrong url</li>
<li>Your session has been expired</li>
</ul>';}?>
</div>
</center>
</body>
</html>
<?php
}
}
$cls=new clsverify('');
$cls->verify();
?>
Return current item: Spam free PHP GuestBook