function __construct($header) { //TODO use https when loggin in // use ssh for login // $host = "https://" . OLIV_SSH_HOST . "/" . OLIV_BASE . "index.php"; $host = "http://" . system::OLIV_SSH_HOST() . "/" . system::OLIV_BASE() . "index.php"; // load login content xml $this->content = OLIVModule::load_content($header); // select template for logged of not logged if (status::OLIV_USER()) { $header->param->template = "logged"; $this->content->username = OLIVUser::getName(status::OLIV_USER()); if (status::OLIV_SU()) { $this->content->su = status::OLIV_SU(); } else { $this->content->user_groups = OLIVUser::getGroupName(status::OLIV_USER()); } } else { // check if wrong login if (argv::action() == "login") { $header->param->template = "incorrect"; } } // load correct template $this->template = OLIVModule::load_template($header); }
private static function checkAccess($access, $strict = FALSE) { $owner = ""; $group = ""; $rights = "000"; $ownRight = ""; $groupRight = ""; $allRight = ""; //echoall($access); //------------------------------------------------------------------------------ // get requested rights $owner = (string) $access->attributes()->owner; $group = (string) $access->attributes()->group; $rights = (string) $access->attributes()->access; $ownRight = intval(substr($rights, 0, 1)); $groupRight = intval(substr($rights, 1, 1)); $allRight = intval(substr($rights, 2, 1)); //------------------------------------------------------------------------------ // get user rights $userRight = OLIVUser::getRight(status::OLIV_USER()); $userOwner = $userRight->getName(); $userGroup = OLIVUser::getGroup(status::OLIV_USER()); //echoall($group); //------------------------------------------------------------------------------ // no rights requested // reset rights $r = $w = $x = 0; // if no rights found, check strict parameter if (!$ownRight and !$groupRight and !$allRight) { if (!$strict) { $r = $w = $x = 1; } else { $r = $w = $x = 0; } } //print_r($userGroup->asXML()); //------------------------------------------------------------------------------ // give all rights if superuser if (status::OLIV_SU()) { $r = $w = $x = 1; } //------------------------------------------------------------------------------ // check owner if (status::OLIV_USER()) { if ($owner == $userOwner) { if ($ownRight & 4) { $r = 1; } if ($ownRight & 2) { $w = 1; } if ($ownRight & 1) { $x = 1; } } } //------------------------------------------------------------------------------ // check group if ($userGroup) { if ($group == (string) $userGroup->{$group}->getName()) { if ($groupRight & 4) { $r = 1; } if ($groupRight & 2) { $w = 1; } if ($groupRight & 1) { $x = 1; } } } //------------------------------------------------------------------------------ // check all rights if ($access) { if ($allRight & 4) { $r = 1; } if ($allRight & 2) { $w = 1; } if ($allRight & 1) { $x = 1; } } return array("r" => $r, "w" => $w, "x" => $x); }