Solved

For WileyKat (Counter)

Posted on 1998-10-22
10
278 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 200 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now