rendered paste body/* s0rs.class.php */<?phpclass s0rscms { var $dbcon; var $content; var $pagecontent; var $sessionid; var $userSettings; var $debug; function connectDB($host, $user, $pass){ $this->dbcon = mysql_connect($host, $user, $pass); return $this->dbcon; } function initSession(){ session_start(); $this->sessionid = session_id(); } function loadSessionData(){ $sessiondata = $this->sqlQueryWithResult("SELECT user FROM sessions WHERE(sessionid='".$this->sessionid."')"); if(strtolower($sessiondata[0]) == "guest"){ $settingsdata = $this->sqlQueryWithResult("SELECT user,style,noads,debug FROM settings WHERE(user='".$sessiondata[0]."')"); list($this->userSettings['user'], $this->userSettings['style'], $this->userSettings['noads'], $this->userSettings['debug']) = $settingsdata; } else{ $settingsdata = $this->sqlQueryWithResult("SELECT user,style,noads,debug FROM settings WHERE(user='".$sessiondata[0]."')"); list($this->userSettings['user'], $this->userSettings['style'], $this->userSettings['noads'], $this->userSettings['debug']) = $settingsdata; } } function sqlQueryWithResult($sql){ $meep = mysql_query($sql, $this->dbcon); $result = mysql_fetch_array($meep, MYSQL_NUM); return $result; } function sqlQuery($sql){ $sql = mysql_real_escape_string($sql, $this->dbcon); $query = @mysql_query($sql, $this->dbcon); return $query; } function debugLogin($user){ $this->loginUserBySession($this->sessionid, $user); } function loginUserBySession($sessionid, $user){ if($this->sqlQuery("SELECT * FROM sessions WHERE(sessionid='$sessionid')")){ //session already exists, update to reflect new user $query = $this->sqlQuery("UPDATE sessions SET user='$user' WHERE(sessionid='$sessionid')"); return $query; } else{ //session doesn't exist, insert into the db $query = $this->sqlQuery("INSERT INTO sessions (sessionid, user) VALUES('$sessionid', '$user')"); return $query; } } function selectDB($db){ $selected = @mysql_select_db($db, $this->dbcon); return $selected; } function loadTemplate(){ $this->content = file_get_contents("includes/template.php"); } function addStaticContent($stuff){ $this->pagecontent .= $stuff; } function getSetting($setting, $tf = true){ if($tf){ if($this->userSettings[$setting]==='1'){ return true; } else{ return false; } } else{ return $this->userSettings[$setting]; } } function loadPageAds(){ if($this->getSetting('noads')){ $this->content = str_replace("##ADBLOCK##", '', $this->content); } else{ $this->content = str_replace("##ADBLOCK##", file_get_contents("includes/adblock.txt"), $this->content); } } function loadDebugArea(){ if($this->getSetting('debug')){ die(var_export($this, true)); } else{ $this->content = str_replace("##DEBUG##", '', $this->content); } } function loadContent($file, $stuff = false){ if($file == "static"){ $this->content = str_replace("##CONTENT##", $stuff, $this->content); } else{ $this->content = str_replace("##CONTENT##", file_get_contents("includes/$file.php", $this->content)); } }}?>/* index.php */<?phprequire "s0rs.class.php";$s0rs = new s0rscms();$s0rs->loadTemplate();$s0rs->initSession();if($s0rs->connectDB("localhost", "web", "web")){$s0rs->addStaticContent("I can connect to the DB server @ localhost");}if($s0rs->selectDB("webdb")){$s0rs->addStaticContent(" and I can select the mysql DB!");}$s0rs->loadSessionData();$s0rs->loadPageAds();$s0rs->loadDebugArea();$s0rs->loadContent("static", $s0rs->pagecontent);print $s0rs->content;?>