From e0140672f1fb7c79e47aadad6fbee57e7262b1a2 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sun, 5 Feb 2017 21:58:04 -0500 Subject: Purge old content --- examples/class/controller.class.php | 35 ----------- examples/class/framework.class.php | 67 -------------------- examples/class/object.class.php | 22 ------- examples/class/user.class.php | 121 ------------------------------------ 4 files changed, 245 deletions(-) diff --git a/examples/class/controller.class.php b/examples/class/controller.class.php index 0ab1a69..3e05812 100644 --- a/examples/class/controller.class.php +++ b/examples/class/controller.class.php @@ -1,25 +1,5 @@ redirectTo("http://" . $_SERVER['SERVER_NAME'] . $this->ap()); } - - /* - * Security check - * Assert that the client's IP address does not change during its session. If a change is detected, logout. - */ - function sec_verify_ip() - { - $addr = $_SERVER['REMOTE_ADDR']; - - if ($this->getCurrentUser() && $addr != $this->getOriginIP()) - { - $this->setCurrentUser(); - $this->redirectTo($this->ar() . "/"); - } - } } ?> diff --git a/examples/class/framework.class.php b/examples/class/framework.class.php index 802c821..0461da7 100644 --- a/examples/class/framework.class.php +++ b/examples/class/framework.class.php @@ -1,30 +1,7 @@ type == "user") - return $user; - - $this->setCurrentUser(); - } - - return false; - } - - /* - * Get the IP address the client held when the current session began - */ - function getOriginIP() - { - return $_SESSION['userip']; - } - - /* - * Set the current logged in user - */ - function setCurrentUser($user = null) - { - if ($user != null && isset($user->guid)) - { - $_SESSION['userguid'] = $user->guid; - $_SESSION['userip'] = $_SERVER['REMOTE_ADDR']; - } - - else - { - unset($_SESSION['userguid']); - unset($_SESSION['userip']); - } - } - /* * Get or create the app's database connection object (this is a singleton object and dependent on system-level config) */ diff --git a/examples/class/object.class.php b/examples/class/object.class.php index 3acea4f..4bafc5c 100644 --- a/examples/class/object.class.php +++ b/examples/class/object.class.php @@ -2,28 +2,6 @@ abstract class Object extends Framework { - /* - * Check if given user (or group) is the owner of this object - */ - function isOwner($ug) - { - return $this->getOwner()->guid == $ug->guid; - } - - /* - * Check if given user (or group) is a member of this object - */ - function isMember($ug) - { - foreach ($this->getMembers() as $member) - { - if ($member->guid == $ug->guid) - return true; - } - - return false; - } - /* * Check if given user has permissions for this object */ diff --git a/examples/class/user.class.php b/examples/class/user.class.php index b8143a9..eff5fd0 100644 --- a/examples/class/user.class.php +++ b/examples/class/user.class.php @@ -1,128 +1,7 @@ loadObj($guid); - } - - /* - * Initialize object by username - */ - function initByUsername($username) - { - $query = "SELECT guid FROM object WHERE type = 'user' AND name = '" . $this->db->esc($username) . "'"; - $result = $this->db->query($query); - - if (count($result) == 0) - return false; - - $this->loadObj($result[0]['guid']); - return true; - } - - /* - * Get all users -- ordered by name, ascending - */ - function getAllUsers_orderByName() - { - $query = "SELECT guid FROM `object` WHERE `type` = 'user' ORDER BY name"; - $result = $this->db->query($query); - - $users = array(); - - foreach ($result as $u) - $users[] = new User($u['guid']); - - return $users; - } - - /* - * Get all users -- ordered by admin DESC (admins first), then by name - */ - function getAllUsers_orderByAdminByName() - { - $query = "SELECT o.guid FROM object o JOIN user u ON o.guid = u.guid WHERE o.type = 'user' ORDER BY u.admin DESC, o.name"; - $result = $this->db->query($query); - - $users = array(); - - foreach ($result as $u) - $users[] = new User($u['guid']); - - return $users; - } - - /* - * Get the number of administrative accounts in the system - */ - function getNumAdmins() - { - $query = "SELECT count(*) as cnt FROM user WHERE admin = 1"; - $results = $this->db->query($query); - return $results[0]['cnt']; - } - - /* - * Check whether a given username is currently in use - */ - function usernameInUse($username) - { - $escd_username = $this->db->esc($username); - - $query = "SELECT name FROM object WHERE type = 'user' AND name = '" . $escd_username . "'"; - $results = $this->db->query($query); - - if (count($results) > 0) - return true; - - return false; - } - - /* - * Generate a key from a user's password and salt - */ - function getKey($password, $salt) - { - return hash("sha256", $salt . $password); - } - /* * Create a new User object with the given username and keyed with the given plain-text password * This function returns false if $username is already being used -- cgit v1.2.3