Posted by ljmacphee on June 30, 2008 under how to |
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
Posted by ljmacphee on June 23, 2008 under cgi, how to, perl, php |
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
Posted by ljmacphee on June 16, 2008 under security, tools, wordpress |
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!
Posted by ljmacphee on June 12, 2008 under how to |
1 ) Reduce image size:
This is probably the single most effect thing you can do. Just how big does that header photo need to be?
See Reducing image size
2 ) Use height and width tags in your image link and make your image the same size it will be displayed. You don’t want the browser to have to adjust the image every time it loads.
Every image link should include a height and width tag. This allows the browser to continue to load up the page and fetch images last.
<img src=”http://timestocome.com/images/big-thicket-pitcher-plants-2.jpg” alt=”Big Thicket wild pitcher plants” width=”480″ height=”360″ />
3 ) Reduce the number of queries you website makes to the server.
Put this line in your footer to see how many requests are being made to your webserver.
<!-- <?php echo get_num_queries(); ?> queries -->
Then reduce them - use html in place of php calls for all things that don’t change - like your website name.
There is a WP plugin that will reduce the requests for you here:Acid Drop PHP Speedy Wordpress plugin
4 ) Use only the plugins you really need. It is nice to see the weather on a garden website but does a site about blog design need a weather icon? Only use plugins that give useful information to your users. Also remove any unused plugins from your website. Many load even when not activated.
5 ) Clean up your database.
PHP MyAdmin makes it very easy. Look for junk. I was amazed to find several plugins I had installed and removed left behind over 300 bits of information in my options table.
I. Back up your data base
II. Remove the junk
III. Click the overhead number ( or size ) on the table list and under ‘Space Usage’ at the bottom click ‘optimize’. This is like defragging your harddrive.
PHP My Admin
See also:
Speed tweak of the week
Firebug Firefox plugin will let you see how long your page takes to download and how long each item takes. Be sure to clean out your browser cache first!