#!/usr/bin/perl # # $Id$ # Copyright 2004-2006 - Michael Sinz # # A simple display of the invocation of this CGI # use CGI; $cgi = new CGI; my $path = $cgi->path_info(); my $p2 = $cgi->param('param2'); my $p3 = $cgi->param('param3'); my @params = $cgi->param; ## Assume things are not good... my $color = '#FF0000'; my $status = 'Failed!'; if ((defined $p2) && (defined $p3) && (@params == 3) && ($path =~ m:^/(.*)/test\.html$:)) { ## Looking better, we have some form of complete path_info() ## And we have parameter #2 and there are exactly 3 parameters. $color = '#FFFF00'; $status = 'Warning!'; my $part = $1; if (($part eq $p2) && ($path eq $p3)) { $color = '#00DD00'; $status = 'Working'; } } print $cgi->header('-Cache-Control' => 'no-cache' , '-type' => 'text/html'); print '' , '' , '' , 'Insurrection Apache mod_rewrite Tests' , '' , '' , '
' , '
URL: 
' , '' , '' , '
' , '' , ''; &printRow('cgi->url',$cgi->url); &printRow('cgi->path_info()',$cgi->path_info()); if (@params > 0) { print ''; foreach my $p (sort @params) { &printRow($p,$cgi->param($p)); } } print '
' , $status , '
Params
' , '
' , ''; foreach my $k (sort keys %ENV) { &printRow($k,$ENV{$k}); } print '
' , '
' , '
' , '' , ''; exit 0; sub printRow($key,$value) { my $key = shift; my $value = shift; print '' , '' , &escape($key) , '' , '' , &escape($value) , '' , ''; } sub escape($str) { my $str = shift; $str =~ s/&/&/sg; $str =~ s//>/sg; $str =~ s/"/"/sg; return $str; }