Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Help with CGI Counter

    This was posted a while ago: Help in modifying CGI/PERL Code.
    I also ran across that script and would like to use it.
    It all works except for displaying the bit map of the count.

    There are no errors generated... when I View Image Info:

    Location: http://www.xxx.net/cgi-bin/count.cgi?test_counter
    Type: X-XBITMAP Image
    Size: Unknown (not cached)
    Dimensions: 0px × 0px (scaled to 24px × 24px)

    I must be missing something...
    Quote Originally Posted by compassman View Post
    ...This works on my page...
    Quote Originally Posted by mlseim View Post
    You could convert all the bits to the inverse of what they are ...
    ... maybe you could help a fellow from your neck of the woods, eh?

    Thanks in advance for any help...

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    0
    Thanked 28 Times in 28 Posts
    That code is very old and does not use strict or warnings. I'd therefore advise against using it, as it will take a while to debug the problem.

    Instead, I'd simply recommend that you get any of the free counters available via google if you really want such for your website. But honestly, I'd advise against bothering with a counter at all.

    - Miller

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't see how my answer about inverting the bits pertains to a page counter.

    Are you doing your site mostly using Perl?


    .

  • #4
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    I don't see how my answer about inverting the bits pertains to a page counter.

    Are you doing your site mostly using Perl?


    .
    No, mostly html but with JavaScript and Perl for stuff html can't do.
    Sorry, but I thought that because you may have looked at the code used in that other post you answered the question about you may have had some insight into why script isn't printing the bit map image to the page...

    Thanks...

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by miller View Post
    That code is very old and does not use strict or warnings. I'd therefore advise against using it, as it will take a while to debug the problem.

    Instead, I'd simply recommend that you get any of the free counters available via google if you really want such for your website. But honestly, I'd advise against bothering with a counter at all.

    - Miller
    Most of the 'free' counters require registration, etc... also, I don't want to link to a third party. With the 'old' code at least I have control. Most of the Counters I have found are not very customizable, i.e., they have borders and colors you can't get rid of or change. I also want to be able to put the count in-line and even hide it. Actually the best I found was a FP component, but I don't want to use any FP extensions. I'm also using this as a coding challenge to get back into coding in Perl/CGI.

    Thanks for the advice. If you happen to know of any code that is similar and would work, please post some links. I've looked at a lot, enough to make my head swim, and most of the snippets always seem to leave something out... no real plain step-by-step examples... hey, I'm not a pro and have a lot to learn and re-learn ... and it doesn't help being old...

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by moot View Post
    Most of the 'free' counters require registration, etc... also, I don't want to link to a third party. With the 'old' code at least I have control. Most of the Counters I have found are not very customizable, i.e., they have borders and colors you can't get rid of or change. I also want to be able to put the count in-line and even hide it. Actually the best I found was a FP component, but I don't want to use any FP extensions. I'm also using this as a coding challenge to get back into coding in Perl/CGI.

    Thanks for the advice. If you happen to know of any code that is similar and would work, please post some links. I've looked at a lot, enough to make my head swim, and most of the snippets always seem to leave something out... no real plain step-by-step examples... hey, I'm not a pro and have a lot to learn and re-learn ... and it doesn't help being old...
    in first sentance miller advise you to add pragma strict and warnings and debug the script
    just do it if you like and we will try to help you if you need,

    best regards

  • #7
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    in first sentance miller advise you to add pragma strict and warnings and debug the script
    just do it if you like and we will try to help you if you need,

    best regards
    Oh, I do need and would appreciate help, anytime...

    I looked at the strict link and tried use strict; and use strict "vars"; that resulted in the Type being forced to text/html (from X-XBITMAP Image)
    use strict "refs"; use strict "subs"; did not make any difference...
    Will add the 'warnings' next... is there any other code I can put in to force a debug mode?

    Will continue... hoping compassman is still around and maybe he can shed some light... seems he may be the only one that has it working...

  • #8
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    You should know that hit counters are meaningless and a complete waste of time.

    If you really want to do this, then start off by using File::CounterFile to track the meaningless "hits". http://search.cpan.org/~gaas/File-Co...CounterFile.pm

    The use css to style it as you wish. If you really want to make it into a graphic image, then look at some of the graphics modules on cpan. I haven't used any myself, so I can't make any firm recommendations as to which module would be best.

  • #9
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FishMonger View Post
    You should know that hit counters are meaningless and a complete waste of time...
    I am aware that hit counters, and for that matter, any numbers gathered may or may not have any relevant meaning... be that as it may, you may be missing a finer point... I'm doing this mainly to get my coding skills back and to find out how something works ( or not in this case)...

    So thank you for your interest in how I 'waste' my time - but - I don't think trying to learn is a 'waste of time'...

    Anyway, if someone has some constructive ideas on why the code does not work, please share... if someone has gotten the code to work, please... share

    I'm going to start modifying the code now to use formatted text to display the numbers ... I like the basic code that allows the unique id so it can be easily used on different pages... I probably will not even put the display on the page(s), just use the counts...

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by moot View Post
    Oh, I do need and would appreciate help, anytime...

    I looked at the strict link and tried use strict; and use strict "vars"; that resulted in the Type being forced to text/html (from X-XBITMAP Image)
    use strict "refs"; use strict "subs"; did not make any difference...
    Will add the 'warnings' next... is there any other code I can put in to force a debug mode?

    Will continue... hoping compassman is still around and maybe he can shed some light... seems he may be the only one that has it working...
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings 'all';
    runing the script with perl -c will give you something like this:
    Code:
    Variable "$in" is not imported at counter.pl line 149.
    Variable "$in" is not imported at counter.pl line 152.
    Variable "@in" is not imported at counter.pl line 156.
    Variable "$in" is not imported at counter.pl line 156.
    Variable "@in" is not imported at counter.pl line 158.
    Variable "@in" is not imported at counter.pl line 160.
    Variable "@in" is not imported at counter.pl line 163.
    Variable "@in" is not imported at counter.pl line 166.
    Variable "@in" is not imported at counter.pl line 167.
    Variable "@in" is not imported at counter.pl line 168.
    Variable "%in" is not imported at counter.pl line 169.
    Variable "%in" is not imported at counter.pl line 169.
    Variable "%in" is not imported at counter.pl line 170.
    Global symbol "$minLen" requires explicit package name at counter.pl line 5.
    Global symbol "$counterdir" requires explicit package name at counter.pl line 8.
    Global symbol "$lockWait" requires explicit package name at counter.pl line 10.
    Global symbol "$len" requires explicit package name at counter.pl line 22.
    Global symbol "$i" requires explicit package name at counter.pl line 24.
    Global symbol "$i" requires explicit package name at counter.pl line 24.
    Global symbol "@bytes" requires explicit package name at counter.pl line 24.
    Global symbol "$i" requires explicit package name at counter.pl line 24.
    Global symbol "@bytes" requires explicit package name at counter.pl line 25.
    Global symbol "$i" requires explicit package name at counter.pl line 25.
    Global symbol "$i" requires explicit package name at counter.pl line 26.
    Global symbol "@bytes" requires explicit package name at counter.pl line 26.
    Global symbol "$i" requires explicit package name at counter.pl line 28.
    Global symbol "$count" requires explicit package name at counter.pl line 37.
    Global symbol "$totalReads" requires explicit package name at counter.pl line 37.
    Global symbol "@bytes" requires explicit package name at counter.pl line 38.
    Global symbol "$len" requires explicit package name at counter.pl line 39.
    Global symbol "$count" requires explicit package name at counter.pl line 39.
    Global symbol "$minLen" requires explicit package name at counter.pl line 39.
    Global symbol "$count" requires explicit package name at counter.pl line 39.
    Global symbol "$minLen" requires explicit package name at counter.pl line 39.
    Global symbol "$outtext" requires explicit package name at counter.pl line 40.
    Global symbol "$len" requires explicit package name at counter.pl line 40.
    Global symbol "$count" requires explicit package name at counter.pl line 40.
    Global symbol "$i" requires explicit package name at counter.pl line 41.
    Global symbol "$i" requires explicit package name at counter.pl line 41.
    Global symbol "$len" requires explicit package name at counter.pl line 41.
    Global symbol "$i" requires explicit package name at counter.pl line 41.
    Global symbol "@bytes" requires explicit package name at counter.pl line 42.
    Global symbol "$y" requires explicit package name at counter.pl line 44.
    Global symbol "$y" requires explicit package name at counter.pl line 44.
    Global symbol "$y" requires explicit package name at counter.pl line 44.
    Global symbol "$x" requires explicit package name at counter.pl line 45.
    Global symbol "$x" requires explicit package name at counter.pl line 45.
    Global symbol "$len" requires explicit package name at counter.pl line 45.
    Global symbol "$x" requires explicit package name at counter.pl line 45.
    Global symbol "@bytes" requires explicit package name at counter.pl line 46.
    Global symbol "%chars" requires explicit package name at counter.pl line 46.
    Global symbol "$outtext" requires explicit package name at counter.pl line 46.
    Global symbol "$x" requires explicit package name at counter.pl line 46.
    Global symbol "$y" requires explicit package name at counter.pl line 46.
    Global symbol "$i" requires explicit package name at counter.pl line 49.
    Global symbol "$i" requires explicit package name at counter.pl line 49.
    Global symbol "$len" requires explicit package name at counter.pl line 49.
    Global symbol "$i" requires explicit package name at counter.pl line 49.
    Global symbol "@bytes" requires explicit package name at counter.pl line 50.
    Global symbol "@in" requires explicit package name at counter.pl line 56.
    Global symbol "$scriptURL" requires explicit package name at counter.pl line 57.
    Global symbol "$scriptURL" requires explicit package name at counter.pl line 61.
    Global symbol "$scriptURL" requires explicit package name at counter.pl line 63.
    Global symbol "$scriptURL" requires explicit package name at counter.pl line 66.
    Global symbol "$countername" requires explicit package name at counter.pl line 72.
    Global symbol "@in" requires explicit package name at counter.pl line 72.
    Global symbol "$countername" requires explicit package name at counter.pl line 73.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 74.
    Global symbol "$counterdir" requires explicit package name at counter.pl line 74.
    Global symbol "$countername" requires explicit package name at counter.pl line 74.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 75.
    Global symbol "$start" requires explicit package name at counter.pl line 76.
    Global symbol "%in" requires explicit package name at counter.pl line 76.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 77.
    Global symbol "$start" requires explicit package name at counter.pl line 78.
    Global symbol "$count" requires explicit package name at counter.pl line 86.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 95.
    Global symbol "$lockCount" requires explicit package name at counter.pl line 99.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 100.
    Global symbol "$lockCount" requires explicit package name at counter.pl line 101.
    Global symbol "$lockWait" requires explicit package name at counter.pl line 101.
    Global symbol "$count" requires explicit package name at counter.pl line 102.
    Global symbol "$lockCount" requires explicit package name at counter.pl line 106.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 108.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 108.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 113.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 114.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 114.
    Global symbol "$totalReads" requires explicit package name at counter.pl line 116.
    Global symbol "$totalReads" requires explicit package name at counter.pl line 117.
    Global symbol "$totalReads" requires explicit package name at counter.pl line 119.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 120.
    Global symbol "$counterFile" requires explicit package name at counter.pl line 120.
    Global symbol "$totalReads" requires explicit package name at counter.pl line 121.
    Global symbol "%chars" requires explicit package name at counter.pl line 126.
    Global symbol "%chars" requires explicit package name at counter.pl line 127.
    Global symbol "%chars" requires explicit package name at counter.pl line 128.
    Global symbol "%chars" requires explicit package name at counter.pl line 129.
    Global symbol "%chars" requires explicit package name at counter.pl line 130.
    Global symbol "%chars" requires explicit package name at counter.pl line 131.
    Global symbol "%chars" requires explicit package name at counter.pl line 132.
    Global symbol "%chars" requires explicit package name at counter.pl line 133.
    Global symbol "%chars" requires explicit package name at counter.pl line 134.
    Global symbol "%chars" requires explicit package name at counter.pl line 135.
    Global symbol "$i" requires explicit package name at counter.pl line 145.
    Global symbol "$loc" requires explicit package name at counter.pl line 145.
    Global symbol "$key" requires explicit package name at counter.pl line 145.
    Global symbol "$val" requires explicit package name at counter.pl line 145.
    Global symbol "$in" requires explicit package name at counter.pl line 149.
    Global symbol "$i" requires explicit package name at counter.pl line 151.
    Global symbol "$i" requires explicit package name at counter.pl line 151.
    Global symbol "$i" requires explicit package name at counter.pl line 151.
    Global symbol "$in" requires explicit package name at counter.pl line 152.
    Global symbol "@in" requires explicit package name at counter.pl line 156.
    Global symbol "$in" requires explicit package name at counter.pl line 156.
    Global symbol "$i" requires explicit package name at counter.pl line 158.
    Global symbol "@in" requires explicit package name at counter.pl line 158.
    Global symbol "@in" requires explicit package name at counter.pl line 160.
    Global symbol "$i" requires explicit package name at counter.pl line 160.
    Global symbol "@in" requires explicit package name at counter.pl line 163.
    Global symbol "$i" requires explicit package name at counter.pl line 163.
    Global symbol "$loc" requires explicit package name at counter.pl line 166.
    Global symbol "@in" requires explicit package name at counter.pl line 166.
    Global symbol "$i" requires explicit package name at counter.pl line 166.
    Global symbol "$key" requires explicit package name at counter.pl line 167.
    Global symbol "@in" requires explicit package name at counter.pl line 167.
    Global symbol "$i" requires explicit package name at counter.pl line 167.
    Global symbol "$loc" requires explicit package name at counter.pl line 167.
    Global symbol "$val" requires explicit package name at counter.pl line 168.
    Global symbol "@in" requires explicit package name at counter.pl line 168.
    Global symbol "$i" requires explicit package name at counter.pl line 168.
    Global symbol "$loc" requires explicit package name at counter.pl line 168.
    Global symbol "%in" requires explicit package name at counter.pl line 169.
    Global symbol "$key" requires explicit package name at counter.pl line 169.
    Global symbol "%in" requires explicit package name at counter.pl line 169.
    Global symbol "$key" requires explicit package name at counter.pl line 169.
    Global symbol "%in" requires explicit package name at counter.pl line 170.
    Global symbol "$key" requires explicit package name at counter.pl line 170.
    Global symbol "$val" requires explicit package name at counter.pl line 170.
    counter.pl had compilation errors.
    most of this come from missing declaration, my or local, and fixing them is just first step, doesn't mean that will work.

    you can use, as FishMonger suggest, File::CounterFile and replace some part of the code ( pretty much of it i guess, ).

    best regards

  • Users who have thanked oesxyl for this post:

    moot (03-28-2011)

  • #11
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    0
    Thanked 28 Times in 28 Posts

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by miller View Post
    this is something like this? http://shemesh.larc.nasa.gov/images/humor-zfc.jpg

    best regards

  • #13
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,871
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Here's a much better example of a graphical hit counter which uses the GD module to create the counter, but this is also on the old side and could use a few adjustments to bring it up to current standards.

    http://linuxgazette.net/81/misc/padala/counter.cgi.txt

    It was taken from here:
    http://linuxgazette.net/81/padala.html

  • Users who have thanked FishMonger for this post:

    moot (03-29-2011)

  • #14
    New Coder
    Join Date
    Mar 2011
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    ...runing the script with perl -c ...
    I changed the first line of count.cgi to #!/usr/bin/perl -c
    and ran the script and got the following error:

    500 Server Error
    A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again. URL: http://www.xxx.net/cgi-bin/count.cgi

    I looked at the server error log but there were no errors from my ip.

    When I run the script the same way without -c I get:

    counter.xbm
    To put a visitor counter like this on your web page, put an image tag in your HTML document like:
    <IMG SRC="http://www.xxx.net:80/cgi-bin/count.cgi?unique_id">
    where "unique_id" is a unique identifier for your counter.

    When creating a new counter you can set the starting value by adding a count parameter to the URL. So if the counter "qwerty" didn't exist, accessing the URL
    http://www.xxx.net:80/cgi-bin/count....rty&COUNT=1234
    will create a new counter called "qwerty" with its counter set to 1234.
    The counter can only be set when creating a new counter.

  • #15
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by moot View Post
    I changed the first line of count.cgi to #!/usr/bin/perl -c
    and ran the script and got the following error:

    500 Server Error
    A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again. URL: http://www.xxx.net/cgi-bin/count.cgi
    no,
    'perl -c scriptname' from command line. This will check only if the script will compile.

    I looked at the server error log but there were no errors from my ip.

    When I run the script the same way without -c I get:

    counter.xbm
    To put a visitor counter like this on your web page, put an image tag in your HTML document like:
    <IMG SRC="http://www.xxx.net:80/cgi-bin/count.cgi?unique_id">
    where "unique_id" is a unique identifier for your counter.

    When creating a new counter you can set the starting value by adding a count parameter to the URL. So if the counter "qwerty" didn't exist, accessing the URL
    http://www.xxx.net:80/cgi-bin/count....rty&COUNT=1234
    will create a new counter called "qwerty" with its counter set to 1234.
    The counter can only be set when creating a new counter.
    to see the error in browser or log:
    Code:
    use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
    then watch the logs.

    best regards


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •