Pete Winter
asked on
php admin login issue
I have recently took over a website from a previous developer who is not contactable. Since moving the website across the admin login for the website is not working. See link below...
http://www.themarblestore.co.uk/admin/
I have turned on php errors and I am getting the following:
Error 1:
Related lines of code:
Error 2:
Related lines of code:
Error 3:
Related lines of code:
Not sure if these error notices are related with why the login is not working. Any idea what might be the problem.
This website is based on http://www.smarty.net
http://www.themarblestore.co.uk/admin/
I have turned on php errors and I am getting the following:
Error 1:
Notice: Undefined index: HTTP_REFERER in /home/marblest/public_html/phplibs/class.Utility.php on line 335
Related lines of code:
function getRequestedURL(){
return $_SERVER['HTTP_REFERER'];
}
Error 2:
Notice: Undefined property: SessionHandler::$userLogged in /home/marblest/public_html/phplibs/class.UserManager.php on line 120
Related lines of code:
public function isLoggedIn($userType = 0) {
/*echo '<pre>';
print_r($this->SessionHandler);
echo '</pre>';*/
//exit();
if ($this->SessionHandler->userLogged === true)
return true;
else
return false;
}
Error 3:
Notice: Undefined property: SessionHandler::$userLogged in /home/marblest/public_html/phplibs/class.SystemUserManager.php on line 55
Related lines of code:
public function isLoggedIn($userType = 0) {
switch ($userType) {
case 0 :
if (($this->SessionHandler->userLogged === true) && ($this->SessionHandler->userType == $userType)) {
return true;
} else {
return false;
}
break;
case 1 :
if (($this->SessionHandler->userLoggedAdmin === true) && ($this->SessionHandler->userTypeAdmin == $userType)) {
return true;
} else {
return false;
}
break;
}
Not sure if these error notices are related with why the login is not working. Any idea what might be the problem.
This website is based on http://www.smarty.net
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
class.UserManager.php code below:
Sorry, but can you supply the exact code for the below as my php knowledge is limited.
One thing you can do is a var_dump or print_r of $this->SessionHandler
Tried this:
print_r $this->SessionHandler;
but not sure if correct?
<?php
session_save_path('/home/marblest/tmp');
class UserManager extends User {
private $dbAccess;
private $table = 'login';
private $tablerequest = 'request';
public $SessionHandler;
private $returnVal = array ();
public function __construct(mySqlDB $dbAccess) {
$this->dbAccess = $dbAccess;
$this->SessionHandler = new SessionHandler ( );
}
public function UpdateUsers($insArr, $record_id) {
$this->dbAccess->queryUpdate ( $this->table, $insArr, true, "userID = " . $record_id );
}
public function __set($var, $val) {
$flds = array ('userID' => 'userID', 'userName' => 'userName', 'userType' => 'userType', 'confirmation' => 'confirmation', 'fullName' => 'fullName', 'email' => 'email', 'telephone' => 'telephone' );
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", $var . " = '" . $this->dbAccess->mySQLSafe ( $val ) . "' LIMIT 0,1" );
if ($result) {
$this->returnVal = $this->dbAccess->getResultSet ( $result, $flds );
} else {
$this->returnVal = array ();
}
}
public function __get($var) {
if (isset ( $var )) {
if (isset ( $this->returnVal [0] [$var] )) {
return $this->returnVal [0] [$var];
} else {
return false;
}
} else {
return FALSE;
}
}
public function AddUsers($insArr, &$insert_id = NULL) {
$this->dbAccess->queryUpdate ( $this->table, $insArr, false, '', $insert_id );
}
public function RemoveUsers($id) {
$this->dbAccess->queryDelete ( $this->table, 'userID = ' . $id );
}
public function AddRequestCode($insArr, &$insert_id = NULL) {
$this->dbAccess->queryDelete ( $this->tablerequest, 'username = "' . $insArr['username'] .'"' );
$this->dbAccess->queryUpdate ( $this->tablerequest, $insArr, false, '', $insert_id );
}
public function isChangeCodeValid($code, $user){
$res = $this->dbAccess->countNumRec ( $this->tablerequest, "id", "code='" . $code . "' AND username = '" . $user . "'" );
if($res>0)
return true;
else
return false;
}
public function checkUser($eMail = '', $psWord = '', $type = 0) {
if ((isset ( $eMail ) && $eMail != '') && (isset ( $psWord ) && $psWord != '')) {
$res = $this->dbAccess->countNumRec ( $this->table, "id", "username='" . $eMail . "' AND password = '" . $psWord . "'" );
if ($res > 0) {
$flds = array ('id' => 'id', 'username' => 'username', 'firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email' );
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", "username = '" . $eMail . "'" );
if ($result) {
$dataSet = $this->dbAccess->getResultSet ( $result, $flds );
return $dataSet;
} else {
return false;
}
} else
return false;
} else {
return false;
}
}
public function getUserDetailsFromUser($username = '', $email = ''){
$flds = array ('id' => 'id', 'username' => 'username', 'firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email' );
if($username != '')
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", "username = '" . $username . "'" );
if($email != '')
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", "email = '" . $email . "'" );
if ($result) {
$dataSet = $this->dbAccess->getResultSet ( $result, $flds );
return $dataSet;
} else {
return false;
}
}
public function getUserDetails($userid){
$flds = array ('id' => 'id', 'username' => 'username', 'firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email' );
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", "id = '" . $userid . "'" );
if ($result) {
$dataSet = $this->dbAccess->getResultSet ( $result, $flds );
return $dataSet;
} else {
return false;
}
}
public function isLoggedIn($userType = 0) {
/*echo '<pre>';
print_r($this->SessionHandler);
echo '</pre>';*/
//exit();
if ($this->SessionHandler->userLogged === true)
return true;
else
return false;
}
public function loginUser($userDataArr) {
if ($userDataArr) {
/* $childArrayTmp = array ();
for($child = 1; $child <= count ( $userDataArr [1] ); $child ++) {
if (trim ( $userDataArr [1] ['admission_no' . $child] ) != '') {
$hash = base64_encode ( $userDataArr [1] ['admission_no' . $child] );
//echo $userDataArr [1] ['admission_no' . $child].'<br>';
$childArrayTmp [] = $hash;
}
}*/
$this->SessionHandler->userid = $userDataArr [0] ['id'];
$this->SessionHandler->username = $userDataArr [0] ['username'];
$this->SessionHandler->firstname = $userDataArr [0] ['firstname'];
$this->SessionHandler->lastname = $userDataArr [0] ['lastname'];
$this->SessionHandler->email = $userDataArr [0] ['email'];
$this->SessionHandler->userLogged = true;
return true;
}
}
public function logoutUser() {
$this->SessionHandler->un_set ( "userid" );
$this->SessionHandler->un_set ( "username" );
$this->SessionHandler->un_set ( "firstname" );
$this->SessionHandler->un_set ( "lastname" );
$this->SessionHandler->un_set ( "email" );
$this->SessionHandler->un_set ( "userLogged" );
}
public function UpdatePassword($insArr, $username = null, $oldpassword = null) {
$flds = array ('id' => 'id');
$result = $this->dbAccess->querySelect ( $this->table, $flds, false, "A", "username = '".$username . "' AND password = '". $oldpassword ."'");
if ($result) {
$this->dbAccess->queryUpdate ( $this->table, $insArr, true, "username = '".$username . "' AND password = '". $oldpassword ."'" );
return 'Update Completed!';
} else {
return 'Wrong old Password!';
}
}
public function setNewPassword($username, $newpassword){
$flds = array ('password' => $newpassword);
$this->dbAccess->queryUpdate ( $this->table, $flds, true, "username = '".$username . "'" );
}
public function ManualQuery($qry){
echo $qry; exit;
$recordSet = $this->dbAccess->queryManual ( $qry );
return $recordSet;
}
}
Sorry, but can you supply the exact code for the below as my php knowledge is limited.
One thing you can do is a var_dump or print_r of $this->SessionHandler
Tried this:
print_r $this->SessionHandler;
but not sure if correct?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You will need to make a similar modification to the isLoggedIn here
/home/marblest/public_html /phplibs/c lass.Syste mUserManag er.php
/home/marblest/public_html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi julianH - Reply No. 39873052
I added your code below at the bottom of the class.Utility.php file
and got this error:
Fatal error: Using $this when not in object context in /home/marblest/public_html /phplibs/c lass.Utili ty.php on line 346
What does that mean?
I added your code below at the bottom of the class.Utility.php file
function fnDump(&$obj)
{
echo "<pre>";
print_r($obj);
echo "</pre>";
}
fnDump($this->SessionHandler);
and got this error:
Fatal error: Using $this when not in object context in /home/marblest/public_html
What does that mean?
ASKER
julianH - In reply to 39873070 & 39873076 - Thanks that has removed the notice error, but the login is still not working so must be a fault some where else.
I get the below errors which are mentioned earlier:
I get the below errors which are mentioned earlier:
Notice: Undefined index: HTTP_SERVER in /home/marblest/public_html/phplibs/class.Utility.php on line 335
Warning: Cannot modify header information - headers already sent by (output started at /home/marblest/public_html/phplibs/class.Utility.php:335) in /home/marblest/public_html/phplibs/class.Utility.php on line 114
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
One another question. I am trying to compare against the old server which uses plesk, but I am not sure how to preview the site as the domain no longer points there.
My server has cpanel and I can preview the address with the ip address and the account name like below...
http://46.32.231.136/~themarbl/
Can you do something similar on plesk?
My server has cpanel and I can preview the address with the ip address and the account name like below...
http://46.32.231.136/~themarbl/
Can you do something similar on plesk?
ASKER
Ray - Thanks for the reply and info.
This is the php set up to the live website on my server: http://www.themarblestore.co.uk/phpinfo.php
I can also add the same phpinfo file to the previous server too, but don't know how to preview it as per my last reply.
I do agree the notices are probably unrelated to why the login is not working. Just trying to find what is causing the probably. I assume it is a difference between server set ups as you mentioned.
This is the php set up to the live website on my server: http://www.themarblestore.co.uk/phpinfo.php
I can also add the same phpinfo file to the previous server too, but don't know how to preview it as per my last reply.
I do agree the notices are probably unrelated to why the login is not working. Just trying to find what is causing the probably. I assume it is a difference between server set ups as you mentioned.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.smarty.net/ Smarty is a template 'compiler' and all the page code is stored in a database. It is the most convoluted *#@&^!%^ I have ever encountered and I always refuse to work on sites that use it.
ASKER
julianH - The old servers ip is 213.246.109.55 and the domain was themarblestore.co.uk , but it's not point there anymore so is there a temporary URL I can use?
Dave Baldwin - I'm glad I helped you get that off your chest, but that's not much use to me! :) I have just took over this website and did not pick the system. However I do agree.
Dave Baldwin - I'm glad I helped you get that off your chest, but that's not much use to me! :) I have just took over this website and did not pick the system. However I do agree.
I told you that not to make myself feel good but as warning to you. Someone must know how to make Smarty work but I don't. And I do have it installed on a test site here.
On the one Smarty site I was hired to work on, the page code was all in the database so we had to edit the database to change anything. I know that's not the way it is supposed to work but I was only there for about two hours and never had time to find the 'front door' to edit and 're-compile' the site. Xoops is also like that as is NetObjects Fusion.
On the one Smarty site I was hired to work on, the page code was all in the database so we had to edit the database to change anything. I know that's not the way it is supposed to work but I was only there for about two hours and never had time to find the 'front door' to edit and 're-compile' the site. Xoops is also like that as is NetObjects Fusion.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
julianH - Thanks, but the domain is unready pointing the new site on my server.
The ip address 213.246.109.55 is the old server. So I am trying to view this site. How would I view the this site?
The ip address 213.246.109.55 is the old server. So I am trying to view this site. How would I view the this site?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all your advice. I found and paid a php developer to look into this error for me and changed as below...
class.UserManager.php
Before...
public function isLoggedIn($userType = 0)
{
return (!empty($_SESSION['userLog ged']) && $_SESSION['userLogged'] === true);
// return (!empty($this->SessionHand ler->userL ogged) && $this->SessionHandler->use rLogged === true);
}
After...
public function loginUser($userDataArr) {
if ($userDataArr) {
/* $childArrayTmp = array ();
for($child = 1; $child <= count ( $userDataArr [1] ); $child ++) {
if (trim ( $userDataArr [1] ['admission_no' . $child] ) != '') {
$hash = base64_encode ( $userDataArr [1] ['admission_no' . $child] );
//echo $userDataArr [1] ['admission_no' . $child].'un_set ( "userLogged" );
}
I think the changes were down to different versions of php on the two servers.
class.UserManager.php
Before...
public function isLoggedIn($userType = 0)
{
return (!empty($_SESSION['userLog
// return (!empty($this->SessionHand
}
After...
public function loginUser($userDataArr) {
if ($userDataArr) {
/* $childArrayTmp = array ();
for($child = 1; $child <= count ( $userDataArr [1] ); $child ++) {
if (trim ( $userDataArr [1] ['admission_no' . $child] ) != '') {
$hash = base64_encode ( $userDataArr [1] ['admission_no' . $child] );
//echo $userDataArr [1] ['admission_no' . $child].'un_set ( "userLogged" );
}
I think the changes were down to different versions of php on the two servers.
ASKER
I changed the HTTP_REFERER line as suggested, then got this error when trying to login...
Open in new window
Lines around 114 is...
Open in new window
What is wrong?
Will post separately on the other comments in a min.