Author Topic: REQUEST: Keycaptcha for 4images  (Read 5666 times)

0 Members and 1 Guest are viewing this topic.

Offline drwebster93

  • Pre-Newbie
  • Posts: 1
    • View Profile
REQUEST: Keycaptcha for 4images
« on: June 04, 2014, 07:17:24 AM »
I saw another topic on the forum outlining how to use reCaptcha, and I was wondering if someone could provide the same for using a Keycaptcha.

They provide the code necessary to implement the captcha in PHP on this page:
https://www.keycaptcha.com/php-captcha/

I am using 4images version 1.7.11

Any help would be greatly appreciated!  Thanks ahead of time!

-drwebster93

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: REQUEST: Keycaptcha for 4images
« Reply #1 on: June 07, 2014, 04:14:27 PM »
I would think it would integrate the same way the recaptcha did. I will look into it and see if I can get it to work.
I have to get my local server seen from the internet again. Something happened with my WAMP that now I cannot hit it from outside.
After I get that fixed then I will see how easy this keycaptcha will be and will let you know.

Update:
Here is what I came up with and it seems to work. I did notice it does not let the admin bypass the captcha code and I do not see a way around that so as long as you are OK with that here are the steps to make this thing work...

Step 1
Copy the "keycaptcha.php" file from their site to your /includes/ folder.
You will need to edit the top of the file putting in your userid and private key in the places they point out on their site.

Step 2
in your pageheader.php file...
Search for
Code: [Select]
$site_template->register_vars($array);insert AFTER
Code: [Select]
//keycaptcha
if (!class_exists('KeyCAPTCHA_CLASS')) {
// Replace '/home/path_to_keycaptcha_file/' with the real path to keycaptcha.php
include('includes/keycaptcha.php');
}
$kc_o = new KeyCAPTCHA_CLASS();

//end keycaptcha

search for...
Code: [Select]
  "url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),insert AFTER
Code: [Select]
  "keycaptcha" => $kc_o->render_js(),
in your includes/captcha_utils.php file
search for
Code: [Select]
$sess_code = trim($site_sess->get_session_var('captcha'));insert BEFORE
Code: [Select]
//keycaptcha
if (!class_exists('KeyCAPTCHA_CLASS')) {
// Replace '/home/path_to_keycaptcha_file/' with the real path to keycaptcha.php
include('includes/keycaptcha.php');
}
$kc_o = new KeyCAPTCHA_CLASS();
if ($kc_o->check_result($_POST['capcode'])) {
return true;
}
else {
// A visitor solved KeyCAPTCHA task incorrectly
// Add your code that will generate an error message
}
//end keycaptcha

Now the difficult part. In your templates, on the ones you want to add this keycaptcha code...
You need to place {keycaptcha} on the template where you are wanting it to be displayed...
also, on the template page you will see something like
Code: [Select]
<input type="hidden" name="action" value="postcomment" /> (value may be different)
insert BEFORE
Code: [Select]
<input type="hidden" name="capcode" id="capcode" value="false" />on the line like...
Code: [Select]
<input type="submit" name="postbutton" value="{lang_post_comment}" class="button" /> (may be different looking depending on page you are editing...
ADD
Code: [Select]
id="postbut" BEFORE the
Code: [Select]
class="button"the line would read...
Code: [Select]
<input type="submit" name="postbutton" value="{lang_post_comment}" id="postbut" class="button" />
and you should be done...
If you are having troubles getting it to work with certain templates, let me know which one and I may have time to take a look.







« Last Edit: June 07, 2014, 11:05:53 PM by budduke »
Buddy Duke
www.budduke.com