Texis Web Script source code for: https:///texisdocs.thunderstone.com
Note: Click on links to view the documentation for HTML tags which are special to the Vortex compiler.
<script language=vortex>
<timeout=-1></timeout>


<!----------------------------------------------------------------------------
Install Notes: 

You must either have Texis 2.5+ or Webinator 2.5+ to run this.

1: Edit the IP address prefix in the <logfile> function for your IP prefix. 

2: Edit the path name to your log file in the <logfile> function  below.

3: Save this file under the filename "weblog" in your ~htdocs/webinator directory

4: Point your browser at http://www.myserver.com/cgi-bin/texis/webinator/weblog/

Note: This program works with the Apache style combined log format only.
      If your log differs from this you'll have to edit the TIMPORT
      shema in the <init> funnction. 
      
------------------------------------------------------------------------------>


<a name=logfile> 
  <$allowip=">>=\L198.49.220." ">>=\L206.183.1." ">>=\L192.168."><!-- EDIT THIS LINE -->
  <rex $allowip $REMOTE_ADDR />
  <if $ret eq "">
     Access Denied
     <exit>
  </if>
  <if '' eq $SERVER_ROOT><$SERVER_ROOT="/usr2/pub/httpd"></if>
  <sum "%s" $SERVER_ROOT "/logs/transfer.log"><$logfile=$ret>
  <!-- EDIT THE ABOVE LINE -->
  <$norefer="www\.thunderstone\.com"
            "thunder\.thunderstone\.com"
      >          <!-- EDIT THIS LINE -->
</a>

<!-----------------------------------------------------------------
Read and parse the log file backwards, filter out the URL spooge 
------------------------------------------------------------------->

<a name=readlog>
<readln maxlines=1000000 REV $logfile> 
   <timport $schema $ret>
     <rex "\.gif=>>=" $Request />
     <if $ret eq "">
	<if $Date lt $dt>
	  <return>
	</if>
	<cleanlog> 
        <$count=($count+1)> 
	<xtree insert $Client   Client />
	<xtree insert $Request  Request />
	<xtree insert $Agent    Agent />
	<rex $norefer $Referrer /> <!- WE only want to know off site refers -->
	<if $ret eq "">
	  <xtree insert $Referrer Referrer />
	</if>
     </if> 
   </timport>
</readln>
</a>

<!-----------------------------------------------------------------
 Filter spooge out of a Request or Referrer 
------------------------------------------------------------------->

<a name=cleanlog>
        <sandr ">>/\+=[^/]+" "" $Request> <!-- clean texis requests -->
        <sandr ">>\?=.+" "" $ret>     
        <$Request=$ret>
        <sandr ">>/\+=[^/]+" "" $Referrer> <!-- clean texis requests -->
        <sandr ">>\?=.+" "" $ret>     
        <$Referrer=$ret>
</a>

<!-----------------------------------------------------------------
 The main entry point: Generate the Report
------------------------------------------------------------------->

<a name=main>
<init>
<dtrpts>
Web Log stats from: 
<$date=(convert( convert(  $dt , 'date' ), 'varchar' ))>
$date
to:
<$date=(convert( convert( 'now' , 'date' ), 'varchar' ))>
$date<br>
<readlog>
<b>$count total hits</b>
<hr><b>Hits by client</b>
<$item=Client>
<obcnt>
<hr><b>Hits by URL</b>
<$item=Request>
<obcnt>
<hr><b>Referred by URLS</b>
<$item=Referrer>
<obcnt>
<hr><b>User Agents</b>
<$item=Agent>
<obcnt>
</a>

<!-----------------------------------------------------------------
 Order,Count and print the Item being reported upon.
------------------------------------------------------------------->

<a name=obcnt>
<$when=(convert($dt, 'date'))>
<xtree dump $item />
<$what=$ret>
<count $what>
<if $ret gt $maxshow> (top $maxshow shown)</if><br>
<b>Total unique: $ret</b><br>
<xtree count $item />
<$count=$ret>
<pre>
<sort $count num desc $what>
<loop max=$maxshow $what $count>
   <fmt "%6d <a href=%s/detail.html?q=%U&dt=%U&var=%U>%H</a>\n" $count $url $what $when $item $what>
</loop>
</pre>
</a>


<!-----------------------------------------------------------------
 This is what happens if you click on a reported item.
 It shows the log lines that match the item within that time-frame
------------------------------------------------------------------->

<a name=detail>
<init>
<pre>
<readln maxlines=1000000 REV $logfile>
   <$ln=$ret>
   <timport $schema $ln>
	<if $Date lt $dt>
	  <return>
	</if>
	<cleanlog> 
	<getvar $var>
        <if $q eq $ret>
           $ln
        </if>
   </timport>
</readln>
</pre>
</a>

<!-----------------------------------------------------------------
 Generate the 'Other Reports' form
------------------------------------------------------------------->

<a name=dtrpts>
<$dts= "-1 min" "-5 min" "-10 min" "-30 min" "-1 hour" "-8 hours" "-1 day" "-1 week">
<$ns= 10 25 50 100 200 500>
<form method=get action=$urlroot>
Other reports: <select name=dt><options $dts $dt $dts></select> 
Top: <select name=maxshow><options $ns $maxshow $ns><select>
<input type=submit value="Make Report">
</form><br>
</a>

<!-----------------------------------------------------------------
 Initialize the variables that we'll need 
------------------------------------------------------------------->

<a name=init>
<if $dt eq "">
  <$dt='-1 min'>
</if>
<if $maxshow="">
  <$maxshow=50>
</if>
<logfile>
<$count=0>
<$schema='
database /tmp/testdb
table    htlog2
recdelim \x0a
multiple
trimspace
datefmt dd/mmm/yyyy:HH:MM:SS
# this expression should be on one line with no intervening spaces
recexpr  >>^\P=[^ ]+ +-?[^ ]* +-?[^ ]* +\[=[^\]]+]= +"=[^ ]+ +[^ "]+ HTTP/?\digit?\.?\digit?"= +[^ ]+ +[^ ]+ +"=[^"]*"= +"=[^/"]*/*[^ "]* *[^"]*"[^\x0a]*
#       Name            Type            Tag
field   Client          varchar(40)     2
field   Ident           varchar(40)     5
field   User            varchar(20)     8
field   Date            date            11
field   Method          varchar(10)     15
field   Request         varchar(100)    17
field   Protocol        varchar(10)     18-21
field   Status          integer         24
field   Bytes           integer         26
field   Referrer        varchar(100)    29
field   Agentname       varchar(10)     33
field   Agentver        varchar(10)     35
field   Agentinfo       varchar(50)     37
field   Agent           varchar(50)     33-37
'>
</a>

</script>

Back to the Code Example List

The Source Viewer is also a Code Example.
Click Here to see its source.
Copyright © 1992-1999 Thunderstone Software
Copyright © 2024 Thunderstone Software LLC. All rights reserved.