本文整理汇总了PHP中parse_ini_file函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_ini_file函数的具体用法?PHP parse_ini_file怎么用?PHP parse_ini_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_ini_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSwarmUAIndex
/** @return object */
public static function getSwarmUAIndex()
{
// Lazy-init and cache
if (self::$swarmUaIndex === null) {
global $swarmInstallDir;
// Convert from array with string values
// to an object with boolean values
$swarmUaIndex = new stdClass();
$rawIndex = parse_ini_file("{$swarmInstallDir}/config/useragents.ini", true);
foreach ($rawIndex as $uaID => $uaItem) {
if (is_array($uaItem)) {
$uaItem2 = $uaItem;
foreach ($uaItem2 as $uaDataKey => $uaDataVal) {
if ($uaDataKey !== "displaytitle" && $uaDataKey !== "displayicon") {
$uaItem[$uaDataKey] = (bool) trim($uaDataVal);
} else {
$uaItem[$uaDataKey] = trim($uaDataVal);
}
}
if (!isset($uaItem["displaytitle"]) || !$uaItem["displaytitle"]) {
throw new SwarmException("User agent `{$uaID}` is missing a displaytitle property.");
}
if (!isset($uaItem["displayicon"]) || !$uaItem["displayicon"]) {
throw new SwarmException("User agent `{$uaID}` is missing a displayicon property.");
}
$swarmUaIndex->{$uaID} = (object) $uaItem;
}
}
self::$swarmUaIndex = $swarmUaIndex;
}
return self::$swarmUaIndex;
}
示例2: getConfigFile
/**
* @param KDLFlavor $target
* @return string configuration to be saved as file
*/
public function getConfigFile(KDLFlavor $target)
{
$configIni = parse_ini_file(PDFCREATOR_CONFIG_TEMPLATE);
if (!$configIni) {
throw new Exception('Cannot parse template configurations files [' . PDFCREATOR_CONFIG_TEMPLATE . ']');
}
// set up output format and filename
$configIni['AutosaveFormat'] = '0';
//PDF format
$configIni['UseAutosave'] = '1';
$configIni['UseAutosaveDirectory'] = '1';
$configIni['AutosaveDirectory'] = KDLCmdlinePlaceholders::OutDir;
$configIni['AutosaveFilename'] = KDLCmdlinePlaceholders::OutFileName;
// pdf parameters from flavor params
if ($target->_pdf->_resolution) {
$configIni['PDFGeneralResolution'] = $target->_pdf->_resolution;
}
if ($target->_pdf->_paperHeight) {
$configIni['UseFixPapersize'] = '0';
$configIni['UseCustomPaperSize'] = '1';
$configIni['DeviceHeightPoints'] = $target->_pdf->_paperHeight;
}
if ($target->_pdf->_paperWidth) {
$configIni['UseFixPapersize'] = '0';
$configIni['UseCustomPaperSize'] = '1';
$configIni['DeviceWidthPoints'] = $target->_pdf->_paperWidth;
}
$configStr = '[Options]' . PHP_EOL;
foreach ($configIni as $key => $value) {
$configStr .= $key . '=' . $value . PHP_EOL;
}
return $configStr;
}
示例3: addConfigFromIni
/**
* Add Configuration from configuration.ini files
*
* @param string $fileName
* @return $this
*/
public function addConfigFromIni($fileName)
{
if ($configs = parse_ini_file($fileName)) {
$this->addConfigs($configs);
}
return $this;
}
示例4: parse
/**
* {@inheritdoc}
*/
public function parse()
{
if ($array = parse_ini_file($this->file, true)) {
return is_null($this->key) ? $array : [$this->key => $array];
}
throw new Exception\ParseException(sprintf('The file (%s) has syntax errors', $this->file));
}
示例5: parseIniFile
private function parseIniFile()
{
$settings = array();
$settingStack = array();
$open_basedir_restriction = ini_get('open_basedir');
if (empty($open_basedir_restriction)) {
$settingStack[] = '/etc/dbc.ini';
$settingStack[] = '/usr/local/etc/dbc.ini';
if (function_exists("posix_getpwuid") && function_exists("posix_getuid")) {
$userData = posix_getpwuid(posix_getuid());
$settingStack[] = $userData['dir'] . '/.dbc.ini';
}
}
$settingStack[] = dirname(__FILE__) . '/../dbc.ini';
$settingStack[] = getcwd() . '/dbc.ini';
foreach ($settingStack as $settingsFile) {
if (is_readable($settingsFile)) {
$settings = array_merge(parse_ini_file($settingsFile, true), $settings);
}
}
//merge with default settings
$settings = array_merge($this->settingsData, $settings);
if (empty($settings)) {
throw new Exception('No settings file found. Aborting.');
}
if (!isset($settings['dbConn:standard'])) {
throw new Exception('Mandatory "dbConn:standard" is missing in settings file. Aborting.');
}
$this->settingsData = $this->parseValues($settings);
}
示例6: bindTextDomain
public function bindTextDomain($domain, $path = '')
{
$file = $path . '/' . getenv('LANG') . '/LC_MESSAGES/' . $domain . '.ini';
if (file_exists($file)) {
$this->translations = parse_ini_file($file);
}
}
示例7: getLangaugeWord
/**
* Get the words from each language
* @return array
*/
public function getLangaugeWord()
{
$langPath = $this->_config->getLanguageFolder();
$root = PathService::getRootDir();
$absLangPath = $root . DIRECTORY_SEPARATOR . $langPath;
$ignore = array('.', '..', '.svn', '.DS_Store');
$langArray = array();
if ($handle = opendir($absLangPath)) {
while (false !== ($file = readdir($handle))) {
$absFile = $absLangPath . DIRECTORY_SEPARATOR . $file;
$tLangArr = array();
if (!in_array($file, $ignore) && !is_dir($absFile)) {
try {
if (($tLangArr = @parse_ini_file($absFile, true)) == false) {
throw new Exception('Cannot Parse INI file: ' . $absFile);
}
} catch (Exception $e) {
error_log($e->getMessage());
}
$langArray = array_merge($langArray, $tLangArr);
}
}
}
return $langArray;
}
示例8: readIni
function readIni(&$config, $path)
{
$ret = array();
$this->path = $path;
# try and read the ini file
if (($ret = @parse_ini_file("{$path}/module.ini")) === false) {
$config->errors[] = "Fatal module error: Module ini \"{$path}/module.ini\" is not readable.";
return false;
}
# extract the required info
if (!isset($ret['name'])) {
$config->errors[] = "Fatal module error: Module ini does not contain a name field.";
return false;
}
if (!isset($ret['compatible'])) {
$config->errors[] = "Fatal module error: Module \"{$ret['name']} does not contain a compatible SLAM version field.";
return false;
}
if (!isset($ret['version'])) {
$config->errors[] = "Fatal module error: Module \"{$ret['name']} does not contain a module version field.";
return false;
}
# extract useful fields
if (!isset($ret['author'])) {
$config->errors[] = "Module error: Module \"{$ret['name']}\" does not have an author property.";
}
if (!isset($ret['author'])) {
$config->errors[] = "Module error: Module \"{$ret['name']}\" does not have an author property.";
}
$this->name = $ret['name'];
$this->compatible = $ret['compatible'];
$this->version = $ret['version'];
$this->author = $ret['author'];
return $ret;
}
示例9: __construct
function __construct($options = array(), $properties = array())
{
if (empty($properties)) {
$properties = parse_ini_file('cybs.ini');
}
parent::__construct($options, $properties, true);
}
示例10: db_connect
protected function db_connect()
{
$database = parse_ini_file("db.ini", true);
$database = $database['Database'];
$this->link = mysql_connect($database['host'], $database['user'], $database['password']) or die('Could not connect: ' . mysql_error());
mysql_select_db($database['db_name']) or die('Could not select database: ' . mysql_error());
}
示例11: getLink
/**
* @param string $config (optional)
* @param string $schema (optional)
* @param bool $reconnect (optional)
* @return PDO
* @throws PDOException
*/
protected static final function getLink($config = self::DEFAULT_CONFIG, $schema = null, $reconnect = false)
{
$key = $config . $schema;
if (!$reconnect && self::is($key)) {
return self::get($key);
}
$parse = parse_ini_file($config, true);
if ($parse === false) {
return false;
}
$driver = $parse['db_driver'];
$dsn = "{$driver}:";
$user = $parse['db_user'];
$password = $parse['db_password'];
$options = $parse['db_options'];
$attributes = $parse['db_attributes'];
if (is_string($schema)) {
$parse['dsn']['dbname'] = $schema;
}
foreach ($parse['dsn'] as $k => $v) {
$dsn .= "{$k}={$v};";
}
try {
$link = new PDO($dsn, $user, $password, $options);
} catch (PDOException $e) {
throw new PDOException($e);
}
foreach ($attributes as $k => $v) {
$link->setAttribute(constant("PDO::{$k}"), constant("PDO::{$v}"));
}
self::set($key, $link);
self::$config = $parse;
return $link;
}
示例12: __construct
/**
* Constructor
*
* @param string $configFile The location of an alternative config file
*
* @access public
*/
public function __construct($configFile = false)
{
if ($configFile) {
// Load Configuration passed in
$this->config = parse_ini_file('conf/' . $configFile, true);
} else {
// Hard Coded Configuration
$this->config = parse_ini_file('conf/Voyager.ini', true);
}
// Set up object for formatting dates and times:
$this->dateFormat = new VuFindDate();
// Define Database Name
$this->dbName = $this->config['Catalog']['database'];
if (isset($this->config['Debug']['log'])) {
$this->logFile = $this->config['Debug']['log'];
}
// Based on the configuration file, use either "SID" or "SERVICE_NAME"
// to connect (correct value varies depending on Voyager's Oracle setup):
$connectType = isset($this->config['Catalog']['connect_with_sid']) && $this->config['Catalog']['connect_with_sid'] ? 'SID' : 'SERVICE_NAME';
$tns = '(DESCRIPTION=' . '(ADDRESS_LIST=' . '(ADDRESS=' . '(PROTOCOL=TCP)' . '(HOST=' . $this->config['Catalog']['host'] . ')' . '(PORT=' . $this->config['Catalog']['port'] . ')' . ')' . ')' . '(CONNECT_DATA=' . "({$connectType}={$this->config['Catalog']['service']})" . ')' . ')';
try {
$this->db = new PDO("oci:dbname={$tns}", $this->config['Catalog']['user'], $this->config['Catalog']['password']);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
throw $e;
}
}
示例13: index
public function index($id = 0, $color = 0, $design_id = '')
{
$id = (int) $id;
$data = array();
$data['color'] = (string) $color;
$data['design_id'] = $design_id;
$this->load->model('settings_m');
$setting = $this->settings_m->getSetting();
$data['setting'] = json_decode($setting->settings);
$langFile = ROOTPATH . DS . 'media' . DS . 'data' . DS . 'lang.ini';
$data['lang'] = parse_ini_file($langFile);
// get product default or product id
if ($id > 0) {
$fields = array('id' => $id, 'published' => 1);
} else {
$fields = array('published' => 1);
}
$this->load->model('product_m');
$rows = $this->product_m->getProduct($fields);
if ($rows != false) {
$product = $rows[0];
// get product design
$design = $this->product_m->getProductDesign($product->id);
if ($design == false) {
$product = false;
} else {
$this->load->helper('product');
$help_design = new helperProduct();
$product->design = $help_design->getDesign($design);
// attribute
$attribute = $this->product_m->getAttribute($product->id);
if (count($attribute)) {
$product->attribute = $help_design->displayAttributes($attribute);
} else {
$product->attribute = '';
}
$product->attribute = $help_design->quantity($product->min_order) . $product->attribute;
$this->load->model('categories_m');
$product->categories = $this->categories_m->getCategories('product');
}
$data['product'] = $product;
} else {
$data['product'] = false;
}
$data['user'] = $this->session->userdata('user');
// check user admin
$is_admin = true;
if (empty($data['user']['id'])) {
$is_admin = false;
} else {
//$this->load->model('users_m');
//$is_admin = $this->users_m->userPermission('art');
}
$data['is_admin'] = $is_admin;
$designer = $this->load->view('components/design/designer', $data, true);
$this->data['meta'] = '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1, minimum-scale=0.5, maximum-scale=1.0"/>';
$this->data['content'] = $designer;
$this->data['subview'] = $this->load->view('layouts/design/default', array(), true);
$this->theme($this->data, 'design');
}
示例14: __construct
/**
* @param string $iniFile Full path to ini file.
* @throws Exception If it can't open or parse file.
*/
public function __construct($iniFile)
{
$this->config = parse_ini_file($iniFile, true);
if (!$this->config) {
throw new \Exception("Can't open or parse ini file.");
}
}
示例15: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->checkAppExists($arguments['application']);
// skeleton directory
if (is_readable(sfConfig::get('sf_data_dir') . '/skeleton/propel_app_form_filter')) {
$skeletonDir = sfConfig::get('sf_data_dir') . '/skeleton/propel_app_form_filter';
} else {
$skeletonDir = dirname(__FILE__) . '/skeleton/app_form_filter';
}
// target directory
if (!file_exists($file = sfConfig::get('sf_app_lib_dir') . '/filter')) {
$this->getFilesystem()->mkdirs($file);
}
// constants
$properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
$constants = array('PROJECT' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'AUTHOR' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'APPLICATION' => $arguments['application']);
foreach ($this->loadModels() as $model) {
$file = sfConfig::get('sf_app_lib_dir') . '/filter/' . $arguments['application'] . $model . 'FormFilter.class.php';
if (class_exists($model . 'FormFilter') && !file_exists($file)) {
$this->getFilesystem()->copy($skeletonDir . '/form.class.php', $file);
$this->getFilesystem()->replaceTokens($file, '##', '##', $constants + array('MODEL' => $model));
}
}
$this->reloadAutoload();
}