Пример #1
1
 /** @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
0
 /**
  * @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;
 }
 /**
  * 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
0
 /**
  * {@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
0
 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
0
 public function bindTextDomain($domain, $path = '')
 {
     $file = $path . '/' . getenv('LANG') . '/LC_MESSAGES/' . $domain . '.ini';
     if (file_exists($file)) {
         $this->translations = parse_ini_file($file);
     }
 }
Пример #7
0
 /**
  * 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
0
 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;
 }
 function __construct($options = array(), $properties = array())
 {
     if (empty($properties)) {
         $properties = parse_ini_file('cybs.ini');
     }
     parent::__construct($options, $properties, true);
 }
Пример #10
0
 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
0
 /**
  * @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
0
 /**
  * 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
0
 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
0
 /**
  * @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.");
     }
 }
 /**
  * @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();
 }
Пример #16
0
 public function __construct($sFile)
 {
     if (!file_exists($sFile)) {
         throw new \Exception("Setting\\Source\\Ini Cannot open {$sFile}");
     }
     $this->_aSettings = parse_ini_file($sFile, true);
 }
Пример #17
0
 /**
  * Parses an INI-formatted string or file. Just an alias
  * for `parse_ini_file`/`parse_ini_string` that's here for
  * completeness and consistency.
  */
 public static function parse($string, $sections = false, $scanner_mode = INI_SCANNER_NORMAL)
 {
     if (file_exists($string)) {
         return parse_ini_file($string, $sections, $scanner_mode);
     }
     return parse_ini_string($string, $sections, $scanner_mode);
 }
Пример #18
0
 protected function onBeforeSetup()
 {
     $dataPath = realpath(__DIR__ . '/../..');
     $this->config = parse_ini_file($dataPath . '/data/entities.csv.ini', true);
     $this->connection = new CsvDataGateway($this->config['dataPath']);
     $this->transactor = new CsvTransactor($this->connection);
 }
Пример #19
0
 /**
  * init client
  * load client.ini and set some constants
  * @return	boolean
  */
 function init()
 {
     $this->ini = new ilIniFile($this->ini_file_path);
     // load defaults only if no client.ini was found
     if (!@file_exists($this->ini_file_path)) {
         //echo "<br>A-".$this->ini_file_path."-";
         $this->ini->GROUPS = parse_ini_file($this->client_defaults, true);
         return false;
     }
     // read client.ini
     if (!$this->ini->read()) {
         $this->error = get_class($this) . ": " . $this->ini->getError();
         return false;
     }
     // only for ilias main
     define("CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId());
     define("CLIENT_DATA_DIR", ILIAS_DATA_DIR . "/" . $this->getId());
     define("DEVMODE", $this->ini->readVariable('system', 'DEVMODE'));
     define("ROOT_FOLDER_ID", $this->ini->readVariable('system', 'ROOT_FOLDER_ID'));
     define("SYSTEM_FOLDER_ID", $this->ini->readVariable('system', 'SYSTEM_FOLDER_ID'));
     define("ROLE_FOLDER_ID", $this->ini->readVariable('system', 'ROLE_FOLDER_ID'));
     define("ANONYMOUS_USER_ID", 13);
     define("ANONYMOUS_ROLE_ID", 14);
     define("SYSTEM_USER_ID", 6);
     define("SYSTEM_ROLE_ID", 2);
     $this->db_exists = $this->connect();
     if ($this->db_exists) {
         $this->db_installed = $this->isInstalledDB($this->db);
     }
     return true;
 }
Пример #20
0
function translateEngine($lang_subdirectory, $languageID, $messageID, $args = array(), $fallback = 'en')
{
    $lang_array = array("en", "de", "pt", "fr", "fi", "nn", "nl", "ca", "tr", "es", "it", "da", "cs", "ru", "et", "sr", "el", "pl", "hr", "hu", "br", "sv", "sk", "gl", "sl", "be", "lv", "lt", "zh", "cn", "ja", "ko", "bg", "mx", "uk", "id", "ro");
    if (!isset($lang_array[$languageID])) {
        return "Unknown Language Selected";
    }
    $lang_folder = ROOTPATH . "/data/langs/{$lang_subdirectory}";
    if (!is_readable($lang_folder)) {
        console("Language Folder for {$lang_subdirectory} is missing or not readable.");
        return "Language Folder for {$lang_subdirectory} is missing or not readable.";
    }
    $lang_file = "{$lang_folder}/{$lang_array[$languageID]}.ini";
    if (is_readable($lang_file)) {
        $LANG = parse_ini_file($lang_file);
    } else {
        $lang_file = "{$lang_folder}/{$fallback}.ini";
        if (is_readable($lang_file)) {
            $LANG = parse_ini_file($lang_file);
            console("Language File for {$lang_array[$languageID]} in {$lang_subdirectory} is missing or not readable.");
        } else {
            console("Language File for {$lang_array[$languageID]} in {$lang_subdirectory} is missing or not readable. No Fallback Available.");
            return "Language File for {$lang_array[$languageID]} in {$lang_subdirectory} is missing or not readable. No Fallback Available.";
        }
    }
    if (isset($LANG[$messageID])) {
        return vsprintf($LANG[$messageID], $args);
    } else {
        console("Missing Language Entry: {$messageID} in {$lang_array[$languageID]}");
        if ($languageID != $fallback) {
            return translateEngine($lang_subdirectory, $fallback, $messageID, $args, $fallback);
        } else {
            return "Missing Language Entry: {$messageID} in {$lang_array[$languageID]}";
        }
    }
}
 /**
  * Get value for a named parameter.
  *
  * @param mixed $parameter Parameter to get a value for
  * @param array $argv Argument values passed to the script when run in console.
  * @return mixed
  */
 public function getValueForParameter($parameter, $argv = array())
 {
     // Configuration file path
     $configurationFilePath = null;
     // Check if a path to a configuration file is specified
     foreach ($argv as $parameterInput) {
         $parameterInput = explode('=', $parameterInput, 2);
         if (strtolower($parameterInput[0]) == '--configfile' || strtolower($parameterInput[0]) == '-f') {
             if (!isset($parameterInput[1])) {
                 require_once 'Zend/Service/Console/Exception.php';
                 throw new Zend_Service_Console_Exception("No path to a configuration file is given. Specify the path using the --ConfigFile or -F switch.");
             }
             $configurationFilePath = $parameterInput[1];
             break;
         }
     }
     // Value given?
     if (is_null($configurationFilePath)) {
         return null;
     }
     if (!file_exists($configurationFilePath)) {
         require_once 'Zend/Service/Console/Exception.php';
         throw new Zend_Service_Console_Exception("Invalid configuration file given. Specify the correct path using the --ConfigFile or -F switch.");
     }
     // Parse values
     $iniValues = parse_ini_file($configurationFilePath);
     // Default value
     $parameterValue = null;
     // Loop aliases
     foreach ($parameter->aliases as $alias) {
         if (array_key_exists($alias, $iniValues)) {
             $parameterValue = $iniValues[$alias];
             break;
         } else {
             if (array_key_exists(strtolower($alias), $iniValues)) {
                 $parameterValue = $iniValues[strtolower($alias)];
                 break;
             } else {
                 if (array_key_exists(str_replace('-', '', $alias), $iniValues)) {
                     $parameterValue = $iniValues[str_replace('-', '', $alias)];
                     break;
                 } else {
                     if (array_key_exists(strtolower(str_replace('-', '', $alias)), $iniValues)) {
                         $parameterValue = $iniValues[strtolower(str_replace('-', '', $alias))];
                         break;
                     }
                 }
             }
         }
     }
     if (strtolower($parameterValue) == 'true') {
         $parameterValue = true;
     } else {
         if (strtolower($parameterValue) == 'false') {
             $parameterValue = false;
         }
     }
     // Done!
     return $parameterValue;
 }
Пример #22
0
 private function _connect($dsn)
 {
     if ($dsn == NULL) {
         $inifile = APJ . DIRECTORY_SEPARATOR . "MyPDO.ini.php";
         if (is_readable($inifile)) {
             $this->_settings = parse_ini_file($inifile);
             if ($this->_settings) {
                 $dsn = 'mysql:dbname=' . $this->_settings["dbname"] . ';host=' . $this->_settings["host"] . ';charset=' . $this->_settings['charset'];
             } else {
                 die($this->_errorLog("El archivo de DSN {$inifile} no se pudo leer."));
             }
         } else {
             die($this->_errorLog("El archivo de DSN {$inifile} no está disponible. "));
         }
     }
     try {
         $this->_pdo = new PDO($dsn, $this->_settings["user"], $this->_settings["password"]);
         $this->_pdo->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES ' . $this->_settings['charset']);
         $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         $this->_connected = true;
     } catch (PDOException $e) {
         die($this->_errorLog($e->getMessage()));
     }
 }
 public function buildCss()
 {
     App::import('Vendor', 'AssetMinify.JSMinPlus');
     // Ouverture des fichiers de config
     $dir = new Folder(Configure::read('App.www_root') . 'css' . DS . 'minified');
     if ($dir->path !== null) {
         foreach ($dir->find('config_.*.ini') as $file) {
             preg_match('`^config_(.*)\\.ini$`', $file, $grep);
             $file = new File($dir->pwd() . DS . $file);
             $ini = parse_ini_file($file->path, true);
             $fileFull = new File($dir->path . DS . 'full_' . $grep[1] . '.css', true, 0644);
             $fileGz = new File($dir->path . DS . 'gz_' . $grep[1] . '.css', true, 0644);
             $contentFull = '';
             foreach ($ini as $data) {
                 // On a pas de version minifié
                 if (!($fileMin = $dir->find('file_' . md5($data['url'] . $data['md5']) . '.css'))) {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css', true, 0644);
                     $this->out("Compression de " . $data['file'] . ' ... ', 0);
                     $fileMin->write(MinifyUtils::compressCss(MinifyUtils::cssAbsoluteUrl($data['url'], file_get_contents($data['file']))));
                     $this->out('OK');
                 } else {
                     $fileMin = new File($dir->path . DS . 'file_' . md5($data['url'] . $data['md5']) . '.css');
                 }
                 $contentFull .= $fileMin->read() . PHP_EOL;
             }
             // version full
             $fileFull->write($contentFull);
             $fileFull->close();
             // compression
             $fileGz->write(gzencode($contentFull, 6));
         }
     }
 }
Пример #24
0
 /**
  * __construct
  *
  */
 function __construct($pRepositoryUrl, $pCheckoutRootDir, $pUserName = "", $pPassWord = "")
 {
     $tSvnConfig = parse_ini_file('config.ini', true);
     if (isset($tSvnConfig['Subversion']['config_path']) && isset($tSvnConfig['Subversion']['client_path'])) {
         $this->mSvnCommand = "{$tSvnConfig['Subversion']['client_path']} --non-interactive --no-auth-cache --config-dir \"{$tSvnConfig['Subversion']['config_path']}\" ";
     } else {
         throw new Exception("请重新配置config.ini文件");
     }
     $this->mRepositoryUrl = dirname($pRepositoryUrl) . "/" . basename($pRepositoryUrl) . "/";
     $this->mCheckoutRootDir = dirname($pCheckoutRootDir) . "/" . basename($pCheckoutRootDir) . "/";
     $this->mUserName = $pUserName;
     $this->mPassWord = $pPassWord;
     $command_divide = "\"";
     if (substr(PHP_OS, 0, 3) != 'WIN') {
         $command_divide = "\"";
         $patterns[0] = "/\\\\/";
         $patterns[1] = "/[\$]/";
         $patterns[2] = "/`/";
         $patterns[3] = "/\"/";
         $replacements[0] = "\\\\\\";
         $replacements[1] = "\\" . "\\\$";
         $replacements[2] = "\\`";
         $replacements[3] = "\\\"";
         $pPassWord = preg_replace($patterns, $replacements, $pPassWord);
     }
     if ($pUserName != "" && $pPassWord != "") {
         $this->mBaseCommand = $this->mSvnCommand . "--username {$command_divide}{$pUserName}{$command_divide} --password {$command_divide}{$pPassWord}{$command_divide} ";
     } else {
         $this->mBaseCommand = $this->mSvnCommand;
     }
     $this->mCurrentCommand = $this->mBaseCommand;
     $this->mExcuteError = false;
 }
Пример #25
0
 /**
  * Load config data. Support php|ini|yml config formats.
  *
  * @param string|\SplFileInfo $configFile
  * @throws ConfigException
  */
 public function loadConfig($configFile)
 {
     if (!$configFile instanceof \SplFileInfo) {
         if (!is_string($configFile)) {
             throw new ConfigException('Mismatch type of variable.');
         }
         $path = realpath($this->basePath . $configFile);
         // check basePath at mutation
         if (strpos($configFile, '..') || !strpos($path, realpath($this->basePath))) {
             throw new ConfigException('Config file name: ' . $configFile . ' isn\'t correct.');
         }
         if (!is_file($path) || !is_readable($path)) {
             throw new ConfigException('Config file: ' . $path . ' not found of file isn\'t readable.');
         }
         $configFile = new \SplFileInfo($path);
     }
     $path = $configFile->getRealPath();
     $ext = $configFile->getExtension();
     $key = $configFile->getBasename('.' . $ext);
     if ('php' === $ext) {
         $this->data[$key] = (include $path);
     } elseif ('ini' === $ext) {
         $this->data[$key] = parse_ini_file($path, true);
     } elseif ('yml' === $ext) {
         if (!function_exists('yaml_parse_file')) {
             throw new ConfigException("Function `yaml_parse_file` isn't supported.\n" . 'http://php.net/manual/en/yaml.requirements.php');
         }
         $this->data[$key] = yaml_parse_file($path);
     }
 }
Пример #26
0
 public function __construct($rootPath)
 {
     global $neardBs, $neardConfig, $neardLang;
     Util::logInitClass($this);
     $this->name = $neardLang->getValue(Lang::TCCLE);
     $this->version = $neardConfig->getRaw(self::ROOT_CFG_VERSION);
     $this->rootPath = $rootPath;
     $this->currentPath = $rootPath . '/tccle' . $this->version;
     $this->neardConf = $this->currentPath . '/neard.conf';
     if (!is_dir($this->currentPath)) {
         Util::logError(sprintf($neardLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
     }
     if (!is_file($this->neardConf)) {
         Util::logError(sprintf($neardLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->neardConf));
     }
     $this->neardConfRaw = parse_ini_file($this->neardConf);
     if ($this->neardConfRaw !== false) {
         $this->exe = $this->currentPath . '/' . $this->neardConfRaw[self::LOCAL_CFG_EXE];
         $this->conf = $this->currentPath . '/' . $this->neardConfRaw[self::LOCAL_CFG_CONF];
     }
     if (!is_file($this->exe)) {
         Util::logError(sprintf($neardLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
     }
     if (!is_file($this->conf)) {
         Util::logError(sprintf($neardLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
     }
 }
Пример #27
0
 /**
  * Method for parsing ini files
  *
  * @param		string	$filename Path and name of the ini file to parse
  *
  * @return	array		Array of strings found in the file, the array indices will be the keys. On failure an empty array will be returned
  *
  * @since		2.5
  */
 public static function parseFile($filename)
 {
     jimport('joomla.filesystem.file');
     if (!JFile::exists($filename)) {
         return array();
     }
     // Capture hidden PHP errors from the parsing
     $version = phpversion();
     $php_errormsg = null;
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     if ($version >= '5.3.1') {
         $contents = file_get_contents($filename);
         $contents = str_replace('_QQ_', '"\\""', $contents);
         $strings = @parse_ini_string($contents);
         if ($strings === false) {
             return array();
         }
     } else {
         $strings = @parse_ini_file($filename);
         if ($strings === false) {
             return array();
         }
         if ($version == '5.3.0' && is_array($strings)) {
             foreach ($strings as $key => $string) {
                 $strings[$key] = str_replace('_QQ_', '"', $string);
             }
         }
     }
     return $strings;
 }
Пример #28
0
 private function load($fileName)
 {
     $this->config = @parse_ini_file($fileName);
     if ($this->config == NULL || count($this->config) == 0) {
         throw new PPConfigurationException("Config file {$fileName} not found", "303");
     }
 }
Пример #29
0
 /**
  * Constructor
  *
  * @param string $config is the name of the config file to parse or a parent agi from which to read the config
  * @param array $optconfig is an array of configuration vars and vals, stuffed into $this->config['asmanager']
  */
 function __construct($config = NULL, $optconfig = array())
 {
     // load config
     if (!is_null($config) && file_exists($config)) {
         $this->config = parse_ini_file($config, true);
     }
     // If optconfig is specified, stuff vals and vars into 'asmanager' config array.
     if (is_array($optconfig)) {
         foreach ($optconfig as $var => $val) {
             $this->config['asmanager'][$var] = $val;
         }
     }
     // add default values to config for uninitialized values
     if (!isset($this->config['asmanager']['server'])) {
         $this->config['asmanager']['server'] = 'localhost';
     }
     if (!isset($this->config['asmanager']['port'])) {
         $this->config['asmanager']['port'] = 5038;
     }
     if (!isset($this->config['asmanager']['username'])) {
         $this->config['asmanager']['username'] = '******';
     }
     if (!isset($this->config['asmanager']['secret'])) {
         $this->config['asmanager']['secret'] = 'snep';
     }
 }
Пример #30
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @param $_config_file
  */
 public function __construct($_config_file)
 {
     /** @var string $log_path */
     $log_path = APPLICATION_PATH . '/tmp/application.log';
     if (file_exists($_config_file)) {
         /** @var array $_attributes */
         $_attributes = parse_ini_file($_config_file, true);
         /** @var definition\config[] $_config */
         $_config = new \stdClass();
         foreach ($_attributes as $_env => $_parameters) {
             if ($_env == APPLICATION_ENV) {
                 foreach ($_parameters as $_parameter => $value) {
                     /** @var definition\config _parameter */
                     $_config->{$_parameter} = new definition\config();
                     $_config->{$_parameter}->_setName($_parameter)->_setValue($value)->_activate();
                 }
             }
         }
         if (isset($_config->log_path) and $_config->log_path->isActivated()) {
             $log_path = $_config->log_path;
         }
         if (is_file($log_path)) {
             defined('APPLICATION_PATH_LOG') || define('APPLICATION_PATH_LOG', $log_path);
         }
         $this->_configuration = $_config;
         /** Set in registry */
         registry::getInstance()->add('config', $this);
     }
 }