protected function initConnection() { $this->hosts = AccessConfig::getHostByName($this->hostname); if (isset($this->hosts["auth"])) { $result = array(); $result[$this->hostname] = $this->hosts; $this->hosts = $result; } $this->setUpConsole(); }
public function executeRead(AgaviRequestDataHolder $rd) { // return host status $hosts = AccessConfig::getAvailableHosts(); $status = array(); foreach ($hosts as $host) { $status[] = $this->getStatusForIcingaOnHost($host); } $this->setAttributeByRef("status", $status); return "Success"; }
/** * Returns wether the user is logged in or not. * * @return boolean * True if logged in, else false. */ public function check_login() { if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { $pw_hash = new PasswordHash(); if ($this->access_config->user_exists($_SERVER['PHP_AUTH_USER'])) { $user = $this->access_config->user_get($_SERVER['PHP_AUTH_USER']); if ($pw_hash->check_password($_SERVER['PHP_AUTH_PW'], $user['password'])) { self::$session->set('username', $_SERVER['PHP_AUTH_USER']); // This is for now the only position where we write, so we can close the session for write operations. // This will speed up the performance. self::$session->close_write(); $this->user = $this->get_config()->user_get(self::$session->get('username')); return true; } } } if (self::$session->get('username') != 0) { $this->user = $this->get_config()->user_get(self::$session->get('username')); return true; } header('WWW-Authenticate: Basic realm="PHPMiner "'); header('HTTP/1.0 401 Unauthorized'); }
public function initialize(AgaviContext $context, array $parameters = array()) { $host = isset($parameters["host"]) ? $parameters["host"] : AccessConfig::getDefaultHostname(); $this->host = AccessConfig::getHostByName($host); }
/** * Ajax request to save new configuration settings. */ public function save_settings() { $params = new ParamStruct(); $params->add_required_param('settings', PDT_ARR); $params->fill(); if (!$params->is_valid()) { AjaxModul::return_code(AjaxModul::ERROR_INVALID_PARAMETER); } if (!$this->access_control->has_permission(AccessControl::PERM_CHANGE_MAIN_SETTINGS)) { AjaxModul::return_code(AjaxModul::ERROR_NO_RIGHTS); } $need_redirect = null; foreach ($params->settings as $key => $val) { if ($key === 'enable_access_control' && !empty($val)) { $access_controll = new AccessConfig(); if ($access_controll->is_empty()) { $need_redirect = true; } } $this->config->set_value($key, $val); } if ($need_redirect) { AjaxModul::return_code(AjaxModul::SUCCESS, array('url' => murl('access', 'index'))); } else { AjaxModul::return_code(AjaxModul::SUCCESS); } }
protected function validateStderr() { $errFile = $this->stdout; if (!$errFile) { return true; } if (!AccessConfig::canWrite($errFile, $this->host)) { throw new ApiRestrictedCommandException($errFile . " is not read enabled"); } }
public static function fromArray(array $data) { // array_merge would reindex numeric keys, so we use the + operator // mind the operand order: keys that exist in the left one aren't overridden self::$config = $data + self::$config; }