[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [809] trunk/lsmb.pl



Revision: 809
          http://svn.sourceforge.net/ledger-smb/?rev=809&view=rev
Author:   jasonjayr
Date:     2007-02-15 14:37:06 -0800 (Thu, 15 Feb 2007)

Log Message:
-----------
'Virtual URL' frontend, this will let us (eventually) encode the company name into the URI
so we can go to /ledger-smb/lsmb.pl/acme/login.pl, and only have to admin and login to acme's database.

Ideally index.html will point to the default company, and/or lsmb.pl/login.pl, but this initial commit will
just be this self-contained code.

Added Paths:
-----------
    trunk/lsmb.pl

Added: trunk/lsmb.pl
===================================================================
--- trunk/lsmb.pl	                        (rev 0)
+++ trunk/lsmb.pl	2007-02-15 22:37:06 UTC (rev 809)
@@ -0,0 +1,47 @@
+#!/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;


Property changes on: trunk/lsmb.pl
___________________________________________________________________
Name: svn:executable
   + *


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.