[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

For WileyKat (Counter)

Posted on 1998-10-22
10
Medium Priority
?
303 Views
Last Modified: 2010-04-09
How about that grafical counter??  Please be more detailed I do not understand it all.  Thanks
0
Comment
Question by:steath_acid
  • 5
  • 4
10 Comments
 
LVL 2

Expert Comment

by:WileyKat
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 :-| ).
0
 

Author Comment

by:steath_acid
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
0
 
LVL 2

Expert Comment

by:WileyKat
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.
0
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.

 
LVL 4

Expert Comment

by:jack_p50
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.
0
 
LVL 2

Expert Comment

by:WileyKat
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.
0
 

Author Comment

by:steath_acid
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!
0
 
LVL 2

Accepted Solution

by:
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.
0
 

Author Comment

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

Expert Comment

by:WileyKat
ID: 1838975
ok
0
 

Author Comment

by:steath_acid
ID: 1838976
here WileyKay go to:
http://www.experts-exchange.com/topics/bin/Q.10084067
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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).
Suggested Courses

834 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