/** * * @param string $groupName * @param string $actionName * @param array $extra * @return boolean */ public function isAuthorized($groupName, $actionName = null, $extra = null) { if ($extra !== null && !is_array($extra)) { trigger_error("`ownerId` parameter has been deprecated, pass `extra` parameter instead\n" . OW_ErrorManager::getInstance()->debugBacktrace(), E_USER_WARNING); } return BOL_AuthorizationService::getInstance()->isActionAuthorized($groupName, $actionName, $extra); }
/** * Returns an instance of class (singleton pattern implementation). * * @return OW_ErrorManager */ public static function getInstance($debugMode = true) { if (self::$classInstance === null) { self::$classInstance = new self($debugMode); } return self::$classInstance; }
/** * Application init actions. */ public function init() { require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'json_err_output.php'; OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_JsonErrOutput()); $authToken = empty($_SERVER["HTTP_API_AUTH_TOKEN"]) ? null : $_SERVER["HTTP_API_AUTH_TOKEN"]; OW_Auth::getInstance()->setAuthenticator(new OW_TokenAuthenticator($authToken)); if (!empty($_SERVER["HTTP_API_LANGUAGE"])) { $tag = $_SERVER["HTTP_API_LANGUAGE"]; $languageDto = BOL_LanguageService::getInstance()->findByTag($tag); if (empty($languageDto)) { $tag = mb_substr($tag, 0, 2); $languageDto = BOL_LanguageService::getInstance()->findByTag($tag); } if (!empty($languageDto) && $languageDto->status == "active") { BOL_LanguageService::getInstance()->setCurrentLanguage($languageDto); } } $this->detectLanguage(); // setting default time zone date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone')); if (OW::getUser()->isAuthenticated()) { $userId = OW::getUser()->getId(); $timeZone = BOL_PreferenceService::getInstance()->getPreferenceValue('timeZoneSelect', $userId); if (!empty($timeZone)) { date_default_timezone_set($timeZone); } } // synchronize the db's time zone OW::getDbo()->setTimezone(); // OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel'); // OW::getRequestHandler()->setStaticPageAttributes('BASE_CTRL_StaticDocument'); // // // router init - need to set current page uri and base url $router = OW::getRouter(); $router->setBaseUrl(OW_URL_HOME . 'api/'); $uri = OW::getRequest()->getRequestUri(); // before setting in router need to remove get params if (strstr($uri, '?')) { $uri = substr($uri, 0, strpos($uri, '?')); } $router->setUri($uri); $router->setDefaultRoute(new OW_ApiDefaultRoute()); OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); $beckend = OW::getEventManager()->call('base.cache_backend_init'); if ($beckend !== null) { OW::getCacheManager()->setCacheBackend($beckend); OW::getCacheManager()->setLifetime(3600); OW::getDbo()->setUseCashe(true); } OW::getResponse()->setDocument($this->newDocument()); if (OW::getUser()->isAuthenticated()) { BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext()); } }
* http://www.oxwall.org/license. The License is based on the Mozilla Public License Version 1.1 * but Sections 14 and 15 have been added to cover use of software over a computer network and provide for * limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent * with Exhibit B. Software distributed under the License is distributed on an “AS IS” basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language * governing rights and limitations under the License. The Original Code is Oxwall software. * The Initial Developer of the Original Code is Oxwall Foundation (http://www.oxwall.org/foundation). * All portions of the code written by Oxwall Foundation are Copyright (c) 2011. All Rights Reserved. * EXHIBIT B. Attribution Information * Attribution Copyright Notice: Copyright 2011 Oxwall Foundation. All rights reserved. * Attribution Phrase (not exceeding 10 words): Powered by Oxwall community software * Attribution URL: http://www.oxwall.org/ * Graphic Image as provided in the Covered Code. * Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work * which combines Covered Code or portions thereof with code not governed by the terms of the CPAL. */ define('OW_USE_CONTEXT', 8); // CLI context define('DS', DIRECTORY_SEPARATOR); define('OW_DIR_ROOT', __DIR__ . DS); require_once OW_DIR_ROOT . 'ow_includes' . DS . 'init.php'; require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'cli_err_output.php'; OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_CliErrOutput()); // setting default time zone date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone')); OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator()); OW::getPluginManager()->initPlugins(); $event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT); OW::getEventManager()->trigger($event); $event = new OW_Event(OW_EventManager::ON_CLI_RUN, array('args' => $argv)); OW::getEventManager()->trigger($event);
define("HAMMU_DB_PAYMENT_TYPE_KEY", "field_2de34e86b2ea038c86f2b4b5be00811e"); define("HAMMU_DB_IM_USING_HAMMU_AS_KEY", "field_8eb4e427b80ac66d870fc0a5a0cc22ba"); define("HAMMU_DB_PREFRENCES_KEY", "field_f2d8bb949d7d74a70bcb2003abc5b436"); define("HAMMU_DB_PREFRENCES_KEY", "field_f2d8bb949d7d74a70bcb2003abc5b436"); define("HAMMU_DB_SERVICES_KEY", "field_f92bbdb57510b86ba6c506c487be3aa1"); define("HAMMU_DB_MOBILE_NUMBER_KEY", "field_391797ad0e06d17d5b5cec0e48def7c2"); mb_internal_encoding('UTF-8'); if (OW_DEBUG_MODE) { ob_start(); } spl_autoload_register(array('OW_Autoload', 'autoload')); // adding standard package pointers $autoloader = OW::getAutoloader(); $autoloader->addPackagePointer('OW', OW_DIR_CORE); $autoloader->addPackagePointer('INC', OW_DIR_INC); $autoloader->addPackagePointer('UTIL', OW_DIR_UTIL); $autoloader->addPackagePointer('BOL', OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'bol'); // Force autoload of classes without package pointer $classesToAutoload = array('Form' => OW_DIR_CORE . 'form.php', 'TextField' => OW_DIR_CORE . 'form_element.php', 'HiddenField' => OW_DIR_CORE . 'form_element.php', 'FormElement' => OW_DIR_CORE . 'form_element.php', 'RequiredValidator' => OW_DIR_CORE . 'validator.php', 'StringValidator' => OW_DIR_CORE . 'validator.php', 'RegExpValidator' => OW_DIR_CORE . 'validator.php', 'EmailValidator' => OW_DIR_CORE . 'validator.php', 'UrlValidator' => OW_DIR_CORE . 'validator.php', 'AlphaNumericValidator' => OW_DIR_CORE . 'validator.php', 'IntValidator' => OW_DIR_CORE . 'validator.php', 'FloatValidator' => OW_DIR_CORE . 'validator.php', 'DateValidator' => OW_DIR_CORE . 'validator.php', 'CaptchaValidator' => OW_DIR_CORE . 'validator.php', 'RadioField' => OW_DIR_CORE . 'form_element.php', 'CheckboxField' => OW_DIR_CORE . 'form_element.php', 'Selectbox' => OW_DIR_CORE . 'form_element.php', 'CheckboxGroup' => OW_DIR_CORE . 'form_element.php', 'RadioField' => OW_DIR_CORE . 'form_element.php', 'PasswordField' => OW_DIR_CORE . 'form_element.php', 'Submit' => OW_DIR_CORE . 'form_element.php', 'Button' => OW_DIR_CORE . 'form_element.php', 'Textarea' => OW_DIR_CORE . 'form_element.php', 'FileField' => OW_DIR_CORE . 'form_element.php', 'TagsField' => OW_DIR_CORE . 'form_element.php', 'SuggestField' => OW_DIR_CORE . 'form_element.php', 'MultiFileField' => OW_DIR_CORE . 'form_element.php', 'Multiselect' => OW_DIR_CORE . 'form_element.php', 'CaptchaField' => OW_DIR_CORE . 'form_element.php', 'InvitationFormElement' => OW_DIR_CORE . 'form_element.php', 'Range' => OW_DIR_CORE . 'form_element.php'); OW::getAutoloader()->addClassArray($classesToAutoload); if (defined("OW_URL_HOME")) { OW::getRouter()->setBaseUrl(OW_URL_HOME); } if (OW_PROFILER_ENABLE) { UTIL_Profiler::getInstance(); } require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'file_log_writer.php'; require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'db_log_writer.php'; require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'err_output.php'; $errorManager = OW_ErrorManager::getInstance(OW_DEBUG_MODE); $errorManager->setErrorOutput(new BASE_CLASS_ErrOutput());
/** * @param $groupName * @param null $actionName * @param array $extra * * @return boolean */ public function isActionAuthorized($groupName, $actionName = null, $extra = null) { if ($extra !== null && !is_array($extra)) { trigger_error("`ownerId` parameter has been deprecated, pass `extra` parameter instead\n" . OW_ErrorManager::getInstance()->debugBacktrace(), E_USER_WARNING); } if (!empty($extra['userId'])) { $userId = (int) $extra['userId']; } else { $userId = OW::getUser()->isAuthenticated() ? OW::getUser()->getId() : 0; } $isAuthorized = $this->isActionAuthorizedForUser($userId, $groupName, $actionName); if ($isAuthorized) { return true; } if (!$userId && !$this->isActionAuthorizedForGuest($groupName, $actionName)) { return false; } // layer check $eventParams = array('userId' => $userId, 'groupName' => $groupName, 'actionName' => $actionName, 'extra' => $extra); try { $event = new BASE_CLASS_EventCollector('authorization.layer_check', $eventParams); OW::getEventManager()->trigger($event); $data = $event->getData(); } catch (Exception $ex) { OW::getLogger()->addEntry($ex->getMessage() . "\n" . print_r($ex->getTrace(), true)); } if (!empty($data)) { usort($data, array($this, 'sortLayersByPriorityAsc')); foreach ($data as $layer) { if ($layer['permission'] === true) { return true; } } } return $isAuthorized; }