Add sessions in order to cache the various mappings. Add a corresponding
authorkkalev <kkalev>
Sun, 8 Sep 2002 00:17:18 +0000 (00:17 +0000)
committerkkalev <kkalev>
Sun, 8 Sep 2002 00:17:18 +0000 (00:17 +0000)
configuration directive general_use_session. Also add a session cache
destroy page.

dialup_admin/conf/admin.conf
dialup_admin/conf/config.php3
dialup_admin/htdocs/session_destroy.php3 [new file with mode: 0644]
dialup_admin/htdocs/user_accounting.php3
dialup_admin/html/buttons/default/buttons.html.php3
dialup_admin/lib/acctshow.php3
dialup_admin/lib/attrshow.php3
dialup_admin/lib/ldap/attrmap.php3

index 2fbc503..d747336 100644 (file)
@@ -12,6 +12,11 @@ general_base_dir: /usr/local/dialup_admin
 general_radiusd_base_dir: /usr/local/radiusd
 general_domain: company.com
 #
+# Set it to yes to use sessions and cache the various mappings
+# This feature is considered experimantal for the moment
+general_use_session: no
+
+#
 general_ldap_attrmap: %{general_radiusd_base_dir}/etc/raddb/ldap.attrmap
 general_sql_attrmap: %{general_base_dir}/conf/sql.attrmap
 general_extra_ldap_attrmap: %{general_base_dir}/conf/extra.ldap-attrmap
index 9f352a7..1a2f345 100644 (file)
@@ -11,4 +11,8 @@ foreach($ARR as $val) {
        }
        $config["$key"]="$v";
 }
+if ($config[general_use_session] == 'yes'){
+       // Start session
+       @session_start();
+}
 ?>
diff --git a/dialup_admin/htdocs/session_destroy.php3 b/dialup_admin/htdocs/session_destroy.php3
new file mode 100644 (file)
index 0000000..589f75b
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+session_start();
+session_unset();
+session_destroy();
+?>
+<html>
+<head>
+<title>Session Cache Destroy Page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<center>
+<b>Session Cache Destroyed</b>
+</body>
+</html>
index 71cfd5c..3bab802 100644 (file)
@@ -106,7 +106,12 @@ if ($link){
                        $acct_server = $da_name_cache[$row[NASIPAddress]];
                        if (!isset($acct_server)){
                                $acct_server = gethostbyaddr($row[NASIPAddress]);
-                               $da_name_cache[$row[NASIPAddress]] = $acct_server;
+                               if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
+                                       $da_name_cache[$row[NASIPAddress]] = $acct_server;
+                                       session_register('da_name_cache');
+                               }
+                               else
+                                       $da_name_cache[$row[NASIPAddress]] = $acct_server;
                        }
                        $acct_server = "$acct_server:$row[NASPortId]";
                        $acct_terminate_cause = "$row[AcctTerminateCause]";
index 49ab0b2..32aba01 100644 (file)
@@ -77,6 +77,16 @@ if ($HTTP_SERVER_VARS["PHP_AUTH_USER"])
        <tr align=left><td id="menu10" onmouseover='myin("10");' onmouseout='myout("10");'>
        <a id="a10" href="user_test.php3?login=da_server_test&test_user=1" target="content" title="Check Server Response">Check Server</a>
        </td></tr>
+<?php
+include('../conf/config.php3');
+if ($config[general_use_session] == 'yes')
+       echo <<<EOM
+       <tr align=left><td><img src="images/black.gif" vspace=2 hspace=0 width=80 height=1></td></tr>
+       <tr align=left><td id="menu15" onmouseover='myin("15");' onmouseout='myout("15");'>
+       <a id="a15" href="session_destroy.php3" target="content" title="Clear Session Cache">Clear Cache</a>
+       </td></tr>
+EOM;
+?>
        <tr align=left><td><img src="images/black.gif" vspace=2 hspace=0 width=80 height=1></td></tr>
        <tr align=left><td id="menu5" onmouseover='myin("5");' onmouseout='myout("5");' nowrap>
        <a id="a5" href="help/help.php3" target="content" title="Show Help">Help</a>
