collapse

* User Info

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

* Who's Online

  • Dot Guests: 80
  • Dot Hidden: 1
  • Dot Users: 1

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • SamElanius: Thank you for info Chen Zhen. It worked
    Today at 12:27:23 pm
  • Chen Zhen: new members are not permitted to post links. for those having an issue please make your posts without any working links. thank you.
    Yesterday at 09:15:16 pm
  • sub5: BoardNews for Frontpage block is the problem, cant get it right, need your help please
    Yesterday at 06:00:09 pm
  • Infernus: What's the problem?
    December 26, 2014, 08:32:26 am
  • sub5: @Elina and SiNaN, can you help me on my post in the BoardNews for frontpage block
    December 26, 2014, 08:28:57 am
  • sub5: I had same issues yesterday,
    December 26, 2014, 08:26:51 am
  • Skhilled: Or first time posters?
    December 26, 2014, 06:58:01 am
  • Skhilled: I get the same too. I think something is wrong with the anti-spam process for new users?
    December 26, 2014, 06:57:47 am
  • SamElanius: What I get when I try to post here in english support new topic is that I get blank (white screen).I tried different browser but same result. If I refresh it, it says that I posted it but no topic is created. Any advice please ?
    December 26, 2014, 06:31:20 am
  • sub5: @Elina thanks, i have been able to post it
    December 25, 2014, 07:16:45 pm
  • Eliana Tamerin: @sub5 I added a few more posts to your count, try now.
    December 25, 2014, 07:08:35 pm
  • ♦ Ninja ZX-10RR ♦: It might be related to the newbie status, I don't really know about it, I'd advise you to ask Eliana or SiNaN, they can manage permissions I think... I am not entitled to post as you nor I am a support team member ;)
    December 25, 2014, 04:58:35 pm
  • sub5: Ijust tried again and its still thesame thing. this is like the 20th times i have tried, can i inbox u what i want to post
    December 25, 2014, 04:45:50 pm
  • ♦ Ninja ZX-10RR ♦: I can reply there... Idk :|
    December 25, 2014, 04:33:43 pm
  • sub5: can u give me a topic to post on so you can see, i actually want to reply to this topic [link]
    December 25, 2014, 10:21:08 am
  • ♦ Ninja ZX-10RR ♦: I can post just fine with the link you provided :| it is the block request sub-board. You'd better post a topic so we can get this sorted.
    December 25, 2014, 10:16:33 am
  • sub5: this is what it is returning [link]
    December 25, 2014, 10:13:12 am
  • sub5: but i have tried and i cant
    December 25, 2014, 10:12:23 am
  • ♦ Ninja ZX-10RR ♦: It is possible to reply there just fine...
    December 25, 2014, 10:09:20 am
  • sub5: @Ninja ZX, thanks but i didnt want to start a new topic, but to reply to one on that board
    December 25, 2014, 09:56:17 am

* Recent Posts

Problems in : "PortalBlocks.php" by SamElanius
[Today at 12:26:48 pm]


Re: TP to SP Help by Skhilled
[Today at 01:19:31 am]


Re: TP to SP Help by Chen Zhen
[Yesterday at 10:18:46 pm]


Re: [Plugin] SP - Extra Shoutbox Permissions by Chen Zhen
[Yesterday at 10:09:07 pm]


Re: TP to SP Help by Chen Zhen
[Yesterday at 09:38:20 pm]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: add adscaptcha in bloks or pages  (Read 1235 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>';