For WileyKat (Counter)

Posted on 1998-10-22
Medium Priority
Last Modified: 2010-04-09
How about that grafical counter??  Please be more detailed I do not understand it all.  Thanks
Question by:steath_acid
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4

Expert Comment

ID: 1838967
Okay, I'll explain the concept in this comment, but I may have to email you the code; a graphical counter uses quite a lot of it. But anyway, here goes:

I assume you know how a basic text counter works. Every time it's called, it opens it's count file, reads the number, increases it, writes it back to the file, and prints the number to the browser. It's the simplest and least useful counter that exists.
More complex counters will check if the IP that's requesting the count has visited the counter in the last x minutes, to prevent someone from flooding the counter.
It's the good counters, the ones that use graphics, that really get people's attention. A graphical counter must do MUCH more than just output a character string to the browser.
A graphical counter starts the same way a textual counter would, by opening it's count file, reading it, and increasing the count by one. However, it must then take the number it gets and break it down into individual numbers. For example, the number 12345 will be broken down into the numbers 1, 2, 3, 4, and 5. If you didn't want to have to worry about this, you'd need one GIF file for EVERY number from 0 to whatever the maxiumum would be. Say the counter went only to 10000. At one K per file, that's STILL 10M+1K of files. To get around this rediculous thing, a graphical counter uses only ten GIF files, namely the numbers from 0 to 9. It then takes EACH number it's broken down and gets the GIF file representing that number. It then must paste that GIF together with the GIFs of the other numbers in the count.
For example, using 12345 again, the counter will take first the graphic file for the number 1 (I'll use 1.gif as the filename). It will read that file, create an empty GIF image, copy the GIF image data from 1.gif into the new GIF, and close 1.gif. It will then take 2.gif, read it, COPY it into the new GIF as a separate part of the picture, and close it. This process will continue for 3.gif, 4.gif, and 5.gif.
The counter will then output the final conglomerate GIF to the browser and save the new count to the count file.
The hard part is in combining the GIF files, something that isn't simple by any means. I don't do it myself. I use a public-domain graphics library written by someone else, a library called gd. It's that code I use to write my graphical counters, and it works very well.
Let me summarize a graphical counter CGI (one that doens't do anything EXCEPT show the counter; it doesn't handle flood protection or any of that):
1. Open the count file.
2. Read the current count.
3. Increase that count by one.
4. Break that count down into it's component place numbers. (1s place, 10s place, etc.)
5. Create an empty GIF image.
6. Open the GIF file for each component number and add that file's data onto the end of the final GIF.
7. Print the final GIF to the browser with a MIME type of image/gif.
8. Save the new count to the count file.
9. Close the count file.
10. Exit.

I'll put together the code for the graphical counter I've described meantime. Do you have any questions on what I've outlined here? (Don't ask me about the GIF format or about how exactly the combination of GIFs is done, I really don't know, though I'm trying to learn :-| ).

Author Comment

ID: 1838968
Ok, I understand this.  What do you enter the code in??  Another wise is it HTml, JAVA, JAVSCRIPT, ect???  Also email the code to,  steath_acid@softhome.net

Expert Comment

ID: 1838969
I'll get that code to you as soon as it's finished. My apologies in advance for any delays. BTW, I'll most likely be doing the code in Perl; it's the best language for it. If not Perl, then C.
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.


Expert Comment

ID: 1838970
You can do counter in Javascript, but there're pages such as geocities and many other,
that can give you free counters that automatically counts - you need only to add link to them from your page.

Expert Comment

ID: 1838971
steath_acid, that counter is on it's way to you via email. I would appreciate some points for my work. to jack_p50: I believe this question specifically said: For WILEYKAT. I would have answered the question myself if you hadn't (excuse this term:) butted in. So, I hope you'll excuse me if I ask you to butt out so steath_acid can give me the points I worked for.

Author Comment

ID: 1838972
Get out of here jack_p50 it says for WileyKat so if you want to comment fine but please do not post answers!

Accepted Solution

WileyKat earned 800 total points
ID: 1838973
I have sent you the counter via email and patiently (ok, maybe not patiently :) await your acceptance of this answer. If the counter does not work, please email me and I will try to identify the problem.

Author Comment

ID: 1838974
Here are your points but I still have not tested it, I will email you if it does not work.

Expert Comment

ID: 1838975

Author Comment

ID: 1838976
here WileyKay go to:
and post a answer it does not matter what you say I will give you the points.  The question seems to be dead and you probely deserve the points anyway. Also if you do not post a answer in one week i will put the points up for grapes to anyone.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question