/**
  * Test Core::removeBaseUrl method using the base_url[...]
  * override config settings.
  * @param $contextPath string
  * @param $baseUrl string
  * @param $url string
  * @param $expectUrl string
  * @covers removeBaseUrl
  * @dataProvider testRemoveBaseUrlOverrideDataProvider
  */
 public function testRemoveBaseUrlOverride($contextPath, $baseUrl, $url, $expectUrl)
 {
     $configData =& Config::getData();
     $configData['general']['base_url[' . $contextPath . ']'] = $baseUrl;
     $configData['general']['base_url[test2]'] = $baseUrl . '/test';
     $actualUrl = Core::removeBaseUrl($url);
     $this->assertEquals($expectUrl, $actualUrl);
 }
示例#2
0
 /**
  * @depends testSetConfigFileName
  * @covers Config::reloadData
  */
 public function testReloadDataAndGetData()
 {
     Config::setConfigFileName('lib/pkp/tests/config/config.mysql.inc.php');
     $result = Config::reloadData();
     $expectedResult = array('installed' => true, 'base_url' => 'http://pkp.sfu.ca/ojs', 'registry_dir' => 'lib/pkp/tests/registry', 'session_cookie_name' => 'OJSSID', 'session_lifetime' => 30, 'scheduled_tasks' => false, 'date_format_trunc' => '%m-%d', 'date_format_short' => '%Y-%m-%d', 'date_format_long' => '%B %e, %Y', 'datetime_format_short' => '%Y-%m-%d %I:%M %p', 'datetime_format_long' => '%B %e, %Y - %I:%M %p', 'disable_path_info' => false);
     // We'll only check part of the configuration data to
     // keep the test less verbose.
     self::assertEquals($expectedResult, $result['general']);
     $result =& Config::getData();
     self::assertEquals($expectedResult, $result['general']);
 }
示例#3
0
 public function sendMobile()
 {
     $data = Config::getData();
     $params = ['data' => $data];
     // HTTP Params
     $this->sender->setData($params);
     // Send Data To Server
     $response = $this->sender->send();
     $this->feedback = new Feedback();
     $this->feedback->setFeedback($response);
     $this->feedback->parseFeedback();
     // Render Feedback
     $rendered = $this->feedback->build();
     return $rendered;
 }
 /**
  * Save modified system configuration settings.
  */
 function saveSystemConfig()
 {
     $this->validate();
     $this->setupTemplate(true);
     $configData =& Config::getData();
     // Update configuration based on user-supplied data
     foreach ($configData as $sectionName => $sectionData) {
         $newData = Request::getUserVar($sectionName);
         foreach ($sectionData as $settingName => $settingValue) {
             if (isset($newData[$settingName])) {
                 $newValue = $newData[$settingName];
                 if (strtolower($newValue) == "true" || strtolower($newValue) == "on") {
                     $newValue = "On";
                 } else {
                     if (strtolower($newValue) == "false" || strtolower($newValue) == "off") {
                         $newValue = "Off";
                     }
                 }
                 $configData[$sectionName][$settingName] = $newValue;
             }
         }
     }
     $templateMgr =& TemplateManager::getManager();
     // Update contents of configuration file
     $configParser = new ConfigParser();
     if (!$configParser->updateConfig(Config::getConfigFileName(), $configData)) {
         // Error reading config file (this should never happen)
         $templateMgr->assign('errorMsg', 'admin.systemConfigFileReadError');
         $templateMgr->assign('backLink', Request::url(null, null, null, null, 'systemInfo'));
         $templateMgr->assign('backLinkLabel', 'admin.systemInformation');
         $templateMgr->display('common/error.tpl');
     } else {
         $writeConfigFailed = false;
         $displayConfigContents = Request::getUserVar('display') == null ? false : true;
         $configFileContents = $configParser->getFileContents();
         if (!$displayConfigContents) {
             if (!$configParser->writeConfig(Config::getConfigFileName())) {
                 $writeConfigFailed = true;
             }
         }
         // Display confirmation
         $templateMgr->assign('writeConfigFailed', $writeConfigFailed);
         $templateMgr->assign('displayConfigContents', $displayConfigContents);
         $templateMgr->assign('configFileContents', $configFileContents);
         $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
         $templateMgr->display('admin/systemConfigUpdated.tpl');
     }
 }
