[SPTUsers] multiple SPT on a server
Edward Almasy
ealmasy at scout.wisc.edu
Tue Sep 2 18:31:39 CDT 2003
On Tue, Sep 02, at 10:00:31AM, Topete, Sergio USA Contractor wrote:
> I am trying to run more than one SPT on a Windows server. My first one
> which is called spt and the database is called spt is working fine.
> However, when I created a second one called Myspt and the database
> called Myspt, I get on error message when I click on Metadata Tools link
> (Error You are not authorized to access this area of the system). The
> sptadmin has full privileges. Anybody have any idea what I need to do to
> run more than one SPT on a server.
This will be fixed in the next release. In the mean time, if this is
a serious problem you can copy the attached file into the top directory
of your SPT installation(s) to prevent this conflict.
Ed
--
Edward Almasy ealmasy at scout.wisc.edu
Co-Director 1308 W Dayton Street
Internet Scout Project Madison WI 53706
Computer Sciences Department 608-262-6606 (voice)
University of Wisconsin - Madison 608-265-9296 (fax)
-------------- next part --------------
<?PHP
#
# Axis--Session.php
# An Object for Maintaining the Values of Variables Across Pages
#
# Copyright 1999-2003 Axis Data
# This code is free software that can be used or redistributed under the
# terms of Version 2 of the GNU General Public License, as published by the
# Free Software Foundation (http://www.fsf.org).
#
# Author: Edward Almasy (almasy at axisdata.com)
#
# Part of the AxisPHP library v1.2.5
# For more information see http://www.axisdata.com/AxisPHP/
#
require_once("Axis--Database.php");
# initialize PHP session support
session_start();
class Session {
# ---- PUBLIC INTERFACE --------------------------------------------------
function Session(&$DB)
{
global $HTTP_SESSION_VARS;
global $APSession_Shutdown_Sessions;
# save database object
$this->DB =& $DB;
# construct session variable name
$SessionVar = "APSessionId".md5($DB->DBHostName().$DB->DBName());
# if session ID available
if (isset($HTTP_SESSION_VARS[$SessionVar]))
{
# look for session ID in database
$this->SessionId = $HTTP_SESSION_VARS[$SessionVar];
$DB->Query(sprintf("SELECT * FROM APSessions WHERE SessionId = '%d'",
$this->SessionId));
# if matching session ID record not found in database
if ($DB->NumRowsSelected() < 1)
{
# clear session ID
unset($this->SessionId);
}
}
# if session ID found
if (isset($this->SessionId))
{
# load session variables from database
$DB->Query(sprintf("SELECT * FROM APSessionData WHERE SessionId = '%d'",
$this->SessionId));
while ($Record = $DB->FetchNextRowArray())
{
$VarName = $Record["DataName"];
$VarValue = unserialize($Record["DataValue"]);
if (substr($VarName, -2) == "-T")
{
$VarName = substr($VarName, 0, -2);
$this->SaveVarFlags[$VarName] = FALSE;
}
else
{
$this->SaveVarFlags[$VarName] = TRUE;
$this->TempVarFlags[$VarName] = FALSE;
}
$this->SessionVariables[$VarName] = $VarValue;
$GLOBALS[$VarName] = $VarValue;
}
}
else
{
# generate session ID (2,147,483,647 is max size of INT in MySQL)
mt_srand((double)microtime() * 1000000);
$this->SessionId = mt_rand(0, 2147483647);
# save session ID
$HTTP_SESSION_VARS[$SessionVar] = $this->SessionId;
}
# make sure session state will be saved when page ends
$APSession_Shutdown_Sessions[] =& $this;
}
function RegisterVariable($VariableName, $Value = NULL)
{
# add variable to list of variables to be saved
if ($Value != NULL)
{
$this->SessionVariables[$VariableName] = $Value;
}
else
{
$this->SessionVariables[$VariableName] = $GLOBALS[$VariableName];
}
$this->SaveVarFlags[$VariableName] = TRUE;
$this->TempVarFlags[$VariableName] = FALSE;
}
function PassVariable($VariableName, $Value = NULL)
{
# add variable to list of variables to be saved
if ($Value != NULL)
{
$this->SessionVariables[$VariableName] = $Value;
}
else
{
$this->SessionVariables[$VariableName] = $GLOBALS[$VariableName];
}
$this->SaveVarFlags[$VariableName] = TRUE;
$this->TempVarFlags[$VariableName] = TRUE;
}
function UnregisterVariable($VariableName)
{
# remove variable from list of variables to be saved (if present)
if (isset($this->SessionVariables[$VariableName]))
{
unset($this->SessionVariables[$VariableName]);
unset($this->TempVarFlags[$VariableName]);
}
}
function IsRegistered($VariableName)
{
return (isset($this->SessionVariables[$VariableName]) ? TRUE : FALSE);
}
function IsPassed($VariableName)
{
return ((isset($this->SessionVariables[$VariableName]) && $this->TempVarFlags[$VariableName])
? TRUE : FALSE);
}
function Get($VariableName)
{
return $this->SessionVariables[$VariableName];
}
# ---- PRIVATE INTERFACE -------------------------------------------------
# handle to SQL database we use to store session information
var $DB;
# session ID
var $SessionId;
# array containing variables to be maintained between pages
var $SessionVariables;
# flags indicating whether to save variable for next session
var $SaveVarFlags;
# flags indicating whether to mark variable as temporary for next session
var $TempVarFlags;
# how long before sessions will expire (in minutes)
var $SessionExpirationTime = 180;
function SaveState()
{
# if session record not found in database
$DB =& $this->DB;
$DB->Query(sprintf("SELECT * FROM APSessions WHERE SessionId = '%d'",
$this->SessionId));
if ($DB->NumRowsSelected() < 1)
{
# create new session record
$DB->Query(sprintf("INSERT INTO APSessions "
."(SessionId, LastActiveDate) VALUES "
."(%d, NOW())",
$this->SessionId));
}
else
{
# update last active timestamp for session
$this->DB->query(sprintf("UPDATE APSessions "
."SET LastActiveDate=NOW() "
."WHERE SessionId='%d'",
$this->SessionId));
}
# clear all old stored session variables from database
$DB->Query(sprintf("DELETE FROM APSessionData WHERE SessionId = '%d'",
$this->SessionId));
# save session variables to database (if any)
if (isset($this->SessionVariables))
{
foreach ($this->SessionVariables as $VariableName => $VariableValue)
{
if ($this->SaveVarFlags[$VariableName])
{
if ($this->TempVarFlags[$VariableName]) { $VariableName .= "-T"; }
$DB->Query(sprintf("INSERT INTO APSessionData "
."(SessionId, DataName, DataValue) VALUES "
."(%d, '%s', '%s')",
$this->SessionId,
$VariableName,
addslashes(serialize($VariableValue))));
}
}
}
# clear any expired sessions from database
$this->DeleteExpiredSessions();
}
function DeleteExpiredSessions()
{
# retrieve expired session records
$DB =& $this->DB;
$DB->Query(sprintf("SELECT * FROM APSessions WHERE DATE_SUB(NOW(), INTERVAL %d MINUTE) > LastActiveDate",
$this->SessionExpirationTime));
# if expired sessions were found
if ($DB->NumRowsSelected() > 0)
{
# for each record
while ($Record = $DB->FetchNextRowArray())
{
# save record ID
$Id[$Record["SessionId"]] = 1;
}
# for each saved session record ID
while (list($SessionId) = each($Id))
{
# delete any stored session data
$DB->Query(sprintf("DELETE FROM APSessionData WHERE SessionId=%d",
$SessionId));
}
# delete expired session records
$DB->Query(sprintf("DELETE FROM APSessions WHERE DATE_SUB(NOW(), INTERVAL %d MINUTE) > LastActiveDate",
$this->SessionExpirationTime));
}
}
};
function APSession_Shutdown()
{
global $APSession_Shutdown_Sessions;
# if we have Sessions to shut down
if (isset($APSession_Shutdown_Sessions))
{
# call shutdown functions
while (list($Key) = each($APSession_Shutdown_Sessions))
{
$SessionObject =& $APSession_Shutdown_Sessions[$Key];
$SessionObject->SaveState();
}
}
}
register_shutdown_function("APSession_Shutdown");
?>
More information about the SPTUsers
mailing list