ispman/ispman-web/htdocs/control_panel index.cgi,1.11,1.12

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

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/control_panel/index.cgi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- index.cgi	14 Jan 2004 22:49:46 -0000	1.11
+++ index.cgi	30 May 2004 23:35:35 -0000	1.12
@@ -1,112 +1,136 @@
 #!/usr/bin/perl
 use strict;
-BEGIN{
-      # see the subroutine at the bottom to figure out the installation location
-      locateInstallDir();
-      use vars qw($InstallDir);
-   unshift @INC,  $ISPMan::InstallDir . "/lib";
 
-   use CGI;
-   my $cgi=CGI->new();
-   #only get in here is a domain cookie is not there
-   if  (!$cgi->cookie("domain") || $cgi->cookie("domain")== -1 ){   
-      # do we have uid and pass passed
-      
+BEGIN {
+
+    # see the subroutine at the bottom to figure out the installation location
+    locateInstallDir();
+    use vars qw($InstallDir);
+    unshift @INC, $ISPMan::InstallDir . "/lib";
+
+    use CGI;
+    my $cgi = CGI->new();
+
+    #only get in here is a domain cookie is not there
+    if ( !$cgi->cookie("domain") || $cgi->cookie("domain") == -1 ) {
+
+        # do we have uid and pass passed
+
       # "use Module" loads the module  on compile time
       # "require Module" and "import Module" does the same thing as "use Module"
       # but loads an runtime only. So we load if we need.
-      require ISPMan::Config;
-      import ISPMan::Config;
-      # get the config informations in $config
-      # we will need the ldapBaseDN and ldapHost values
-      my $config=ISPMan::Config->new();
-      
-      if ($cgi->param("domain") && $cgi->param("pass")) {  
-         
-         my $dn="ispmanDomain=";
-         $dn.=$cgi->param("domain");
-         $dn.=",$config->{'ldapBaseDN'}";
+        require ISPMan::Config;
+        import ISPMan::Config;
 
-         require Net::LDAP;
-         import Net::LDAP;
-         my $ldap = Net::LDAP->new($config->{'ldapHost'},version=>$config->{'ldapVersion'}) or die "$@";
-         my $result=$ldap->bind( $dn, password => $cgi->param("pass"));
-         if ($result->code) {
-            # There was an error.
-            # Either the domain did not exist
-            # or the pass is incorrect
-            # complain and exit
+        # get the config informations in $config
+        # we will need the ldapBaseDN and ldapHost values
+        my $config = ISPMan::Config->new();
+
+        if ( $cgi->param("domain") && $cgi->param("pass") ) {
+
+            my $dn = "ispmanDomain=";
+            $dn .= $cgi->param("domain");
+            $dn .= ",$config->{'ldapBaseDN'}";
+
+            require Net::LDAP;
+            import Net::LDAP;
+            my $ldap =
+              Net::LDAP->new( $config->{'ldapHost'},
+                version => $config->{'ldapVersion'} )
+              or die "$@";
+            my $result = $ldap->bind( $dn, password => $cgi->param("pass") );
+            if ( $result->code ) {
+
+                # There was an error.
+                # Either the domain did not exist
+                # or the pass is incorrect
+                # complain and exit
+                print $cgi->header();
+                print $result->error;
+                exit;
+            }
+            else {
+
+                # set the cookie and the session
+                my $cookie = $cgi->cookie(
+                    -name    => 'domain',
+                    -value   => $cgi->param("domain"),
+                    -expires => +"1h"
+                );
+                $cgi->delete("pass");
+                $cgi->delete("domain");
+                $cgi->param( "mode", "index" );
+                print $cgi->redirect( -url => $cgi->self_url,
+                    -cookie => $cookie );
+            }
+        }
+        else {
+            require ISPMan::L10N;
+            import ISPMan::L10N;
+            require 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/customerMan/login.tmpl"
+            );
             print $cgi->header();
-            print $result->error;
+            print $template->fill_in( HASH => $config );
             exit;
-         } else {
-            # set the cookie and the session
-            my $cookie=$cgi->cookie(-name => 'domain', -value=>$cgi->param("domain") , -expires=>+"1h");
-            $cgi->delete("pass");
-            $cgi->delete("domain");
-            $cgi->param("mode", "index");
-            print $cgi->redirect(-url => $cgi->self_url , -cookie=>$cookie);
-         }
-      } else {
-         require ISPMan::L10N;
-         import ISPMan::L10N;
-         require 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/customerMan/login.tmpl"
-         );
-         print $cgi->header();
-         print $template->fill_in( HASH => $config );
-         exit;
-      }
-   }
+        }
+    }
 