index 3ba0d66..a5d5c64 100644 (file)
@@ -1,13 +1,17 @@
 <?php
 #Read sql attribute map
-$ARR = file($config[general_sql_attrs_file]);
-foreach($ARR as $val){
-       $val=chop($val);
-       if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
-               continue;
-       list($key,$desc,$show,$func)=split("\t+",$val);
-       $sql_attrs["$key"][desc] = "$desc";
-       $sql_attrs["$key"][show] = "$show";
-       $sql_attrs["$key"][func] = ($func == "") ? "nothing" : "$func";
+if (!isset($sql_attrs)){
+       $ARR = file($config[general_sql_attrs_file]);
+       foreach($ARR as $val){
+               $val=chop($val);
+               if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
+                       continue;
+               list($key,$desc,$show,$func)=split("\t+",$val);
+               $sql_attrs["$key"][desc] = "$desc";
+               $sql_attrs["$key"][show] = "$show";
+               $sql_attrs["$key"][func] = ($func == "") ? "nothing" : "$func";
+       }
+       if ($config[general_use_session] == 'yes')
+               session_register('sql_attrs');
 }
 ?>
index 8c26f14..a14b9ef 100644 (file)
@@ -1,11 +1,15 @@
 <?php
 #Read user_edit attribute map
-$ARR = file($config[general_user_edit_attrs_file]);
-foreach($ARR as $val){
-       $val=chop($val);
-       if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
-               continue;
-       list($key,$v)=split("\t+",$val);
-       $show_attrs["$key"]=($v != '') ? "$v" : "$key";
+if (!isset($show_attrs)){
+       $ARR = file($config[general_user_edit_attrs_file]);
+       foreach($ARR as $val){
+               $val=chop($val);
+               if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
+                       continue;
+               list($key,$v)=split("\t+",$val);
+               $show_attrs["$key"]=($v != '') ? "$v" : "$key";
+       }
+       if ($config[general_use_session] == 'yes')
+               session_register('show_attrs');
 }
 ?>
index e5aac1c..6469c86 100644 (file)
@@ -1,23 +1,27 @@
 <?php
 #Read ldap attribute map
-$ARR = file("$config[general_ldap_attrmap]");
-foreach($ARR as $val){
-       $val=chop($val);
-       if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
-               continue;
-       list(,$key,$v,$g)=split('[[:space:]]+',$val);
-       $v = strtolower($v);
-       $attrmap["$key"]=$v;
-       $attrmap[generic]["$key"]=$g;
-}
-$ARR = file("$config[general_extra_ldap_attrmap]");
-foreach($ARR as $val){
-       $val=chop($val);
-       if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
-               continue;
-       list(,$key,$v,$g)=split('[[:space:]]+',$val);
-       $v = strtolower($v);
-       $attrmap["$key"]=$v;
-       $attrmap[generic]["$key"]=$g;
+if (!isset($attrmap)){
+       $ARR = file("$config[general_ldap_attrmap]");
+       foreach($ARR as $val){
+               $val=chop($val);
+               if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
+                       continue;
+               list(,$key,$v,$g)=split('[[:space:]]+',$val);
+               $v = strtolower($v);
+               $attrmap["$key"]=$v;
+               $attrmap[generic]["$key"]=$g;
+       }
+       $ARR = file("$config[general_extra_ldap_attrmap]");
+       foreach($ARR as $val){
+               $val=chop($val);
+               if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
+                       continue;
+               list(,$key,$v,$g)=split('[[:space:]]+',$val);
+               $v = strtolower($v);
+               $attrmap["$key"]=$v;
+               $attrmap[generic]["$key"]=$g;
+       }
+       if ($config[general_use_session] == 'yes')
+               session_register('attrmap');
 }
 ?>