4 const PATH = '/etc/musiikki.conf';
5 const SHARE_READ = 'musicread';
6 const SHARE_WRITE = 'musicwrite';
8 private static $main = false;
10 private $values = array();
12 public static function main()
14 if (self::$main === false)
15 self::$main = new Config(Config::PATH);
20 private function __construct($path)
22 $this->loadValues($path);
25 private function loadValues($path)
27 if (!is_readable($path))
28 throw new Exception('Cannot open config file ' . $path);
30 $f = fopen($path, 'r');
32 throw new Exception('Cannot open config file ' . $path);
34 while (($line = fgets($f)) !== false) {
36 if (substr($line,0,1) == '#') continue;
37 if (!strlen($line)) continue;
39 $parts = explode('=', $line, 2);
40 $this->values[$parts[0]] = $parts[1];
46 public function get($name)
48 if (!array_key_exists($name, $this->values))
51 return $this->values[$name];