home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / cgi-bin / stat.pl < prev   
Perl Script  |  2009-11-06  |  5KB  |  113 lines

  1. #!/usr/bin/perl
  2. #  ^
  3. # / \
  4. #  |   Modify the line the arrow is pointing to, to the correct
  5. #  |   location of Perl v5 or better.
  6. #Uninet######################################################################
  7. #   w  w  w  .  u  n  i  n  e  t  s  o  l  u  t  i  o  n  s  .  c  o   m    #
  8. # UNINET PERL COMPANY(TM) PRESENTS                                          #
  9. # StatsPlus 1.25                                                            #
  10. # A simple statistical solution.                                            #
  11. # ------------------------------------------------------------------------- #
  12. # (C)1997-98 Uninet Communications Co., All Rights Reserved.                #
  13. #                                                                           #
  14. # This program is free software; you can redistribute it and/or             #
  15. # modify it under the terms of the GNU General Public License               #
  16. # as published by the Free Software Foundation; either version 2            #
  17. # of the License, or (at your option) any later version.                    #  
  18. #                                                                           #
  19. # This program is distributed in the hope that it will be useful,           #
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of            #
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
  22. # GNU General Public License for more details.                              # 
  23. #                                                                           #
  24. # You should have received a copy of the GNU General Public License         #
  25. # along with this program; if not, write to the                             #
  26. #                Free Software Foundation, Inc.                             #
  27. #                59 Temple Place - Suite 330                                #
  28. #                Boston, MA  02111-1307, USA.                               #
  29. #                                                                           #
  30. # -->A full copy of the GNU General Public License is included in gpl.txt   #
  31. # ------------------------------------------------------------------------- #
  32. # Need Support? Email support@uninetsolutions.com                           #
  33. # ------------------------------------------------------------------------- #
  34. # Modification History:                                                     #
  35. # 1.0: 4/8/1997  StatsPlus released. Product based on Uninet Countran 1.0   #
  36. # 1.25: 4/30/97    Updated to have easy links to the referer.               #
  37. #######################################################################Uninet 
  38. #Just follow the instructions:
  39. #When typing type inside " and ". 
  40. #Setup Part 1/2 - Steps 1 to 7
  41. #1/5 Type The absolute of the the LOG file.
  42. $log = "../data/log.txt";
  43.  
  44. #2/5 Type the absolute path to the counter file.
  45. $count = "../data/num.txt";
  46.  
  47. #3/5 Type the path to the date command
  48. $datecommand = "/usr/bin/date/";
  49.  
  50. #4/5 Type name of your site
  51. $name = "RTSI";
  52.  
  53. #5/5Where will the statistics page be?
  54. $stat = "../stat.html";
  55. #########################################################
  56. #Setup Part 2/2 - Steps 1 to 3
  57. #Place all files in their respective directory.
  58. #1/3 Now chmod 'cstat.pl' 775
  59. #2/3 Then chmod 'log.txt', 'num.txt', and 'stat.htm' 777
  60. #3/3 Now add <!--#exec cgi="cgi-bin/stat.pl" --> to the location in your
  61. #    webpage where you want the counter.
  62. #To see your stats run the page you specified (by default stat.html). 
  63. #  ##    ##    #   #   ###
  64. #  # #  #  #   ##  #   # 
  65. #  # #  #  #   # # #   ###
  66. #  # #  #  #   #  ##   #  
  67. #  ##    ##    #   #   ###    #
  68. #########################################################
  69. #Remember to upload the files in ASCII.
  70. #
  71. #Your done REALLY... So go save this file and leave!
  72. #
  73. #You just don't give up do you? :-) 
  74. #########################################################
  75. #Testing Date
  76. @months = ('Jan','Feb','Mar','Apr','May','June',
  77.          'July','Aug','Sept','Oct','Nov','Dec');
  78.  
  79. @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  80.  
  81. ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
  82. $date = " $days[$wday], $months[$mon]/$mday/$year $hour:$min:$sec";
  83. # Get Count
  84. open (CD, "$count");
  85. $counter = <CD>;
  86. close (CD);
  87. chop ($counter) if $count =~ /\n$/;
  88. # Increase Count
  89. $counter += 1;
  90. open (CD, ">$count");
  91. print CD ("$counter");
  92. close (CD);
  93. print ("Content-type: text/html\n\n");
  94. print "<!-- Processed by StatPlus on $date-->";
  95. #Logging
  96. open (datk, ">>$log");
  97. print datk "<td>$counter</td><td>$ENV{'HTTP_REFERER'}</td><td>$ENV{'REMOTE_ADDR'}</td><td>$date</td><td>$ENV{'HTTP_USER_AGENT'}</td><TR>";
  98. close (datk);
  99. open (datk, "$log");
  100. $data = <datk>;
  101. close (datk);
  102. #Should tell user about update
  103. open (UP,"http://www.serve.com/twn/upd.html");
  104. $upd = <UP>;
  105. close (up);
  106. #Print Sheet
  107. open (logs,">$stat");
  108. print logs "<html><head><title>Statistics for $name.</title></head><body>You currently have had $counter hits.<BR><table border = 1><td>Hit No.</td><td>Referer</td><td>IP address</td><td>date</td><td>client</td><TR>$data</table><BR>(C)1997 TWN Perl Company. Count Stat V1.0 .<BR>$upd<BR><i>$ENV{'SERVER_SOFTWARE'}</i> </body></html>"; 
  109. close (logs);
  110.  
  111.  
  112.  
  113.