public function systemConfig() { $sc = new SystemConfig(); $workRoot = trim(Input::get('workRoot')); // if (File::isWritable($workRoot)) { // $sc->set(SystemConfig::WORK_ROOT_FIELD, $workRoot); // } else { // return Response::json(array( // 'res' => 1, // 'errMsg' => 'Work Root目录不可写!', // )); // } $sc->set(SystemConfig::WORK_ROOT_FIELD, $workRoot); return Response::json(array('res' => 0, 'write' => File::isWritable($workRoot))); }
protected function setApiKey() { $this->apiKey = \SystemConfig::getInstance()->google['api_key']; if (!$this->apiKey) { throw new ProviderException("Google Maps API Key was not set"); } }
public static function load_system_config($file) { if (file_exists($file)) { require_once $file; if (is_array($server) and is_array($database)) { self::$database = $database; define("BASE_DIR", $server['main_folder']); define("WWW_DIR", constant("BASE_DIR") . "/www"); define("LOG_DIR", constant("BASE_DIR") . "/logs"); define("BIN_DIR", constant("BASE_DIR") . "/bin"); define("INCLUDE_DIR", constant("WWW_DIR") . "/core/include"); define("MODULES_DIR", constant("WWW_DIR") . "/core/modules"); define("DEBUG", $server['behaviour']['debug_mode']); define("AVOID_CSS_CACHE", $server['behaviour']['avoid_css_cache']); define("AVOID_JS_CACHE", $server['behaviour']['avoid_js_cache']); define("ENABLE_DB_LOG_ON_ROLLBACK", $server['behaviour']['on_db_rollback']); define("ENABLE_DB_LOG_ON_EXP_ROLLBACK", $server['behaviour']['on_db_expected_rollback']); define("ENABLE_DB_LOG_ON_COMMIT", $server['behaviour']['on_db_commit']); define("SENDMAIL_FROM", $mail['from']); } else { return false; } } else { return false; } }
/** * TimeZoneDbFree constructor. */ public function __construct() { $this->apiKey = \SystemConfig::getInstance()->timezone_db['api_key']; if (!$this->apiKey) { throw new ProviderException("API Key for Time Zone DB is not set"); } }
/** * * * @param \ClientHttpRequest $req */ public function __construct($req) { $this->response = new Response(); $req->addHook(new RequestLogger(), 1000); $this->currentVersion = doubleval(\SystemConfig::getInstance()->system['current_version']); $this->userVersion = doubleval($req->getQueryParam('version')); parent::__construct($req); $this->showtimeService = ShowtimeService::instance(); }
public static function getStringSystemConf($key, $defaultValue) { $syskey = SystemConfig::model()->find('sys_key=:sys_key and status=:status', array(':sys_key' => $key, ':status' => 1)); if (isset($syskey) && !is_null($syskey) && isset($syskey->sys_value) && !is_null($syskey->sys_value)) { return $syskey->sys_value; } else { return $defaultValue; } }
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException(_w('Access denied')); } $contact_id = waRequest::get('id'); $group_ids = null; if ($contact_id > 0) { $user_groups_model = new waUserGroupsModel(); $group_ids = $user_groups_model->getGroupIds($contact_id); $group_ids[] = 0; } $app_id = waRequest::get('app'); $right_model = new waContactRightsModel(); $rights = $right_model->get($contact_id, $app_id, null, false); $group_rights = null; if ($group_ids) { $group_rights = $right_model->get(array_map(wa_lambda('$a', 'return -$a;'), $group_ids), $app_id, null, false); } // Check custom rights items $app_config = SystemConfig::getAppConfig($app_id); $class_name = $app_config->getPrefix() . "RightConfig"; $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php"); if (file_exists($file_path)) { // Init app waSystem::getInstance($app_id, $app_config, true); include $file_path; /** * @var waRightConfig $right_config */ $right_config = new $class_name(); $rights += $right_config->getRights($contact_id); if ($group_ids) { $group_rights += $right_config->getRights(array_map(wa_lambda('$a', 'return -$a;'), $group_ids)); } $this->view->assign('html', $right_config->getHTML($rights, $group_rights)); waSystem::setActive('contacts'); } else { $this->view->assign('html', ''); } if ($contact_id > 0) { $this->view->assign('user', new waContact($contact_id)); } else { $gm = new waGroupModel(); $this->view->assign('group', $gm->getById(-$contact_id)); } $app = wa()->getAppInfo($app_id); $app['id'] = $app_id; $this->view->assign('app', $app); $this->view->assign('rights', $rights); $this->view->assign('group_rights', $group_rights); }
public static function Set($param, $val) { if (is_array($param)) { self::$Settings = array_merge(self::$Settings, $param); } else { $path = explode("/", $param); if (count($path) == 1) { self::$Settings[$param] = $val; } else { self::$Settings[$path[0]][$path[1]] = $val; } } }
function getAccount($req, $hash, $apiId, $sign) { $af = new AccountManager(); $db = SystemConfig::GetDatabaseInstance(); $db->Query("SELECT `AccountId` FROM `Authorized` WHERE `Hash`=?", $hash); $accountId = $db->Assoc('AccountId'); $acc = $af->GetAccountById($accountId); if ($acc) { $db->Query("SELECT `Secret` FROM `Apps` WHERE `Id`=?d", $api); $key = $db->Assoc('Secret'); $acc = encrypt(toXml($acc), $key); return api_response(array('Account' => $acc)); } }
public static function keyWordValid($keyword) { if (SystemConfig::getBooleanSystemConf(Constants::SYS_CONF_OPEN_FILTER_KEYWORD, false)) { $keywords = SystemConfig::getStringSystemConf(Constants::SYS_CONF_FILTER_KEYWORD_KEY, ''); if (!FilterUtils::isN($keywords)) { $keywordArray = explode("{Array}", str_replace(Chr(13), "{Array}", str_replace(Chr(10), "", trim($keywords)))); foreach ($keywordArray as $keywordS) { $keywordS = trim($keywordS); if (strpos($keyword, $keywordS) !== false || strpos($keywordS, $keyword) !== false) { return false; } } } } return true; }
/** * Get meta description of the table and generate fields array * @return array */ public function getMetadata() { if ($this->table && !$this->fields) { $runtime_cache = new waRuntimeCache('db/' . $this->table); if ($this->fields = $runtime_cache->get()) { return $this->fields; } if (SystemConfig::isDebug()) { $this->fields = $this->getFields(); } else { $cache = new waSystemCache('db/' . $this->table); if (!($this->fields = $cache->get())) { $this->fields = $this->getFields(); $cache->set($this->fields); } } $runtime_cache->set($this->fields); } return $this->fields; }
require_once "config/version.php"; require_once "core/include/base/system/system_config.class.php"; SystemConfig::load_system_config("config/main.php"); date_default_timezone_set($server['timezone']); require_once "core/db/db.php"; $database = SystemConfig::get_database(); $db = new Database($database['type']); $db->db_connect($database[0]['server'], $database[0]['port'], $database['user'], $database['password'], $database['database']); require_once "core/include/base/system/transaction.class.php"; require_once "core/include/base/system/events/event.class.php"; require_once "core/include/base/system/events/delete_event.class.php"; require_once "core/include/base/system/system_handler.class.php"; require_once "core/include/base/security/security.class.php"; require_once "core/include/base/security/session.class.php"; require_once "core/include/base/system/autoload.function.php"; SystemConfig::load_module_config(); if ($_GET['session_id'] and $_GET['file_id']) { $transaction = new Transaction(); try { $system_handler = new SystemHandler(false); } catch (Exception $e) { die("Exception"); } Security::protect_session(); $session = new Session($_GET['session_id']); $user = new User($session->get_user_id()); $session_valid_array = $session->is_valid(); if ($session_valid_array[0] === true) { try { $image_cache = new ImageCache($_GET['file_id']); } catch (Exception $e) {
public function execute() { // only allowed to global admin if (!wa()->getUser()->getRights('webasyst', 'backend')) { throw new waRightsException('Access denied.'); } $app_id = waRequest::post('app_id'); $name = waRequest::post('name'); $value = (int) waRequest::post('value'); $contact_id = waRequest::get('id'); $has_backend_access_old = $this->hasBackendAccess($contact_id); if (!$name && !$value) { $values = waRequest::post('app'); if (!is_array($values)) { throw new waException('Bad values for access rights.'); } } else { $values = array($name => $value); } $right_model = new waContactRightsModel(); $is_admin = $right_model->get($contact_id, 'webasyst', 'backend', false); if ($is_admin && $app_id != 'webasyst') { throw new waException('Cannot change application rights for global admin.'); } // If $contact_id used to have limited access and we're changing global admin privileges, // then need to notify all applications to remove their custom access records. if (!$is_admin && $app_id == 'webasyst' && $name == 'backend') { foreach (wa()->getApps() as $aid => $app) { try { if (isset($app['rights']) && $app['rights']) { $app_config = SystemConfig::getAppConfig($aid); $class_name = $app_config->getPrefix() . "RightConfig"; $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php"); $right_config = null; if (!file_exists($file_path)) { continue; } waSystem::getInstance($aid, $app_config); include_once $file_path; /** * @var waRightConfig */ $right_config = new $class_name(); $right_config->clearRights($contact_id); } } catch (Exception $e) { // silently ignore other applications errors } } } // Update $app_id access records $app_config = SystemConfig::getAppConfig($app_id); $class_name = $app_config->getPrefix() . "RightConfig"; $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php"); $right_config = null; if (file_exists($file_path)) { // Init app waSystem::getInstance($app_id, $app_config); include_once $file_path; /** * @var waRightConfig */ $right_config = new $class_name(); } foreach ($values as $name => $value) { if ($right_config && $right_config->setRights($contact_id, $name, $value)) { // If we've got response from custom rights config, then no need to update main rights table continue; } // Set default limited rights if ($right_config && $name == 'backend' && $value == 1) { /** * @var $right_config waRightConfig */ foreach ($right_config->setDefaultRights($contact_id) as $n => $v) { $right_model->save($contact_id, $app_id, $n, $v); } } $right_model->save($contact_id, $app_id, $name, $value); } waSystem::setActive('contacts'); if ($contact_id) { // TODO: use waContact method for disabling $is_user = waRequest::post('is_user', null, 'int'); if ($is_user === -1 || $is_user === 0 || $is_user === 1) { $contact = new waContact($contact_id); $contact->save(array('is_user' => $is_user)); $this->response['access_disable_msg'] = contactsHelper::getAccessDisableMsg($contact); } } $has_backend_access_new = $this->hasBackendAccess($contact_id); if ($has_backend_access_new !== $has_backend_access_old) { if ($has_backend_access_new) { $this->logAction("grant_backend_access", null, $contact_id); } else { $this->logAction("revoke_backend_access", null, $contact_id); } } }
/** * @param bool|string $app_id - true for system version * @return string */ public function version($app_id = null) { if ($app_id === true) { $app_info = wa()->getAppInfo('webasyst'); return isset($app_info['version']) ? $app_info['version'] : '0.0.1'; } else { if ($this->version === null) { $app_info = wa()->getAppInfo($app_id); $this->version = isset($app_info['version']) ? $app_info['version'] : '0.0.1'; if (SystemConfig::isDebug()) { $this->version .= "." . time(); } else { $file = wa()->getAppPath('lib/config/build.php', $app_id); if (file_exists($file)) { $build = (include $file); $this->version .= '.' . $build; } } } return $this->version; } }
function smarty_block_wa_js($params, $content, &$smarty) { if (!$content) { return ''; } // jquery ui custom bundle $ui_custom = array('core' => 0, 'widget' => 0, 'mouse' => 0, 'draggable' => 0, 'droppable' => 0, 'sortable' => 0, 'datepicker' => 1); $files = explode("\n", $content); $wa = waSystem::getInstance(); $jquery_ui_path = "wa-content/js/jquery-ui/jquery.ui."; $jquery_ui_path_n = strlen($jquery_ui_path); $n = strlen($wa->getRootUrl()); $locale = $wa->getLocale(); // // Non-debug mode: merge all files into one cache // if (!SystemConfig::isDebug() && isset($params['file'])) { $root_path = $wa->getConfig()->getRootPath(); $app_path = $wa->getConfig()->getAppPath(); $result = ''; $files_combine = array(); $mtime = file_exists($app_path . '/' . $params['file']) ? filemtime($app_path . '/' . $params['file']) : 0; $r = true; foreach ($files as $f) { $f = trim($f); $f = substr($f, $n); if ($f) { if (substr($f, 0, $jquery_ui_path_n) == $jquery_ui_path) { $jquery_f = substr($f, $jquery_ui_path_n); if (substr($jquery_f, -7) == '.min.js') { $jquery_f = substr($jquery_f, 0, -7); } if (isset($ui_custom[$jquery_f])) { if (!$result) { $result = '<script type="text/javascript" src="' . $wa->getRootUrl() . 'wa-content/js/jquery-ui/jquery-ui.custom.min.js"></script>' . "\n"; } // include locale if ($ui_custom[$jquery_f] && $locale != 'en_US') { $result .= '<script type="text/javascript" src="' . $wa->getRootUrl() . 'wa-content/js/jquery-ui/i18n/jquery.ui.' . $jquery_f . '-' . $locale . '.js"></script>' . "\n"; } continue; } } if (!file_exists($f)) { $r = false; break; } $files_combine[] = $f; if ($mtime && filemtime($root_path . '/' . $f) > $mtime) { $mtime = 0; } } } if ($files_combine) { if ($r && !$mtime && waFiles::create($app_path . '/' . $params['file'])) { // check Google Closure Compiler // https://developers.google.com/closure/compiler/docs/gettingstarted_app if ($compiler = waSystemConfig::systemOption('js_compiler')) { $cmd = 'java -jar "' . $compiler . '"'; foreach ($files_combine as $file) { $cmd .= ' --js "' . $root_path . '/' . $file . '"'; } $cmd .= ' --js_output_file "' . $app_path . '/' . $params['file'] . '"'; system($cmd, $res); $r = !$res; if (!$r) { waLog::log("Error occured while compress files:\n\t" . implode("\n\t", $files_combine) . "\n\t{$params['file']}\n\ncommand:\n{$cmd}", __FUNCTION__ . '.log'); } } else { $r = false; } if (!$r) { $data = ""; foreach ($files_combine as $file) { $data .= file_get_contents($root_path . '/' . $file) . ";\n"; } $r = @file_put_contents($app_path . '/' . $params['file'], $data); if (!$r) { waLog::log("Error occured while compress files:\n\t" . implode("\n\t", $files_combine) . "\n\t{$params['file']}", __FUNCTION__ . '.log'); } } } } if ($r) { if ($files_combine) { $result .= '<script type="text/javascript" src="' . $wa->getAppStaticUrl() . $params['file'] . '?v' . $wa->getVersion() . '"></script>' . "\n"; } return $result; } } // // Debug mode (or no file specified): include all files separately // $result = ""; foreach ($files as $f) { $f = trim($f); if ($f) { // Add ?version to circumvent browser caching if (substr($f, $n, 10) !== 'wa-content') { $f .= '?v' . $wa->getVersion(); } $result .= '<script type="text/javascript" src="' . $f . '"></script>' . "\n"; // Add datepicker localization automatically // !!! This is not really a good idea since it will break in non-debug mode anyways if (substr($f, $n) == $jquery_ui_path . 'datepicker.min.js' && $locale != 'en_US') { $result .= '<script type="text/javascript" src="' . $wa->getRootUrl() . 'wa-content/js/jquery-ui/i18n/jquery.ui.datepicker-' . $locale . '.js"></script>' . "\n"; } } } return $result; }
<?php /** * Created by PhpStorm. * User: zhenghua.hao * Date: 15/3/31 * Time: 上午11:48 */ date_default_timezone_set('Asia/Shanghai'); if (empty($_SERVER['UNIQUE_ID'])) { $_SERVER['UNIQUE_ID'] = uniqid(); } require '../application/config/SystemConfig.php'; SystemConfig::init(); $app = new Yaf_Application(APPLICATION_PATH . '/config/application.ini'); $app->bootstrap()->run();
public static function getCustomUrl($tag, $secure = false) { return ($secure ? "https://" : "http://") . ($tag ? "{$tag}." : "") . SystemConfig::getInstance()->system['root_domain'] . "/"; }
/** * Checks basic requirements, includes basic files, creates global classes and starts Database-Connection */ function __construct($type = "io") { $this->type = $type; if (version_compare(PHP_VERSION, '5.3.0', 'le')) { $GLOBALS['fatal_error'] = "PHP 5.3.0 is minimum required!"; } if (!extension_loaded("imagick")) { $GLOBALS['fatal_error'] = "Extension \"Imagick\" is missing!"; } if (!extension_loaded("mbstring")) { $GLOBALS['fatal_error'] = "Extension \"mbstring\" is missing!"; } if (!extension_loaded("gd")) { $GLOBALS['fatal_error'] = "Extension \"GD\" is missing!"; } if (!file_exists(constant("BASE_DIR")) or !file_exists(constant("WWW_DIR"))) { $GLOBALS['fatal_error'] = "main-folder not found, check \$server['main_folder'] in config!"; } if (!isset($GLOBALS['fatal_error'])) { global $db, $runtime_data, $transaction; require_once "core/db/db.php"; $database = SystemConfig::get_database(); $db = new Database($database['type']); @($connection_result = $db->db_connect($database[0]['server'], $database[0]['port'], $database['user'], $database['password'], $database['database'])); require_once "include/base/system/error_handler.php"; // set_error_handler('error_handler'); require_once "include/base/system/events/event.class.php"; require_once "include/base/system/events/delete_event.class.php"; require_once "include/base/system/system_handler.class.php"; require_once "include/base/system/autoload.function.php"; if ($connection_result == true) { if (SystemHandler::check_installation() == false) { $GLOBALS['fatal_error'] = "Installation Not Found! Install Database first."; } else { SystemConfig::load_module_config(); require_once "include/base/system/transaction.class.php"; $transaction = new Transaction(); require_once "include/base/security/security.class.php"; require_once "include/base/security/session.class.php"; require_once "include/base/system/runtime_data.class.php"; require_once "include/base/system_fe/system_log.class.php"; $runtime_data = new RuntimeData(); try { if ($type == "io") { $system_handler = new SystemHandler(true); } else { $system_handler = new SystemHandler(false); } } catch (BaseIncludeDataCorruptException $e) { $GLOBALS['fatal_error'] = "The config-data of a module is corrupt!"; } catch (BaseIncludeProcessFailedException $e) { $GLOBALS['fatal_error'] = "Include register process failed!"; } catch (BaseIncludeRequirementFailedException $e) { $GLOBALS['fatal_error'] = "An include-module requirement is not found!"; } catch (BaseIncludeFolderEmptyException $e) { $GLOBALS['fatal_error'] = "Include folder is empty!"; } catch (BaseModuleProcessFailedException $e) { $GLOBALS['fatal_error'] = "Module register process failed!"; } catch (BaseModuleDataCorruptException $e) { $GLOBALS['fatal_error'] = "Module Data Corrupt!"; } catch (BaseEventHandlerCreationFailedException $e) { $GLOBALS['fatal_error'] = "Event-handler creation failed!"; } Security::protect_session(); } } else { $GLOBALS['fatal_error'] = "Database-Connection failed!"; } } }
$_SESSION["session_lang"] = $_GET['lang']; } // Database initialisation if (OOO_USEDB) { include_once OOO_LIB . '/adodb/adodb.inc.php'; $DB =& ADONewConnection(DB_TYPE); $result = $DB->Connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME); if (!$result) { echo 'Initialise: Cannot connect to database. Check database configuration. Application stopped.'; // TODO: isolate message to language file exit; } $DB->debug = OOO_DEBUG ? true : false; // get system configuration from db include_once OOO_CORE . '/SystemConfig.php'; $systemconfig = new SystemConfig(); $config['theme'] = $systemconfig->getThemesByDB($DB); $config['lang'] = $systemconfig->getLangByDB($DB, $_SESSION["session_lang"]); include_once OOO_CORE . '/Config.php'; include_once OOO_CORE . '/gui/SmartyUtil.php'; $smartyutil = new SmartyUtil(); $configobject = new Config($DB); $arr_data = $configobject->selectAllConfig(); $arr_config = $smartyutil->toSmartyArray($arr_data, 'config_value', 'config_name'); } // configuration of phpgacl if (OOO_USEGACL) { $gacl_options = array('items_per_page' => 100, 'max_select_box_items' => 100, 'max_search_return_items' => 200, 'db_type' => DB_TYPE, 'db_host' => DB_SERVER, 'db_user' => DB_USERNAME, 'db_password' => DB_PASSWORD, 'db_name' => DB_NAME, 'db_table_prefix' => 'ooo_', 'caching' => FALSE, 'force_cache_expire' => TRUE, 'cache_dir' => '/tmp/phpgacl_cache', 'cache_expire_time' => 600); $gacl_options['debug'] = OOO_DEBUG ? true : false; } // Language data file
public function version() { $this->init(); if ($this->_version === null) { $this->_version = !empty($this->info['version']) ? $this->info['version'] : '0.0.1'; if (SystemConfig::isDebug()) { $this->_version .= "." . time(); } else { $file = $this->path . '/build.php'; if (file_exists($file)) { $build = (include $file); $this->_version .= '.' . $build; } } } return $this->_version; }
public function testGetInitialConfig() { $initialConfig = ['foo' => 'bar', 'bat' => 'baz']; $config = new SystemConfig($initialConfig); $this->assertTrue(empty(array_diff($initialConfig, $config->getInitialConfig()))); }
private function shouldDeferDistanceInfo() { return !!\SystemConfig::getInstance()->service['defer_distance_info']; }
/** * Trigger event with given $name from current active application. * * @param string $name Event name. * @param mixed $params Parameters passed to event handlers. * @param string[] $array_keys Array of expected template items for UI events. * @return array app_id or plugin_id => data returned from handler (unless null is returned) */ public function event($name, &$params = null, $array_keys = null) { $result = array(); if (is_array($name)) { $event_app_id = $name[0]; $event_system = self::getInstance($event_app_id); $name = $name[1]; } else { $event_app_id = $this->getConfig()->getApplication(); $event_system = $this; } $event_prefix = wa($event_app_id)->getConfig()->getPrefix(); if (!isset(self::$handlers['apps'])) { self::$handlers['apps'] = array(); $cache_file = $this->config->getPath('cache', 'config/handlers'); if (!waSystemConfig::isDebug() && file_exists($cache_file)) { self::$handlers['apps'] = (include $cache_file); } if (!self::$handlers['apps'] || !is_array(self::$handlers['apps'])) { $apps = $this->getApps(); $path = $this->getConfig()->getPath('apps'); foreach ($apps as $app_id => $app_info) { $files = waFiles::listdir($path . '/' . $app_id . '/lib/handlers/'); foreach ($files as $file) { if (substr($file, -12) == '.handler.php') { $file = explode('.', substr($file, 0, -12), 2); self::$handlers['apps'][$file[0]][$file[1]][] = $app_id; } } } if (!waSystemConfig::isDebug()) { waUtils::varExportToFile(self::$handlers['apps'], $cache_file); } } } if (!isset(self::$handlers['plugins'][$event_app_id])) { self::$handlers['plugins'][$event_app_id] = array(); $plugins = $event_system->getConfig()->getPlugins(); foreach ($plugins as $plugin_id => $plugin) { if (!empty($plugin['handlers'])) { foreach ($plugin['handlers'] as $handler_event => $handler_method) { self::$handlers['plugins'][$event_app_id][$handler_event][$plugin_id] = $handler_method; } } } } if (isset(self::$handlers['apps'][$event_app_id][$name])) { $path = $this->getConfig()->getPath('apps'); foreach (self::$handlers['apps'][$event_app_id][$name] as $app_id) { $file_path = $path . '/' . $app_id . '/lib/handlers/' . $event_prefix . "." . $name . ".handler.php"; if (!file_exists($file_path)) { continue; } wa($app_id); include_once $file_path; $class_name = $name; if (strpos($name, '.') !== false) { $class_name = strtok($class_name, '.') . ucfirst(strtok('')); } $class_name = $app_id . ucfirst($event_prefix) . ucfirst($class_name) . "Handler"; /** * @var $handler waEventHandler */ $handler = new $class_name(); try { $r = $handler->execute($params); if ($r !== null) { $result[$app_id] = $r; } } catch (Exception $e) { waLog::log('Event handling error in ' . $file_path . ': ' . $e->getMessage()); } } } if (isset(self::$handlers['plugins'][$event_app_id][$name])) { $plugins = $event_system->getConfig()->getPlugins(); foreach (self::$handlers['plugins'][$event_app_id][$name] as $plugin_id => $method) { if (!isset($plugins[$plugin_id])) { continue; } $plugin = $plugins[$plugin_id]; self::pushActivePlugin($plugin_id, $event_prefix); $class_name = $event_app_id . ucfirst($plugin_id) . 'Plugin'; try { $class = new $class_name($plugin); // Load plugin locale if it exists $locale_path = $this->getAppPath('plugins/' . $plugin_id . '/locale', $event_app_id); if (is_dir($locale_path)) { waLocale::load($this->getLocale(), $locale_path, self::getActiveLocaleDomain(), false); } if (method_exists($class, $method) && null !== ($r = $class->{$method}($params))) { if ($array_keys && is_array($r)) { foreach ($array_keys as $k) { if (!isset($r[$k])) { $r[$k] = ''; } } } $result[$plugin_id . '-plugin'] = $r; } } catch (Exception $e) { waLog::log('Event handling error in ' . $class_name . '->' . $name . '(): ' . $e->getMessage()); } self::popActivePlugin(); } } return $result; }
public function getRootUrl($absolute = false, $script = false) { return $this->config->getRootUrl($absolute, $script); }
public function isUsingPhysicalDistance() { return !!\SystemConfig::getInstance()->service['physical_distance']; }
/** * Returns information about all app's installed plugins as an associative array. * * @return array */ public function getPlugins() { if ($this->plugins === null) { $locale = wa()->getLocale(); $file = waConfig::get('wa_path_cache') . "/apps/" . $this->application . '/config/plugins.' . $locale . '.php'; if (!file_exists($file) || SystemConfig::isDebug()) { waFiles::create(waConfig::get('wa_path_cache') . "/apps/" . $this->application . '/config'); // read plugins from file wa-config/[APP_ID]/plugins.php $path = $this->getConfigPath('plugins.php', true); if (!file_exists($path)) { $this->plugins = array(); return $this->plugins; } $all_plugins = (include $path); $this->plugins = array(); foreach ($all_plugins as $plugin_id => $enabled) { if ($enabled) { $plugin_config = $this->getPluginPath($plugin_id) . "/lib/config/plugin.php"; if (!file_exists($plugin_config)) { continue; } $plugin_info = (include $plugin_config); waSystem::pushActivePlugin($plugin_id, $this->application); // Load plugin locale if it exists $locale_path = wa()->getAppPath('plugins/' . $plugin_id . '/locale', $this->application); if (is_dir($locale_path)) { waLocale::load($locale, $locale_path, wa()->getActiveLocaleDomain(), false); } $plugin_info['name'] = _wp($plugin_info['name']); if (isset($plugin_info['title'])) { $plugin_info['title'] = _wp($plugin_info['title']); } if (isset($plugin_info['description'])) { $plugin_info['description'] = _wp($plugin_info['description']); } waSystem::popActivePlugin(); $plugin_info['id'] = $plugin_id; $plugin_info['app_id'] = $this->application; if (isset($plugin_info['img'])) { $plugin_info['img'] = 'wa-apps/' . $this->application . '/plugins/' . $plugin_id . '/' . $plugin_info['img']; } if (isset($plugin_info['rights']) && $plugin_info['rights']) { $plugin_info['handlers']['rights.config'] = 'rightsConfig'; } if (isset($plugin_info['frontend']) && $plugin_info['frontend']) { $plugin_info['handlers']['routing'] = 'routing'; } if (!empty($plugin_info[$this->application . '_settings'])) { $plugin_info['custom_settings'] = $plugin_info[$this->application . '_settings']; } $this->plugins[$plugin_id] = $plugin_info; } } if (!SystemConfig::isDebug()) { waUtils::varExportToFile($this->plugins, $file); } else { waFiles::delete($file); } } else { $this->plugins = (include $file); } } return $this->plugins; }
public function version($edition = false) { static $build; $this->init(); if ($this->_version === null || $edition) { $this->_version = !empty($this->info['version']) ? $this->info['version'] : '0.0.1'; if (SystemConfig::isDebug()) { $this->_version .= "." . time(); } else { if ($edition === true) { $edition = $this->edition; } if ($build === null) { $file = $this->path . '/build.php'; if (file_exists($file)) { $build = (include $file); } else { $build = 0; } } if ($build) { if ($edition) { $build += $edition; return $this->_version . '.' . $build; } $this->_version .= '.' . $build; } elseif ($edition) { return $this->_version . '.' . $edition; } } } return $this->_version; }
* Available at http://www.open-lims.org * * This program is free software; * you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; * version 3 of the License. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program; * if not, see <http://www.gnu.org/licenses/>. */ /** * */ set_time_limit(0); header("Content-Type: text/html; charset=utf-8"); define("UNIT_TEST", false); require_once "config/version.php"; require_once "core/include/base/system/system_config.class.php"; SystemConfig::load_system_config("config/main.php"); date_default_timezone_set($server['timezone']); require_once "core/include/base/system/template.class.php"; require_once "core/include/base/system/html_template.class.php"; require_once "core/include/base/system/js_template.class.php"; Template::set_fallback_folder("xhtml"); Template::set_current_folder("xhtml"); require_once "core/main.php"; $main = new Main(); $main->init();
public static function revokeUser($id) { // wa_contact $user = new waContact($id); $user['is_user'] = 0; $user['login'] = null; $user['password'] = ''; $user->save(); // user groups $ugm = new waUserGroupsModel(); $ugm->delete($id); // Access rigths $right_model = new waContactRightsModel(); $right_model->deleteByField('group_id', -$id); // Custom application access rigths foreach (wa()->getApps() as $aid => $app) { if (isset($app['rights']) && $app['rights']) { $app_config = SystemConfig::getAppConfig($aid); $class_name = $app_config->getPrefix() . "RightConfig"; $file_path = $app_config->getAppPath('lib/config/' . $class_name . ".class.php"); $right_config = null; if (!file_exists($file_path)) { continue; } waSystem::getInstance($aid, $app_config); include_once $file_path; /** * @var waRightConfig $right_config */ $right_config = new $class_name(); $right_config->clearRights($id); } } }
private function create() { $this->instance = new \Redis(); // TODO allow configuring a RedisArray, see https://github.com/nicolasff/phpredis/blob/master/arrays.markdown#redis-arrays $config = $this->config->getValue('redis', array()); if (isset($config['host'])) { $host = $config['host']; } else { $host = '127.0.0.1'; } if (isset($config['port'])) { $port = $config['port']; } else { $port = 6379; } if (isset($config['timeout'])) { $timeout = $config['timeout']; } else { $timeout = 0.0; // unlimited } $this->instance->connect($host, $port, $timeout); if (isset($config['password']) && $config['password'] !== '') { $this->instance->auth($config['password']); } if (isset($config['dbindex'])) { $this->instance->select($config['dbindex']); } }