Help with integrating AdsCaptcha with cPanel Login
Posted: Tue Aug 23, 2011 12:07 pm
I am trying to add AdsCaptcha to the cPanel login. I have found the file to edit and have "somewhat" got it working. I can get it to show the captcha first, then once answered correctly, it loads the fields for the login. However, once I hit submit on that form, it just reloads and the captcha reappears.
The goal here is to force the user into answering the captcha to be able to login to cPanel.
I may be doing this totally wrong and I am more than happy to take any advice...
Here's the setup:
I have a page "login.php" and it has content and an iframe that loads the captcha and login.
Inside the iframe:
Once it verifies the captcha it loads "loginframe.php" which has the cPanel login fields (pulled from the cPanel site):
From what I can tell, it is verifying the captcha and loading the fields to login. It's after trying to actually login that I'm having issues (it's just reloading the iframe to the captcha.)
I personally don't care if the captcha loads with the form or before the form. I just want this thing to work! Any suggestions or help would be greatly appreciated.
Thanks!
The goal here is to force the user into answering the captcha to be able to login to cPanel.
I may be doing this totally wrong and I am more than happy to take any advice...
Here's the setup:
I have a page "login.php" and it has content and an iframe that loads the captcha and login.
Inside the iframe:
Code: Select all
<?php
session_start();
require_once('adscaptchalib.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdsCaptcha for PHP</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form action="" method="post">
<?php
$captchaId = 'removed'; // Set your captcha id here
$publicKey = 'removed'; // Set your public key here
$privateKey = 'removed'; // Set your private key here
$challengeValue = $_POST['adscaptcha_challenge_field'];
$responseValue = $_POST['adscaptcha_response_field'];
$remoteAddress = $_SERVER["REMOTE_ADDR"];
if ($challengeValue == null) {
echo GetCaptcha($captchaId, $publicKey);
?>
<input type="submit" id="submit" name="submit" />
<?php
} else {
if (ValidateCaptcha($captchaId, $privateKey, $challengeValue, $responseValue, $remoteAddress) == "true")
{
require("loginframe.php");
// Corrent answer, continue with your submission process
} else {
echo "Wrong";
// Wrong answer, you may display a new AdsCaptcha and add an error message
}
}
?>
</form>
</body>
</html>Code: Select all
<html>
<p><br>
<?php
if ($_GET['failed'] == "1") {
?>
<font color=#FF0000>Your login attempt failed!</font>
<?php
}
print "<form action='http://removed.com:2082/login/' method=POST>";
?>
Username:
<input type="text" name="user"><br>
Password:
<input type="password" name="pass"><br>
<?php
print "<input type=hidden name=failurl value=\"http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?failed=1\">";
?>
<input type="hidden" name="login_theme" value="default">
<input type="submit" value="Login">
</form><br>
</p>
</html>I personally don't care if the captcha loads with the form or before the form. I just want this thing to work! Any suggestions or help would be greatly appreciated.
Thanks!