3 UserCake Version: 2.0.2
\r
7 require_once("models/config.php");
\r
8 if (!securePage($_SERVER['PHP_SELF'])){die();}
\r
11 if(!empty($_POST) && $emailActivation)
\r
13 $email = $_POST["email"];
\r
14 $username = $_POST["username"];
\r
16 //Perform some validation
\r
17 //Feel free to edit / change as required
\r
18 if(trim($email) == "")
\r
20 $errors[] = lang("ACCOUNT_SPECIFY_EMAIL");
\r
22 //Check to ensure email is in the correct format / in the db
\r
23 else if(!isValidEmail($email) || !emailExists($email))
\r
25 $errors[] = lang("ACCOUNT_INVALID_EMAIL");
\r
28 if(trim($username) == "")
\r
30 $errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
\r
32 else if(!usernameExists($username))
\r
34 $errors[] = lang("ACCOUNT_INVALID_USERNAME");
\r
37 if(count($errors) == 0)
\r
39 //Check that the username / email are associated to the same account
\r
40 if(!emailUsernameLinked($email,$username))
\r
42 $errors[] = lang("ACCOUNT_USER_OR_EMAIL_INVALID");
\r
46 $userdetails = fetchUserDetails($username);
\r
48 //See if the user's account is activation
\r
49 if($userdetails["active"]==1)
\r
51 $errors[] = lang("ACCOUNT_ALREADY_ACTIVE");
\r
55 if ($resend_activation_threshold == 0) {
\r
59 $last_request = $userdetails["last_activation_request"];
\r
60 $hours_diff = round((time()-$last_request) / (3600*$resend_activation_threshold),0);
\r
63 if($resend_activation_threshold!=0 && $hours_diff <= $resend_activation_threshold)
\r
65 $errors[] = lang("ACCOUNT_LINK_ALREADY_SENT",array($resend_activation_threshold));
\r
69 //For security create a new activation url;
\r
70 $new_activation_token = generateActivationToken();
\r
72 if(!updateLastActivationRequest($new_activation_token,$username,$email))
\r
74 $errors[] = lang("SQL_ERROR");
\r
78 $mail = new userCakeMail();
\r
80 $activation_url = $websiteUrl."activate-account.php?token=".$new_activation_token;
\r
82 //Setup our custom hooks
\r
84 "searchStrs" => array("#ACTIVATION-URL","#USERNAME#"),
\r
85 "subjectStrs" => array($activation_url,$userdetails["display_name"])
\r
88 if(!$mail->newTemplateMsg("resend-activation.txt",$hooks))
\r
90 $errors[] = lang("MAIL_TEMPLATE_BUILD_ERROR");
\r
94 if(!$mail->sendMail($userdetails["email"],"Activate your ".$websiteName." Account"))
\r
96 $errors[] = lang("MAIL_ERROR");
\r
100 //Success, user details have been updated in the db now mail this information out.
\r
101 $successes[] = lang("ACCOUNT_NEW_ACTIVATION_SENT");
\r
111 //Prevent the user visiting the logged in page if he/she is already logged in
\r
112 if(isUserLoggedIn()) { header("Location: account.php"); die(); }
\r
114 require_once("models/header.php");
\r
119 <div id='top'><div id='logo'></div></div>
\r
122 <h2>Resend Activation</h2>
\r
123 <div id='left-nav'>";
\r
125 include("left-nav.php");
\r
131 echo resultBlock($errors,$successes);
\r
133 echo "<div id='regbox'>";
\r
135 //Show disabled if email activation not required
\r
136 if(!$emailActivation)
\r
138 echo lang("FEATURE_DISABLED");
\r
142 echo "<form name='resendActivation' action='".$_SERVER['PHP_SELF']."' method='post'>
\r
144 <label>Username:</label>
\r
145 <input type='text' name='username' />
\r
148 <label>Email:</label>
\r
149 <input type='text' name='email' />
\r
152 <label> </label>
\r
153 <input type='submit' value='Submit' class='submit' />
\r
161 <div id='bottom'></div>
\r