public function __construct($page_id, $read_only = true) { exMethod("Page: Initializing with input({$page_id})"); $this->read_only = $read_only; /* The "try to fetch" Block */ // Try with Identifier exMethod("Page: Trying 'fetch with id'"); $_page = query(SharedPage::$statements['fetch_with_id'], $page_id); // Try with Reference Identifier if (mysql_num_rows($_page) != 1) { exMethod("Page: Trying 'fetch with ref'"); $_page = query(SharedPage::$statements['fetch_with_data'], 'ref_id', $page_id); } // Try with crunch(Name) if (mysql_num_rows($_page) != 1) { exMethod("Page: Trying 'fetch with name'"); $_page = query(SharedPage::$statements['fetch_with_data'], 'ref_name', crunch($page_id, true)); } if (is_resource($_page) and mysql_num_rows($_page) == 1) { $page = mysql_fetch_assoc($_page); $this->id = $page['id']; $this->ref_id = $page['ref_id']; $this->name = $page['name']; $this->ref_name = $page['ref_name']; // TODO add ex: parsing, add special comment parsing, add [[]] parsing $this->content = $page['content']; $this->author = new User($page['author']); $this->date_modified = $page['date_modified']; $this->date_created = $page['date_created']; $this->draft = $page['draft']; } else { exLog("Page->__construct(): No page exists with ID, Ref ID, or name of {$page_id}."); } }
public function query($sql) { $sql = str_replace('[prefix]', $this->prefix, $sql); $sql = str_replace('[database]', $this->database, $sql); $this->queries[] = $sql; exMethod("Database: MySQL Query -> {$sql}"); return mysql_query($sql); }
public static function Initialize() { /* Setup Registry */ self::$_database = new Database(); self::$_configuration = new Configuration(); self::$_interface = new InterfaceHandler(); self::$_authority = new Authority(); self::$_user = new User(); /* Set base values and cleanup */ crunch($_GET['app']); crunch($_GET['arg']); self::$application = priority_select($_GET['app'], cfRead('Default Application'), 'System'); exMethod('System: _application = ' . self::$application); self::$arg = $_GET['arg']; }
public function __construct($_id = null, $isID = true) { $this->statements['user_from_id'] = "SELECT * FROM `[prefix]users` WHERE `id` LIKE CONVERT(_utf8 '%s' USING latin1) COLLATE latin1_swedish_ci"; $this->statements['user_from_username'] = "******"; $this->statements['update_user_custom'] = "UPDATE `[database]`.`[prefix]users` SET %s WHERE CONVERT(`[prefix]users`.`id` USING utf8) = '%s' LIMIT 1;"; if (is_null($_id)) { exLog("User->__construct(): New user with no id, defaulting to guest."); $_id = 'guest'; $_is_id = false; } if ($isID) { exMethod("User: Initializing with id({$_id})"); $_user = query($this->statements['user_from_id'], $_id); } else { exMethod("User: Initializing with username({$_id})"); $_user = query($this->statements['user_from_username'], $_id); } if (is_resource($_user) and mysql_num_rows($_user) == 1) { $user = mysql_fetch_assoc($_user); } $this->id = $user['id']; $this->username = $user['username']; $this->first_name = $user['fname']; $this->middle_name = $user['mname']; $this->last_name = $user['lname']; $this->display_name = $user['dname']; $this->display_name = str_replace('%u', $this->username, $this->display_name); $this->display_name = str_replace('%f', $this->first_name, $this->display_name); $this->display_name = str_replace('%m', $this->middle_name, $this->display_name); $this->display_name = str_replace('%l', $this->last_name, $this->display_name); $this->email = $user['email']; $this->registered = $user['registered']; $this->configuration = unserialize($user['configuration']); $this->configuration_hash = md5($this->configuration); $this->type = $user['type']; $this->role = $user['role']; $this->banned = $user['banned']; }
public function requireRole() { exMethod("Authority->requireRole(): Role is {$this->role}"); $roles = func_get_args(); if (is_array($roles[0])) { $roles = $roles[0]; } foreach ($roles as $role) { if ($role == $this->role) { if (!$this->verified) { return false; } else { return true; } } } $this->verified = false; return false; }
<?php # Pages Application if (!is_null($_GET['arg']) and $_GET['arg'] != '') { exMethod("Pages: View -> Single Page with ID {$_GET['arg']}"); $page = new Page(mysql_safe($_GET['arg']), true); if (!is_null($page->id)) { add(template('Single Page', 'Page Name: %1$s<br />Date Mod: %3$s | Date Created: %4$s<br />Author: %7$s<br /><pre style="color:green">%2$s</pre>'), $page->name, $page->content, format_date($page->date_modified), format_date($page->date_created), $page->author->id, $page->author->username, $page->author->display_name); } else { error('Page Not Found', 'You entered an invalid page.'); } } else { exMethod("Pages: View -> List with offset({$_GET['offset']}) and count({$_GET['count']})"); $pages = SharedPage::Fetch(mysql_safe($_GET['offset']), mysql_safe($_GET['count']), true); // DONT CARE YET }
function priority_select() { $choices = func_get_args(); $choices[] = false; do { $choice = array_shift($choices); } while ((is_null($choice) or $choice == '') and count($choices) > 0); exMethod("priority_select(): _choice = {$choice}"); return $choice; }