TNG Rip Prevention

From Genwiki

Jump to: navigation, search

If you are not comfortable with html and php editing, this page may not be for you


This TNG modification includes several features:

  • Rip Prevention
It can help deter some of the automated processes that simply rip (copy) our sites for potential comercial gain. It monitors the time interval between visitor accesses. If the accesses are rapid and repeated, a warning is issued. If the accesses continue rapid and repeatedly, the visitor is temporarily banned and an explanation page is displayed. Warnings and bans are disabled for administrators.
To view an example of this, you may access my site and simply hit the refresh quickly. A few rapid accesses will result in a warning page. Simply wait a few seconds and operation will return to normal. Repeated rapid access will result in a 60 second ban where an explanation page is displayed.
To deter those slow automated programs that scrape your site, if you are running V6.2.0, you may optionally add a Rip Prevention captcha challenge. If added, you may configure the number of visits within a specified time that you will allow before a graphical challenge is presented to confirm the visitor is human and not an automated program. Check here to see an example of the captcha page.
  • Site Access Statistics Page
In addition to the warning and ban pages, a simple access stats page is available on the admin page. The left banner will include an entry (in English) "Show Access" which will display the current stored access information. I have sorted it by Bans, Warnings, Total fast page access, and Total accesses. A button is included to optionally sort the information using alternate columns. A view only version of the access stats may be viewed on my site as well. The delete functions are disabled since you are not logged in. Check it here ( I'm always playing with the colors and fonts, so that would be up to your choosing.)
  • Custom Message to browsing IP address
Create a custom message to specific IP addresses that are browsing your site. This feature allows selection of the IP/Host that is viewing your site, adding a custom message, and monitoring whether they have viewed it or not. The custom message will be displayed for a selectable (1-9) page views, then disappear. The number of page views left will be displayed in the site statistics page. To view this in action, check the link above to the statistics page, sort by time, and your address should be at the top. Since you are not logged in as administrator, the messaging system will only work for your originating IP address/hostname. A default message (max 1000 characters) is included, but may be customized.
  • Specific Host Banning
Provides a convenient way to permanently ban specific user accesses based upon host name. This feature allows selection of specific host names on the "Show Access" page by using the "B"an button. Banned host names will be displayed with their IP address bolded in a red font. Clicking the "B"an button of a banned host name will remove the ban. Users logged in as admin will not be banned, but be careful. Banning your IP, then logging out will cause you to be banned. (You'll have to log in from an alternate IP and then unban yourself).

Rev 1.20e Feb 25, 2009 - update to begin.php to include the latest security update regarding the url injection hack identified on Feb 25, 2009.
Rev 1.20e Jan 16, 2009 - update to instructions for 7.0.3 for better backward compatibility.
Rev 1.20d Nov 30, 2008 - minor update to instructions for 7.0.2 for the genlib modification.
Rev 1.20c Nov 20, 2008 - minor update to zip packaging and instructions with regard to genlib.php change note. It was easy to miss these couple lines of changes due to the instructions. The message feature would not work if you missed this.


  1. A working TNG installation - see The Next Generation of Genealogy Sitebuilding
  2. PHP Graphics support (GD library)
    • to check your server; use TNG->admin->Setup&Configuration->PHP-info-Screen
    • look for a section that indicates "GD support enabled"
  3. A backup of your TNG files
    • begin.php
    • admin/leftbanner.php

Side Effects

  1. As with any modification to a TNG file, this modification will get lost during your next TNG version update and you will need to re-implement the mod. However, it is only a single line addition to each of the files.
  2. The captcha graphics can be difficult to read for the visually impaired. Although a reload button has been included to

allow users to request alternate graphics, they may not be able to gain access to your site after too many attempts.

Package Contents

The following zip file contains the necessary files to allow the addition of this feature.

  • The zip file TNG Rip Prevention Rev contains:
    • the two display pages: rip_warning.html and rip_ban.html
    • check_access.php - the visitor monitor code
    • showaccess.php - the visitor access display code
    • genlib changes 7.0.x.txt - describes two single line changes in the genlib.php file for version 7.0.2-7.0.3
    • genlib changes pre-7.0.2.txt - describes two single line changes in the genlib.php file for version prior to 7.0.2
    • challenge/version 7.0.0-7.0.3/rip_challenge.php - the visitor challenge page
    • challenge/version 7.0.0-7.0.3/genlib changes.txt - a description of required changes
    • challenge/version 7.0.0-7.0.3/English/rip_challenge_text.php - the customizable text for the challenge display
    • challenge/version 7.0.0-7.0.3/freecap/** - 12 files required for the captcha graphics
    • challenge/version 6.2.0/rip_challenge.php - the visitor challenge page
    • challenge/version 6.2.0/genlib.php - a modified V6.2.0 TNG file
    • challenge/version 6.2.0/English/rip_challenge_text.php - the customizable text for the challenge display
    • challenge/version 6.2.0/freecap/** - 12 files required for the captcha graphics
    • version 5.1.4/admin/leftbanner.php - a modified TNG file
    • version 5.1.4/begin.php - a modified TNG file
    • version 6.0.0/admin/leftbanner.php - a modified TNG file
    • version 6.0.0/begin.php - a modified TNG file
      • version 6.0.1 - use the V6.0.0 file set
    • version 6.0.2/admin/leftbanner.php - a modified TNG file
    • version 6.0.2/begin.php - a modified TNG file
      • version 6.0.3, 6.0.4 or 6.1.0 - use the V6.0.2 file set
    • version 6.1.1/admin/leftbanner.php - a modified TNG file
    • version 6.1.1/begin.php - a modified TNG file
    • version 6.1.3/admin/leftbanner.php - a modified TNG file
    • version 6.1.3/begin.php - a modified TNG file
    • version 6.2.0/admin/leftbanner.php - a modified TNG file
    • version 6.2.0/begin.php - a modified TNG file
    • version 7.0.0-7.0.3/admin/leftbanner.php - a modified TNG file
    • version 7.0.0-7.0.3/begin.php - a modified TNG file

Installation Instructions

  • IF you are running Version 5.1.4 or 6.0.0 to 6.1.1 or 6.1.3 or 6.2.0 or 7.0.0-7.0.3 then

If you have previously modified your TNG begin.php or admin/leftbanner.php file, do not continue. You WILL lose any changes to that file you have previously made.

  1. backup your existing TNG begin.php, genlib.php, and admin/leftbanner.php file
  2. download this zip {TNG Rip Prevention Rev}
  3. unzip it, examine the contents
  4. open the rip_warning.html file and edit the contents (you can use something like notepad or wordpad)
    • personalize the text with your name, or modify to suit
  5. open the rip_ban.html file and edit the contents (you can use something like notepad or wordpad)
    • personalize the text with your name, or modify to suit
  6. copy your version of rip_ban.html and rip_warning.html to the base TNG folder (where the begin.php file is)
  7. copy check_access.php file to the same base TNG folder
  8. copy showaccess.php file to the TNG ./admin folder
  9. select the appropriate version folder
    • copy the begin.php to the base TNG folder
  10. make the two couple line changes to your genlib.php script as described in the "genlib changes.txt" file. Choose the appropriate changes description depending on the version of TNG you are running.
  11. Optional CAPTCHA Challenge screen (TNG V6.2.0 and V7.0.x only)
    1. copy the "freecap" folder to the main TNG folder if you have not already installed my CAPTCHA mod
      • make sure it is readable and executable by all
      • verify that all the ".ht****" files and the freecap.php file are in the new "freecap" folder
      • ensure they are all readable
      • MAC users - please note that the .ht*** files are reported to be hidden files and may not be visible. The program "Transfer" has been recommended to assist with this.
      • copy the rip_challenge_text.php files to your language folders if it is not already there.
      • for example, copy the /./English/rip_challenge_text.php to the ./English folder
      • add the include line for the rip_challenge_text to the /./English/cust_text.php file as per the example file provided in the challenge language folder
    2. copy the rip_challenge.php file to the main TNG folder
      • if you have chosen to use the Captcha page with the email address, you should update the email address using the instructions described a little further on.
  12. check it out

  • IF you are NOT running v5.1.4/v6/v7 or you HAVE made changes to either of the above files then, you must add the single include line to the begin.php file on your own and the link to the showaccess.php file in the leftbanner.php file. Follow the instructions above, except open and edit the begin.php and admin/leftbanner.php files, do not copy them.
  1. before following the instructions above
    • open and edit your begin.php from:
  • to
 include($cms[tngpath] . "check_access.php");
  • open your admin/leftbanner.php and edit the following:
 <tr><td><a href="reports.php" target="main" class="lightlink"><?php echo $admtext[reports]; ?></a></td></tr>
 <tr><td><a href="languages.php" target="main" class="lightlink"><?php echo $admtext[languages]; ?></a></td></tr>

  • to
 <tr><td><a href="reports.php" target="main" class="lightlink"><?php echo $admtext[reports]; ?></a></td></tr>
 <tr><td><a href="showaccess.php" target="main" class="lightlink">Show Access</a></td></tr>
 <tr><td><a href="languages.php" target="main" class="lightlink"><?php echo $admtext[languages]; ?></a></td></tr>


Although the default values in the check_access.php file work well for me, the parameters may be customized

  • visitor access speed detection
  • number of fast accesses before a warning is displayed
  • number of fast accesses before a ban is displayed
  • length of time for a visitor ban
  • number of visits within the specified time before a captcha challenge is presented
  • number of seconds (specified time) over which the number of visits is monitored
  • names of valid search engine indexers

How do I use the Messaging Feature

When viewing the site statistics page, locate the particular IP/Hostname of interest. The numbered button in the Host Name column indicates how many views of the message are left. If the number is 0, then clicking on the button will bring up a text edit box with a default message. Edit this, or leave it as is and click ADD. The page will refresh, highlight the Host Name in red, and indicate the number of message views remaining on the button.

If you click a button with a non-zero on it, it will remove the message request.

How do I BAN a specific IP address

If you have one of those pesky browsers that keep returning, and refuses to contact you or contribute, you might choose to BAN them from your site. (This is not my choice of action, but it may suit some) Clicking the 'B' button will result in that address being banned permanently. To "undo" a ban, simply click the 'B' button again. The page will refresh and highlight the IP address in red if it is Banned. Keep in mind that this is simply an IP ban. Your annoying browser can simply go to another address and continue again.

How do I remove old entries, or the very low count accesses

Table maintenance is provided while viewing the access table in the "Show Access" under the admin area. Selecting either of the Date or Page Hit "Sort" buttons will display the "Del" option button to enable record deletions. Clicking the "Del" button will display the access page with an individual button in each of the date or hit cells. These cell buttons will immediately remove all table entries before the date selected, or all table entries with fewer page hits, depending on the "Del" operations that has been activated.

Customization - Embedded email address in the Captcha Challenge page

If you would like to use the Captcha Challenge page which displays your email address (but hidden from robots), you may use the TNG_captcha.php file in the "Captcha with email address" folder. This file MUST be customized with your email address information. Follow these instructions:

  1. open the TNG_captcha.php file in the "Captcha with email address" folder
  2. if your email address is then
    • edit the line xa="myname";
    • edit the line xs="";
    • edit the line xq="The Subject line for the email message";
  3. edit line 65 and change "My Name" to the name you would like displayed on the page
  4. close the file and copy it to the main TNG folder
  5. check it out

In the event of a problem with your TNG site

  1. copy your backup begin.php to your base TNG folder
  2. copy your backup leftbanner.php file back to the admin sub folder
    • all should be well now
  3. you may also delete the additional files you copied in


  1. You're sort of on your own... If you have a specific question, or feel some additional info in the above would help others, feel free to contact me directly. Mail me here
    • Please post suggestions, or your own flavour of this mod to the forum or list
Personal tools