2000-06-02 18:41:36 +00:00
|
|
|
<?
|
|
|
|
$access = array("Administrator" => 0x00000001,
|
|
|
|
"User manager" => 0x00000002,
|
|
|
|
"News manager" => 0x00000004);
|
|
|
|
|
|
|
|
class User {
|
|
|
|
function User($userid, $passwd="") {
|
2000-06-22 09:08:12 +00:00
|
|
|
$result = db_query("SELECT * FROM users WHERE LOWER(userid)=LOWER('$userid') && passwd=PASSWORD('$passwd') && STATUS=0");
|
|
|
|
if (db_num_rows($result) == 1) {
|
|
|
|
foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; }
|
2000-06-02 18:41:36 +00:00
|
|
|
}
|
|
|
|
}
|
Hoeray! I have a first core version of submission moderation up and
running. This means people can submit stories, and moderators can
moderate stories. When a submission reaches a certain positive
threshold (currently set to 2) the submission becomes a story and up
it goes. If a submission reaches a certain negative threshold
(currently set to -2) the submission is dumped.
The fact this is all done by our visitors (without our intervention)
makes it truly spiffy imho. The website can live a life on it's own,
fed by the visitors.
Beware, a lot of work need to be done though ... it's just a first
basic implementation with the core functionality. There are quite
a lot of things that I'll need to change, extend and improve. But
comments, suggestions and ideas are - as always - welcomed.
Please read this log message carefully! It features quite a lot of
important information.
To test the moderation, log in, select theme 'Dries' (the other themes
need a small update) and head by clicking the one and only 'submission
moderation' link. Don't be afraid to submit lame/funny/useless
stories for testing purpose ... as soon we go public, we'll wipe out
the story database. ;-)
WHAT'S NEW?
-----------
* Added 2 new operations to user.class.php to set and retrieve the
user's "history". Very evil but required to avoid people voting
twice.
* Moved dbsave() from account.php to functions.php. In addition, I
added a new function to user.class.php called `save()' that ...
well, saves the object back to the database. It's (IMHO) a better
approach compared to dbsave(): it keeps things organized. ;-)
BUGFIXES:
---------
* Fixed a (heavy) memory leak in the constructor of user.class.php:
mysql_fetch_array() returns an _associative_ array which made the
constructor `pollute' the object with a lot of useless variables.
* Fixed the slash-problem on the account pages. :-)
* Fixed UnConeD's theme glitch, alas the warning.
* Fixed the e-mail address not showing in the confirmation email
(upon registration).
* Fixed the typical quote and backslash problems in submit.php.
* submit.php now uses the database abstraction layer.
IMPORTANT:
----------
* You can check the new submission system at:
http://beta.drop.org/submission.php
or by following the `submission moderation' link from my theme.
* UnConeD, Jeroen: you'll need to update your themes to take
advantage of the new function: displayAccount(). This function
will display the `submission moderation' link when a user is
logged on.
* Natrak: you might want to apply the patches in user.class.php
on the other sites using the same user-system.
2000-06-13 09:42:58 +00:00
|
|
|
function save() {
|
|
|
|
### Compose query to update user record:
|
|
|
|
$query .= "UPDATE users SET ";
|
|
|
|
foreach ($this->field as $key=>$field) { $value = $this->$field; $query .= "$field = '". addslashes($value) ."', "; }
|
|
|
|
$query .= " id = $this->id WHERE id = $this->id";
|
|
|
|
### Perform query:
|
2000-06-22 09:08:12 +00:00
|
|
|
db_query($query);
|
Hoeray! I have a first core version of submission moderation up and
running. This means people can submit stories, and moderators can
moderate stories. When a submission reaches a certain positive
threshold (currently set to 2) the submission becomes a story and up
it goes. If a submission reaches a certain negative threshold
(currently set to -2) the submission is dumped.
The fact this is all done by our visitors (without our intervention)
makes it truly spiffy imho. The website can live a life on it's own,
fed by the visitors.
Beware, a lot of work need to be done though ... it's just a first
basic implementation with the core functionality. There are quite
a lot of things that I'll need to change, extend and improve. But
comments, suggestions and ideas are - as always - welcomed.
Please read this log message carefully! It features quite a lot of
important information.
To test the moderation, log in, select theme 'Dries' (the other themes
need a small update) and head by clicking the one and only 'submission
moderation' link. Don't be afraid to submit lame/funny/useless
stories for testing purpose ... as soon we go public, we'll wipe out
the story database. ;-)
WHAT'S NEW?
-----------
* Added 2 new operations to user.class.php to set and retrieve the
user's "history". Very evil but required to avoid people voting
twice.
* Moved dbsave() from account.php to functions.php. In addition, I
added a new function to user.class.php called `save()' that ...
well, saves the object back to the database. It's (IMHO) a better
approach compared to dbsave(): it keeps things organized. ;-)
BUGFIXES:
---------
* Fixed a (heavy) memory leak in the constructor of user.class.php:
mysql_fetch_array() returns an _associative_ array which made the
constructor `pollute' the object with a lot of useless variables.
* Fixed the slash-problem on the account pages. :-)
* Fixed UnConeD's theme glitch, alas the warning.
* Fixed the e-mail address not showing in the confirmation email
(upon registration).
* Fixed the typical quote and backslash problems in submit.php.
* submit.php now uses the database abstraction layer.
IMPORTANT:
----------
* You can check the new submission system at:
http://beta.drop.org/submission.php
or by following the `submission moderation' link from my theme.
* UnConeD, Jeroen: you'll need to update your themes to take
advantage of the new function: displayAccount(). This function
will display the `submission moderation' link when a user is
logged on.
* Natrak: you might want to apply the patches in user.class.php
on the other sites using the same user-system.
2000-06-13 09:42:58 +00:00
|
|
|
}
|
2000-06-20 07:33:17 +00:00
|
|
|
function rehash() {
|
2000-06-22 09:08:12 +00:00
|
|
|
$result = db_query("SELECT * FROM users WHERE id=$this->id");
|
|
|
|
if (db_num_rows($result) == 1) {
|
|
|
|
foreach (db_fetch_array($result) as $key=>$value) { $this->$key = stripslashes($value); }
|
2000-06-02 18:41:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function valid($access=0) {
|
|
|
|
if (!empty($this->userid)) {
|
2000-06-20 07:33:17 +00:00
|
|
|
$this->rehash(); // synchronisation purpose
|
2000-06-02 18:41:36 +00:00
|
|
|
$this->last_access = time();
|
|
|
|
$this->last_host = (!empty($GLOBALS[REMOTE_HOST]) ? $GLOBALS[REMOTE_HOST] : $GLOBALS[REMOTE_ADDR] );
|
2000-06-22 09:08:12 +00:00
|
|
|
db_query("UPDATE users SET last_access='$this->last_access',last_host='$this->last_host' WHERE id=$this->id");
|
2000-06-02 18:41:36 +00:00
|
|
|
if ($this->access & $access || $access == 0) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
Hoeray! I have a first core version of submission moderation up and
running. This means people can submit stories, and moderators can
moderate stories. When a submission reaches a certain positive
threshold (currently set to 2) the submission becomes a story and up
it goes. If a submission reaches a certain negative threshold
(currently set to -2) the submission is dumped.
The fact this is all done by our visitors (without our intervention)
makes it truly spiffy imho. The website can live a life on it's own,
fed by the visitors.
Beware, a lot of work need to be done though ... it's just a first
basic implementation with the core functionality. There are quite
a lot of things that I'll need to change, extend and improve. But
comments, suggestions and ideas are - as always - welcomed.
Please read this log message carefully! It features quite a lot of
important information.
To test the moderation, log in, select theme 'Dries' (the other themes
need a small update) and head by clicking the one and only 'submission
moderation' link. Don't be afraid to submit lame/funny/useless
stories for testing purpose ... as soon we go public, we'll wipe out
the story database. ;-)
WHAT'S NEW?
-----------
* Added 2 new operations to user.class.php to set and retrieve the
user's "history". Very evil but required to avoid people voting
twice.
* Moved dbsave() from account.php to functions.php. In addition, I
added a new function to user.class.php called `save()' that ...
well, saves the object back to the database. It's (IMHO) a better
approach compared to dbsave(): it keeps things organized. ;-)
BUGFIXES:
---------
* Fixed a (heavy) memory leak in the constructor of user.class.php:
mysql_fetch_array() returns an _associative_ array which made the
constructor `pollute' the object with a lot of useless variables.
* Fixed the slash-problem on the account pages. :-)
* Fixed UnConeD's theme glitch, alas the warning.
* Fixed the e-mail address not showing in the confirmation email
(upon registration).
* Fixed the typical quote and backslash problems in submit.php.
* submit.php now uses the database abstraction layer.
IMPORTANT:
----------
* You can check the new submission system at:
http://beta.drop.org/submission.php
or by following the `submission moderation' link from my theme.
* UnConeD, Jeroen: you'll need to update your themes to take
advantage of the new function: displayAccount(). This function
will display the `submission moderation' link when a user is
logged on.
* Natrak: you might want to apply the patches in user.class.php
on the other sites using the same user-system.
2000-06-13 09:42:58 +00:00
|
|
|
function getHistory($field) {
|
|
|
|
return getHistory($this->history, $field);
|
|
|
|
}
|
|
|
|
function setHistory($field, $value) {
|
|
|
|
$this->history = setHistory($this->history, $field, $value);
|
|
|
|
}
|
2000-06-02 18:41:36 +00:00
|
|
|
}
|
Hoeray! I have a first core version of submission moderation up and
running. This means people can submit stories, and moderators can
moderate stories. When a submission reaches a certain positive
threshold (currently set to 2) the submission becomes a story and up
it goes. If a submission reaches a certain negative threshold
(currently set to -2) the submission is dumped.
The fact this is all done by our visitors (without our intervention)
makes it truly spiffy imho. The website can live a life on it's own,
fed by the visitors.
Beware, a lot of work need to be done though ... it's just a first
basic implementation with the core functionality. There are quite
a lot of things that I'll need to change, extend and improve. But
comments, suggestions and ideas are - as always - welcomed.
Please read this log message carefully! It features quite a lot of
important information.
To test the moderation, log in, select theme 'Dries' (the other themes
need a small update) and head by clicking the one and only 'submission
moderation' link. Don't be afraid to submit lame/funny/useless
stories for testing purpose ... as soon we go public, we'll wipe out
the story database. ;-)
WHAT'S NEW?
-----------
* Added 2 new operations to user.class.php to set and retrieve the
user's "history". Very evil but required to avoid people voting
twice.
* Moved dbsave() from account.php to functions.php. In addition, I
added a new function to user.class.php called `save()' that ...
well, saves the object back to the database. It's (IMHO) a better
approach compared to dbsave(): it keeps things organized. ;-)
BUGFIXES:
---------
* Fixed a (heavy) memory leak in the constructor of user.class.php:
mysql_fetch_array() returns an _associative_ array which made the
constructor `pollute' the object with a lot of useless variables.
* Fixed the slash-problem on the account pages. :-)
* Fixed UnConeD's theme glitch, alas the warning.
* Fixed the e-mail address not showing in the confirmation email
(upon registration).
* Fixed the typical quote and backslash problems in submit.php.
* submit.php now uses the database abstraction layer.
IMPORTANT:
----------
* You can check the new submission system at:
http://beta.drop.org/submission.php
or by following the `submission moderation' link from my theme.
* UnConeD, Jeroen: you'll need to update your themes to take
advantage of the new function: displayAccount(). This function
will display the `submission moderation' link when a user is
logged on.
* Natrak: you might want to apply the patches in user.class.php
on the other sites using the same user-system.
2000-06-13 09:42:58 +00:00
|
|
|
|
|
|
|
function getHistory($history, $field) {
|
|
|
|
$data = explode(";", $history);
|
|
|
|
for (reset($data); current($data); next($data)) {
|
|
|
|
$entry = explode(":", current($data));
|
|
|
|
if (reset($entry) == $field) $rval = end($entry);
|
|
|
|
}
|
|
|
|
return $rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHistory($history, $field, $value) {
|
|
|
|
if (!$value) {
|
|
|
|
### remove entry:
|
|
|
|
$data = explode(";", $history);
|
|
|
|
for (reset($data); current($data); next($data)) {
|
|
|
|
$entry = explode(":", current($data));
|
|
|
|
if ($entry[0] != $field) $rval .= "$entry[0]:$entry[1];";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr($history, "$field:")) {
|
|
|
|
### found: update exsisting entry:
|
|
|
|
$data = explode(";", $history);
|
|
|
|
for (reset($data); current($data); next($data)) {
|
|
|
|
$entry = explode(":", current($data));
|
|
|
|
if ($entry[0] == $field) $entry[1] = $value;
|
|
|
|
$rval .= "$entry[0]:$entry[1];";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
### not found: add new entry:
|
|
|
|
$rval = "$history$field:$value;";
|
|
|
|
}
|
|
|
|
return $rval;
|
|
|
|
}
|
|
|
|
|
2000-06-02 18:41:36 +00:00
|
|
|
?>
|