Subversion Repositories stackman

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 daniel-mar 1
<?php
2
 
3
// Defaults
4
stam_read_config(__DIR__ . '/../defaults/.stam_config');
5
 
6
// Read config in user dir
7
$home = $_SERVER['HOME'];
8
stam_read_config($home.'/.stam_config');
9
 
10
// ---
11
 
12
function stam_read_config($file) {
13
        if (!file_exists($file)) return false;
14
        global $stam_cfg;
15
        $x = file($file);
16
        foreach ($x as &$a) {
17
                $a = trim($a);
18
                if ($a == '') continue;
19
                $ary = explode('=', $a, 2);
20
                $name = trim($ary[0]);
21
                if ($name[0] == '#') continue; // Comment
22
                if (!isset($ary[1])) {
23
                        // Invalid entry
24
                        fwrite(STDERR, "Ignore invalid config line: $a\n");
25
                        continue;
26
                }
27
                $val  = trim($ary[1]);
28
                $stam_cfg[$name] = $val;
29
        }
30
}