in reply to Re^2: What's the deal with apostrophes?
in thread What's the deal with apostrophes?

I still see a problem with your code: You are not counting "pages requested", but "pages requested with a browser that supports and allows Javascript". The real page request counts are in the access log of your web server. If you don't have access to that, you could deliver all pages through a perl script that counts the request.

Oh, and by the way: You are using file locks when you update the counter file, right? And you check that the file name passed by the browser is one of the files you want to update, right?

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^3: What's the deal with apostrophes?

Replies are listed 'Best First'.
Re^4: What's the deal with apostrophes?
by tallCoolOne (Initiate) on Jun 09, 2009 at 21:02 UTC
    ok, hmmm... Some new points to ponder. I guess I kind of assumed that javascript was pretty ubiquitous. I do have access to "real" server access logs provided by my host. But where's the fun in that, when I can write scripts to do things?
    Ummm... file locks? I am not updating the counter file myself, the perl program in the cgi-bin directory does that. It is just a simple increment script that increments the number in the file supplied to it by the calling command. I have made sure that there is a count file for every page, with the same name as the content page, but with no extension (it seems the perl code wants it this way), and that the javascript call in the webpage has the name of the count file for that page. So it all lines up nicely.
    Now I am trying to figure out how to add LWP to my cygwin installation so that I can request the count files, and put the numbers into a report that shows each page that is visited. To be sure, I can validate this against the server logs if I want, but again, where's the fun in that?
    It's great to have come this far after so long, but now I want to do all the cool stuff that the big people do with real websites, but I can still only barely crawl.
    Can you explain the file locking thing a little more for me please? If need be, I can supply the count program code, to check it to see if it locks files.
    Thanks for your help.
      I guess I kind of assumed that javascript was pretty ubiquitous.

      The most recent data I've seen claims that 93% of users have javascript available, but I'm not clear on whether that's defined as "using a javascript-capable browser" or "have javascript turned on".

      Personally, I use Firefox with the NoScript plugin, which prevents javascript from running unless I've specifically whitelisted the site that the javascript-containing document came from. So I do have javascript... but I won't be running yours unless you give me a reason to.

      Also keep in mind that, in general, spiders and other bots don't process any javascript in the pages they encounter. Depending on your objectives, this may be either an advantage or a disadvantage to using javascript.

      I do have access to "real" server access logs provided by my host. But where's the fun in that, when I can write scripts to do things?

      What about writing scripts to parse and summarize the access logs, then generate pages (maybe even graphs) for you to easily view this information? That sounds a lot more interesting to me than one that just does "open a file, increment the number, write it back out".

        There are graphs and things that come with the tools that are built in, and I can take a look at that, but some of it is fairly cryptic, and doesn't say much about specific page hits. The "open file, increment, write it out" script was provided by the host, and it works fine. What I am going to work on next is a script that will check all of the "counter" files, and get the number inside each one for each page, and list that out.
        So I am getting LWP installed with my Cygwin installation, and I am learning about "wget", and other similar functions. The tips you provided about opening and closing files, and going through lists of things are a big help, and I will use those tips to help me write a cleaner, more straightforward script to check the counts of all the pages.
        The javascript I am using is dynamically setting CSS style values to show or hide sections of menus to the various pages. I have worked on it for a while, unfortunately javascript is not my strength, and so I mostly rely on the help of friends to get that going. There is a bug right now in one code module that IE cannot deal with at all, but Firefox will get around, but still flag it. So if you want to take a look at it, feel free. I'd be happy to hear any opinions you have on the site in general.
        Additionally, your help will help me improve my scripts that generate my html pages from the source text files, so you have really helped me out.
        Thank you again for everything.
      Can you explain the file locking thing a little more for me please?
      Suppose your site gets so much traffic, you have two people requesting your page almost at the same time. So you have two instances of your count program opening the counter file, reading in the value, incrementing it, and writing the new value back. If the second instance reads the value before the first instance has written the new value, your count will be off. And you're back to writing a script processing the log files. Which I would think is far more enjoyable than writing 1995 style counters, but you don't.