ispman/ispman-web/htdocs/admin index.cgi,1.15,1.16

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/ispman-web/htdocs/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/ispman-web/htdocs/admin

Modified Files:
	index.cgi 
Log Message:
code reformatting by perltidy conforming perl style guide


Index: index.cgi
===================================================================
RCS file: /cvsroot/ispman/ispman/ispman-web/htdocs/admin/index.cgi,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- index.cgi	1 May 2004 21:45:16 -0000	1.15
+++ index.cgi	30 May 2004 23:35:34 -0000	1.16
@@ -6,255 +6,249 @@
 # see the subroutine at the bottom to figure out the installation location
 locateInstallDir();
 
-
 use vars qw($InstallDir);
-unshift @INC,  $ISPMan::InstallDir . "/lib";
-
+unshift @INC, $ISPMan::InstallDir . "/lib";
 
 use vars qw($r $ispman);
 
-
-
 require CGI::Session::File;
 import CGI::Session::File;
 
-require  CGI;
+require CGI;
 import CGI;
 
-require  CGI::Carp;
-import CGI::Carp  "fatalsToBrowser";
-
+require CGI::Carp;
+import CGI::Carp "fatalsToBrowser";
 
 undef $r;
-$r=new CGI;
-
-
-
+$r = new CGI;
 
 my $sid = $r->cookie("SESSION_ID") || $r->param("sid") || undef;
 
-my $session = new CGI::Session::File($sid, 
-                {
-                        LockDirectory   =>'/tmp', 
-                        Directory       =>'/tmp'
-                });
+my $session = new CGI::Session::File(
+    $sid,
+    {
+        LockDirectory => '/tmp',
+        Directory     => '/tmp'
+    }
+);
 
+$sid = $session->id();
 
+my $cookie = $r->cookie( -name => "SESSION_ID", -value => $sid );
 
