collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 50
  • Dot Hidden: 0
  • Dot Users: 1
  • Dot Users Online:

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • kiki26022003: hi
    Yesterday at 02:54:28 PM
  • larry007: test
    November 20, 2014, 03:17:39 PM
  • {OCS}MasterSeal: HI, WhiteEagle
    November 12, 2014, 04:20:18 AM
  • WhiteEagle: Hello all.
    November 09, 2014, 05:33:00 PM
  • {OCS}MasterSeal: Oh and I almost forgot THANK YOU SP TEAM!
    November 04, 2014, 05:02:38 AM
  • {OCS}MasterSeal: I think I'll spam the shoutbox with as many SP IS AWESOME posts as I can.. but no more than one per day :
    November 04, 2014, 04:48:39 AM
  • desertcities: How long does it take to get approval here?  I posted on 10/29, my site is down, I need help.
    November 01, 2014, 08:50:30 PM
  • Zz: hello everyone! I posted a topic recently on Custom COdind section but it is still waiting for approval. Can anyone help with this?
    November 01, 2014, 04:21:31 PM
  • {OCS}MasterSeal: WOW> I'm so impressed at the developer involvement here at SP. Great stuff. Thank you!
    October 30, 2014, 11:42:03 PM
  • [SiNaN]: Feel free to customize it to your liking, however, this is the best we can currently offer.
    October 30, 2014, 08:19:04 AM
  • xeon365: ie where username profile link.. its just getting the membergroup color directly and adding it as inline style.. would be better if it instead just added the membergroup as a css class that can be styled by the theme
    October 29, 2014, 11:00:10 PM
  • xeon365: omg why isn't membergroup got proper css class.. not dumping inline css style
    October 29, 2014, 10:58:03 PM
  • BurkeKnight: [SiNaN] old friend. Great Job. I can't wait to see what you add next. :)
    October 13, 2014, 04:13:53 PM
  • [SiNaN]: Thank you everyone, for the kind words and support. For those who are interested, check out our Donators Program: [link]
    October 13, 2014, 11:57:44 AM
  • {OCS}MasterSeal: Glad to be here, glad to use your amazing portal THank you!
    October 13, 2014, 11:33:35 AM
  • Mike Vail: I'd like to donate to you for all your wonderful work. Do you guys have a place on your site to do that? THANKS FOR EVERYTHING!
    October 13, 2014, 11:12:16 AM
  • Mstcool: Yay, an update! :D
    October 12, 2014, 01:39:17 AM
  • stanyy: You're right. I have no idea how I got to the "Archived" index. It looks too similar.
    October 03, 2014, 11:38:32 AM
  • [SiNaN]: SimplePortal 2.3.5 package is listed in Stable SimplePortal Packages category in Downloads area.
    October 03, 2014, 06:08:01 AM
  • stanyy: SP 2.3.5 is not available in the downloads section?? The big download link on the homepage points newcomers to the downloads section who then download 2.3.4. Not good.
    October 03, 2014, 03:54:21 AM

* Recent Posts

Re: Block with links to topics of chosen board by Tonymura
[Today at 01:56:54 PM]


Staff list order, once again by ♦ Ninja ZX-10RR ♦
[Today at 05:23:19 AM]


Re: Adding a navigation button by andy
[Today at 02:24:35 AM]


Re: Adding a navigation button by Tonymura
[Yesterday at 12:46:59 PM]


Re: Adding a navigation button by andy
[Yesterday at 11:03:24 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: add adscaptcha in bloks or pages  (Read 1209 times)

0 Members and 1 Guest are viewing this topic.

Offline iulyz

  • Newbie
  • Posts: 4
add adscaptcha in bloks or pages
« on: December 21, 2011, 05:28:09 PM »
How do i make this code work in a block or page?
I try to add this code via php custom block but do not working... appear only button from form.
Can some one help me with this please. :'(

Code: [Select]
$ADSCAPTCHA_API = 'api.adscaptcha.com';

function GetCaptcha($captchaId, $publicKey) {
global $ADSCAPTCHA_API;

$dummy = rand(1, 9999999999);
$urlGet = 'http://' . $ADSCAPTCHA_API . "/Get.aspx";
$urlNoScript = 'http://' . $ADSCAPTCHA_API . "/NoScript.aspx";
$params = "?CaptchaId="  . $captchaId .
  "&PublicKey=" . $publicKey .
  "&Dummy=" . $dummy;

$result  = "<script src='" . $urlGet . $params . "' type='text/javascript'></script>\n";
$result .= "<noscript>\n";
$result .= "\t<iframe src='" . $urlNoScript . $params . "' width='300' height='100' frameborder='0'></iframe>\n";
$result .= "\t<table>\n";
$result .= "\t<tr><td>Type challenge here:</td><td><input type='text' name='adscaptcha_response_field' value='' /></td></tr>\n";
$result .= "\t<tr><td>Paste code here:</td><td><input type='text' name='adscaptcha_challenge_field' value='' /></td></tr>\n";
$result .= "\t</table>\n";
$result .= "</noscript>\n";

return $result;
}

function ValidateCaptcha($captchaId, $privateKey, $challengeValue, $responseValue, $remoteAddress) {
global $ADSCAPTCHA_API;

$host = $ADSCAPTCHA_API;
$path = "/Validate.aspx";

$params = "CaptchaId=" . $captchaId . "&PrivateKey=" . $privateKey . "&ChallengeCode=" . $challengeValue . "&UserResponse=" . $responseValue . "&RemoteAddress=" . $remoteAddress;

$result = HttpPost($host, $path, $params);

return $result;
}

function FixEncoding($str) {
$curr_encoding = mb_detect_encoding($str) ;

if($curr_encoding == "UTF-8" && mb_check_encoding($str,"UTF-8")) {
return $str;
} else {
return utf8_encode($str);
}
}

function HttpPost($host, $path, $data, $port = 80) {
$data = FixEncoding($data);

$http_request  = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$http_request .= "Content-Length: " . strlen($data) . "\r\n";
$http_request .= "\r\n";
$http_request .= $data;

$response = '';
if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == false) {
die ('Could not open socket! ' . $errstr);
}

fwrite($fs, $http_request);

while (!feof($fs))
$response .= fgets($fs, 1160);
fclose($fs);

$response = explode("\r\n\r\n", $response, 2);
return $response[1];
}


echo '<form action="" method="post">';

$captchaId  = '';   // Set your captcha id here
$publicKey  = '';   // Set your public key here
$privateKey = '';   // 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);

echo '<input type="submit" id="submit" name="submit" />';

} else {
if (ValidateCaptcha($captchaId, $privateKey, $challengeValue, $responseValue, $remoteAddress) == "true")
{
echo "Correct :)";
// Corrent answer, continue with your submission process
} else {
echo "Wrong :(";
// Wrong answer, you may display a new AdsCaptcha and add an error message
}
}

echo '</form>';