ispman/ispman-web/htdocs/admin index.cgi,1.23,1.24

Joerg Delker <[email protected]> Tue, 31 Jul 2007 10:10:56 +0000
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/ispman-web/htdocs/admin
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv27357/ispman-web/htdocs/admin

Modified Files:
	index.cgi 
Log Message:
fixed bug [ 1693935 ] ispmanUrlPrefix is not honored

Index: index.cgi
===================================================================
RCS file: /cvsroot/ispman/ispman/ispman-web/htdocs/admin/index.cgi,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- index.cgi	28 May 2006 23:48:13 -0000	1.23
+++ index.cgi	31 Jul 2007 10:10:54 -0000	1.24
@@ -10,7 +10,6 @@
 use CGI::Session qw(-ip-match);
 use CGI::Carp qw(fatalsToBrowser);
 
-
 use strict;
 
 # global vars
@@ -25,37 +24,46 @@
 my $sid = $r->cookie("CGISESSID") || $r->param("CGISESSID") || undef;
 
 # get/create session
-my $session = new CGI::Session("driver:File", $sid, {Directory=>'/tmp'});
+my $session = new CGI::Session( "driver:File", $sid, { Directory => '/tmp' } );
+
+# get ispman config
+require ISPMan::Config;
+my $config = ISPMan::Config->new();
+
+if ( $ispman->getConfig("ispmanUrlPrefix") ) {
+    $ENV{'SCRIPT_NAME'} =
+      $ispman->getConfig("ispmanUrlPrefix") . "/admin/index.cgi";
+}
 
 # do we have a authenticated session?
-if ($session->param("uid")) { # yes
-    
+if ( $session->param("uid") ) {    # yes
+
     # is this a logout request?
-    if ($r->param("logout")){
+    if ( $r->param("logout") ) {
+
         # delete session and invalidate cookie
         $session->delete();
-        my $cookie = $r->cookie(CGISESSID => "" );
+        my $cookie = $r->cookie( CGISESSID => "" );
 
         # redirect to login page
-        print $r->redirect( -url => $ENV{'SCRIPT_NAME'},
-                            -cookie => $cookie );
+        print $r->redirect(
+            -url    => $ENV{'SCRIPT_NAME'},
+            -cookie => $cookie
+        );
         exit;
     }
 }
-else { # no session
-
-    # get ispman config
-    require ISPMan::Config;
-    my $config = ISPMan::Config->new();
+else {    # no session
 
     # do we have login credentials?
-    if ( $r->param("uid") && $r->param("pass") ) { # yes, so try logon
+    if ( $r->param("uid") && $r->param("pass") ) {    # yes, so try logon
 
         # create LDAP object
         require Net::LDAP;
-        my $ldap = Net::LDAP->new( $config->{'ldapHost'},
-                                   version => $config->{'ldapVersion'} )
-            or die "$@";
+        my $ldap =
+          Net::LDAP->new( $config->{'ldapHost'},
+            version => $config->{'ldapVersion'} )
+          or die "$@";
 
         my ( $binddn, $base, $filter, $scope );
         my $uid = $r->param("uid");
@@ -94,8 +102,8 @@
 
             $binddn = $entry->dn();
         }
-        else { # logintype undef or admin
-            
+        else {    # logintype undef or admin
+
             $r->param( "logintype", "admin" );
             $binddn = join ',',
               (
@@ -111,21 +119,21 @@
             print $result->error;
             $ldap->unbind();
         }
-        else { # success
+        else {    # success
 
             # save necessary data in session and continue login
-            $session->save_param($r, ["logintype","language"]);
+            $session->save_param( $r, [ "logintype", "language" ] );
             $session->param( "sessID", time );
-            $session->param( "uid", $uid );
-            if ($binddn =~ /ispmanResellerId=(\d+)/){
-                $session->param("ispmanResellerId",$1);
+            $session->param( "uid",    $uid );
+            if ( $binddn =~ /ispmanResellerId=(\d+)/ ) {
+                $session->param( "ispmanResellerId", $1 );
+            }
+            if ( $binddn =~ /ispmanClientId=(\d+)/ ) {
+                $session->param( "ispmanClientId", $1 );
             }
-            if ($binddn =~ /ispmanClientId=(\d+)/){
-                $session->param("ispmanClientId",$1);
-            }                
 
             # create session cookie
-            my $cookie = $r->cookie(CGISESSID => $session->id );
+            my $cookie = $r->cookie( CGISESSID => $session->id );
 
             # start from the beginning with this new session
             print $r->redirect(
@@ -138,14 +146,14 @@
         $ldap->unbind();
         exit;
     }
-    else { # no sessions, no credentials
-        
+    else {    # no sessions, no credentials
+
         require ISPMan::L10N;
         require Text::Template;
 
         # prepare HTML template for login page
         my $templateDirectory = "$config->{'installDir'}/cgi-bin/tmpl";
-        my $template = new Text::Template(
+        my $template          = new Text::Template(
             DELIMITERS => [ '<perl>', '</perl>' ],
             TYPE       => "FILE",
             SOURCE     => "$templateDirectory/login.tmpl"
@@ -162,7 +170,7 @@
 # So the user is properly authenticated...
 
 # set new session ID when requested
-$session->param("sessID", time) if $r->param("newSession");
+$session->param( "sessID", time ) if $r->param("newSession");
 $session->flush;
 
 print $r->header( -charset => "UTF-8" );
@@ -201,4 +209,3 @@
 
 1;
 
-


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/