public function __construct($config = null) { if (!is_array($config) || empty($config)) { $config = Kurogo::getSiteSection('database'); } $this->init($config); }
public function __construct($config = null) { if (!is_array($config) || empty($config)) { $config = Kurogo::getSiteSection('database'); $config = array_merge($config, array_intersect_key($_SERVER, $config)); } $this->init($config); }
protected function init($args) { parent::init($args); if (!isset($args['DB_TYPE'])) { $args = array_merge(Kurogo::getSiteSection('database'), $args); } if (isset($args['SQL'])) { $this->setSQL($args['SQL']); } if (isset($args['PARAMETERS']) && is_array($args['PARAMETERS'])) { $this->setParameters($args['PARAMETERS']); } $this->connection = new db($args); }
public function session() { $this->addPackage('Session'); if (!$this->session) { $args = Kurogo::getSiteSection('authentication'); //default session class $controllerClass = 'SessionFiles'; //maintain previous config compatibility if (isset($args['AUTHENTICATION_USE_SESSION_DB']) && $args['AUTHENTICATION_USE_SESSION_DB']) { $controllerClass = 'SessionDB'; } if (isset($args['AUTHENTICATION_SESSION_CLASS'])) { $controllerClass = $args['AUTHENTICATION_SESSION_CLASS']; } $this->session = Session::factory($controllerClass, $args); } return $this->session; }
default: throw new Exception("Invalid API request: '{$_SERVER['REQUEST_URI']}'", 1); break; } /* log the api call */ PageViews::log_api($id, Kurogo::deviceClassifier()->getPlatform()); $module->executeCommand(); } else { $id = $parts[0]; $page = 'index'; /* see if there's a redirect for this path */ if ($url_redirects = Kurogo::getSiteSection('urls')) { if (array_key_exists($id, $url_redirects)) { if (preg_match("#^http(s)?://#", $url_redirects[$id])) { $url = $url_redirects[$id]; } else { $parts[0] = $url_redirects[$id]; $url = URL_PREFIX . implode("/", $parts); } header("Location: " . $url); exit; } } // find the page part if (isset($parts[1])) { if (strlen($parts[1])) {
protected function init($args) { parent::init($args); $args = is_array($args) ? $args : array(); if (!isset($args['DB_TYPE'])) { $args = array_merge(Kurogo::getSiteSection('database'), $args); } $this->connection = new db($args); if (isset($args['SORTFIELDS']) && is_array($args['SORTFIELDS'])) { $this->sortFields = $args['SORTFIELDS']; } $this->table = isset($args['DB_USER_TABLE']) ? $args['DB_USER_TABLE'] : 'users'; $this->fieldMap = array( 'userid'=>isset($args['DB_USERID_FIELD']) ? $args['DB_USERID_FIELD'] : 'userID', 'email'=>isset($args['DB_EMAIL_FIELD']) ? $args['DB_EMAIL_FIELD'] : 'email', 'firstname'=>isset($args['DB_FIRSTNAME_FIELD']) ? $args['DB_FIRSTNAME_FIELD'] : 'firstname', 'lastname'=>isset($args['DB_LASTNAME_FIELD']) ? $args['DB_LASTNAME_FIELD'] : 'lastname' ); }
public function init($args) { parent::init($args); $args = is_array($args) ? $args : array(); if (!isset($args['DB_TYPE'])) { $args = array_merge(Kurogo::getSiteSection('database'), $args); } $this->connection = new db($args); $this->tableMap = array('user' => 'users', 'group' => 'groups', 'groupmembers' => 'groupmembers'); $this->fieldMap = array('user_userid' => 'userID', 'user_password' => 'password', 'user_email' => 'email', 'user_firstname' => 'firstname', 'user_lastname' => 'lastname', 'user_fullname' => 'fullname', 'group_groupname' => 'group', 'group_gid' => 'gid', 'group_groupmember' => 'gid', 'groupmember_group' => 'gid', 'groupmember_user' => 'userID', 'groupmember_authority' => ''); foreach ($args as $arg => $value) { if (preg_match("/^db_(user|group|groupmember)_(.*?)_field\$/", strtolower($arg), $bits)) { $key = sprintf("%s_%s", $bits[1], $bits[2]); if (isset($this->fieldMap[$key])) { $this->fieldMap[$key] = $value; } } elseif (preg_match("/^db_(.*?)_table\$/", strtolower($arg), $bits)) { $key = $bits[1]; if (isset($this->tableMap[$key])) { $this->tableMap[$key] = $value; } } else { switch ($arg) { case 'DB_USER_PASSWORD_HASH': if (preg_match("/^hmac_(.+)\$/", $value, $bits)) { if (!isset($args['DB_USER_PASSWORD_KEY'])) { throw new KurogoConfigurationException("HMAC hash requires DB_USER_PASSWORD_KEY"); } $this->hmac = true; $value = $bits[1]; } if (!in_array($value, hash_algos())) { throw new KurogoConfigurationException("Hashing algorithm {$value} not available"); } $this->hashAlgo = $value; break; case 'DB_USER_PASSWORD_KEY': $this->hashKey = $value; break; case 'DB_USER_PASSWORD_SALT': case 'DB_USER_PASSWORD_SALT_BEFORE': $this->hashSaltBefore = $value; break; case 'DB_USER_PASSWORD_SALT_AFTER': $this->hashSaltAfter = $value; break; case 'DB_USER_PASSWORD_SALT_FIELD_BEFORE': $this->hashSaltFieldBefore = $value; break; case 'DB_USER_PASSWORD_SALT_FIELD_AFTER': $this->hashSaltFieldAfter = $value; break; case 'DB_GROUP_GROUPMEMBER_PROPERTY': if (!in_array($value, array('group', 'gid'))) { throw new KurogoConfigurationException("Invalid value for DB_GROUP_GROUPMEMBER_PROPERTY {$value}. Should be gid or group"); } $this->fieldMap['group_groupmember'] = $value; break; } } } }
private function loadPageConfig() { if (!isset($this->pageConfig)) { Kurogo::log(LOG_DEBUG, "Loading page configuration for {$this->configModule} - {$this->page}", 'module'); $this->setPageTitle($this->moduleName); // Load site configuration and help text $this->assign('strings', Kurogo::getSiteSection('strings')); // load module config file $pageData = $this->getPageData(); if (!isset($pageData[$this->page])) { throw new KurogoPageNotFoundException(Kurogo::getLocalizedString("ERROR_PAGE_NOT_FOUND", $this->page)); } $pageConfig = $pageData[$this->page]; if (KurogoWebBridge::isNativeCall()) { $this->hasWebBridgePageRefresh = self::argVal($pageConfig, 'nativePageRefresh', false); $this->hasWebBridgeAutoRefresh = self::argVal($pageConfig, 'nativePageAutoRefresh', false); } if (KurogoWebBridge::isNativeCall() && self::argVal($pageConfig, 'nativePageTitle', '')) { $this->pageTitle = $pageConfig['nativePageTitle']; } else { if (isset($pageConfig['pageTitle']) && strlen($pageConfig['pageTitle'])) { $this->pageTitle = $pageConfig['pageTitle']; } } if (KurogoWebBridge::isNativeCall() && self::argVal($pageConfig, 'nativeBreadcrumbTitle', '')) { $this->breadcrumbTitle = $pageConfig['nativeBreadcrumbTitle']; } else { if (isset($pageConfig['breadcrumbTitle']) && strlen($pageConfig['breadcrumbTitle'])) { $this->breadcrumbTitle = $pageConfig['breadcrumbTitle']; } else { $this->breadcrumbTitle = $this->pageTitle; } } if (isset($pageConfig['breadcrumbLongTitle']) && strlen($pageConfig['breadcrumbLongTitle'])) { $this->breadcrumbLongTitle = $pageConfig['breadcrumbLongTitle']; } else { $this->breadcrumbLongTitle = $this->pageTitle; } $this->pageConfig = $pageConfig; } // Ajax overrides for breadcrumb title and long title if (isset($this->args[self::AJAX_BREADCRUMB_TITLE])) { $this->breadcrumbTitle = $this->args[self::AJAX_BREADCRUMB_TITLE]; $this->breadcrumbLongTitle = $this->breadcrumbTitle; } if (isset($this->args[self::AJAX_BREADCRUMB_LONG_TITLE])) { $this->breadcrumbLongTitle = $this->args[self::AJAX_BREADCRUMB_LONG_TITLE]; } }
/** * Returns the current login session * @param string $type, the type of module to load (web/api) */ protected function getSession() { if (!$this->session) { $args = Kurogo::getSiteSection('authentication'); $args['DEBUG_MODE'] = Kurogo::getSiteVar('DATA_DEBUG'); $this->session = new Session($args); } return $this->session; }
private static function timezoneFilter($tzid) { static $timezoneMap; if (!$timezoneMap) { $timezoneMap = Kurogo::getSiteSection('timezones'); } return Kurogo::arrayVal($timezoneMap, $tzid, $tzid); }