All pastes #396295 Raw Edit

Anonymous

public php v1 · immutable
·published 2007-03-15 17:31 UTC
rendered paste body
<?php     /* Forum Class for subeta.      * This API is for better expandability      */      class forums {      	protected $error;	protected $object;	protected $query;	public $categories=array();	public $forums=array();	public $threads=array();	public $posts=array();	public $topic;	public $forum_one;	public $mods;		public function __construct() { }		public function get_categories() {			unset($this->categories);			global $thisuser;			$this->query = mysql_query("SELECT `name`,`catid` FROM `new_forum_categorys` WHERE open=1 AND level LIKE '%".$thisuser->usertype."%'") or forums::error(mysql_error());			while ($temp = mysql_fetch_array($this->query)) {				$this->categories[] = $temp;			}					return $this->categories;						}		public function get_forums($parent) {			unset($this->forums);			global $thisuser;			$parent = mysql_real_escape_string($parent);			$this->query = mysql_query("SELECT `forumid`,`desc`,`name`,`order`,`last_topic`,`last_user` FROM `new_forum_forum` WHERE catid=$parent AND level LIKE '%".$thisuser->usertype."%' AND `sub` = 'f' ORDER BY `order` DESC") or forums::error(mysql_error());			while ($temp = mysql_fetch_array($this->query)) {				$this->forums[] = $temp;			}			return $this->forums;		}		public function get_topic($topic,$type='object') {			$topic = mysql_real_escape_string($topic);			$this->query = mysql_query("SELECT * FROM `new_forum_topic` a, `new_forum_forum` b WHERE a.forumid=b.forumid AND topicid=$topic") or forums::error(mysql_error());			switch ($type) {				case 'object':					$this->topic=mysql_fetch_object($this->query);					break;				case 'array':					$this->topic=mysql_fetch_array($this->query);					break;				case 'assoc':					$this->topic=mysql_fetch_assoc($this->query);					break;			}			return $this->topic;		}				public function get_forum_one($topic,$type='object') {			$topic = mysql_real_escape_string($topic);			$this->query = mysql_query("SELECT * FROM `new_forum_forum` WHERE forumid=$topic") or forums::error(mysql_error());			switch ($type) {				case 'object':					$this->forum_one=mysql_fetch_object($this->query);					break;				case 'array':					$this->forum_one=mysql_fetch_array($this->query);					break;				case 'assoc':					$this->forum_one=mysql_fetch_assoc($this->query);					break;			}			return $this->forum_one;		}		public function get_moderators($topic,$type='object') {			$topic = mysql_real_escape_string($topic);			$this->query = mysql_query("SELECT `mods` FROM `new_forum_forum` WHERE forumid=$topic") or forums::error(mysql_error());			switch ($type) {				case 'object':					$this->mods=mysql_fetch_object($this->query);					break;				case 'array':					$this->mods=mysql_fetch_array($this->query);					break;				case 'assoc':					$this->mods=mysql_fetch_assoc($this->query);					break;			}			return $this->mods;		}		private function error($what) {			echo $what;		}      }?>