30
|
1 <?php
|
|
2 include_once('config.php');
|
|
3
|
|
4 class Settings extends SimpleXMLElement {
|
|
5
|
|
6 const CONFIG_XML = "/settings/config.xml";
|
|
7
|
|
8 public static function factory() {
|
|
9
|
|
10 if( file_exists( INSTALL_PATH . self::CONFIG_XML ) ) {
|
|
11 $xmlfile = file_get_contents(INSTALL_PATH . self::CONFIG_XML);
|
|
12 return new self($xmlfile);
|
|
13 }
|
|
14 else {
|
|
15 // 初回起動
|
|
16 $xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>';
|
|
17 $xml = new self($xmlfile);
|
|
18
|
|
19 // 旧config.phpを読み取って設定
|
|
20 if(defined("SPOOL") ) $xml->spool = SPOOL;
|
|
21 else $xml->spool = "/video";
|
|
22
|
|
23 if(defined("THUMBS") ) $xml->thumbs = THUMBS;
|
|
24 else $xml->thumbs = "/thumbs";
|
|
25
|
|
26 if(defined("INSTALL_URL")) $xml->install_url = INSTALL_URL;
|
|
27 else $xml->install_url = "http://localhost/epgrec";
|
|
28
|
|
29 if(defined("BS_TUNERS")) $xml->bs_tuners = BS_TUNERS;
|
|
30 else $xml->bs_tuenrs = 0;
|
|
31
|
|
32 if(defined("GR_TUNERS")) $xml->gr_tuenrs = GR_TUNERS;
|
|
33 else $xml->gr_tuners = 1;
|
|
34
|
|
35 if(defined("USE_KUROBON")) $xml->use_kurobon = USE_KUROBON;
|
|
36 else $xml->use_kurobon = 0;
|
|
37
|
|
38 if(defined("FORMER_TIME")) $xml->former_time = FORMER_TIME;
|
|
39 else $xml->former_time = 20;
|
|
40
|
|
41 if(defined("EXTRA_TIME")) $xml->extra_time = EXTRA_TIME;
|
|
42 else $xml->extra_time = 0;
|
|
43
|
|
44 if(defined("FORCE_CONT_REC")) $xml->force_cont_rec = FORCE_CONT_REC;
|
|
45 else $xml->force_cont_rec = 0;
|
|
46
|
|
47 if(defined("REC_SWITCH_TIME")) $xml->rec_switch_time = REC_SWITCH_TIME;
|
|
48 else $xml->rec_switch_time = 5;
|
|
49
|
|
50 if(defined("USE_THUMBS")) $xml->use_thumbs = USE_THUMBS;
|
|
51 else $xml->use_thumbs = 0;
|
|
52
|
|
53 if(defined("MEDIATOMB_UPDATE")) $xml->mediatomb_update = MEDIATOMB_UPDATE;
|
|
54 else $xml->mediatomb_update = 0;
|
|
55
|
|
56 if(defined("FILENAME_FORMAT")) $xml->filename_format = FILENAME_FORMAT;
|
|
57 else $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%";
|
|
58
|
|
59 if(defined("DB_HOST")) $xml->db_host = DB_HOST;
|
|
60 else $xml->db_host = "localhost";
|
|
61
|
|
62 if(defined("DB_NAME")) $xml->db_name = DB_NAME;
|
|
63 else $xml->db_name = "yourdbname";
|
|
64
|
|
65 if(defined("DB_USER")) $xml->db_user = DB_USER;
|
|
66 else $xml->db_user = "yourname";
|
|
67
|
|
68 if(defined("DB_PASS")) $xml->db_pass = DB_PASS;
|
|
69 else $xml->db_pass = "yourpass";
|
|
70
|
|
71 if(defined("TBL_PREFIX")) $xml->tbl_prefix = TBL_PREFIX;
|
|
72 else $xml->tbl_prefix = "Recorder_";
|
|
73
|
|
74 if(defined("EPGDUMP")) $xml->epgdump = EPGDUMP;
|
|
75 else $xml->epgdump = "/usr/local/bin/epgdump";
|
|
76
|
|
77 if(defined("AT")) $xml->at = AT;
|
|
78 else $xml->at = "/usr/bin/at";
|
|
79
|
|
80 if(defined( "ATRM" )) $xml->atrm = ATRM;
|
|
81 else $xml->atrm = "/usr/bin/atrm";
|
|
82
|
|
83 if(defined( "SLEEP" )) $xml->sleep = SLEEP;
|
|
84 else $xml->sleep = "/bin/sleep";
|
|
85
|
|
86 if(defined( "FFMPEG" )) $xml->ffmpeg = FFMPEG;
|
|
87 else $xml->ffmpeg = "/usr/bin/ffmpeg";
|
|
88
|
|
89 if(defined("TEMP_DATA" )) $xml->temp_data = TEMP_DATA;
|
|
90 else $xml->temp_data = "/tmp/__temp.ts";
|
|
91
|
|
92 if(defined("TEMP_XML")) $xml->temp_xml = TEMP_XML;
|
|
93 else $xml->temp_xml = "/tmp/__temp.xml";
|
|
94
|
|
95 // index.phpで使う設定値
|
|
96 // 表示する番組表の長さ(時間)
|
|
97 $xml->top_program_length = 8;
|
|
98 // 1局の幅
|
|
99 $xml->top_ch_set_width = 150;
|
|
100 // 1分あたりの高さ
|
|
101 $xml->top_height_per_min = 2;
|
|
102
|
|
103 $xml->save();
|
|
104
|
|
105 return $xml;
|
|
106 }
|
|
107 }
|
|
108
|
|
109 public function exists( $property ) {
|
|
110 return (int)count( $this->{$property} );
|
|
111 }
|
|
112
|
|
113 public function post() {
|
|
114 global $_POST;
|
|
115
|
|
116 foreach( $POST as $key => $value ) {
|
|
117
|
|
118 if( $this->exists($key) ) {
|
|
119 $this->{$key} = trim($value);
|
|
120 }
|
|
121 }
|
|
122 }
|
|
123
|
|
124 public function save() {
|
|
125 $this->asXML(INSTALL_PATH . self::CONFIG_XML);
|
|
126 }
|
|
127 }
|
|
128
|
|
129 $settings = Settings::factory();
|
|
130
|
|
131 print_r( get_object_vars( $settings ) );
|
|
132
|
|
133 ?> |