[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

656 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