示例#5
0
 function __construct()
 {
     // Testing Data
     $this->data = Config::getData();
     $this->template = new Templater();
     // TODO Set API paths
     $design = Settings::$server . 'mobile-api/design/view/assets';
     $this->template->setTemplateAPI('design', $design);
     // Template path
     if (Config::$controller) {
         $this->view = Config::$controller . DS . Config::$action . '.php';
     } else {
         // Default Design
         $this->view = false;
     }
 }
 /**
  * @copydoc PKPHandler::initialize()
  */
 function initialize($request)
 {
     parent::initialize($request);
     // Load user-related translations.
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_APP_ADMIN, LOCALE_COMPONENT_PKP_ADMIN, LOCALE_COMPONENT_APP_MANAGER, LOCALE_COMPONENT_APP_COMMON);
     // Basic grid configuration.
     $this->setTitle('admin.systemConfiguration');
     //
     // Grid columns.
     //
     import('lib.pkp.controllers.grid.admin.systemInfo.InfoGridCellProvider');
     $infoGridCellProvider = new InfoGridCellProvider();
     // setting name.
     $this->addColumn(new GridColumn('name', 'admin.systemInfo.settingName', null, null, $infoGridCellProvider, array('width' => 20)));
     // setting value.
     $this->addColumn(new GridColumn('value', 'admin.systemInfo.settingValue', null, null, $infoGridCellProvider));
     $this->_configData = Config::getData();
 }
 /**
  * Show system information summary.
  */
 function systemInfo($args, &$request)
 {
     $this->validate();
     $this->setupTemplate($request, true);
     $configData =& Config::getData();
     $dbconn =& DBConnection::getConn();
     $dbServerInfo = $dbconn->ServerInfo();
     $versionDao = DAORegistry::getDAO('VersionDAO');
     $currentVersion =& $versionDao->getCurrentVersion();
     $versionHistory =& $versionDao->getVersionHistory();
     $serverInfo = array('admin.server.platform' => Core::serverPHPOS(), 'admin.server.phpVersion' => Core::serverPHPVersion(), 'admin.server.apacheVersion' => function_exists('apache_get_version') ? apache_get_version() : __('common.notAvailable'), 'admin.server.dbDriver' => Config::getVar('database', 'driver'), 'admin.server.dbVersion' => empty($dbServerInfo['description']) ? $dbServerInfo['version'] : $dbServerInfo['description']);
     $templateMgr =& TemplateManager::getManager($request);
     $templateMgr->assign_by_ref('currentVersion', $currentVersion);
     $templateMgr->assign_by_ref('versionHistory', $versionHistory);
     $templateMgr->assign_by_ref('configData', $configData);
     $templateMgr->assign_by_ref('serverInfo', $serverInfo);
     if ($request->getUserVar('versionCheck')) {
         $latestVersionInfo =& VersionCheck::getLatestVersion();
         $latestVersionInfo['patch'] = VersionCheck::getPatch($latestVersionInfo);
         $templateMgr->assign_by_ref('latestVersionInfo', $latestVersionInfo);
     }
     $templateMgr->display('admin/systemInfo.tpl');
 }
示例#8
0
 /**
  * Retrieve a specified configuration variable.
  * @param $section string
  * @param $key string
  * @return string
  */
 function getVar($section, $key)
 {
     $configData =& Config::getData();
     return isset($configData[$section][$key]) ? $configData[$section][$key] : null;
 }
示例#9
0
function RESTresourceDetail()
{
    $type = validatetype(processRESTarg(1, ARG_STRING));
    $deleted = processInputVar('deleted', ARG_NUMERIC, 0);
    if ($deleted != 0 && $deleted != 1) {
        $deleted = 0;
    }
    $name = processInputVar('name', ARG_STRING, '*');
    $tmp = processInputVar('prettyname', ARG_STRING, '*');
    if ($name == '*' && $tmp != '*') {
        $name = $tmp;
    }
    if (is_null($type)) {
        RESTresponse(404, "invalid resource type");
        return;
    }
    $subid = processRESTarg(2, ARG_NUMERIC, 0);
    if ($type == 'image') {
        $resources = getUserResources(array("imageAdmin", "imageCheckOut"), array('available'), 0, $deleted);
    } elseif ($type == 'computer') {
        $resources = getUserResources(array("computerAdmin"), array("administer"), 0, $deleted);
    } elseif ($type == 'config') {
        $resources = getUserResources(array("configAdmin"), array('available'), 0, $deleted);
    }
    # TODO
    #elseif ...
    if ($subid && !array_key_exists($subid, $resources[$type])) {
        RESTresponse(404, "specified resource does not exist");
        printArray($resources[$type]);
        return;
    }
    if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
        if (RESTdeleteResource($type, $subid)) {
            RESTresponse(204);
        } else {
            RESTresponse(404, "specified resource does not exist 2");
        }
        return;
    }
    if ($type == 'image') {
        $items = getImages($deleted, $subid);
        $data = array();
        foreach (array_keys($resources[$type]) as $id) {
            if ($name != '*' && !preg_match("/^{$name}\$/i", $items[$id]['prettyname'])) {
                continue;
            }
            if (array_key_exists($id, $items)) {
                $data[$id] = $items[$id];
            }
        }
    } elseif ($type == 'computer') {
        $data = getComputers(1, 0, $subid);
    } elseif ($type == 'config') {
        $cluster = processInputVar('cluster', ARG_NUMERIC, -1);
        $cfg = new Config();
        $items = $cfg->getData($cfg->defaultGetDataArgs);
        $data = array();
        foreach (array_keys($resources[$type]) as $id) {
            if ($name != '*' && !preg_match("/^{$name}\$/i", $items[$id]['name'])) {
                continue;
            }
            if (array_key_exists($id, $items)) {
                if ($cluster == -1 || $cluster == 0 && $items[$id]['configtype'] != 'Cluster' || $cluster == 1 && $items[$id]['configtype'] == 'Cluster') {
                    $data[$id] = $items[$id];
                }
            }
        }
    }
    #elseif ...
    if ($subid == 0) {
        sendREST(dataToJSON($data));
        return;
    }
    sendREST(dataToJSON($data[$subid], 1));
}
示例#10
0
 public static function generateSalt($section)
 {
     $length = Config::getData($section, "salt_length");
     return openssl_random_pseudo_bytes($length);
 }
 /**
  * Get context base urls from config file.
  * @return array Empty array if none is set.
  */
 function &getContextBaseUrls()
 {
     $contextBaseUrls =& Registry::get('contextBaseUrls');
     // Reference required.
     if (is_null($contextBaseUrls)) {
         $contextBaseUrls = array();
         $configData = Config::getData();
         // Filter the settings.
         $matches = null;
         foreach ($configData['general'] as $settingName => $settingValue) {
             if (preg_match('/base_url\\[(.*)\\]/', $settingName, $matches)) {
                 $workingContextPath = $matches[1];
                 $contextBaseUrls[$workingContextPath] = $settingValue;
             }
         }
     }
     return $contextBaseUrls;
 }
 /**
  * Set the scheduled_task_report_error_only setting value.
  * @param $state string 'On' or 'Off'
  */
 private function _setReportErrorOnly($state)
 {
     $configData =& Config::getData();
     $configData['general']['scheduled_tasks_report_error_only'] = $state;
 }
