<% use inspui::cmn; my ($info,$title,$type,$filename) = @_; %>
<div id=content>
<% 
    my @lines;
    if ($type eq 'fn' || $type eq 'status') {
	{
	    open(FFF,"<$filename");
	    @lines = <FFF>;	
	    close FFF;
	}
	if ($filename =~ /httpd-access_log$/) {
	    @lines = grep { $_ !~ m,(POST|GET) (/webserver-special-interface/|/stunnix-websrv-inspector/|/res/skins/modern/|/stunnix-websrv-utils/|/inspector-root/res), }  @lines;
	};
	if ($filename =~ /httpd-error_log$/) {
	    @lines = grep { $_ !~ m,(exec\(\) may not be safe)|(GetHandleInformation\([^)]+\) failed), }  @lines;
	};
	
    }
    if ($type eq 'fn') {
%>
<pre>
<%$	join("",@lines) %> 
</pre>
    <p><%$ __('Number of lines: ') . (0+@lines) %>
<%












    } elsif ($type eq 'env') {
%>
These are environment variables available to server-side scripts. The ones that are shown in bold 
contain some key information about web server properties (location of various directories and port numbers). 
More information can be found using <a href=viewfile.status>special JSON file</a> containing all properties of server.
<p>

<table>
<thead><tr><th><%= __('Variable') %></th><th align=left><%= __('Value') %></th>
<%    foreach(sort keys %ENV) {
    my %keyvars = map { ($_,1) } qw(DOCUMENT_ROOT MYSQL_HOST_PHP MYSQL_PORT SQLITE_TABLES STUNNIXWS_STATEDIR
    STUNNIXWS_TMPSTATEDIR STUNNIXWS_PORT  STUNNIXWS_PERMSTATEDIR );
%>
<tr><td><%$ $keyvars{$_} ? "<b>$_</b>" : $_ %></td><td><%= $ENV{$_} %></td>
<%    } %>
</table><p>&nbsp;<p>
<%











    } elsif ($type eq 'status') {
%>	

<p>
    Web server exports all its runtime properties in JSON format. It's generated at startup of SAWS and is never
    changed till SAWS is stopped or restarted.
    <p>
    Server-side scritps can read it from file named <tt>status-all-json.js</tt> in directory pointed by environment variable
    <tt>STUNNIXWS_TMPSTATEDIR</tt>.<p>

    Client-side JavaScript can read as JSON using the URL 
    <a href=/webserver-special-interface/status-all-json.js>/webserver-special-interface/status-all-json.js</a>.
    Alternatively your HTML can load 
    <a href=/webserver-special-interface/status-all.js>/webserver-special-interface/status-all.js</a> and read
    the values from JavaScript variable with name <tt>stunnix_web_server_status</tt>.
    <p>
    Here is content from  <tt>status-all-json.js</tt>:
<p>
    
<pre class=server-status >
<%$	join("",@lines) %> 
</pre>


<%    };
%>
</div>



<% if ($type eq 'fn') { 
	$filename =~ s,/+,\\,g if $^O =~ /Win32/i;
%>
	<p>
	<center><div style='font-size: 65%;' ><%$ sprintf(__('Showing content of file: <tt>%s</tt>'), $filename) %></div></center>
<% } %>






<script language=javascript>
<!--
scrollBy(0,document.height);
-->
</script>
