Jump to content

[SOLVED] syntax error, unexpected


ballhogjoni

Recommended Posts

Hi everyone,

 

I am getting this error and I can't figure out why. Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\xampp\htdocs\www\allcbreviews\Classes\general.php on line 100.

 

Line 100 is the very last line ?>

 

Can someone help?

 

<?php
class User { 
var $db = null; // PEAR::DB pointer 
var $failed = false; // failed login attempt 
var $date; // current date GMT 
var $id = 0; // the current user's id 

/* Constructor */
function User(&$db) { 
  $this->db = $db; 
  $this->date = $GLOBALS['date']; 
  if ($_SESSION['logged']) { 
  $this->_checkSession(); 
} elseif ( isset($_COOKIE['allcbreviewswebLogin']) ) { 
  $this->_checkRemembered($_COOKIE['allcbreviewswebLogin']); 
}

/* Sets session defaults */
function session_defaults() { 
  $_SESSION['logged'] = false; 
  $_SESSION['uid'] = 0; 
  $_SESSION['username'] = ''; 
  $_SESSION['cookie'] = 0; 
  $_SESSION['remember'] = false; 
}

/* Logging in Users*/
function _checkLogin($username, $password, $remember) { 
  $username = $this->db->quote($username); 
  $password = $this->db->quote(md5($password)); 
  $sql = "SELECT * FROM member WHERE " . "username = $username AND " . "password = $password"; 
  $result = $this->db->getRow($sql);
  if ( is_object($result) ) { 
   $this->_setSession($result, $remember); 
   return true; 
  } else { 
   $this->failed = true; 
   $this->_logout(); 
   return false; 
  } 
}

/* Setting the Session */
function _setSession(&$values, $remember, $init = true) { 
  $this->id = $values->id; 
  $_SESSION['uid'] = $this->id; 
  $_SESSION['username'] = htmlspecialchars($values->username); 
  $_SESSION['cookie'] = $values->cookie; 
  $_SESSION['logged'] = true; 
  if ($remember) { 
   $this->updateCookie($values->cookie, true); 
  } 
  if ($init) { 
   $session = $this->db->quote(session_id()); 
   $ip = $this->db->quote($_SERVER['REMOTE_ADDR']); 
   $sql = "UPDATE member SET session = $session, ip = $ip WHERE " . "id = $this->id"; 
   $this->db->query($sql); 
  }
}

/* Persistent Logins */
function updateCookie($cookie, $save) { 
  $_SESSION['cookie'] = $cookie; 
  if ($save) { 
   $cookie = serialize(array($_SESSION['username'], $cookie) ); 
   set_cookie('mtwebLogin', $cookie, time() + 31104000, '/directory/'); 
  } 
}

/* Checking Persistent Login Credentials */
function _checkRemembered($cookie) { 
  list($username, $cookie) = @unserialize($cookie); 
  if (!$username or !$cookie) { 
   return; 
  }
  $username = $this->db->quote($username); 
  $cookie = $this->db->quote($cookie); 
  $sql = "SELECT * FROM member WHERE " . "(username = $username) AND (cookie = $cookie)"; 
  $result = $this->db->getRow($sql); 
  if (is_object($result) ) { 
   $this->_setSession($result, true); 
  } 
}

/* Ensuring Valid Session Data */
function _checkSession() { 
  $username = $this->db->quote($_SESSION['username']); 
  $cookie = $this->db->quote($_SESSION['cookie']); 
  $session = $this->db->quote(session_id()); 
  $ip = $this->db->quote($_SERVER['REMOTE_ADDR']); 
  $sql = "SELECT * FROM member WHERE " . "(username = $username) AND (cookie = $cookie) AND " . "(session = $session) AND (ip = $ip)";
  $result = $this->db->getRow($sql); 
  if (is_object($result) ) { 
   $this->_setSession($result, false, false); 
  } else { 
   $this->_logout(); 
  } 
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.