Server IP : 104.21.14.48 / Your IP : 13.59.182.74 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/wp-all-export/classes/ |
Upload File : |
<?php /** * Class to load config files * * @author Pavel Kulbakin <[email protected]> */ class PMXE_Config implements IteratorAggregate { /** * Config variables stored * @var array */ protected $config = array(); /** * List of loaded files in order to avoid loading same file several times * @var array */ protected $loaded = array(); /** * Static method to create config instance from file on disc * @param string $filePath * @param string[optional] $section * @return PMXE_Config */ public static function createFromFile($filePath, $section = NULL) { $config = new self(); return $config->loadFromFile($filePath, $section); } /** * Load config file * @param string $filePath * @param string [optional] $section * @return PMXE_Config */ public function loadFromFile($filePath, $section = NULL) { if (!is_null($section)) { $this->config[$section] = self::createFromFile($filePath); } else { $filePath = realpath($filePath); if ($filePath and !in_array($filePath, $this->loaded)) { require $filePath; if (!isset($config)) { $config = array(); } } $this->loaded[] = $filePath; $this->config = array_merge($this->config, $config); } return $this; } /** * Return value of setting with specified name * @param string $field Setting name * @param string[optional] $section Section name to look setting in * @return mixed */ public function get($field, $section = NULL) { return ! is_null($section) ? $this->config[$section]->get($field) : $this->config[$field]; } /** * Magic method for checking whether some config option are set * @param string $field * @return bool */ public function __isset($field) { return isset($this->config[$field]); } /** * Magic method to implement object-like access to config parameters * @param string $field * @return mixed */ public function __get($field) { return $this->config[$field]; } /** * Return all config options as array * @return array */ public function toArray($section = NULL): array { return ! is_null($section) ? $this->config[$section]->toArray() : $this->config; } public function getIterator(): \Traversable { return new ArrayIterator($this->config); } }