This blog is intended to keep my family and friends up-to-date about my
activities, thoughts and feelings, while being away from Germany "across
the pond" working as an intern at DaimlerChrysler RTNA in Palo Alto, CA.

Tuesday, March 1

Hit Me Baby

As you might have discovered (if you have Java-Script enabled), there has been a hit-counter at the end of the sidebar for some days now. Some time ago, I was looking for a free text-counter, but didn't find any and since I didn't want a graphical counter I wrote my own PHP-based one.

The invocation is quite funny: since I didn't figure out a way to execute remote PHP scripts non-interactively from within a HTML page in the browser (is there any?), the browser now thinks it downloads an external Java-Script file, which it wants to execute. This is why a Java-Script enabled browser is required to invoke the counter. But instead of downloading a static Java-Script file, the actual counter.php script is remotely executed, which dynamically creates the requested Java-Script. The created Java-Script consists only of a lousy document.write($content); line, while the $content is computed by the counter.php script. Got it? ;)

The text-counter has some nice features:
  • The counter is per-site/per-referer based, so you have a different counter for each of your HTML files.
  • The output is completely configurable via key=value pairs, which you append to the counter's URL.
  • The counter supports multiple users with their own counter file.
If you are interested, you can download the counter here. Note that there is absolutely no form of authentication at the moment, which means everybody can link to and use the counter. Maybe I will add some domain-based reg-exps in the future to restrict access.

0 Comments:

Post a Comment

<< Home