[prev in list] [next in list] [prev in thread] [next in thread] 

List:       os-sim-commits
Subject:    [Os-sim-commits] os-sim/include/classes Session.inc,1.64,1.65
From:       "Tomas V.V.Cox" <tvvcox () users ! sourceforge ! net>
Date:       2006-03-29 18:28:27
Message-ID: E1FOfPA-0002Zc-4m () mail ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/os-sim/os-sim/include/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29742/include/classes

Modified Files:
	Session.inc 
Log Message:
 phpgacl on "new gacl()" does a lot of heavy operations like:
 parsing files, including code and btw opens a new persistant
 connection to the BD. So better make $gacl global avaible as

$GLOBAL['ACL'];

Index: Session.inc
===================================================================
RCS file: /cvsroot/os-sim/os-sim/include/classes/Session.inc,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- Session.inc	29 Mar 2006 16:02:19 -0000	1.64
+++ Session.inc	29 Mar 2006 18:28:25 -0000	1.65
@@ -1,19 +1,19 @@
 <?php
 
-include ('classes/Locale.inc');
-
-require_once ('classes/Host.inc');
-require_once ('classes/Net.inc');
-require_once ('classes/Log_action.inc');
+require_once 'classes/Locale.inc';
+require_once 'classes/Host.inc';
+require_once 'classes/Net.inc';
+require_once 'classes/Log_action.inc';
 
-require_once ('ossim_db.inc');
-require_once ('ossim_acl.inc');
+require_once 'ossim_db.inc';
+require_once 'ossim_acl.inc';
 
 /* global configuration */
-require_once ('ossim_conf.inc');
+require_once 'ossim_conf.inc';
 
 session_start();
 
