Author Topic: [MOD] Registration with security code validation v1.0  (Read 101368 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Registration with security code validation v1.0
« on: October 27, 2005, 02:58:03 AM »
This mod is usefull against auto-registrations, bots. It will display a picture with random code and visitor must type the code in the field.



As of v1.0 this mod works only with GD, no ImageMagick or NetPBM is supported. Also, GD must be compilled with TrueType library (you can check it in phpinfo())

--------[ Installation ]----------

Step 1

Download this package.
Unzip it and upload all files to the root of your 4images installation and restore the following file-tree:
rndimg.php
fonts/comicbd.tff
bg/1.png
bg/2.png
bg/3.png


CHMOD 666 all files

Try to execute rndimg.php by typing in your browser: http://example.com/4images/rndimg.php
If you see an image with code, then you can continue to the next step, otherwise its possible this mod will not work for you at all.


Step 2

Open register.php
Find:
Code: [Select]
    else {
      $msg .= (($msg != "") ? "<br />" : "").$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['email']), $lang['field_required']);
      $error = 1;
    }
Insert below:
Code: [Select]
    $code = $site_sess->get_session_var("rnd_code");
    if (!$code || !isset($HTTP_POST_VARS['code']) || empty($HTTP_POST_VARS['code']))
    {
      $msg .= (($msg != "") ? "<br />" : "").$lang['rndimg_required'];
      $error = 1;
    }
    elseif (strtoupper(trim($HTTP_POST_VARS['code'])) != $code)
    {
      $msg .= (($msg != "") ? "<br />" : "").$lang['rndimg_missmatch'];
      $error = 1;
    }



Step 2.1
Find:
Code: [Select]
  if ($error) {Insert below:
Code: [Select]
    include(ROOT_PATH."rndimg.php");
    $site_template->register_vars(array(
      "lang_rndimg" => $lang['rndimg'],
      "lang_rndimg_expl" => $lang['rndimg_expl'],
      "rndimg_url" => $site_sess->url(ROOT_PATH."rndimg.php?".MD5(time()), "&")."&",
    ));



Step 3

Open lang/<your langauge>/main.php
At the end, above closing ?> insert:
Code: [Select]
$lang['rndimg'] = "Security code";
$lang['rndimg_expl'] = "Please type code from the image<br />Click the image to change it's background";
$lang['rndimg_required'] = "Security code is required";
$lang['rndimg_missmatch'] = "You have entered a wrong security code";



Step 4

Open templates/<your template>/register_form.html
Add
Code: [Select]
          <tr>
            <td class="row2"><b>{lang_rndimg}:</b><br /><img src="{rndimg_url}" onClick="this.src='{rndimg_url}'+((Math.round(Math.random()*(999-100)))+100);"></td>
            <td class="row2 valign="top"><input type="text" name="code" size="5" value="" /><br /><span class="smalltext">{lang_rndimg_expl}</td>
          </tr>
(design is your task ;))




You can upload as many background images and fonts as you wish, no script changes required, the script will pick them randomly. The background images must be jpeg, gif or png type and should be bigger or equal then the WIDTH and HEIGHT settings that set in rndimg.php.
Fonts must be .ttf type.

The default number of letters in the "code" is set to 5, you can change it in rndimg.php in this line:
Quote
function get_code($num = 5, $safe = 1, $norepeat = 0)
when $safe variable is set to true (1) the letters from this array:
Code: [Select]
  $no = array("0","1","i","l","o","7"); //list of characters 0-9 and a-z to exclude from the list. lower case only!will be filtered out from the "code", they will not be used. Set to false (0) if you dont want use the filter.

When $norepeat is set to true (1) it will ensure that no the same letter/number will be generated more then ones. Default is allow duplicate letters/numbers.


There is also a little config that you can play with, which allow you to change size of the image, size of font, font color (shade of grey actualy)



If you would like integrate this mod into comments form, then you can follow ch€ri{Bi}² instructions from this post:
http://www.4homepages.de/forum/index.php?topic=10200.msg68176#msg68176
« Last Edit: April 26, 2006, 01:19:03 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline urmasmuld

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: [MOD] Registration with security code validation v1.0
« Reply #1 on: October 27, 2005, 09:37:47 AM »
Great MOD. Thanks V@no :lol:

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Registration with security code validation v1.0
« Reply #2 on: October 27, 2005, 10:39:16 AM »
hi v@no,
excellent MOD ... great work ...  thanks ...  :D
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Bear

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: [MOD] Registration with security code validation v1.0
« Reply #3 on: October 27, 2005, 01:58:35 PM »
Excellent mod  8)
Thank you

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [MOD] Registration with security code validation v1.0
« Reply #4 on: October 27, 2005, 09:31:48 PM »
i've tried install it , but this give me error on Line : 117 any ideia ???  (in rndimg.php )

 8O

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Registration with security code validation v1.0
« Reply #5 on: October 28, 2005, 12:05:07 AM »
Your server did not meet the minimum requirements:
GD with TrueType
It seems that your server has GD, but without TrueType.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

freiserk_

  • Guest
Re: [MOD] Registration with security code validation v1.0
« Reply #6 on: October 28, 2005, 03:36:12 PM »
not work for my.

say: La imagen “http://localhost:81/rndimg.php” no puede mostrarse, porque contiene errores.

http://luifer.no-ip.info/rndimg.php

http://luifer.no-ip.info/info.php

I have gd and FT.

Many thanks for the work.

freiserk_

  • Guest
Re: [MOD] Registration with security code validation v1.0
« Reply #7 on: October 28, 2005, 03:42:41 PM »
Sorry, corrected.

I have: ./bg and ./fonts

I put: complete dir at line script. (D:\htdocs\WEB\luifer.no-ip.info\web\bg)

Thanks.

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: [MOD] Registration with security code validation v1.0
« Reply #8 on: October 28, 2005, 05:50:37 PM »
I get the same error-message like

Stoleti 
Quote
i've tried install it , but this give me error on Line : 117 any ideia ???  (in rndimg.php )

I asked my provider and he told me GD Library allreday installed with TrueType -> that´s the path -> /usr/bin/GD

Edit: It works on localhost...

Project offline

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Registration with security code validation v1.0
« Reply #9 on: October 28, 2005, 11:31:57 PM »
I asked my provider and he told me GD Library allreday installed with TrueType -> thatґs the path -> /usr/bin/GD
then please show me the link to your phpinfo (PM me if you dont want publish in public)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Registration with security code validation v1.0
« Reply #10 on: October 29, 2005, 12:29:20 AM »
ok, here is the full error message:
Quote
Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /<path>/rndimg.php on line 117
as you see, it can not find the needed font file, the sollution is:
1) double check the permissions on the new files (perhaps try CHMOD 755)
2) double check that atleast one .ttf font file exists in fonts/ folder
3) try to use full local path instead of relative:
Code: [Select]
  define("FONTS_DIR", "/www/htdocs/v116307/lite/fonts"); //path to directory with fonts (.ttf only!)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: [MOD] Registration with security code validation v1.0
« Reply #11 on: October 29, 2005, 12:39:03 AM »
Yeah, it was the path that´s strange  8O

One more time :oops: - thanks V@no  :mrgreen:

Question: ther´re 3 backgrounds, can I change one of them, or delete 2 others ?

Edit: Okay, I know: Step 4 :)

Project offline

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Registration with security code validation v1.0
« Reply #12 on: October 29, 2005, 01:17:28 AM »
Great Mod, Thanks for this. Works perfect....
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Registration with security code validation v1.0
« Reply #13 on: October 29, 2005, 06:45:37 AM »
Question: therґre 3 backgrounds, can I change one of them, or delete 2 others ?

Edit: Okay, I know: Step 4 :)
The backgrounds in the package are more like an example, you can add/delete as many as you wish, as long as there is atleast one image present in bg folder.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline elcorazon

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: [MOD] Registration with security code validation v1.0
« Reply #14 on: October 31, 2005, 01:28:37 PM »
Hello,
No problem of startup.  :P  Thank you  :wink: