/**
  * Get Config Parameters
  *
  * This method is used to retrieve the functions contained in the {@link $data}
  * property.  It also sets the {@link $data} property if it hasn't already been set.
  * It is provided two parameters:
  *   section - The section of the configuration file the setting is under.
  *             Ex. [database]
  *      name - The name of the parameter.  Ex. errmode
  *
  * @param    string      $section    The name of the section in the config.ini
  *                                   you're wanting to get the setting for.
  * @param    string      $name       The name of the parameter you're wanting the
  *                                   value of.
  * @return   bool|string|array       Returns bool and throws an Exception on failure,
  *                                   string if $name parameter is used and matches,
  *                                   and an array is $name parameter is null.
  * @static
  * @access   public
  */
 public static function getParam($section, $name = null)
 {
     // Check if data has already been set
     if (self::$data === null) {
         // Try to parse the config.ini file
         self::$data = parse_ini_file('config.ini', true);
         // If config.ini couldn't be parsed, throw an exception
         if (self::$data === false) {
             $this->handleError('Configuration file missing/corrupt.');
         }
     }
     // Check if the section in in the {@link $data} array
     if (array_key_exists($section, self::$data)) {
         // Check if the {@link $name} parameter is in the array if it's defined
         if ($name && array_key_exists($name, self::$data[$section])) {
             // Return the data string
             return self::$data[$section][$name];
         } else {
             return self::$data[$section];
         }
     } else {
         // No exception is thrown here since it will be handled in the
         // by the script calling it instead.
         return false;
     }
 }
Example #2
0
 /**
  * Begin initiation.
  * @param  array $config Assets global configuration
  * @param  array $data Assets data
  * @return void
  */
 public function __construct(array $config, array $data)
 {
     $conf = new Config($config);
     $this->config = $conf->data();
     $this->provider = new Provider($this->config, $data);
     $this->data = $this->provider->getData();
 }
Example #3
0
 static function get()
 {
     if (self::$data === null) {
         self::$data = Toml\Parser::fromFile('config/config.toml');
     }
     return self::$data;
 }
 private static function getData()
 {
     if (self::$data !== null) {
         return self::$data;
     }
     self::$data = parse_ini_file('../config/config.ini', true);
     return self::$data;
 }
Example #5
0
 protected static function getData()
 {
     global $CONFIG;
     if (!isset(self::$data)) {
         self::$data = $CONFIG;
     }
     return self::$data;
 }
Example #6
0
 private function LogHeader()
 {
     $file = 'log.txt';
     $message = "Results:\n";
     file_put_contents($file, $message);
     //PHP 5, без FILE_APPEND, затираю предыдущие записи
     Config::data();
     // display how many members of family we have
 }
Example #7
0
 function load($filename = null)
 {
     if (empty($filename)) {
         $filename = MICROSITE_CONFIG;
     }
     self::$data = parse_ini_file($filename, true);
     $replacements = array('#{MICROSITE_PATH}#' => MICROSITE_PATH, '#{MICROSITE_CONFIG}#' => MICROSITE_CONFIG, '#{MICROSITE_CONFIG_PATH}#' => dirname(MICROSITE_CONFIG));
     self::$data = self::replace(self::$data, $replacements);
 }
Example #8
0
 /**
  * Loads the configuration information given in file $filename into
  * the configuration object.  This uses the function parse_ini_file()
  * internally, so the passed file should be compatible with it.
  *
  * If load is called multiple times, the configuration settings are 
  * merged; in the case of a conflict, last file wins.
  *
  * @param string $filename
  */
 static function load($filename)
 {
     if (!file_exists($filename)) {
         trigger_error("fatal: configuration file [{$filename}] does not exist", E_USER_WARNING);
     } else {
         $filename = realpath($filename);
     }
     $d = @parse_ini_file($filename);
     if (is_null($d)) {
         trigger_error("fatal: couldn't parse configuration file [{$filename}]", E_USER_WARNING);
     }
     self::$data = array_merge(self::$data, $d);
     self::$filename[] = $filename;
 }
Example #9
0
 public static function html($unsafeHTML)
 {
     // Get the HTMLPurifier Library
     if (!method_exists("HTMLPurifier_Config", "createDefault")) {
         require SYS_PATH . '/third-party/htmlpurifier/HTMLPurifier.auto.php';
     }
     // If the purifier library was detected, utilize it
     if (method_exists("HTMLPurifier_Config", "createDefault")) {
         Config::$data = HTMLPurifier_Config::createDefault();
         $purifier = new HTMLPurifier(Config::$data);
         $clean_html = $purifier->purify($unsafeHTML);
         return $clean_html;
     }
     return "{error: unsanitized html}";
 }
Example #10
0
 /**
  * @expectedException \Mi\Exception\MiException
  */
 public function testAsNotFile()
 {
     $config = new Config('nofile.php');
     $this->assertNull($config->data());
 }
 /**
  * Returns an array containing the required config data.
  *
  * If the setting core.installed is not equal 1 an error will be thrown.
  *
  * @return array Configuration from the file specified in the constant Config::FILENAME.
  **/
 public static function baseConfig()
 {
     if (is_array(self::$data) == false) {
         require self::FILENAME;
         self::$data = $config;
     }
     return self::$data;
 }
 /**
  * Dump All Settings
  *
  * This method is made for use during development to show all settings as an
  * array and should NOT ever be used on a production server since it reveils
  * all sensitive data.
  *
  * @param    void
  * @static
  * @access   public
  */
 public static function devDump()
 {
     // Check if data has already been set
     if (self::$data === null) {
         // Try to parse the config.ini file
         self::$data = parse_ini_file('errors.settings.ini', true);
         // If config.ini couldn't be parsed, throw an exception
         if (self::$data === false) {
             $this->handleError('Configuration file missing/corrupt.');
         }
     }
     echo '<pre>';
     print_r(self::$data);
     echo '</pre>';
 }