comparison storeProgram.inc.php @ 142:481e789605e3

mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
author epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
date Sun, 21 Mar 2010 16:42:58 +0900
parents 9c5e597ef6c6
children fa1b0995992b
comparison
equal deleted inserted replaced
136:6754b6aa50cf 142:481e789605e3
10 // 8ヤ札筝若帥井 10 // 8ヤ札筝若帥井
11 $arr = array(); 11 $arr = array();
12 $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 ) "); 12 $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 ) ");
13 foreach( $arr as $val ) $val->delete(); 13 foreach( $arr as $val ) $val->delete();
14 14
15 // 8ヤ札筝違羔 15 // 30ヤ札筝違羔
16 $arr = array(); 16 $arr = array();
17 $arr = DBRecord::createRecords( LOG_TBL, "WHERE endtime < subdate( now(), 8 )" ); 17 $arr = DBRecord::createRecords( LOG_TBL, "WHERE endtime < subdate( now(), 30 )" );
18 foreach( $arr as $val ) $val->delete(); 18 foreach( $arr as $val ) $val->delete();
19 } 19 }
20 20
21 function doKeywordReservation() { 21 function doKeywordReservation() {
22 // 若若牙私膣 22 // 若若牙私膣
23 $arr = array(); 23 $arr = array();
24 $arr = Keyword::createKeywords(); 24 $arr = Keyword::createKeywords();
25 foreach( $arr as $val ) { 25 foreach( $arr as $val ) {
26 try { 26 try {
27 $val->reservation(); 27 $val->reservation();
28 reclog( "getepg::若若ID".$val->id."篋膣"); 28 reclog( "getepg::若若ID".$val->id."牙祉篋膣");
29 } 29 }
30 catch( Exception $e ) { 30 catch( Exception $e ) {
31 // ∴ 31 // ∴
32 } 32 }
33 } 33 }
43 else if( $type == "CS") $map = $CS_CHANNEL_MAP; 43 else if( $type == "CS") $map = $CS_CHANNEL_MAP;
44 44
45 // XML parse 45 // XML parse
46 $xml = @simplexml_load_file( $xmlfile ); 46 $xml = @simplexml_load_file( $xmlfile );
47 if( $xml === false ) { 47 if( $xml === false ) {
48 reclog( "getepg::".$xmlfile."篏c罔≧", E_ERROR ); 48 reclog( "getepg:: 罩e幻".$xmlfile."篏c罔≧(冗絽с馹障)" );
49 return; // XML茯水篏 49 return; // XML茯水篏
50 } 50 }
51 // channel遵 51 // channel遵
52 foreach( $xml->channel as $ch ) { 52 foreach( $xml->channel as $ch ) {
53 $disc = $ch['id']; 53 $disc = $ch['id'];
87 87
88 try { 88 try {
89 $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" ); 89 $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" );
90 } 90 }
91 catch( Exception $e ) { 91 catch( Exception $e ) {
92 reclog( "getepg::c潟潟若肴с", E_ERROR ); 92 reclog( "getepg::c潟潟若 $channel_disc 肴с", E_ERROR );
93 } 93 }
94 if( $channel_rec == null ) continue; // 緇莎激 94 if( $channel_rec == null ) continue; // 緇莎激
95 if( $channel_rec->skip == 1 ) continue; // 篆<c潟 95 if( $channel_rec->skip == 1 ) continue; // 篆<c潟
96 96
97 $starttime = str_replace(" +0900", '', $program['start'] ); 97 $starttime = str_replace(" +0900", '', $program['start'] );
104 if( $cat['lang'] == "ja_JP" ) $cat_ja = $cat; 104 if( $cat['lang'] == "ja_JP" ) $cat_ja = $cat;
105 if( $cat['lang'] == "en" ) $cat_en = $cat; 105 if( $cat['lang'] == "en" ) $cat_en = $cat;
106 } 106 }
107 $program_disc = md5( $channel_disc . $starttime . $endtime ); 107 $program_disc = md5( $channel_disc . $starttime . $endtime );
108 // printf( "%s %s %s %s %s %s %s \n", $program_disc, $channel, $starttime, $endtime, $title, $desc, $cat_ja ); 108 // printf( "%s %s %s %s %s %s %s \n", $program_disc, $channel, $starttime, $endtime, $title, $desc, $cat_ja );
109 try { 109
110 // 眼 110 // 眼脂
111 $category_disc = md5( $cat_ja . $cat_en ); 111
112 $num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" ); 112 $cat_rec = null;
113 $cat_rec = null; 113 try {
114 if( $num == 0 ) { 114 // 眼
115 // 域眼菴遵 115 $category_disc = md5( $cat_ja . $cat_en );
116 $cat_rec = new DBRecord( CATEGORY_TBL ); 116 $num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" );
117 $cat_rec->name_jp = $cat_ja; 117 if( $num == 0 ) {
118 $cat_rec->name_en = $cat_en; 118 // 域眼菴遵
119 $cat_rec->category_disc = $category_disc; 119 $cat_rec = new DBRecord( CATEGORY_TBL );
120 } 120 $cat_rec->name_jp = $cat_ja;
121 else 121 $cat_rec->name_en = $cat_en;
122 $cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc ); 122 $cat_rec->category_disc = $category_disc;
123 // 123 reclog("getepg:: 域眼".$cat_ja."菴遵" );
124 $num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '".$program_disc."'" ); 124 }
125 if( $num == 0 ) { 125 else
126 // 域腟 126 $cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc );
127 // 茲с 絽腟 127 }
128 $options = "WHERE channel_disc = '".$channel_disc."' ". 128 catch( Exception $e ) {
129 "AND starttime < '". $endtime ."' AND endtime > '".$starttime."'"; 129 reclog("getepg:: 眼若≪祉鴻紊掩罔≧", E_ERROR );
130 $battings = DBRecord::countRecords(PROGRAM_TBL, $options ); 130 reclog("getepg:: ".$e->getMessage()."" ,E_ERROR );
131 if( $battings > 0 ) { 131 exit( $e->getMessage() );
132 // 茲榊鐚丈紊 132 }
133 $records = DBRecord::createRecords(PROGRAM_TBL, $options ); 133
134 foreach( $records as $rec ) { 134 // 違脂
135 // 牙私膣腟丈紊眼cゃ 135
136 try { 136 try {
137 $reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id ); 137 //
138 if( $reserve->autorec ) { 138 $num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '".$program_disc."'" );
139 reclog( "getepg::牙ID".$reserve->id."紊眼醇с篋膣羔"); 139 if( $num == 0 ) {
140 Reservation::cancel( $reserve->id ); 140 // 域腟
141 // 茲с 絽腟
142 $options = "WHERE channel_disc = '".$channel_disc."' ".
143 "AND starttime < '". $endtime ."' AND endtime > '".$starttime."'";
144 $battings = DBRecord::countRecords(PROGRAM_TBL, $options );
145 if( $battings > 0 ) {
146 // 茲榊鐚丈紊
147 $records = DBRecord::createRecords(PROGRAM_TBL, $options);
148 foreach( $records as $rec ) {
149 // 牙私膣腟丈紊眼cゃ
150 try {
151 $reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id );
152 if( $reserve->autorec ) {
153 reclog( "getepg::牙ID".$reserve->id.":".$reserve->type.$reserve->channel.$reserve->title."紊眼醇с篋膣羔" );
154 Reservation::cancel( $reserve->id );
155 }
141 } 156 }
157 catch( Exception $e ) {
158 // ∴
159 }
160 // 腟
161 reclog( "getepg::冗茲榊腟ID".$rec->id." ".$rec->type.$rec->channel.$rec->title."" );
162 $rec->delete();
142 } 163 }
143 catch( Exception $e ) { 164 }
144 // ∴ 165 // //
166 $rec = new DBRecord( PROGRAM_TBL );
167 $rec->channel_disc = $channel_disc;
168 $rec->channel_id = $channel_rec->id;
169 $rec->type = $type;
170 $rec->channel = $channel_rec->channel;
171 $rec->title = $title;
172 $rec->description = $desc;
173 $rec->category_id = $cat_rec->id;
174 $rec->starttime = $starttime;
175 $rec->endtime = $endtime;
176 $rec->program_disc = $program_disc;
177 }
178 else {
179 // 腟絎号贋
180 $rec = new DBRecord( PROGRAM_TBL, "program_disc", $program_disc );
181 $rec->title = $title;
182 $rec->description = $desc;
183 $rec->category_id = $cat_rec->id;
184
185 try {
186 $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id );
187 if( $reserve->dirty == 0 ) {
188 $reserve->title = $title;
189 $reserve->description = $desc;
190 reclog( "getepg:: 篋膣ID".$reserve->id."EPG宴贋違" );
145 } 191 }
146 // 腟
147 reclog( "getepg::冗茲榊腟ID".$rec->id."" );
148 $rec->delete();
149 } 192 }
150 } 193 catch( Exception $e ) {
151 // // 194 // ∴
152 $rec = new DBRecord( PROGRAM_TBL ); 195 }
153 $rec->channel_disc = $channel_disc; 196 }
154 $rec->channel_id = $channel_rec->id;
155 $rec->type = $type;
156 $rec->channel = $channel_rec->channel;
157 $rec->title = $title;
158 $rec->description = $desc;
159 $rec->category_id = $cat_rec->id;
160 $rec->starttime = $starttime;
161 $rec->endtime = $endtime;
162 $rec->program_disc = $program_disc;
163 }
164 else {
165 // 腟絎号贋
166 $rec = new DBRecord( PROGRAM_TBL, "program_disc", $program_disc );
167 $rec->title = $title;
168 $rec->description = $desc;
169 $rec->category_id = $cat_rec->id;
170 }
171 } 197 }
172 catch(Exception $e) { 198 catch(Exception $e) {
173 reclog( "getepg::DBュ阪馹罔≧", E_ERROR ); 199 reclog( "getepg:: 違若馹罔≧", E_ERROR );
200 reclog( "getepg:: ".$e->getMessage()."" , E_ERROR);
174 exit( $e->getMessage() ); 201 exit( $e->getMessage() );
175 } 202 }
176 } 203 }
177 // Programme緇絎篋 204 // Programme緇絎篋
178 } 205 }