collapse

* User Info

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

* Who's Online

  • Dot Guests: 56
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • oNLy1: Nakroma, please use the forum for support - ask all the questions (dumb or not) they will get answered
    April 18, 2014, 08:03:49 PM
  • Nakroma: i know this is just another question but im too dumb for it, where can I actualy get into the GENERAL SETTINGS page? im dumb sorry ;-;
    April 18, 2014, 04:27:39 PM
  • Nakroma: ahh okey, i get it. thanks
    April 18, 2014, 04:16:18 PM
  • [SiNaN]: Please don't get me wrong; I didn't mean that. You need to use the navigation menu right above the yellow Documentation bar you describe to navigate through different sections of documentation.
    April 18, 2014, 04:12:37 PM
  • Nakroma: okey I am dumb, could someone point out where at the top of the site it is? with a screenshot or something? if you mean the yellow Documention bar, thats not clickable for  me :|
    April 18, 2014, 03:57:34 PM
  • [SiNaN]: I wouldn't say it's hidden, lol. And it's extensive enough, thanks to Angelina.
    April 18, 2014, 02:28:55 PM
  • oNLy1: Documentation [link] (hidden at top of site)
    April 18, 2014, 12:48:01 PM
  • Nakroma: am I dumb or is there actually no tutorial? [link]
    April 18, 2014, 08:29:41 AM
  • AngelinaBelle: Welcome Gusto Prod.  Please visit [link] for info on creating an SMF forum
    April 17, 2014, 12:04:00 PM
  • GUSTO PROD: hi all give me creat new forum free
    April 16, 2014, 12:21:54 PM
  • AngelinaBelle: Hello w1ck3d! Welcome to Simple Portal. Unfortunately, there are not Russian speakers here very often.  Aplogies
    April 14, 2014, 07:49:26 AM
  • w1ck3d: тест
    April 14, 2014, 02:50:12 AM
  • Underdog: How to use Simple Portal for SMF: [link]
    April 02, 2014, 07:52:45 PM
  • Underdog: Thariq, please post questions in the forum. thank you.
    April 02, 2014, 07:51:40 PM
  • Thariq: how to create portal/site
    April 02, 2014, 06:30:42 AM
  • Ali çelen: forum nasıl oluştırıcam
    March 30, 2014, 10:59:08 PM
  • Ali çelen: sa
    March 30, 2014, 10:58:54 PM
  • AngelinaBelle: processor -- I think your customization will probably be just fine.
    February 14, 2014, 07:18:41 PM
  • AngelinaBelle: noumankhan: Welcome to SimplePortal.  Please read the documentation above. If you have questions about how to make a forum, please seek help at [link]
    February 14, 2014, 07:16:45 PM
  • noumankhan: how can i make forum plz tell me
    February 13, 2014, 09:41:03 AM

* Team Blog

* Recent Posts

Re: Shoutbox refresh and page reload discrepancy by andy
[Today at 07:34:38 AM]


Re: Why I think the Documentation is hidden by andy
[Today at 07:30:26 AM]


Re: Meta description by andy
[Today at 07:27:39 AM]


Re: Where is the GENERAL SETTINGS tab? by andy
[Today at 07:26:16 AM]


Re: Where is the GENERAL SETTINGS tab? by Nakroma
[Yesterday at 04:48:17 PM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

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