Mercurial > epgrec.yaz
annotate Settings.class.php @ 149:5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
---|---|
date | Sat, 27 Mar 2010 16:04:54 +0900 |
parents | 2646140c5ba7 |
children | a18df712fc7e |
rev | line source |
---|---|
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); | |
66
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
12 $obj = new self($xmlfile); |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
13 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
14 // 814ヤ札菴遵荐絎 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
15 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
16 // 若若牙祉牙祉≪若 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
17 if( $obj->exists("autorec_mode") == 0 ) { |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
18 $obj->autorec_mode = 0; |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
19 $obj->save(); |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
20 } |
80
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
21 // CS牙 |
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
22 if( $obj->exists("cs_rec_flg") == 0 ) { |
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
23 $obj->cs_rec_flg = 0; |
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
24 $obj->save(); |
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
25 } |
66
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
26 return $obj; |
30 | 27 } |
28 else { | |
29 // 莎桁 | |
30 $xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>'; | |
31 $xml = new self($xmlfile); | |
32 | |
33 // config.php茯水c荐絎 | |
34 if(defined("SPOOL") ) $xml->spool = SPOOL; | |
35 else $xml->spool = "/video"; | |
36 | |
37 if(defined("THUMBS") ) $xml->thumbs = THUMBS; | |
38 else $xml->thumbs = "/thumbs"; | |
39 | |
40 if(defined("INSTALL_URL")) $xml->install_url = INSTALL_URL; | |
41 else $xml->install_url = "http://localhost/epgrec"; | |
42 | |
43 if(defined("BS_TUNERS")) $xml->bs_tuners = BS_TUNERS; | |
32
01a8fdc0cebb
testing: Web base setting page.
Sushi-k <epgrec@park.mda.or.jp>
parents:
31
diff
changeset
|
44 else $xml->bs_tuners = 0; |
30 | 45 |
55 | 46 if(defined("GR_TUNERS")) $xml->gr_tuners = GR_TUNERS; |
30 | 47 else $xml->gr_tuners = 1; |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
55
diff
changeset
|
48 |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
55
diff
changeset
|
49 if(defined("CS_REC_FLG")) $xml->cs_rec_flg = CS_REC_FLG; |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
55
diff
changeset
|
50 else $xml->cs_rec_flg = 0; |
30 | 51 |
54
6f961c8ab304
modified: Settings.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
32
diff
changeset
|
52 if(defined("USE_KUROBON")) $xml->use_kurobon = USE_KUROBON ? 1 : 0; |
30 | 53 else $xml->use_kurobon = 0; |
54 | |
55 if(defined("FORMER_TIME")) $xml->former_time = FORMER_TIME; | |
56 else $xml->former_time = 20; | |
57 | |
58 if(defined("EXTRA_TIME")) $xml->extra_time = EXTRA_TIME; | |
59 else $xml->extra_time = 0; | |
60 | |
54
6f961c8ab304
modified: Settings.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
32
diff
changeset
|
61 if(defined("FORCE_CONT_REC")) $xml->force_cont_rec = FORCE_CONT_REC ? 1 : 0; |
30 | 62 else $xml->force_cont_rec = 0; |
63 | |
64 if(defined("REC_SWITCH_TIME")) $xml->rec_switch_time = REC_SWITCH_TIME; | |
65 else $xml->rec_switch_time = 5; | |
66 | |
54
6f961c8ab304
modified: Settings.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
32
diff
changeset
|
67 if(defined("USE_THUMBS")) $xml->use_thumbs = USE_THUMBS ? 1 : 0; |
30 | 68 else $xml->use_thumbs = 0; |
69 | |
54
6f961c8ab304
modified: Settings.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
32
diff
changeset
|
70 if(defined("MEDIATOMB_UPDATE")) $xml->mediatomb_update = MEDIATOMB_UPDATE ? 1 : 0; |
30 | 71 else $xml->mediatomb_update = 0; |
72 | |
73 if(defined("FILENAME_FORMAT")) $xml->filename_format = FILENAME_FORMAT; | |
74 else $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%"; | |
75 | |
76 if(defined("DB_HOST")) $xml->db_host = DB_HOST; | |
77 else $xml->db_host = "localhost"; | |
78 | |
79 if(defined("DB_NAME")) $xml->db_name = DB_NAME; | |
80 else $xml->db_name = "yourdbname"; | |
81 | |
82 if(defined("DB_USER")) $xml->db_user = DB_USER; | |
83 else $xml->db_user = "yourname"; | |
84 | |
85 if(defined("DB_PASS")) $xml->db_pass = DB_PASS; | |
86 else $xml->db_pass = "yourpass"; | |
87 | |
88 if(defined("TBL_PREFIX")) $xml->tbl_prefix = TBL_PREFIX; | |
89 else $xml->tbl_prefix = "Recorder_"; | |
90 | |
91 if(defined("EPGDUMP")) $xml->epgdump = EPGDUMP; | |
92 else $xml->epgdump = "/usr/local/bin/epgdump"; | |
93 | |
94 if(defined("AT")) $xml->at = AT; | |
95 else $xml->at = "/usr/bin/at"; | |
96 | |
97 if(defined( "ATRM" )) $xml->atrm = ATRM; | |
98 else $xml->atrm = "/usr/bin/atrm"; | |
99 | |
100 if(defined( "SLEEP" )) $xml->sleep = SLEEP; | |
101 else $xml->sleep = "/bin/sleep"; | |
102 | |
103 if(defined( "FFMPEG" )) $xml->ffmpeg = FFMPEG; | |
104 else $xml->ffmpeg = "/usr/bin/ffmpeg"; | |
105 | |
106 if(defined("TEMP_DATA" )) $xml->temp_data = TEMP_DATA; | |
107 else $xml->temp_data = "/tmp/__temp.ts"; | |
108 | |
109 if(defined("TEMP_XML")) $xml->temp_xml = TEMP_XML; | |
110 else $xml->temp_xml = "/tmp/__temp.xml"; | |
111 | |
112 // index.phpт戎荐絎 | |
113 // 茵腓冴腟茵激鐚鐚 | |
32
01a8fdc0cebb
testing: Web base setting page.
Sushi-k <epgrec@park.mda.or.jp>
parents:
31
diff
changeset
|
114 $xml->program_length = 8; |
30 | 115 // 1絮綛 |
32
01a8fdc0cebb
testing: Web base setting page.
Sushi-k <epgrec@park.mda.or.jp>
parents:
31
diff
changeset
|
116 $xml->ch_set_width = 150; |
30 | 117 // 1蕭 |
32
01a8fdc0cebb
testing: Web base setting page.
Sushi-k <epgrec@park.mda.or.jp>
parents:
31
diff
changeset
|
118 $xml->height_per_hour = 120; |
30 | 119 |
66
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
120 // 814ョ篁ラ菴遵荐絎 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
121 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
122 // 若若牙祉牙祉≪若 |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
123 $xml->autorec_mode = 0; |
3d6e7c606896
testing: auto record with mode
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
55
diff
changeset
|
124 |
131 | 125 // CS牙 |
126 $xml->cs_rec_flg = 0; | |
127 | |
30 | 128 $xml->save(); |
129 | |
130 return $xml; | |
131 } | |
132 } | |
133 | |
134 public function exists( $property ) { | |
135 return (int)count( $this->{$property} ); | |
136 } | |
137 | |
138 public function post() { | |
139 global $_POST; | |
140 | |
32
01a8fdc0cebb
testing: Web base setting page.
Sushi-k <epgrec@park.mda.or.jp>
parents:
31
diff
changeset
|
141 foreach( $_POST as $key => $value ) { |
30 | 142 |
143 if( $this->exists($key) ) { | |
144 $this->{$key} = trim($value); | |
145 } | |
146 } | |
147 } | |
148 | |
149 public function save() { | |
150 $this->asXML(INSTALL_PATH . self::CONFIG_XML); | |
151 } | |
152 } | |
80
cce6f88590fd
add: db table updater script.
Sushi-k <epgrec@park.mda.or.jp>
parents:
69
diff
changeset
|
153 ?> |