本文整理汇总了PHP中Basic::setConstant方法的典型用法代码示例。如果您正苦于以下问题:PHP Basic::setConstant方法的具体用法?PHP Basic::setConstant怎么用?PHP Basic::setConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basic
的用法示例。
在下文中一共展示了Basic::setConstant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parsIni
/**
Parses the configuration file.
@param string $filename Path to the configuration file.
@return null.
**/
public static function parsIni($filename)
{
if (empty($filename) || !file_exists($filename)) {
return "Configuration not found";
}
$config = parse_ini_file($filename, true);
Basic::setConstant("DEFAULT_SOCKET_TIMEOUT", Basic::getConfigKey($config, 'general', 'socketTimeout'), 10);
$phpCommand = Basic::getConfigKey($config, 'general', 'phpCommand');
if (!empty($phpCommand)) {
static::$phpCommand = $phpCommand;
}
$disablePanelTitle = Basic::getConfigKey($config, 'general', 'disablePanelTitle');
if (!empty($disablePanelTitle)) {
static::$disablePanelTitle = $disablePanelTitle;
}
Basic::setConstant("TMP_FOLDER", Basic::getConfigKey($config, 'general', 'tmpFolder'), sys_get_temp_dir());
Basic::setConstant("SPECIAL_CHAR", Basic::getConfigKey($config, 'general', 'specialChar'), "&");
Basic::setConstant("DATABASE_TYPE", strtolower(Basic::getConfigKey($config, 'general', 'databaseType')), "influxdb");
Basic::setConstant("FORECAST_DATASOURCE_NAME", strtolower(Basic::getConfigKey($config, 'general', 'forecastDatasourceName')), "nagflux_forecast");
Basic::setConstant("URL", Basic::getConfigKey($config, DATABASE_TYPE, 'url'), "http://127.0.0.1:8086/query?db=nagflux");
define('INFLUXDB', 'influxdb');
define('ELASTICSEARCH', 'elasticsearch');
if (DATABASE_TYPE == INFLUXDB && preg_match(";db=(\\w*);", URL, $matches)) {
define('INFLUXDB_DB', $matches[1]);
} elseif (DATABASE_TYPE == ELASTICSEARCH) {
$path = parse_url(URL, PHP_URL_PATH);
if ($path) {
define('ELASTICSEARCH_INDEX', ltrim($path, '/'));
}
}
Basic::setConstant("HOSTCHECK_ALIAS", Basic::getConfigKey($config, DATABASE_TYPE, 'hostcheckAlias'), "hostcheck");
Basic::setConstant("DEFAULT_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'defaultTemplateFolder'), "histou/templates/default/");
Basic::setConstant("CUSTOM_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'customTemplateFolder'), "histou/templates/custom/");
Basic::setConstant("FORECAST_TEMPLATE_FOLDER", Basic::getConfigKey($config, 'folder', 'forecastTemplateFolder'), "histou/forecasts/");
}