KB / Web Programming / CGI, PHP, and Databases / Canned Scripts

From DreamHost

Jump to: navigation, search

From counters to formmail, take advantage of the pre-written CGI scripts we offer to all of our customers, free of charge. Keep reading for more information.


Contents

Parent Article

Example of how to set up a counter

How do I set up counters?

Easy. First pick a filename for your counter data (it should be something like 'username-countername.dat'...see clarification below). So if your NDN ID (DreamHost ID when you signed up) is john and your domain is doe.com your filename selection could be:    john-doe.dat

Next, pick which font you want to use for your counter (it should be something like '&dd=XXXX&istrip=XXXX'). Select a font from the images located here:

Dream Host Counter PageFor example, if you like the groovy purple font called Katt078, your font selection would be:    dd=katt078&istrip=T

  • So now just put your filename and font selection in the proper place of the template example. The final source to cut and paste would be:

<img src=http://counter.dreamhost.com/cgi-bin/Count.cgi?df=john-doe.dat&pad=F&ft=0&dd=katt078&istrip=T>

How do I change the number on my counter?

My counter currently reads 503, but my site on my previous web host had about 16,000 hits before I left. Is there any way to get my counter to reflect my real number of hits?

Certainly, although you'll need to contact us in order to have it changed. All counts are stored in a single text file, stashed away on one of our servers. To change the value, all we need to do is edit it for you. It takes almost no time at all from our end of things, and will result in an accurate count for you. Just let us know what you'd like your number to be, and which count file you are using (ie. 'yourfile.dat') and we'll change it for you.

You can set the counter to a start number the first time you set it up. Use the &st=##### field where ##### is your start number (See counters). If you've already set up a counter this won't work but you can change the name of your counter with the start number added and it will start counting from there.

What kind of canned scripts do you have?

Our "canned" scripts are pre-written cgi scripts that come with all of our plans. They include form-mail, counters, and mailing lists.


Setting up a graphical counter on your web site.

I would like to place a counter on my web site. How do I do this?

One of our most popular "canned" CGI scripts is our web based counter, which allows you to keep a running 'count' on your web page of all the people who have accessed it (since the counter was installed). Our counters are available to all DreamHost customers. You can install as many as you'd like, anywhere on your site, all at no cost!

To put a counter on your page, you will need to embed the following somewhere within your page's code:

????? <IMG SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=sample.dat&dd=A&istrip=T&pad=F&ft=0" ALT="">

But wait! Don't do it yet! You need to customize the code first!

  1. Counter Data File The first thing you will need to do is create a unique name for your counter's data file. In the code snippet above, replace 'sample.dat' with a unique name for your data file, ending in '.dat' - we suggest something like 'username_count.dat', instead replacing 'username' with your own username. Thus, the code should look something like this: <img SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=my_data_file.dat&dd=A&istrip=T&pad=F&ft=0" ALT="">
  2. Choosing A Counter Font Our counter allows you to specify one of several different fonts, so you can pick one that matches your site's look and feel. To do so, simply change the letter 'A' in the counter image HTML given above to match the name given with one of the following counter fonts (remember, upper and lower case letters are different - 'A' is not the same as 'a'). To view our selection of counter fonts, go here: http://counter.dreamhost.com Thus, if you chose the counter called 'visitation,' the finished code you embed in your html page should look something like this: <IMG SRC="http://counter.dreamhost.com/cgi-bin/Count.cgi?df=my_data_file.dat&dd=visitation&istrip=T&pad=F&ft=0" ALT="">



Clarification Notes On Counter Operation -- There is a one to one correspondence between webpages and counter files.

  • If two webpages use the same counter file name then the count will be the sum of the hits on both pages.
  • If you want to count individual page hits you need to have unique file names for each webpage being counted.

The naming convention stated on DreamHost Counter Page is: UserName-CounterName.dat

With this naming convention it is unlikely other people will use your UserName in naming their counter files. In shared servers the user name is required to be unique from other users. This covers the problem of webpages in other domains ending up with the same counter file name. In order to maintain unique file names within your domain you need the second part of the dashed name. In a dynamic webpage you use the page index to automatically generate the -CounterName part.


Question
How do I go about fixing a very slow counter? I have put it on several times, and it does not seem to be advancing but one count every few weeks. The counter on the emailed bulletins is advancing just fine, but the one on an index page is not. What could the problem be?

Personal tools