+
 class Session {
 
     var $login;
@@ -103,17 +103,10 @@
 
     function menu_perms($menu, $submenu)
     {
-        # session_start();
-        if ( ! isset($_SESSION["_user"]) )
-            return True;
-
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
+        $gacl = $GLOBALS['ACL'];
 
-        global $ACL_OPTIONS;
-        $gacl = new gacl($ACL_OPTIONS);
+        if (!isset($_SESSION["_user"]) )
+            return True;
      
         if (! $gacl->acl_check($menu,
                                $submenu,
@@ -135,6 +128,7 @@
 
     function logcheck($menu, $submenu, $login_location = "../session/login.php")
     {
+        $gacl = $GLOBALS['ACL'];
         if (array_key_exists('user', $_POST))
             $user = $_POST["user"];
         
@@ -152,14 +146,6 @@
             exit;
         }
 
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
-        $gacl = new gacl($ACL_OPTIONS);
-
         if (! $gacl->acl_check($menu,
                                $submenu,
                                ACL_DEFAULT_USER_SECTION,
@@ -183,13 +169,14 @@
 
     function logcheck_ext($menu, $submenu, $axo_sec, $axo_val, $login_location = "../session/login.php")
     {
-    	  $user = $_POST["user"];
-    	  $pass = $_POST["pass"];
-
-		  if ($user && $pass) {
-		  		$sess = new Session($user, $pass, "");
-		  		$sess->login();
-		  }
+        $gacl = $GLOBALS['ACL'];
+        $user = $_POST["user"];
+        $pass = $_POST["pass"];
+        
+        if ($user && $pass) {
+        	$sess = new Session($user, $pass, "");
+        	$sess->login();
+        }
     
         $dest = $_SERVER["PHP_SELF"];
         if ( ! isset($_SESSION["_user"]) ) {
@@ -197,14 +184,6 @@
             exit;
         }
 
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
-        $gacl = new gacl($ACL_OPTIONS);
-
         if (! $gacl->acl_check($menu,
                                $submenu,
                                ACL_DEFAULT_USER_SECTION,
@@ -240,6 +219,7 @@
     /* Wraps the acl_return_value() function */
     function allowedNets($user = "")
     {
+        $gacl = $GLOBALS['ACL'];
         static $allowedNetsCache;
     
         if (!$user)
@@ -248,15 +228,6 @@
         if (isset($allowedNetsCache["$user"]))
             return $allowedNetsCache["$user"];
 
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
-        $gacl = new gacl($ACL_OPTIONS);
-
         $allowedNetsCache["$user"] =
             $gacl->acl_return_value (ACL_DEFAULT_DOMAIN_SECTION,
                                      ACL_DEFAULT_DOMAIN_NETS,
@@ -267,6 +238,7 @@
 
     function allowedSensors($user = "")
     {
+        $gacl = $GLOBALS['ACL'];
         static $allowedSensorsCache;
     
         if (!$user)
@@ -275,15 +247,6 @@
         if (isset($allowedSensorsCache["$user"]))
             return $allowedSensorsCache["$user"];
 
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
-        $gacl = new gacl($ACL_OPTIONS);
-
         $allowedSensorsCache["$user"] =
             $gacl->acl_return_value (ACL_DEFAULT_DOMAIN_SECTION,
                                      ACL_DEFAULT_DOMAIN_SENSORS,
@@ -355,17 +318,17 @@
             return $groupAllowedCache["$user"]["$group"];
         }
 
-	$networks = Net_group::get_networks($conn, $group);
+        $networks = Net_group::get_networks($conn, $group);
 
-	foreach ($networks as $network){
-		if(Session::netAllowed($conn, $network->net_name, $user)){
-            		$groupAllowedCache["$user"]["$group"] = True;
-			return True;
-		}
-	}
+        foreach ($networks as $network){
+        	if(Session::netAllowed($conn, $network->net_name, $user)){
+                		$groupAllowedCache["$user"]["$group"] = True;
+        		return True;
+        	}
+        }
 
         $groupAllowedCache["$user"]["$group"] = False;
- 	return False;
+        return False;
     }
 
     function netAllowed($conn, $net = "ANY", $user = "")
@@ -474,6 +437,7 @@
                      $perms, $nets, $sensors, $company, $department)
     {
         global $ACL_MAIN_MENU;
+        global $ACL_OPTIONS;
         $pass = md5($pass);
 
         /* bug with mrtg graphing? */
@@ -489,12 +453,7 @@
         }
 
         /* insert into GACL database */
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
+        
         $gacl_api = new gacl_api($ACL_OPTIONS);
 
         $gacl_api->add_object (ACL_DEFAULT_USER_SECTION, /* section */
@@ -552,14 +511,15 @@
                 True,
                 $sensors);
                 
-    $infolog = array($login);
-    Log_action::log(4,$infolog);
+        $infolog = array($login);
+        Log_action::log(4,$infolog);
     }
 
     function update ($conn, $login, $name, $email, $perms, $nets, $sensors, $company, $department)
     {
         global $ACL_MAIN_MENU;
-
+        global $ACL_OPTIONS;
+        
         /* modify OSSIM database */
         $query = OssimQuery("UPDATE users SET name = '$name', allowed_nets = '$nets',
             email = '$email', company = '$company', department = '$department' WHERE login = '$login'");
@@ -569,12 +529,6 @@
         }
 
         /* update GACL database */
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
         $gacl_api = new gacl_api($ACL_OPTIONS);
 
         $aro_ids = array (ACL_DEFAULT_USER_SECTION => array($login));
@@ -678,8 +632,7 @@
         $pass = md5($pass);
         $query = OssimQuery("UPDATE users SET
             pass = '$pass' WHERE login = '$login'");
-        if (
-        $conn->Execute($query) === false) {
+        if ($conn->Execute($query) === false) {
             print 'error updating: '.$conn->ErrorMsg().'<BR>';
             exit;
         }
@@ -690,7 +643,8 @@
     function delete ($conn, $login)
     {
         global $ACL_MAIN_MENU;
-
+        global $ACL_OPTIONS;
+        
         if ($login == ACL_DEFAULT_OSSIM_ADMIN) {
             print "<p>Can't remove default user</p>";
             exit;
@@ -702,16 +656,8 @@
             exit;
         }
 
-        $conf = $GLOBALS["CONF"];
-        $phpgacl = $conf->get_conf("phpgacl_path");
-
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl.class.php";
-        require_once $phpgacl . DIRECTORY_SEPARATOR . "gacl_api.class.php";
-
-        global $ACL_OPTIONS;
         $gacl_api = new gacl_api($ACL_OPTIONS);
 
-
         /* delete ACLs */
         if ($acl_ids = $gacl_api->search_acl(FALSE,
                                          FALSE,



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Os-sim-commits mailing list
Os-sim-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/os-sim-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic