id = $row[id]; //Int(6) $this->user = $row[user]; //Varchar (case sensitive) $this->pass = $row[pass]; //Varchar $this->email = $row[email]; //Varchar $this->visits = $row[visits]; //Int $this->rank = $row[rank]; //Varchar $this->time_registered = $row[timestamp]; //Int $this->onladder = $row[onladder]; //Int (bool) $this->onstaff = $row[onstaff]; //Varchar (array struct, explode by "," see admin script $this->onnewsmail = $row[onnewsmail]; //Int (bool) $this->imsstatus = $row[imsstatus]; //Varchar (string with IMS status) //this->forumstats is an array with index 0 = total post count, and other indexes are individual forum post counts $forum = explode(",",$row[forumstats]); $this->forumstats[total] = $forum[0]; for ($i=0;$i!=$GLOBALS[forumnumber];$i++) { if (!isset($forum[$i+1])) $forum[$i+1] = 0; $this->forumstats[$i] = $forum[$i+1]; } $this->buddylist = $row[buddylist]; $this->cars = $row[cars]; $this->location = $row[location]; } function destroy () { //This is the destructor. It collects all variables and puts them back in the SQL database $forum = implode(",",$this->forumstats); //The big chunk of queries have been replaced by only one. This is much faster on the database (as it performs only one seek operation, then it updates the whole row). mysql_query("UPDATE unified SET user = '$this->user',pass = '$this->pass',email = '$this->email',visits = '$this->visits',rank = '$this->rank',onladder = '$this->onladder',onstaff = '$this->onstaff',forumstats = '$forum',onnewsmail = '$this->onnewsmail',buddylist = '$this->buddylist', cars = '$this->cars', location = '$this->location' WHERE id = '$this->id'"); } function buddy_dropdown ($name) { //Creates a SELECT dropdown box with user buddylist if ($this->buddylist == "") { //Show entire user list $html = ""; } else { //Only the buddylist $array = explode(",",$this->buddylist); $html = "Below is your personal BuddyList. Click here for a full list of users. Click here to edit your BuddyList.
"; } return $html; } function buddy_add ($id) { //Adds a buddy to the buddylist if ($this->buddylist == "") { $this->buddylist = "$id"; } else { $this->buddylist .= ",$id"; } } function get_var ($varname) { //Give back requested varname return $this->{$varname}; } function log_hit () { $stats = $GLOBALS[trackstats]; if ($stats[users] == true) { $this->visits++; } } function change_username ($newname) { //Change username $this->user = $newname; } function change_password ($newpass) { //Change password $this->pass = $newpass; } function change_email ($newemail) { //Change email address //FUCK !!! strstr crashes the server :/ //if (!strstr($newmail,"@")) { error("Invalid Email","Your email address did not contain the @-sign. Changes have NOT been saved"); } //if (!strstr($newmail,".")) { error("Invalid Email","Your email address did not contain a dot. At least one dot must be present. Changes have NOT been saved"); } $this->email = $newemail; } function change_onnewsmail ($bool) { //Change onnewsmail status $this->onnewsmail = $bool; } function change_cars ($cars) { $this->cars = $cars; } function change_location ($location) { $this->location = $location; } function forum_addpost ($forum) { //Increment forum post count & update database $this->forumstats[total]++; $this->forumstats[$forum]++; } function forum_delpost ($forum) { //Decrement forum post count & update database $this->forumstats[total]--; $this->forumstats[$forum]--; } function forum_getpost () { //Return post amount return $this->forumstats[total]; } function forum_promoinfo () { //Format the current forum info in a nice string & return it back $rankname = $GLOBALS[rankname]; $rankchng = $GLOBALS[rankchng]; $numranks = $GLOBALS[numranks]; if (in_array($this->rank,$rankname)) { for ($i=0;$i<$numranks;$i++) { if ($rankname[$i] == $this->rank) break; } $prom = $rankchng[$i+1] - $posts; $html = "Your current rank : $this->rank
Posts until promotion (".$rankname[$i+1].") : $prom
Total posts in forum : ".$this->forumstats[total].""; } else { $html = "Your current rank : $this->rank
Since you have a custom rank, you will not get promoted automatically.
Total posts in forum : ".$this->forumstats[total].""; } return $html; } function forum_post_details () { //Return a string with amounts of posts in each individual forum $name = $GLOBALS[forumname]; $number = $GLOBALS[forumnumber]; for ($i=1;$i!=$number;$i++) { $html .= " -".$this->forumstats[$i]." posts in forum '$name[$i]'
"; } return $html; } function ranking_reset () { //Put user ranking back to default standard one $array = $GLOBALS[rankname]; $this->rank = $array[0]; $this->ranking_calculate(); } function ranking_calculate () { //Calculate & attribute new rank if needed $rankname = $GLOBALS[rankname]; $rankchng = $GLOBALS[rankchng]; if (strstr(implode(",",$rankname),$this->rank)) { //User does not have a custom rank, proceed for ($i=0;$i<$GLOBALS[numranks];$i++) { if ($this->forumstats[total] > $rankchng[$i]) { $this->rank = $rankname[$i]; } } } } function ladder_add () { //Add user on ladder $this->onladder = 1; } function ladder_rem () { //Add user on ladder $this->onladder = 0; } function admin_secure () { //Check wether or not an user has access to the admin panel if ($this->onstaff == "") { error("Access Denied","You have no access to this restricted area"); } } function get_regdate () { //Return string with formatted registration date return date("l, F dS Y",$this->time_registered); } function get_member($id) { //Get random username $query = mysql_query("SELECT user FROM unified WHERE id = '$id'"); $row = mysql_fetch_array($query); return $row[user]; } //begin Roger's added functions.... function get_member_email($id) { //Get email - Tri, I didn't know where the above function was used and so decided to make a new function //to get the email value. I suppose you could call it a temp fix... //Garner, I should slap you. A function like this has to be written in core.unified, not in user.class!! //It just returns the email for a random id, not the current user object. GARGHLLL... >:( $query = mysql_query("SELECT email FROM unified WHERE id = '$id'"); $row = mysql_fetch_array($query); return $row[email]; } function get_userid($un) { //Get the id of the user (for profile) $query = mysql_query("SELECT id FROM unified WHERE user = '$un'"); $row = mysql_fetch_array($query); return $row[id]; } } //End class ?>