Mercurial > epgrec.yaz
comparison Settings.class.php @ 159:66eabfc1b118
revoke all whitespace modifications
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 31 Mar 2010 06:42:51 +0900 |
parents | a18df712fc7e |
children |
comparison
equal
deleted
inserted
replaced
158:be39a7efcc87 | 159:66eabfc1b118 |
---|---|
1 <?php | 1 <?php |
2 include_once('config.php'); | 2 include_once('config.php'); |
3 | 3 |
4 class Settings extends SimpleXMLElement { | 4 class Settings extends SimpleXMLElement { |
5 | 5 |
6 const CONFIG_XML = "/settings/config.xml"; | 6 const CONFIG_XML = "/settings/config.xml"; |
7 | 7 |
8 public static function factory() { | 8 public static function factory() { |
9 | 9 |
10 if( file_exists( INSTALL_PATH . self::CONFIG_XML ) ) { | 10 if( file_exists( INSTALL_PATH . self::CONFIG_XML ) ) { |
11 $xmlfile = file_get_contents(INSTALL_PATH . self::CONFIG_XML); | 11 $xmlfile = file_get_contents(INSTALL_PATH . self::CONFIG_XML); |
12 $obj = new self($xmlfile); | 12 $obj = new self($xmlfile); |
13 | 13 |
14 // 8月14日以降に追加した設定項目の自動生成 | 14 // 8月14日以降に追加した設定項目の自動生成 |
15 | 15 |
16 // キーワード自動録画の録画モード | 16 // キーワード自動録画の録画モード |
17 if( $obj->exists("autorec_mode") == 0 ) { | 17 if( $obj->exists("autorec_mode") == 0 ) { |
18 $obj->autorec_mode = 0; | 18 $obj->autorec_mode = 0; |
19 $obj->save(); | 19 $obj->save(); |
20 } | 20 } |
27 } | 27 } |
28 else { | 28 else { |
29 // 初回起動 | 29 // 初回起動 |
30 $xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>'; | 30 $xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>'; |
31 $xml = new self($xmlfile); | 31 $xml = new self($xmlfile); |
32 | 32 |
33 // 旧config.phpを読み取って設定 | 33 // 旧config.phpを読み取って設定 |
34 if(defined("SPOOL") ) $xml->spool = SPOOL; | 34 if(defined("SPOOL") ) $xml->spool = SPOOL; |
35 else $xml->spool = "/video"; | 35 else $xml->spool = "/video"; |
36 | 36 |
37 if(defined("THUMBS") ) $xml->thumbs = THUMBS; | 37 if(defined("THUMBS") ) $xml->thumbs = THUMBS; |
38 else $xml->thumbs = "/thumbs"; | 38 else $xml->thumbs = "/thumbs"; |
39 | 39 |
40 if(defined("INSTALL_URL")) $xml->install_url = INSTALL_URL; | 40 if(defined("INSTALL_URL")) $xml->install_url = INSTALL_URL; |
41 else $xml->install_url = "http://localhost/epgrec"; | 41 else $xml->install_url = "http://localhost/epgrec"; |
42 | 42 |
43 if(defined("BS_TUNERS")) $xml->bs_tuners = BS_TUNERS; | 43 if(defined("BS_TUNERS")) $xml->bs_tuners = BS_TUNERS; |
44 else $xml->bs_tuners = 0; | 44 else $xml->bs_tuners = 0; |
45 | 45 |
46 if(defined("GR_TUNERS")) $xml->gr_tuners = GR_TUNERS; | 46 if(defined("GR_TUNERS")) $xml->gr_tuners = GR_TUNERS; |
47 else $xml->gr_tuners = 1; | 47 else $xml->gr_tuners = 1; |
48 | 48 |
49 if(defined("CS_REC_FLG")) $xml->cs_rec_flg = CS_REC_FLG; | 49 if(defined("CS_REC_FLG")) $xml->cs_rec_flg = CS_REC_FLG; |
50 else $xml->cs_rec_flg = 0; | 50 else $xml->cs_rec_flg = 0; |
51 | 51 |
52 if(defined("USE_KUROBON")) $xml->use_kurobon = USE_KUROBON ? 1 : 0; | 52 if(defined("USE_KUROBON")) $xml->use_kurobon = USE_KUROBON ? 1 : 0; |
53 else $xml->use_kurobon = 0; | 53 else $xml->use_kurobon = 0; |
54 | 54 |
55 if(defined("FORMER_TIME")) $xml->former_time = FORMER_TIME; | 55 if(defined("FORMER_TIME")) $xml->former_time = FORMER_TIME; |
56 else $xml->former_time = 20; | 56 else $xml->former_time = 20; |
57 | 57 |
58 if(defined("EXTRA_TIME")) $xml->extra_time = EXTRA_TIME; | 58 if(defined("EXTRA_TIME")) $xml->extra_time = EXTRA_TIME; |
59 else $xml->extra_time = 0; | 59 else $xml->extra_time = 0; |
60 | 60 |
61 if(defined("FORCE_CONT_REC")) $xml->force_cont_rec = FORCE_CONT_REC ? 1 : 0; | 61 if(defined("FORCE_CONT_REC")) $xml->force_cont_rec = FORCE_CONT_REC ? 1 : 0; |
62 else $xml->force_cont_rec = 0; | 62 else $xml->force_cont_rec = 0; |
63 | 63 |
64 if(defined("REC_SWITCH_TIME")) $xml->rec_switch_time = REC_SWITCH_TIME; | 64 if(defined("REC_SWITCH_TIME")) $xml->rec_switch_time = REC_SWITCH_TIME; |
65 else $xml->rec_switch_time = 5; | 65 else $xml->rec_switch_time = 5; |
66 | 66 |
67 if(defined("USE_THUMBS")) $xml->use_thumbs = USE_THUMBS ? 1 : 0; | 67 if(defined("USE_THUMBS")) $xml->use_thumbs = USE_THUMBS ? 1 : 0; |
68 else $xml->use_thumbs = 0; | 68 else $xml->use_thumbs = 0; |
69 | 69 |
70 if(defined("MEDIATOMB_UPDATE")) $xml->mediatomb_update = MEDIATOMB_UPDATE ? 1 : 0; | 70 if(defined("MEDIATOMB_UPDATE")) $xml->mediatomb_update = MEDIATOMB_UPDATE ? 1 : 0; |
71 else $xml->mediatomb_update = 0; | 71 else $xml->mediatomb_update = 0; |
72 | 72 |
73 if(defined("FILENAME_FORMAT")) $xml->filename_format = FILENAME_FORMAT; | 73 if(defined("FILENAME_FORMAT")) $xml->filename_format = FILENAME_FORMAT; |
74 else $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%"; | 74 else $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%"; |
75 | 75 |
76 if(defined("DB_HOST")) $xml->db_host = DB_HOST; | 76 if(defined("DB_HOST")) $xml->db_host = DB_HOST; |
77 else $xml->db_host = "localhost"; | 77 else $xml->db_host = "localhost"; |
78 | 78 |
79 if(defined("DB_NAME")) $xml->db_name = DB_NAME; | 79 if(defined("DB_NAME")) $xml->db_name = DB_NAME; |
80 else $xml->db_name = "yourdbname"; | 80 else $xml->db_name = "yourdbname"; |
81 | 81 |
82 if(defined("DB_USER")) $xml->db_user = DB_USER; | 82 if(defined("DB_USER")) $xml->db_user = DB_USER; |
83 else $xml->db_user = "yourname"; | 83 else $xml->db_user = "yourname"; |
84 | 84 |
85 if(defined("DB_PASS")) $xml->db_pass = DB_PASS; | 85 if(defined("DB_PASS")) $xml->db_pass = DB_PASS; |
86 else $xml->db_pass = "yourpass"; | 86 else $xml->db_pass = "yourpass"; |
87 | 87 |
88 if(defined("TBL_PREFIX")) $xml->tbl_prefix = TBL_PREFIX; | 88 if(defined("TBL_PREFIX")) $xml->tbl_prefix = TBL_PREFIX; |
89 else $xml->tbl_prefix = "Recorder_"; | 89 else $xml->tbl_prefix = "Recorder_"; |
90 | 90 |
91 if(defined("EPGDUMP")) $xml->epgdump = EPGDUMP; | 91 if(defined("EPGDUMP")) $xml->epgdump = EPGDUMP; |
92 else $xml->epgdump = "/usr/local/bin/epgdump"; | 92 else $xml->epgdump = "/usr/local/bin/epgdump"; |
93 | 93 |
94 if(defined("AT")) $xml->at = AT; | 94 if(defined("AT")) $xml->at = AT; |
95 else $xml->at = "/usr/bin/at"; | 95 else $xml->at = "/usr/bin/at"; |
96 | 96 |
97 if(defined( "ATRM" )) $xml->atrm = ATRM; | 97 if(defined( "ATRM" )) $xml->atrm = ATRM; |
98 else $xml->atrm = "/usr/bin/atrm"; | 98 else $xml->atrm = "/usr/bin/atrm"; |
99 | 99 |
100 if(defined( "SLEEP" )) $xml->sleep = SLEEP; | 100 if(defined( "SLEEP" )) $xml->sleep = SLEEP; |
101 else $xml->sleep = "/bin/sleep"; | 101 else $xml->sleep = "/bin/sleep"; |
102 | 102 |
103 if(defined( "FFMPEG" )) $xml->ffmpeg = FFMPEG; | 103 if(defined( "FFMPEG" )) $xml->ffmpeg = FFMPEG; |
104 else $xml->ffmpeg = "/usr/bin/ffmpeg"; | 104 else $xml->ffmpeg = "/usr/bin/ffmpeg"; |
105 | 105 |
106 if(defined("TEMP_DATA" )) $xml->temp_data = TEMP_DATA; | 106 if(defined("TEMP_DATA" )) $xml->temp_data = TEMP_DATA; |
107 else $xml->temp_data = "/tmp/__temp.ts"; | 107 else $xml->temp_data = "/tmp/__temp.ts"; |
108 | 108 |
109 if(defined("TEMP_XML")) $xml->temp_xml = TEMP_XML; | 109 if(defined("TEMP_XML")) $xml->temp_xml = TEMP_XML; |
110 else $xml->temp_xml = "/tmp/__temp.xml"; | 110 else $xml->temp_xml = "/tmp/__temp.xml"; |
111 | 111 |
112 // index.phpで使う設定値 | 112 // index.phpで使う設定値 |
113 // 表示する番組表の長さ(時間) | 113 // 表示する番組表の長さ(時間) |
114 $xml->program_length = 8; | 114 $xml->program_length = 8; |
115 // 1局の幅 | 115 // 1局の幅 |
116 $xml->ch_set_width = 150; | 116 $xml->ch_set_width = 150; |
117 // 1分あたりの高さ | 117 // 1分あたりの高さ |
118 $xml->height_per_hour = 120; | 118 $xml->height_per_hour = 120; |
119 | 119 |
120 // 8月14日版以降に追加した設定項目 | 120 // 8月14日版以降に追加した設定項目 |
121 | 121 |
122 // キーワード自動録画の録画モード | 122 // キーワード自動録画の録画モード |
123 $xml->autorec_mode = 0; | 123 $xml->autorec_mode = 0; |
124 | 124 |
125 // CS録画 | 125 // CS録画 |
126 $xml->cs_rec_flg = 0; | 126 $xml->cs_rec_flg = 0; |
127 | 127 |
128 $xml->save(); | 128 $xml->save(); |
129 | 129 |
130 return $xml; | 130 return $xml; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 public function exists( $property ) { | 134 public function exists( $property ) { |
135 return (int)count( $this->{$property} ); | 135 return (int)count( $this->{$property} ); |
136 } | 136 } |
137 | 137 |
138 public function post() { | 138 public function post() { |
139 global $_POST; | 139 global $_POST; |
140 | 140 |
141 foreach( $_POST as $key => $value ) { | 141 foreach( $_POST as $key => $value ) { |
142 | 142 |
143 if( $this->exists($key) ) { | 143 if( $this->exists($key) ) { |
144 $this->{$key} = trim($value); | 144 $this->{$key} = trim($value); |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 public function save() { | 149 public function save() { |
150 $this->asXML(INSTALL_PATH . self::CONFIG_XML); | 150 $this->asXML(INSTALL_PATH . self::CONFIG_XML); |
151 } | 151 } |
152 } | 152 } |
153 ?> | 153 ?> |