Re: parse error -- can't find it in my class.
| From: | Charles Killian | Date: | Wed, 04 Oct 2000 17:18:47 +0000 |
| Subject: | Re: parse error -- can't find it in my class. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18619@lists.php.net to get a copy of this message | ||
It looks like you are missing a " from this line:
$query = "select " . USER_GROUP . " where " . USER_NAME
."=\"{$this->username}\";
should be
$query = "select " . USER_GROUP . " where " . USER_NAME
."=\"{$this->username}\"";
Add a " at the very end.
charles
----- Original Message -----
Sent: Wednesday, October 04, 2000 12:40 AM
Subject: [PHP] parse error -- can't find it in my class.
Major problems: I'm getting the following error:
Parse error: parse error in /path/to/classes/User.phpc on line 97
I've tried to find any parse errors in this file and have yet to find any.
I've deliberately created parse errors before and after the error line, I've
tried only including this file (and none others), and I've tried
commenting/deleting the "offending" lines -- all to no avail. The error
still shows up. Very strange, but I can't find it.
Any help would be appreciated. Just assume that all my includes work fine
and that all functions and classes not defined in this file work fine.
Thanks.
Dean.
<?
if(!defined("__DEF_USER_CLASS__") or (__DEF_USER_CLASS__ !=
"__DEF_USER_CLASS__")):
define("__DEF_USER_CLASS__", "__DEF_USER_CLASS__");
?>
<?
include("classes/DB.phpc");
include("funcs/db.phpf");
include("funcs/crypt.phpf");
/* Table column name constants: */
define("USER_NAME", "username");
define("USER_PASS", "password");
define("USER_REAL_NAME", "realname");
define("USER_EMAIL", "email");
define("USER_GROUP", "group");
/* Table column name array: */
$user_cols[USER_NAME] = "Username";
$user_cols[USER_PASS] = "Password";
$user_cols[USER_GROUP] = "User Group";
$user_cols[USER_REAL_NAME] = "Real Name";
$user_cols[USER_EMAIL] = "Email";
/* Lengths of table columns: */
$col_len[USER_NAME] = 32;
$col_len[USER_PASS] = 64;
$col_len[USER_REAL_NAME] = 128;
$col_len[USER_EMAIL] = 64;
/* Database constants: */
define("USER_DB", "apt7");
define("USERS_TAB", "Users");
define("USER_GROUP_DEFS", "UserGroupDefs");
define("USER_GROUPS", "UserGroups");
/* Session authentication constants: */
define("USER_SESSION_AUTH", "auth");
class User {
var $username;
var $password;
var $real_name;
var $email;
var $groups;
var $db;
var $authenticated;
function User($username = "guest") {
$this->username = $username;
$this->authenticated = FALSE;
$db_info = getUserDBInfo(USER_DB);
$this->db = new DB($db_info[host], $db_info[user], $db_info[pass],
USER_DB);
$query = "select * from " . USERS_TAB . " where " . USER_NAME .
"=\"{$this->username}\"";
$this->db->query($query);
$rarray = $this->db->getArray();
$this->db->freeResult();
$this->password = BFDecrypt($rarray[USER_PASS]);
$this->real_name = $rarray[USER_REAL_NAME];
$this->email = $rarray[USER_EMAIL];
$this->db->close();
$query = "select " . USER_GROUP . " where " . USER_NAME .
"=\"{$this->username}\";
$this->db->query($query);
while($rarray = $this->db->getArray()) {
$this->groups[] = $rarray[USER_GROUP];
}
reset($this->groups);
}
function isGroupMember($group) {
if(!is_array($this->groups)) {
return FALSE;
}
reset($this->groups);
foreach($this->groups as $ugroup) {
if(strcmp($ugroup, $group) == 0) {
reset($this->groups);
return TRUE;
}
}
reset($this->groups);
return FALSE;
}
function authenticate($session) {
$this->authenticated = FALSE;
if(($this->username == "guest") or (strlen($this->password) == 0)) { //
LINE 97!!!
return FALSE;
}
$auth_seed = $session->id . $this->password;
$real_auth = md5($auth_seed);
if(strcmp($real_auth, $session->vars[USER_SESSION_AUTH]) == 0) {
$this->authenticated = TRUE;
return TRUE;
}
return FALSE;
}
function startLoginSession($timestamp, $pass_hash) {
$this->authenticated = FALSE;
// Don't start sessions for guest user or for users with empty passwords.
if(($this->username == "guest") or (strlen($this->password) == 0)) {
return FALSE;
}
// If the user authenticates, start a session.
$hash_seed = $this->password . $timestamp;
$real_hash = md5($auth_seed);
if(strcmp($real_hash, $pass_hash) == 0) {
$this->authenticated == TRUE;
$session = new Session();
$session->start(TRUE);
$auth_seed = $session->id . $this->password;
$session->register(USER_SESSION_AUTH, md5($auth_seed));
return TRUE;
}
return FALSE;
}
}
?>
<?
endif;
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net