/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to setups/katrin/classes/kdbconfigfile.php

  • Committer: Suren A. Chilingaryan
  • Date: 2012-02-07 22:44:15 UTC
  • Revision ID: csa@dside.dyndns.org-20120207224415-sy360wa1ammhd1ph
Use localization subsystem, updated Katrin configs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
// $Id$
3
 
// Author: Sebastian Voecking <sebastian.voecking@uni-muenster.de>
4
 
 
5
 
class KDBConfigFile
6
 
{
7
 
    private $fEntries = array();
8
 
    
9
 
    function __construct($filename)
10
 
    {
11
 
        $file = fopen($filename, 'r');
12
 
 
13
 
        if ($file) {
14
 
            while (!feof($file)) {
15
 
                $line = fgets($file);
16
 
                $line = ltrim($line);
17
 
 
18
 
                $pos = strpos($line, '#');
19
 
                if ($pos !== false) {
20
 
                    $line = substr($line, 0, $pos);
21
 
                }
22
 
 
23
 
                $line = rtrim($line);
24
 
                if (strlen($line) == 0) continue;
25
 
 
26
 
                $pos = strpos($line, '=');
27
 
                if ($pos !== false) {
28
 
                    $key = rtrim(substr($line, 0, $pos));
29
 
                    $value = ltrim(substr($line, $pos + 1));
30
 
 
31
 
                    $this->fEntries[$key] = $value;
32
 
                }
33
 
            }
34
 
 
35
 
            fclose($file);
36
 
        }
37
 
    }
38
 
 
39
 
    function GetValue($key, $default=NULL)
40
 
    {
41
 
        if (array_key_exists($key, $this->fEntries)) {
42
 
            return $this->fEntries[$key];
43
 
        }
44
 
        else {
45
 
            return $default;
46
 
        }
47
 
    }
48
 
 
49
 
    function GetValueList($key, $default=NULL)
50
 
    {
51
 
        if (array_key_exists($key, $this->fEntries)) {
52
 
            $items = array();
53
 
            
54
 
            $tok = strtok($this->fEntries[$key], ',');
55
 
            while ($tok !== false) {
56
 
                $items[] = trim($tok);
57
 
            }
58
 
            return $items;
59
 
        }
60
 
        else {
61
 
            return $default;
62
 
        }
63
 
    }
64
 
}
65
 
?>