Last change
on this file was 95, checked in by chronos, 10 years ago |
- Upraveno: Soubory různých logických částí systému odděleny do aplikačních modulů.
|
File size:
1.0 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Base/Model.php');
|
---|
4 |
|
---|
5 | class MangosConfigurationFile extends Model
|
---|
6 | {
|
---|
7 | var $ParameterList;
|
---|
8 |
|
---|
9 | function __construct($System)
|
---|
10 | {
|
---|
11 | parent::__construct($System);
|
---|
12 | $this->Parameters = array();
|
---|
13 | }
|
---|
14 |
|
---|
15 | function Load($FileName)
|
---|
16 | {
|
---|
17 | $this->ParameterList = array();
|
---|
18 | $Lines = explode("\n", file_get_contents($FileName));
|
---|
19 | foreach($Lines as $Line)
|
---|
20 | {
|
---|
21 | $Line = trim($Line);
|
---|
22 | if((strlen(trim($Line)) > 0) and ($Line{0} != '#'))
|
---|
23 | {
|
---|
24 | $Name = trim(substr($Line, 0, strpos($Line, '=')));
|
---|
25 | $Value = trim(substr($Line, strpos($Line, '=') + 1));
|
---|
26 | if($Value{0} == '"') $Value = substr($Value, 1, -1);
|
---|
27 | $this->ParameterList[$Name] = $Value;
|
---|
28 | }
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | function Save($FileName)
|
---|
33 | {
|
---|
34 | $Lines = array();
|
---|
35 | foreach($this->ParameterList as $Name => $Value)
|
---|
36 | {
|
---|
37 | if(!is_numeric($Value)) $Value = '"'.$Value.'"';
|
---|
38 | $Lines[] = $Name.' = '.$Value;
|
---|
39 | }
|
---|
40 | file_put_contents($FileName, implode("\n", $Lines));
|
---|
41 | }
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.