# # SMArT # # Static file server # # Copyright 2001 Wilmer van der Gaast (lintux@lintux.cx) # # # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # sub handle_request() { $f = $c[1]; $f =~ s/[^-_\.A-Za-z0-9]//g; if( ! open( FILE, $smart_static_dir . '/' . $f ) ) { error( 404 ); } $e = $f; $e =~ s/^.*\.//; if( $e eq 'html' ) { $t = 'text/html'; } elsif( $e eq 'gif' ) { $t = 'image/gif'; } elsif( $e eq 'jpg' ) { $t = 'image/jpeg'; } else { $t = 'application/octet-stream'; } print < ) { print; } }