The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding AdsCaptcha to cPanel Login

Discussion in 'User Experience' started by jaspert, Aug 23, 2011.

  1. jaspert

    jaspert Registered

    Joined:
    Aug 23, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    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.

    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:
    <?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>
    Once it verifies the captcha it loads "loginframe.php" which has the cPanel login fields (pulled from the cPanel site):

    Code:
    <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>
    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!
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,446
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    I've moved your thread to the Themes and Branding forum since it involved editing a theme.
     
  3. jaspert

    jaspert Registered

    Joined:
    Aug 23, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    After 3 days of banging my head against the wall, I solved the issue. It was a matter of creating another page and calling a redirect with loginframe.php in it. Looks like the other page was just reloading the captcha form using require or include.
     
Loading...
Similar Threads - Adding AdsCaptcha cPanel
  1. Steini Petur
    Replies:
    5
    Views:
    198

Share This Page