4 const PATH = '/etc/musiikki.conf';
6 private static $main = false;
8 private $values = array();
10 public static function main()
12 if (self::$main === false)
13 self::$main = new Config(Config::PATH);
18 private function __construct($path)
20 $this->loadValues($path);
23 private function loadValues($path)
25 if (!is_readable($path))
26 throw new Exception('Cannot open config file ' . $path);
28 $f = fopen($path, 'r');
30 throw new Exception('Cannot open config file ' . $path);
32 while (($line = fgets($f)) !== false) {
34 if (substr($line,0,1) == '#') continue;
35 if (!strlen($line)) continue;
37 $parts = explode('=', $line, 2);
38 $this->values[$parts[0]] = $parts[1];
44 public function get($name)
46 if (!array_key_exists($name, $this->values))
49 return $this->values[$name];