CGI-SSI_Parser

 view release on metacpan or  search on metacpan

SSI_Parser.pm  view on Meta::CPAN

package CGI::SSI_Parser;

use strict;
use POSIX;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;

@ISA = qw(Exporter AutoLoader);
@EXPORT = qw(fssi sssi);
$VERSION = '0.01';

use vars qw($recursive $debug);

$recursive = 0;
$debug = 0;

my $error_msg = '[an error occurred while processing this directive]';
my $SIZEFMT_BYTES = 0;	# sizefmt = bytes
my $SIZEFMT_KMG = 1;	# sizefmt = abbrev
my $sizefmt = $SIZEFMT_KMG;
my $timefmt = "%c";	# current locale's default
my($starting_sequence, $ending_sequence) = ('<!--#', '-->');
my($real_path, $virtual_path);


# Usage:         ssi_init();
#
sub ssi_init {
	my(@real_path, @virtual_path);
	my $i;

	unless (defined($ENV{'DOCUMENT_ROOT'}) ||
		defined($ENV{'SCRIPT_FILENAME'}) ||
		defined($ENV{'SCRIPT_NAME'})) {
		print FOUT $error_msg;
		return 0;
	}

	@real_path = reverse split(/\//, $ENV{'SCRIPT_FILENAME'});
	pop(@real_path);
	@virtual_path = reverse split(/\//, $ENV{'SCRIPT_NAME'});
	pop(@virtual_path);

	for ($i=0; (($i <= $#virtual_path) && ($virtual_path[$i] eq $real_path[$i])); $i++) {
	}

	$real_path = "/" . join("/", reverse @real_path[$i..$#real_path]);
	$virtual_path = "/" . join("/", reverse @virtual_path[$i..$#virtual_path]);

#	$file =~ s/^$virtual_path/$real_path\//o;
#	warn($file) if ($debug);
}

# Usage:         ssi_config_errmsg($line);
#
sub ssi_config_errmsg {
	my $line = shift;

	$error_msg = $line;
}

# Usage:         ssi_config_sizefmt($line);
#
sub ssi_config_sizefmt {
	my $line = shift;

	if ($line eq "bytes") {
		$sizefmt = $SIZEFMT_BYTES;
	} elsif ($line eq "abbrev") {
		$sizefmt = $SIZEFMT_KMG;
	}
}

# Usage:         ssi_config_timefmt($line);
#
sub ssi_config_timefmt {
	my $line = shift;

	$timefmt = $line;
}



( run in 0.710 second using v1.01-cache-2.11-cpan-ceb78f64989 )