--- /dev/null
+<?php\r
+/*\r
+UserCake Version: 2.0.2\r
+http://usercake.com\r
+*/\r
+\r
+require_once("models/config.php");\r
+if (!securePage($_SERVER['PHP_SELF'])){die();}\r
+\r
+//Forms posted\r
+if(!empty($_POST) && $emailActivation)\r
+{\r
+ $email = $_POST["email"];\r
+ $username = $_POST["username"];\r
+ \r
+ //Perform some validation\r
+ //Feel free to edit / change as required\r
+ if(trim($email) == "")\r
+ {\r
+ $errors[] = lang("ACCOUNT_SPECIFY_EMAIL");\r
+ }\r
+ //Check to ensure email is in the correct format / in the db\r
+ else if(!isValidEmail($email) || !emailExists($email))\r
+ {\r
+ $errors[] = lang("ACCOUNT_INVALID_EMAIL");\r
+ }\r
+ \r
+ if(trim($username) == "")\r
+ {\r
+ $errors[] = lang("ACCOUNT_SPECIFY_USERNAME");\r
+ }\r
+ else if(!usernameExists($username))\r
+ {\r
+ $errors[] = lang("ACCOUNT_INVALID_USERNAME");\r
+ }\r
+ \r
+ if(count($errors) == 0)\r
+ {\r
+ //Check that the username / email are associated to the same account\r
+ if(!emailUsernameLinked($email,$username))\r
+ {\r
+ $errors[] = lang("ACCOUNT_USER_OR_EMAIL_INVALID");\r
+ }\r
+ else\r
+ {\r
+ $userdetails = fetchUserDetails($username);\r
+ \r
+ //See if the user's account is activation\r
+ if($userdetails["active"]==1)\r
+ {\r
+ $errors[] = lang("ACCOUNT_ALREADY_ACTIVE");\r
+ }\r
+ else\r
+ {\r
+ if ($resend_activation_threshold == 0) {\r
+ $hours_diff = 0;\r
+ }\r
+ else {\r
+ $last_request = $userdetails["last_activation_request"];\r
+ $hours_diff = round((time()-$last_request) / (3600*$resend_activation_threshold),0);\r
+ }\r
+ \r
+ if($resend_activation_threshold!=0 && $hours_diff <= $resend_activation_threshold)\r
+ {\r
+ $errors[] = lang("ACCOUNT_LINK_ALREADY_SENT",array($resend_activation_threshold));\r
+ }\r
+ else\r
+ {\r
+ //For security create a new activation url;\r
+ $new_activation_token = generateActivationToken();\r
+ \r
+ if(!updateLastActivationRequest($new_activation_token,$username,$email))\r
+ {\r
+ $errors[] = lang("SQL_ERROR");\r
+ }\r
+ else\r
+ {\r
+ $mail = new userCakeMail();\r
+ \r
+ $activation_url = $websiteUrl."activate-account.php?token=".$new_activation_token;\r
+ \r
+ //Setup our custom hooks\r
+ $hooks = array(\r
+ "searchStrs" => array("#ACTIVATION-URL","#USERNAME#"),\r
+ "subjectStrs" => array($activation_url,$userdetails["display_name"])\r
+ );\r
+ \r
+ if(!$mail->newTemplateMsg("resend-activation.txt",$hooks))\r
+ {\r
+ $errors[] = lang("MAIL_TEMPLATE_BUILD_ERROR");\r
+ }\r
+ else\r
+ {\r
+ if(!$mail->sendMail($userdetails["email"],"Activate your ".$websiteName." Account"))\r
+ {\r
+ $errors[] = lang("MAIL_ERROR");\r
+ }\r
+ else\r
+ {\r
+ //Success, user details have been updated in the db now mail this information out.\r
+ $successes[] = lang("ACCOUNT_NEW_ACTIVATION_SENT");\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+//Prevent the user visiting the logged in page if he/she is already logged in\r
+if(isUserLoggedIn()) { header("Location: account.php"); die(); }\r
+\r
+require_once("models/header.php");\r
+\r
+echo "\r
+<body>\r
+<div id='wrapper'>\r
+<div id='top'><div id='logo'></div></div>\r
+<div id='content'>\r
+<h1>UserCake</h1>\r
+<h2>Resend Activation</h2>\r
+<div id='left-nav'>";\r
+\r
+include("left-nav.php");\r
+\r
+echo "\r
+</div>\r
+<div id='main'>";\r
+\r
+echo resultBlock($errors,$successes);\r
+\r
+echo "<div id='regbox'>";\r
+\r
+//Show disabled if email activation not required\r
+if(!$emailActivation)\r
+{ \r
+ echo lang("FEATURE_DISABLED");\r
+}\r
+else\r
+{\r
+ echo "<form name='resendActivation' action='".$_SERVER['PHP_SELF']."' method='post'>\r
+ <p>\r
+ <label>Username:</label>\r
+ <input type='text' name='username' />\r
+ </p> \r
+ <p>\r
+ <label>Email:</label>\r
+ <input type='text' name='email' />\r
+ </p> \r
+ <p>\r
+ <label> </label>\r
+ <input type='submit' value='Submit' class='submit' />\r
+ </p>\r
+ </form>";\r
+}\r
+\r
+echo "\r
+</div> \r
+</div>\r
+<div id='bottom'></div>\r
+</div>\r
+</body>\r
+</html>";\r
+\r
+?>\r