Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Archive for June, 2008

How to keep your IP number out of your Awstats

without comments

I started using Awstats to track website activity. It came with cPanel and does a nice job.

However it was tracking my IP number as well. So I read the Awstats directions which tell you to put your *.conf file in your /etc directory. That doesn’t work. You must put your *.conf file in /tmp/awstats.

Ok so we got that far but every night the *.conf files were overwritten by Awstats removing the
SkipHosts=”111.111.111.111″
entry.

It turns out you must also change the file permissions to 0444 to prevent Awstats from overwriting your file each night.

So
1) edit your config file and change the SkipHosts=”" to contain your IP number
SkipHosts=”111.111.111.111″

2) Put this file in /tmp/awstats

3) Chmod the file to 0444

Written by timestocome

June 30th, 2008 at 5:00 am

Posted in how to

How to convert your old Perl-CGI scripts to work in your blog using PHP

without comments

The original TimesToCome site was created in 1997. The web has changed a great deal since then but my scripts hadn’t. I just hacked my blogs to use the PERL scripts. Converting them to work in your blog without using PERL or CGI is actually quite simple.

The first thing to do is convert your old CGI scripts to PHP. Your forms will remain the same except for the name of the script they are calling. ( <form method=”post” action=”new-script-url”> ) I found that User Friendly Forms in PHP, and PHP Form Handling gave me enough information to convert the forms from PERL to PHP. Most of what works in PERL, works in PHP, you’ll find very little needs to be changed. ( ‘PHP Black Book’ is the best book I’ve found so far. )

Once you have a working PHP form you need to incorporate it into your blog. To do this you need to create a page template. The easiest way is to copy an existing page template in your theme. The archives.php page usually works well.

Remove the archives information from the page. I deleted everything after <div id=”content” class=”pages”> down to the matching </div> tag for that division. Your template may be slightly different.

Now copy and paste your PHP form – everything between <body> and </body> into that space between <div id=”content” class=”pages”> and </div>.

Rename the page to something useful, and don’t forget to change the ‘Template Name: xxxx ‘ in the template.

Now log into your Wordpress or other blog. Create a new page, name it something useful. Then go to the templated drop down menu (‘Templates’) and select your newly created template from the menu. Save and publish.

If you wish to use multiple pages for your form just create multiple pages. If you wish it to reload the same page when the script runs, call yourself in the action= and place a hidden check that lets you know if this page is being loaded or if the form is filled out and submitted.

Put the hidden check if form submitted in the form:

<input type=”hidden” name=”submit_check” value=”1″ />

The check for it in the part of the form you do your calculations:
if ($_POST['submit_check'] == 1 ) { /*do something*/ }

See example: Calorie calculator
Download example: Calories example php form in a WP blog

Written by timestocome

June 23rd, 2008 at 5:00 am

Posted in cgi, how to, perl, php

WordPress plugin ‘Tripwire’ 3rd of three part security plugin set

with 10 comments

The final plugin of the three part TTC ( TimesToCome ) WordPress security set is ready. This one acts as a tripwire. If a file is changed by you or more importantly someone other than you you’ll know.

Simply install and activate the plugin. Once activated go to the plugin management page and tell it you want a list of all files changed in the last 0-99 days ( pick your day ) and it will bring up a list of altered files for you.

If your WordPress install is in the top directory of your website this will check all the directories on your website. If you are down one level ( http://yoursite.com/wordpress/ ) then you can change this line:

$directories_to_read[$dir_count] = “../”; // plugins run from wp-admin so bounce up a directory

to this:

$directories_to_read[$dir_count] = “../../”; // plugins run from wp-admin so bounce up a directory

And it will check all the directories not just your WordPress directories.

Download

Part 1: WP plugin to prevent bot registrations

Part 2: WP Security Plugin: block bots, scrapers, cross-script attacks and more

Part 3: Tripwire

Install them all for best results!

Written by timestocome

June 16th, 2008 at 1:00 am

Posted in security, tools, wordpress