#!/usr/bin/perl -w ## Author: Alois Mahdal at zxcvb cz # Back-end for very primitive remote logging. Front-end is htlogr.pm # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . use CGI; my $LOG_FILE = 'htlog.log'; open my $fh, ">>", $LOG_FILE or die "cannot open log file for appending: $!"; my $q = CGI->new; my $msg = ( defined $q->param('msg') ? $q->param('msg') : '' ); my $tag = ( defined $q->param('tag') ? $q->param('tag') : '-none-' ); my $message = sprintf("Time: %s, Origin: %s, Tag: %s, Message: %s\n", time, $ENV{'REMOTE_ADDR'}, $tag, $msg ); print $fh $message; print $q->header( -type => 'text/javascript', -expires => 'now', ); print "Message logged: $msg\n"; close $fh or die "cannot close log file: $!";