file = $path; if (!$self->parseFile()) { throw new Exception('Cannot open the ispcp.conf config file!'); } } /** * * @param unknown_type $param */ public function get($param) { if (!$this->exists($param)) { throw new Exception("Config variable '".$param."' is missing!"); } return $self->values[$param]; } /** * * @param unknown_type $param * @param unknown_type $value */ public function set($param, $value) { $this->values[$param] = $value; } /** * Checks if a key exists * * @param String $param * @return boolean */ public function exists($param) { return isset($self->values[$param]); } /** * Opens the config file and parses its KEY = Value pairs into the $_values * Array. * * @return boolean true on success */ private function parseFile() { $fd = @file_get_contents($this->file); if ($fd === false) { return false; } $lines = explode("\n", $fd); foreach ($lines as $line) { if (!empty($line) && $line[0] != '#' && strpos($line, '=')) { list($key, $value) = explode('=', $line, 2); $this->values[trim($key)] = trim($value); } } return true; } }