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