Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 74dec2448b
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 52 lines (36 sloc) 1.037 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#!/usr/bin/perl -w
use warnings;
use strict;

LedgerSMB::Handler->cgi_handle();

package LedgerSMB::Handler;
use LedgerSMB::Log;
use warnings;
use strict;
use CGI::Carp qw(fatalsToBrowser);

sub cgi_handle {
    my $self = shift;

    my $script = $ENV{PATH_INFO};

    $script =~ s/^\///;

    # TODO: we can parse out other information, such as
    # Company Identifier, and what not here.

    #return $self->debug();

    if ( $script =~ /\.pl$/ ) {

        # perl scripts should be directly executed.
        warn "[LedgerSMB::Handler] running $script";
        exec("./$script") or croak $!;
    }
    else {

        # redirect them back to the original url

        # infer the base URI, this fails unless the script is named lsmb.pl
        my ($base_uri) = $ENV{SCRIPT_NAME} =~ m#^(.*?)/lsmb.pl#;
        print "Status: 301\nLocation: $base_uri/$script\n\n";
    }
}

sub debug {
    my $self = shift;

    use Data::Dumper;
    print "Content-type: text/plain\n\n";
    print "\$0 is $0\n";
    print Dumper( \%ENV );

}

1;
Something went wrong with that request. Please try again.