From ea46bd0a4a040040c9cadd45441089bce9769bea Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 16 Feb 2017 03:07:26 -0500 Subject: Rm old content --- examples/class/controller.class.php | 31 ---- examples/class/framework.class.php | 59 -------- examples/class/object.class.php | 291 ------------------------------------ examples/class/setting.class.php | 90 ----------- 4 files changed, 471 deletions(-) delete mode 100644 examples/class/controller.class.php delete mode 100644 examples/class/framework.class.php delete mode 100644 examples/class/setting.class.php diff --git a/examples/class/controller.class.php b/examples/class/controller.class.php deleted file mode 100644 index 3e05812..0000000 --- a/examples/class/controller.class.php +++ /dev/null @@ -1,31 +0,0 @@ -redirectTo("https://" . $_SERVER['SERVER_NAME'] . $this->ap()); - } - - /* - * Security check - * Assert that the current connection to this server is NOT secure. Redirects if not. - */ - function sec_forbid_https() - { - if (isset($_SERVER['HTTPS'])) - $this->redirectTo("http://" . $_SERVER['SERVER_NAME'] . $this->ap()); - } -} - -?> diff --git a/examples/class/framework.class.php b/examples/class/framework.class.php deleted file mode 100644 index 0461da7..0000000 --- a/examples/class/framework.class.php +++ /dev/null @@ -1,59 +0,0 @@ -ar() . $_REQUEST['path']; - } - - /* - * Redirect to the given URL and die - */ - function redirectTo($url) - { - header("Location: " . $url); - exit; - } - - /* - * Get or create the app's database connection object (this is a singleton object and dependent on system-level config) - */ - static function getDbConnection() - { - global $_SCROTT; - - if (self::$dbobj != null) - return self::$dbobj; - - switch ($_SCROTT['dbEngine']) - { - case "mysql": - $host = $_SCROTT['dbAddress']; - $username = $_SCROTT['dbUser']; - $password = $_SCROTT['dbPass']; - $dbName = $_SCROTT['dbName']; - self::$dbobj = new Mysql($host, $username, $password, $dbName); - break; - - default: - throw new Exception("Problem with Scrott Configuration. Invalid database engine specified."); - break; - } - - return self::$dbobj; - } -} - -?> diff --git a/examples/class/object.class.php b/examples/class/object.class.php index 4bafc5c..6c036ed 100644 --- a/examples/class/object.class.php +++ b/examples/class/object.class.php @@ -2,297 +2,6 @@ abstract class Object extends Framework { - /* - * Check if given user has permissions for this object - */ - function canAccess($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user)) - return true; - - if ($this->perms & 0x004) // accessible by public - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canAccessSub($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canAccessSub($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModify($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x100) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySub($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySub($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModifyMembers($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x080) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySubMembers($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySubMembers($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModifyPermissions($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySubPermissions($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySubPermissions($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canAccessSub($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x040) - return true; - - if ($this->perms & 0x002) // accessible by public - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canAccessSub($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canAccessSub($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canCreateSub($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x020) - return true; - - if ($this->perms & 0x001) // accessible by public - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canCreateSub($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canCreateSub($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModifySub($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x010) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySub($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySub($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModifySubMembers($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->isMember($user) && $this->perms & 0x008) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySubMembers($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySubMembers($user)) - return true; - } - - return false; - } - - /* - * Check if given user has permissions for this object - */ - function canModifySubPermissions($user) - { - if ($user->admin) - return true; - - if ($this->isOwner($user)) - return true; - - if ($this->parent != "") - { - $parent = new DBObject($this->parent); - - if ($parent->canModifySubPermissions($user)) - return true; - } - else if ($this->owner != $this->guid) - { - $owner = new DBObject($this->owner); - - if ($owner->canModifySubPermissions($user)) - return true; - } - - return false; - } - /* * Get URL to this object */ diff --git a/examples/class/setting.class.php b/examples/class/setting.class.php deleted file mode 100644 index c0965a3..0000000 --- a/examples/class/setting.class.php +++ /dev/null @@ -1,90 +0,0 @@ -esc($key); - - $query = "SELECT `value` FROM `setting` WHERE `key` = '" . $escdKey . "'"; - $res = $db->query($query); - - if (count($res) == 0) - return false; - - return $res[0]['value']; - } - - /* - * Helper function for setting setting values on the database - */ - static function setValue($key, $value) - { - $db = parent::getDbConnection(); - $escdKey = $db->esc($key); - $escdValue = $db->esc($value); - - if (self::getValue($key) === false) - $query = "INSERT INTO setting (`key`, value) VALUES('" . $escdKey . "', '" . $escdValue . "')"; - else - $query = "UPDATE setting SET value = '" . $escdValue . "' WHERE `key` = '" . $escdKey . "'"; - - $db->query($query); - } - - /* - * Force or forbid SSL connections? - */ - static function settSSL($value = null) - { - $opt = "settSSL"; - - if ($value != null) - self::setValue($opt, $value); - - $value = self::getValue($opt); - - if ($value === false) - return "neither"; - - return $value; - } - - /* - * Should the app allow the public to signup their own accounts with Scrott? - */ - static function allowPublicSignup($value = null) - { - $opt = "allowPublicSignup"; - - if ($value != null) - self::setValue($opt, $value); - - return self::getValue($opt); - } -} - -?> -- cgit v1.2.3