-   if  (defined $cgi->param("logout")){   
-      my $cookie=$cgi->cookie(-name => 'domain', -value=>'-1',  -expires=>"-1h");
-      print $cgi->redirect(-url => $ENV{'SCRIPT_NAME'}, -cookie=>$cookie);
-   }
+    if ( defined $cgi->param("logout") ) {
+        my $cookie =
+          $cgi->cookie( -name => 'domain', -value => '-1', -expires => "-1h" );
+        print $cgi->redirect( -url => $ENV{'SCRIPT_NAME'}, -cookie => $cookie );
+    }
 
+    sub locateInstallDir {
+        my @script_components = split '/', $ENV{'SCRIPT_FILENAME'};
 
-   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
+        #remove the script name
+        pop @script_components;
 
-	my $chopDirs=0;
+     #now @script_components contains all the directories from the / in an array
 
-   	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;
-   	}
+        my $chopDirs = 0;
 
-	if ($chopDirs){
-		for (1..$chopDirs){
-			pop @script_components;
-		}
-	}
-	$ISPMan::InstallDir=join '/', @script_components;
-	return $ISPMan::InstallDir;
- }
+        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 ($chopDirs) {
+            for ( 1 .. $chopDirs ) {
+                pop @script_components;
+            }
+        }
+        $ISPMan::InstallDir = join '/', @script_components;
+        return $ISPMan::InstallDir;
+    }
+
+}
 
 package CustomerMan;
 use strict;
@@ -115,57 +139,47 @@
 
 use vars qw($r $customer $ispman $lang);
 undef $r;
-$r=new CGI;
-
+$r = new CGI;
 
-$customer=CustomerMan->new($r->cookie("domain"));
-*ispman=*customer;
+$customer = CustomerMan->new( $r->cookie("domain") );
+*ispman   = *customer;
 
-if ($r->param("lang")) {
-   $lang=$r->param("lang");
-   my $cookie = $r->cookie(-name=>'lang', -value=>$lang, -path=>'/');
-   print $r->header(-cookie => $cookie);
-   $customer->{'translator'}->setLanguage($lang);
-} else {
-   print $r->header;
-   if ($r->cookie("lang")) {
-      $lang=$r->cookie("lang");
-   } else {
-      $lang='en';
-      $r->param("lang", $lang);
-   }
-   $customer->{'translator'}->setLanguage($lang);
+if ( $r->param("lang") ) {
+    $lang = $r->param("lang");
+    my $cookie = $r->cookie( -name => 'lang', -value => $lang, -path => '/' );
+    print $r->header( -cookie => $cookie );
+    $customer->{'translator'}->setLanguage($lang);
 }
-
-
-
-
-
-
-
-
-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);
-   }
+else {
+    print $r->header;
+    if ( $r->cookie("lang") ) {
+        $lang = $r->cookie("lang");
+    }
+    else {
+        $lang = 'en';
+        $r->param( "lang", $lang );
+    }
+    $customer->{'translator'}->setLanguage($lang);
 }
 
-$r->param("domain", $r->cookie("domain"));
-$r->param("ispmanDomain", $r->cookie("domain"));
-
-
-my $mode=$r->param("mode");
-
-$mode||="summary";
+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 );
+    }
+}
 
+$r->param( "domain",       $r->cookie("domain") );
+$r->param( "ispmanDomain", $r->cookie("domain") );
 
-my $_path=$ENV{'SCRIPT_NAME'};
-$_path=~s!/control_panel/index.cgi!!;
-$customer->setConfig("ispmanUrlPrefix", $_path);
+my $mode = $r->param("mode");
 
+$mode ||= "summary";
 
+my $_path = $ENV{'SCRIPT_NAME'};
+$_path =~ s!/control_panel/index.cgi!!;
+$customer->setConfig( "ispmanUrlPrefix", $_path );
 
 $customer->$mode($r);
 



-------------------------------------------------------
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.