function CheckCaptcha() { $app = JFactory::getApplication(); $jinput = $app->input; $user = JFactory::getUser(); $params = JComponentHelper::getParams('com_alfcontact'); $captchatype = $params->get('captchatype', 0); $captcha = $params->get('captcha'); $captchas_user = $params->get('captchas_user', 'demo'); $captchas_key = $params->get('captchas_key', 'secret'); $captchas_alphabet = $params->get('captchas_alphabet', 'abcdefghijklmnopqrstuvwxyz'); $captchas_chars = $params->get('captchas_chars', '6'); $captchas_width = $params->get('captchas_width', '240'); $captchas_height = $params->get('captchas_height', '80'); $captchas_color = $params->get('captchas_color', '000000'); $captchas_random_path = JPATH_SITE . '/tmp/captchasnet-random-strings'; $captchas_entry = $jinput->getString('captchas_entry'); $captchas_random = $jinput->getString('captchas_random'); // not using captcha! if ($captcha == 0 or $captcha == 2 and $user->name) { return true; } $return = false; if ($captchatype == 0) { $post = $jinput->getArray($_POST); JPluginHelper::importPlugin('captcha'); $dispatcher = JEventDispatcher::getInstance(); $resp = $dispatcher->trigger('onCheckAnswer', $post['recaptcha_response_field']); if ($resp[0]) { $return = true; } } else { require_once JPATH_COMPONENT_SITE . '/captchasdotnet.php'; $captchas = new CaptchasDotNet($captchas_user, $captchas_key, $captchas_random_path, '3600', $captchas_alphabet, $captchas_chars, $captchas_width, $captchas_height, $captchas_color); // Check the random string to be valid and verify with user entry. $validate = $captchas->validate($captchas_random); $verify = $captchas->verify($captchas_entry); if ($validate and $verify) { $return = true; } } if ($return) { return true; } else { return false; } }
<?php include 'headers/header_signup.php'; require 'CaptchasDotNet.php'; $captchas = new CaptchasDotNet('rpalle', 'ulGFjlYn4nww2M3R1IBqPAiMsGgivLQoES0YYUWm', '/tmp/captchasnet-random-strings', '3600', 'abcdefghkmnopqrstuvwxyz', '6', '240', '80', '000088'); ?> <?php $wrngcap = false; if ($_POST['signup']) { $username = $con->real_escape_string($_POST['user_name']); $password = $con->real_escape_string($_POST['user_pass']); $email = $con->real_escape_string($_POST['user_email']); $mail = $con->real_escape_string($_POST['mail']); $captcha = $con->real_escape_string($_POST['captcha']); $random = $con->real_escape_string($_POST['random']); if (!$captchas->validate($random)) { echo 'The session key (random) does not exist, please go back and reload form.<br/>'; echo 'In case you are the administrator of this page, '; echo 'please check if random keys are stored correct.<br/>'; echo 'See http://captchas.net/sample/php/ "Problems with save mode"'; } elseif (!$captchas->verify($captcha)) { echo 'You entered the wrong Captcha. '; $wrngcap = true; } else { list($user, $domain) = split('[@]', $email); if ($domain == 'cs.odu.edu') { $password = md5($password); $check = $con->query("SELECT * FROM proj4_users WHERE user_name='{$username}'"); if (mysqli_num_rows($check) >= 1) { echo "user name already taken";
function main() { try { global $sid; global $session; global $returnURI; global $DOMAIN; global $FROM_ADDR; global $X_MAILER; $PHP_SELF = $_SERVER['PHP_SELF']; $message = $_REQUEST['message']; $captchaCode = $_REQUEST['txtCaptchaCode']; $random = $_REQUEST['txtRandom']; $post = $_POST['blnPost']; $username = $_POST['txtUsername']; $password = $_POST['txtPassword']; $repassword = $_POST['txtRePassword']; $email = $_POST['txtEmail']; $emailPassword = $_POST['btnEmailPassword'] != ""; $create = $_POST['btnCreateAccount'] != ""; if (!$create) { $create = $_GET['create'] != ""; } if (!$emailPassword) { $emailPassword = $_GET['emailPassword'] != ""; } if ($post) { if ($emailPassword) { $user = new User("username='******'"); if ($user->Email() != '') { $capLogin = GetCap('capLogin'); $sub = GetCap('capPassword'); $path = dirname($_SERVER['SCRIPT_NAME']); $msg = GetCap('capBelowAreYourCredentials') . "\r\n"; $msg .= "Username: "******"\r\n"; $msg .= 'Password: '******'capEmailHasBeenSent') . '</center></b>'; } else { print "<b><center>" . GetCap('capUserAccountDoesn\'tHaveEmailAddress</center></b>'); } $username = $user->UserName(); $email = $user->Email(); } elseif ($create) { $captcha = new CaptchasDotNet('demo', 'secret'); if (!$captcha->validate($random)) { $password = $_POST['txtPassword']; $rePassword = $_POST['txtRePassword']; print "<center>" . GetCap('capCaptchaWasReused') . "</center>"; $session->ReusedCaptcha("session", $session->ID(), $random); } elseif (!$captcha->verify($captchaCode)) { $password = $_POST['txtPassword']; $rePassword = $_POST['txtRePassword']; print "<center>" . GetCap('capInvalidConfirmationCode') . "</center>"; $session->InvalidConfirmationCode($captchCode); } elseif ($password == $repassword) { $user = new User(); $user->UserName($username); $user->Password($password); $user->Email($email); if (UpdateObject($user)) { $session->UserID($user->ID()); $session->LoggedIn(true); UpdateObject($session); $username = $user->UserName(); $email = $user->Email(); ReturnURI(); print '<center>' . GetCap("capUpdateSucceded") . '</center>'; } } else { $password = $_POST['txtPassword']; $rePassword = $_POST['txtRePassword']; print "<center>" . GetCap('capPasswordsDoNotMatch') . "</center>"; } } } /* TODO:PREROLL Go to captcha.net and register an actual account (not demo) before rolling to production */ if ($create) { $captcha = new CaptchasDotNet('demo', 'secret'); } ?> <form name="frm" method="post" action="<?php echo "login.php?returnURI={$returnURI}"; ?> "> <table> <tr> <td> <b><?php echo GetCap('capUsername'); ?> : </b> </td> <td> <input type="text" name="txtUsername" value="<?php echo $username; ?> "/> </td> </tr> <?php if ($create) { ?> <tr> <td> <b><?php echo GetCap('capPassword'); ?> : </b> </td> <td> <input type="password" name="txtPassword" value="<?php echo $password; ?> "/> </td> </tr> <tr> <td> <b><?php echo GetCap('capRe-typePassword'); ?> : </b> </td> <td> <input type="password" name="txtRePassword" value="<?php echo $_POST['txtRePassword']; ?> "/> </td> </tr> <tr> <td> <b><?php echo GetCap('capEmail (optional)'); ?> : </b> </td> <td> <input type="text" name="txtEmail" value="<?php echo $email; ?> "/> </td> <td> <i><?php echo GetCap('capIn case you forget your password we can email you a new one.'); ?> </i> </td> </tr> <tr valign="top"> <td> <b><?php echo GetCap('capEnterConfirmationCodeFromPicture'); ?> : </b> </td> <td> <input type="text" name="txtCaptchaCode"/> <input type="hidden" name="txtRandom" value="<?php echo $captcha->random(); ?> " /> <br /><br/><br/> <a href="<?php echo $captcha->audio_url(); ?> "><?php echo GetCap('capPhoenieticSpelling(mp3)'); ?> </a> </td> <td> <?php echo $captcha->Image(false, 'captchas.net', GetCap('capLoadingCaptcha...')); ?> </td> </tr> <tr> <td> <input type="submit" name="btnCreateAccount" value="<?php echo GetCap('capCreateAccount'); ?> "/> </td> </tr> <?php } if ($emailPassword) { ?> <tr> <td> </td> <td> <input type="submit" name="btnEmailPassword" value="<?php echo GetCap('capEmailMePassword'); ?> "/> </td> </tr> <?php } ?> <tr> <td> <input type="hidden" name="blnPost" value="1"/> </td> </tr> </table> </form> <?php } catch (Exception $ex) { ProcessException($ex); } }
$captchas_chars = $params->get('captchas_chars', '6'); $captchas_width = $params->get('captchas_width', '240'); $captchas_height = $params->get('captchas_height', '80'); $captchas_color = $params->get('captchas_color', '000000'); $captchas_audiolink = $params->get('captchas_audiolink', 0); $captchas_audiolng = $params->get('captchas_audiolng', 'en'); $captchas_random_path = JPATH_SITE . '/tmp/captchasnet-random-strings'; if ($captcha == 1 or $captcha == 2) { // Joomla reCaptcha support JPluginHelper::importPlugin('captcha'); $dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onInit', 'dynamic_recaptcha_1'); } if ($captchatype == 1) { require_once JPATH_COMPONENT_SITE . '/captchasdotnet.php'; $captchas = new CaptchasDotNet($captchas_user, $captchas_key, $captchas_random_path, '3600', $captchas_alphabet, $captchas_chars, $captchas_width, $captchas_height, $captchas_color); } ?> <script language="javascript" type="text/javascript"> var $j = jQuery; $j(document).ready(function(){ //At the opening of the form updateForm(); //And whenever changing the selectorbox $j("#emailid").change(function(){ updateForm(); });