php 4.3.3 & Classes
Moderator: General Moderators
php 4.3.3 & Classes
I have just upgraded to using php 4.3.3, now the installation whent fine, no issues there.. setup my ini file again with everything i had before..
But now during authentication, it sets the session fine, creates a new user class fine, populates the class variables ... But it will NOT run the setuserdata() function I have as the final part of teh auth proccess .. I continues to indicate;
PHP Fatal error: Call to undefined function: setuserdata() in \path\to\include
oh as a note I am running this class function from within the authentication function.
auth(user,pass)
{
$_SESSION['UserData']->SetUserData(stuff,morestuff,foo);
}
But now during authentication, it sets the session fine, creates a new user class fine, populates the class variables ... But it will NOT run the setuserdata() function I have as the final part of teh auth proccess .. I continues to indicate;
PHP Fatal error: Call to undefined function: setuserdata() in \path\to\include
oh as a note I am running this class function from within the authentication function.
auth(user,pass)
{
$_SESSION['UserData']->SetUserData(stuff,morestuff,foo);
}
does this (not so useful) example work?
Code: Select all
<?php
class UserData
{
var $timeLogin;
function setLoginTime($unixtime)
{
$this->timeLogin = $unixtime;
}
function getLoginTime()
{
return $this->timeLogin;
}
function getFormatLoginTime($formatDate)
{
return date($formatDate, $this->timeLogin);
}
}
session_start();
?>
<html>
<body>
<span style="border: 1px solid grey; display: block">
<?php
if (!isset($_SESSION['UserData']))
{
$_SESSION['UserData'] = new UserData;
$_SESSION['UserData']->setLoginTime(time());
echo 'new login';
}
else
echo 'logged in: ', $_SESSION['UserData']->getFormatLoginTime('F j, Y, g:i a');
?>
</span>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">reload page</a>
</body>
</html>Code: Select all
<?php
function Authorize($Username, $Password)
{
$IsTrue = true;
if( isset($Username) && isset($Password) )
{
$QueryString = "
SELECT AccountItemUsername,AccountItemPassword,ItemID
FROM AccountItemDescriptors_PersonItemDemographics
WHERE AccountItemUsername = '$Username' AND AccountItemPassword = '$Password'
";
$SqlQuery = new SqlQuery;
$Results = $SqlQuery->ExecuteQuery($QueryString);
unset($SqlQuery);
}
else
$Results = false;
if( !$Results )
{
$IsTrue = false;
unset($_SESSION['UserData']);
}
else
{
$_SESSION['UserData'] ->Categories = GetAllCategories($Results['ItemID'][0]);
if( array_search(SERVICE_HYDRA,$_SESSION['UserData'] ->Categories) )
{
$_SESSION['UserData']->SetUserData($Results['AccountItemUsername'][0], $Results['ItemID'][0], session_id());
$_SESSION['UserData']->CurrentPage = "welcome.php";
}
else
{
unset($_POST);
echo '<SCRIPT LANGUAGE="JavaScript">alert("You do not have access to this service (HYRDA)");</SCRIPT>';
}
}
return $IsTrue;
}function Authorize($Username, $Password)
{
$IsTrue = true;
if( isset($Username) && isset($Password) )
{
$QueryString = "
SELECT AccountItemUsername,AccountItemPassword,ItemID
FROM AccountItemDescriptors_PersonItemDemographics
WHERE AccountItemUsername = '$Username' AND AccountItemPassword = '$Password'
";
$SqlQuery = new SqlQuery;
$Results = $SqlQuery->ExecuteQuery($QueryString);
unset($SqlQuery);
}
else
$Results = false;
if( !$Results )
{
$IsTrue = false;
unset($_SESSION['UserData']);
}
else
{
$_SESSION['UserData'] ->Categories = GetAllCategories($Results['ItemID'][0]);
if( array_search(SERVICE_HYDRA,$_SESSION['UserData'] ->Categories) )
{
$_SESSION['UserData']->SetUserData($Results['AccountItemUsername'][0], $Results['ItemID'][0], session_id());
$_SESSION['UserData']->CurrentPage = "welcome.php";
}
else
{
unset($_POST);
echo '<SCRIPT LANGUAGE="JavaScript">alert("You do not have access to this service (HYRDA)");</SCRIPT>';
}
}
return $IsTrue;
}
if( !isset($UserData) )
$UserData = new UserData;
session_start();
session_register("UserData");
if( empty($_SESSION['UserData']->SessionID) )
{
if( !Authorize($_POST['Username'], $_POST['Password']) )
$_SESSION['UserData']->CurrentPage = "login.php";
}
?>Code: Select all
<?php
class UserData
{
var $Username;
var $UserID;
var $SessionID;
var $LoginTime;
var $BrowsingClient;
var $Transactions;
var $CurrentPage;
var $Errors_Alerts;
var $Categories;
var $Security;
function UserData()
{
$this->Username = '';
$this->UserID = 0;
$this->SessionID = '';
$this->LoginTime = '';
$this->BrowsingClient = '';
$this->Transactions = array();
$this->CurrentPage = '';
$this->Errors_Alerts = '';
$this->Categories = array();
$this->Security = array();
}
function SetUserData($Username, $UserID, $SessionID)
{
$this->Username = $Username;
$this->UserID = $UserID;
$this->SessionID = $SessionID;
$this->LoginTime = date('m/d/y H:i:s');
}
function DestroyUserData()
{
$this->UserData();
}
}
?>Code: Select all
<?php
if( !isset($UserData) )
$UserData = new UserData;
session_start();
session_register("UserData");
?>var_dump($_SESSION);
results in;
array(1) { ["UserData"]=> NULL }
expected is
object(userdata)(10)/*snip*/