|  | @@ -0,0 +1,46 @@
 | 
	
		
			
			|  | 1 | +#!/usr/bin/perl -w
 | 
	
		
			
			|  | 2 | +
 | 
	
		
			
			|  | 3 | +## Author: Alois Mahdal at zxcvb cz
 | 
	
		
			
			|  | 4 | +# Back-end for very primitive remote logging. Front-end is htlogr.pm
 | 
	
		
			
			|  | 5 | +
 | 
	
		
			
			|  | 6 | +# This program is free software: you can redistribute it and/or modify
 | 
	
		
			
			|  | 7 | +# it under the terms of the GNU General Public License as published by
 | 
	
		
			
			|  | 8 | +# the Free Software Foundation, either version 3 of the License, or
 | 
	
		
			
			|  | 9 | +# (at your option) any later version.
 | 
	
		
			
			|  | 10 | +
 | 
	
		
			
			|  | 11 | +# This program is distributed in the hope that it will be useful,
 | 
	
		
			
			|  | 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
	
		
			
			|  | 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
	
		
			
			|  | 14 | +# GNU General Public License for more details.
 | 
	
		
			
			|  | 15 | +
 | 
	
		
			
			|  | 16 | +# You should have received a copy of the GNU General Public License
 | 
	
		
			
			|  | 17 | +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
	
		
			
			|  | 18 | +
 | 
	
		
			
			|  | 19 | +use CGI;
 | 
	
		
			
			|  | 20 | +
 | 
	
		
			
			|  | 21 | +my $LOG_FILE = 'htlog.log';
 | 
	
		
			
			|  | 22 | +open my $fh, ">>", $LOG_FILE or die "cannot open log file for appending: $!";
 | 
	
		
			
			|  | 23 | +
 | 
	
		
			
			|  | 24 | +my $q = CGI->new;
 | 
	
		
			
			|  | 25 | +my $msg = ( defined $q->param('msg')    ? $q->param('msg')  : '' );
 | 
	
		
			
			|  | 26 | +my $tag = ( defined $q->param('tag')    ? $q->param('tag')  : '-none-' );
 | 
	
		
			
			|  | 27 | +
 | 
	
		
			
			|  | 28 | +my $message = sprintf("Time: %s, Origin: %s, Tag: %s, Message: %s\n",
 | 
	
		
			
			|  | 29 | +    time,
 | 
	
		
			
			|  | 30 | +    $ENV{'REMOTE_ADDR'},
 | 
	
		
			
			|  | 31 | +    $tag,
 | 
	
		
			
			|  | 32 | +    $msg
 | 
	
		
			
			|  | 33 | +);
 | 
	
		
			
			|  | 34 | +
 | 
	
		
			
			|  | 35 | +
 | 
	
		
			
			|  | 36 | +print $fh $message;
 | 
	
		
			
			|  | 37 | +
 | 
	
		
			
			|  | 38 | +print $q->header(
 | 
	
		
			
			|  | 39 | +    -type               => 'text/javascript',
 | 
	
		
			
			|  | 40 | +    -expires            => 'now',
 | 
	
		
			
			|  | 41 | +);
 | 
	
		
			
			|  | 42 | +
 | 
	
		
			
			|  | 43 | +print "Message logged: $msg\n";
 | 
	
		
			
			|  | 44 | +
 | 
	
		
			
			|  | 45 | +close $fh or die "cannot close log file: $!";
 | 
	
		
			
			|  | 46 | +
 |