-$sid  = $session->id();
+if ( $session->param("uid") ) {
+    if ( $r->param("logout") ) {
+        $session->clear( [ "uid", "pass", "language" ] );
+        print $r->redirect( -url => $ENV{'SCRIPT_NAME'} );
+        exit;
+    }
+}
+else {
+    require ISPMan::Config;
+    import ISPMan::Config;
+    my $config = ISPMan::Config->new();
+    if ( $r->param("uid") && $r->param("pass") ) {
+        require Net::LDAP;
+        import Net::LDAP;
+        my $ldap =
+          Net::LDAP->new( $config->{'ldapHost'},
+            version => $config->{'ldapVersion'} )
+          or die "$@";
 
-my $cookie = $r->cookie(-name=>"SESSION_ID", -value=>$sid);
+        my $uid = $r->param("uid");
 
-       
+        my ( $dn, $base, $filter, $scope );
 
-       
+        if ( $r->param("logintype") && $r->param("logintype") ne "admin" ) {
+            if ( $r->param("logintype") eq "reseller" ) {
+                $base   = "ou=ispman,$config->{'ldapBaseDN'}";
+                $scope  = "one";
+                $filter = "&(objectClass=ispmanReseller)(uid=$uid)";
+            }
+            if ( $r->param("logintype") eq "client" ) {
+                $base   = "ou=ispman,$config->{'ldapBaseDN'}";
+                $scope  = "sub";
+                $filter = "&(objectClass=ispmanClient)(uid=$uid)";
+            }
+            my $mesg = $ldap->search(
+                base    => $base,
+                scope   => $scope,
+                filter  => "($filter)",
+                "attrs" => []
+            );
+            my ($entry) = $mesg->entry(0);
 
-if ($session->param("uid")) {
-   if ($r->param("logout")) {
-      $session->clear(["uid", "pass", "language"]);
-      print $r->redirect(-url => $ENV{'SCRIPT_NAME'});
-      exit;
-   }
-} else {
-   require ISPMan::Config;
-   import ISPMan::Config;
-   my $config=ISPMan::Config->new();
-   if ($r->param("uid") && $r->param("pass")) {  
-      require Net::LDAP;
-      import Net::LDAP;
-      my $ldap = Net::LDAP->new($config->{'ldapHost'},version=>$config->{'ldapVersion'}) or die "$@";
-      
-      my $uid=$r->param("uid");
+            unless ($entry) {
+                print $r->header();
+                print "Entry not found.<br>";
 
-      my ($dn, $base, $filter, $scope);
+                print "Using base: $base<br>";
+                print "Using scope: $scope<br>";
+                print "Using filter: $filter<br>";
 
-      if ($r->param("logintype") && $r->param("logintype") ne "admin" ) {
-         if ($r->param("logintype") eq "reseller") {
-            $base="ou=ispman,$config->{'ldapBaseDN'}";
-            $scope="one";
-            $filter="&(objectClass=ispmanReseller)(uid=$uid)";
-         }
-         if ($r->param("logintype") eq "client") {
-            $base="ou=ispman,$config->{'ldapBaseDN'}";
-            $scope="sub";
-            $filter="&(objectClass=ispmanClient)(uid=$uid)";
-         }
-         my $mesg= $ldap->search(base => $base , scope=> $scope , filter => "($filter)", "attrs" => []);
-         my ($entry)= $mesg->entry(0) ;
+                exit;
+            }
 
-         unless ($entry) {
-            print $r->header();
-            print "Entry not found.<br>";
+            $dn = $entry->dn();
+        }
+        else {
 
-            print "Using base: $base<br>";
-            print "Using scope: $scope<br>";
-            print "Using filter: $filter<br>";
+            # there was no logintype set.
+            # set this to "admin"
+            # backwards compatibility.
+            $r->param( "logintype", "admin" );
+            $dn = join ',',
+              (
+                sprintf( "uid=%s", $r->param("uid") ),
+                "ou=admins", $config->{'ldapBaseDN'}
+              );
+        }
 
+        my $result = $ldap->bind( $dn, password => $r->param("pass") );
+        if ( $result->code ) {
+            print $r->header();
+            print $result->error;
             exit;
-         }
+        }
+        else {
 
-         $dn=$entry->dn();
-      } else { 
-         # there was no logintype set.
-         # set this to "admin"
-         # backwards compatibility.
-         $r->param("logintype", "admin");
-         $dn=join ',', (sprintf("uid=%s" , $r->param("uid")) , "ou=admins", $config->{'ldapBaseDN'});
-      }
-      
+            # set the cookie and the session
+            $session->param( "dn", $dn );
+            my @attr = split( /\s*,\s*/, CGI::unescape($dn) );
+            for (@attr) {
+                my ( $var, $val ) = split( /\s*=\s*/, $_ );
+                $session->param( $var, $val );
+            }
+            $session->save_param($r);
+            print $r->redirect( -url => $ENV{'SCRIPT_NAME'},
+                -cookie => $cookie );
+        }
+    }
+    else {
+        require ISPMan::L10N;
+        import ISPMan::L10N;
+        require Text::Template;
+        import Text::Template;
+        my $templateDirectory;
+        if ( -d "$config->{'installDir'}/cgi-bin" ) {
+            $templateDirectory = "$config->{'installDir'}/cgi-bin/tmpl";
+        }
+        else {
+            $templateDirectory =
+              "$config->{'installDir'}/ispman-web/cgi-bin/tmpl";
+        }
 
-      
-      my $result=$ldap->bind( $dn, password => $r->param("pass"));
-      if ($result->code) {
-         print $r->header();
-         print $result->error;
-         exit;
-      } else {
-         # set the cookie and the session
-         $session->param("dn", $dn);
-         my @attr=split(/\s*,\s*/ , CGI::unescape($dn));
-         for (@attr){
-            my ($var, $val)=split(/\s*=\s*/, $_);
-            $session->param($var, $val);
-         }
-         $session->save_param($r);
-         print $r->redirect(-url => $ENV{'SCRIPT_NAME'}, -cookie=>$cookie);
-      }
-   } else {
-      require ISPMan::L10N;
-      import ISPMan::L10N;
-      require Text::Template;
-      import Text::Template;
-		my $templateDirectory;
-		if (-d "$config->{'installDir'}/cgi-bin"){
-			$templateDirectory="$config->{'installDir'}/cgi-bin/tmpl";
-		} else {
-			$templateDirectory="$config->{'installDir'}/ispman-web/cgi-bin/tmpl";
-		}
-	
-      my $template= new Text::Template(
-         DELIMITERS => ['<perl>', '</perl>'],
-         TYPE => "FILE",  
-         SOURCE => "$templateDirectory/login.tmpl"
-      );
-      print $r->header(-charset=>"UTF-8");
-      print $template->fill_in( HASH => $config );
-      exit;
-   }
+        my $template = new Text::Template(
+            DELIMITERS => [ '<perl>', '</perl>' ],
+            TYPE       => "FILE",
+            SOURCE     => "$templateDirectory/login.tmpl"
+        );
+        print $r->header( -charset => "UTF-8" );
+        print $template->fill_in( HASH => $config );
+        exit;
+    }
 
 }
 
+if ( !$session->param("sessID") || $r->param("newSession") ) {
+    $session->param( "sessID",    time );
+    $session->param( "logintype", $r->param("logintype") );
+    $session->param( "language",  $r->param("language") );
 
-if (!$session->param("sessID") || $r->param("newSession")){
-   $session->param("sessID" , time );
-   $session->param("logintype" , $r->param("logintype") );
-   $session->param("language" , $r->param("language") );
-# disabled session save because
-# a) cookie expires at session end, so no need for saving the session
-# b) security breach! password is saved in clear
-#   $session->save_param($r);
+    # disabled session save because
+    # a) cookie expires at session end, so no need for saving the session
+    # b) security breach! password is saved in clear
+    #   $session->save_param($r);
 }
 
-if ($r->param("language")) {
-   $session->param("language" , $r->param("language") );
-#   $session->save_param($r);
-}
+if ( $r->param("language") ) {
+    $session->param( "language", $r->param("language") );
 
+    #   $session->save_param($r);
+}
 
+print $r->header( -charset => "UTF-8" );
 
-print $r->header(-charset=>"UTF-8");
 #print "<p>Session Language is ", $session->param("language");
 #print "<p>Request Language is ", $r->param("language");
 
-
-
-
 require ISPMan;
 require ISPMan::Log;
 import ISPMan;
 import ISPMan::Log;
 
+$ENV{'LANGUAGE'} = $r->param("language") || $session->param("language");
 
+$ispman = ISPMan->new();
 
+$ispman->remote_user( $session->param("uid") );
+$ispman->{'sessID'} = $session->param("sessID");
 
-
-
-
-$ENV{'LANGUAGE'}=$r->param("language") || $session->param("language");
-
-
-
-$ispman=ISPMan->new();
-
-
-$ispman->remote_user($session->param("uid"));
-$ispman->{'sessID'}=$session->param("sessID");
-
-if ($r->param("domain")) {
-   $r->param("ispmanDomain", $r->param("domain"));
+if ( $r->param("domain") ) {
+    $r->param( "ispmanDomain", $r->param("domain") );
 }
 
-if ($r->param("dn")) {
-   my @attr=split(/\s*,\s*/ , CGI::unescape($r->param("dn")));
-   for (@attr){
-      my ($var, $val)=split(/\s*=\s*/, $_);
-      $r->param($var, $val);
-   }
+if ( $r->param("dn") ) {
+    my @attr = split( /\s*,\s*/, CGI::unescape( $r->param("dn") ) );
+    for (@attr) {
+        my ( $var, $val ) = split( /\s*=\s*/, $_ );
+        $r->param( $var, $val );
+    }
 }
 
+my $_path = $ENV{'SCRIPT_NAME'};
+$_path =~ s!/admin/index.cgi!!;
+$ispman->setConfig( "ispmanUrlPrefix", $_path );
 
+my $mode = $r->param("mode");
 
-my $_path=$ENV{'SCRIPT_NAME'};
-$_path=~s!/admin/index.cgi!!;
-$ispman->setConfig("ispmanUrlPrefix", $_path);
-
-
-
-
-
-my $mode=$r->param("mode");
-
-if ($mode){
-   $ispman->printHeaders() unless $mode =~/^(ispman|menu|summary|status)$/;
-} else{
-   $mode||="ispman";
+if ($mode) {
+    $ispman->printHeaders() unless $mode =~ /^(ispman|menu|summary|status)$/;
+}
+else {
+    $mode ||= "ispman";
 }
 
-$ispman->{'session'}=$session;
+$ispman->{'session'} = $session;
 $ispman->$mode($r);
 
 1;
 
+sub locateInstallDir {
+    my @script_components = split '/', $ENV{'SCRIPT_FILENAME'};
 
+    #remove the script name
+    pop @script_components;
 
-sub locateInstallDir {
-	my @script_components=split '/', $ENV{'SCRIPT_FILENAME'};
-	#remove the script name
-	pop @script_components;
-	#now @script_components contains all the directories from the / in an array
+    #now @script_components contains all the directories from the / in an array
 
-	my $chopDirs=0;
+    my $chopDirs = 0;
 
-   	if (-e "../../lib/ISPMan.pm") {
-      		#remove two directories from the end
-      		$chopDirs=2;
-   	} elsif (-e "../../../lib/ISPMan.pm") {
-      		#Developers/maintainers. Without Install
-      		$chopDirs=3;
-   	} else {
-      		#There should be more code here to determine the InstallationPath
-		print "Content-type: text/plain\n\n";
-      		print "Cannot determin Installation Path\n";
-      		exit;
-   	}
+    if ( -e "../../lib/ISPMan.pm" ) {
 
-	if ($chopDirs){
-		for (1..$chopDirs){
-			pop @script_components;
-		}
-	}
-	$ISPMan::InstallDir=join '/', @script_components;
-	return $ISPMan::InstallDir;
-}
+        #remove two directories from the end
+        $chopDirs = 2;
+    }
+    elsif ( -e "../../../lib/ISPMan.pm" ) {
+
+        #Developers/maintainers. Without Install
+        $chopDirs = 3;
+    }
+    else {
+
+        #There should be more code here to determine the InstallationPath
+        print "Content-type: text/plain\n\n";
+        print "Cannot determin Installation Path\n";
+        exit;
+    }
 
+    if ($chopDirs) {
+        for ( 1 .. $chopDirs ) {
+            pop @script_components;
+        }
+    }
+    $ISPMan::InstallDir = join '/', @script_components;
+    return $ISPMan::InstallDir;
+}
 



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.