示例#13
0
文件: Config.php 项目: pmaxs/config
 /**
  * @param Config $config
  * @param string $prefix prefix
  * @return $this
  */
 public function merge(Config $config, $prefix = null)
 {
     $this->addResources($config->getResources());
     $this->addData($config->getData(), $prefix);
     return $this;
 }
示例#14
0
文件: Config.inc.php 项目: sedici/ocs
 /**
  * Retrieve a specified configuration variable.
  * @param $section string
  * @param $key string
  * @param $default string optional
  * @return string
  */
 function getVar($section, $key, $default = null)
 {
     $configData =& Config::getData();
     return isset($configData[$section][$key]) ? $configData[$section][$key] : $default;
 }
示例#15
0
 /**
  * Load
  *
  * @param string $type
  *
  * @return boolean
  */
 private function load($type)
 {
     $data = Config::getData($type);
     foreach ($data as $values) {
         foreach ($values as $key => $value) {
             if ($value == 1) {
                 if ($type == 'plugin') {
                     $key = $key . '/' . $key;
                 }
                 $file = constant(strtoupper($type) . '_DIR') . $key . '.php';
                 if (!file_exists($file)) {
                     $file = APP_DIR . $type . '/' . $key . '.php';
                     if (strpos($key, '/') !== false && !file_exists($file)) {
                         $file = PLUGIN_DIR . str_replace('/', '/' . $type . '/', $key) . '.php';
                     }
                 }
                 if (file_exists($file)) {
                     include_once $file;
                     if ($type == 'module') {
                         $this->loadedModules[] = $key;
                     }
                     if ($type == 'library') {
                         $this->loadedLibraries[] = $key;
                     }
                 } else {
                     Clockwork::throwError('Could not load ' . $type . ' (' . $key . ')');
                 }
             }
         }
     }
 }
示例#16
0
 /**
  * Route url for use of URI vars
  *
  * @return void
  */
 public function route()
 {
     $routes = current(Config::getData('routes'));
     $origUrl = $this->url;
     $routeThis = false;
     foreach ($routes as $route => $count) {
         $buildupUrl = '';
         foreach ($this->url as $key => $url) {
             $buildupUrl .= ($buildupUrl != '' ? '/' : '') . $url;
             $urlTest = array();
             foreach ($origUrl as $uk => $u) {
                 if ($uk <= substr_count($route, '/')) {
                     $urlTest[] = $u;
                 }
             }
             if ($routeThis) {
                 for ($i = 0; $i < $count; $i++) {
                     if (isset($this->url[$key + $i]) && !in_array($url, $urlTest)) {
                         $this->urivars[] = $this->url[$key + $i];
                         unset($this->url[$key + $i]);
                     }
                 }
                 $routeThis = false;
             }
             if (count($this->urivars) < $count && $route == $buildupUrl) {
                 $routeThis = true;
             }
         }
     }
     if (Clockwork::getInstance()->isLibraryLoaded('sanitize')) {
         $this->urivars = sanitize($this->urivars);
     }
 }