diff 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
line wrap: on
line diff
--- a/storeProgram.inc.php	Sun Mar 21 00:00:58 2010 +0900
+++ b/storeProgram.inc.php	Sun Mar 21 16:42:58 2010 +0900
@@ -12,9 +12,9 @@
 	$arr = DBRecord::createRecords(  PROGRAM_TBL, "WHERE starttime  > adddate( now(), 8 ) ");
 	foreach( $arr as $val ) $val->delete();
 
-	// 8ヤ札筝違羔
+	// 30ヤ札筝違羔
 	$arr = array();
-	$arr = DBRecord::createRecords(  LOG_TBL, "WHERE endtime < subdate( now(), 8 )" );
+	$arr = DBRecord::createRecords(  LOG_TBL, "WHERE endtime < subdate( now(), 30 )" );
 	foreach( $arr as $val ) $val->delete();
 }
 
@@ -25,7 +25,7 @@
 	foreach( $arr as $val ) {
 		try {
 			$val->reservation();
-			reclog( "getepg::若若ID".$val->id."篋膣");
+			reclog( "getepg::若若ID".$val->id."牙祉篋膣");
 		}
 		catch( Exception $e ) {
 			// ∴
@@ -45,7 +45,7 @@
 	// XML parse
   	$xml = @simplexml_load_file( $xmlfile );
 	if( $xml === false ) {
-		reclog( "getepg::".$xmlfile."篏c罔≧", E_ERROR );
+		reclog( "getepg:: 罩e幻".$xmlfile."篏c罔≧(冗絽с馹障)" );
 		return;	// XML茯水篏
 	}
 	// channel遵
@@ -89,7 +89,7 @@
 			$channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" );
 		}
 		catch( Exception $e ) {
-			reclog( "getepg::c潟潟若肴с", E_ERROR );
+			reclog( "getepg::c潟潟若 $channel_disc 肴с", E_ERROR );
 		}
 		if( $channel_rec == null ) continue;	// 緇莎激
 		if( $channel_rec->skip == 1 ) continue;	// 篆<c潟
@@ -106,71 +106,98 @@
 		}
 		$program_disc = md5( $channel_disc . $starttime . $endtime );
 		// printf( "%s %s %s %s %s %s %s \n", $program_disc, $channel, $starttime, $endtime, $title, $desc, $cat_ja );
+		
+		// 眼脂
+		
+		$cat_rec = null;
 		try {
-		 // 眼
-		 $category_disc = md5( $cat_ja . $cat_en );
-		 $num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" );
-		 $cat_rec = null;
-		 if( $num == 0 ) {
-			// 域眼菴遵
-			$cat_rec = new DBRecord( CATEGORY_TBL );
-			$cat_rec->name_jp = $cat_ja;
-			$cat_rec->name_en = $cat_en;
-		 	$cat_rec->category_disc = $category_disc;
-		 }
-		 else
-			$cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc );
-		 //
-		 $num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '".$program_disc."'" );
-		 if( $num == 0 ) {
-			// 域腟
-			// 茲с 絽腟
-			$options = "WHERE channel_disc = '".$channel_disc."' ".
-				"AND starttime < '". $endtime ."' AND endtime > '".$starttime."'";
-			$battings = DBRecord::countRecords(PROGRAM_TBL, $options );
-			if( $battings > 0 ) {
-				// 茲榊鐚丈紊
-				$records = DBRecord::createRecords(PROGRAM_TBL, $options );
-				foreach( $records as $rec ) {
-					// 牙私膣腟丈紊眼cゃ
-					try {
-						$reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id );
-						if( $reserve->autorec ) {
-							reclog( "getepg::牙ID".$reserve->id."紊眼醇с篋膣羔");
-							Reservation::cancel( $reserve->id );
+			// 眼
+			$category_disc = md5( $cat_ja . $cat_en );
+			$num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" );
+			if( $num == 0 ) {
+				// 域眼菴遵
+				$cat_rec = new DBRecord( CATEGORY_TBL );
+				$cat_rec->name_jp = $cat_ja;
+				$cat_rec->name_en = $cat_en;
+				$cat_rec->category_disc = $category_disc;
+				reclog("getepg:: 域眼".$cat_ja."菴遵" );
+			}
+			else
+				$cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc );
+		}
+		catch( Exception $e ) {
+			reclog("getepg:: 眼若≪祉鴻紊掩罔≧", E_ERROR );
+			reclog("getepg:: ".$e->getMessage()."" ,E_ERROR );
+			exit( $e->getMessage() );
+		}
+		
+		// 違脂
+		
+		try {
+			//
+			$num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '".$program_disc."'" );
+			if( $num == 0 ) {
+				// 域腟
+				// 茲с 絽腟
+				$options = "WHERE channel_disc = '".$channel_disc."' ".
+					"AND starttime < '". $endtime ."' AND endtime > '".$starttime."'";
+				$battings = DBRecord::countRecords(PROGRAM_TBL, $options );
+				if( $battings > 0 ) {
+					// 茲榊鐚丈紊
+					$records = DBRecord::createRecords(PROGRAM_TBL, $options);
+					foreach( $records as $rec ) {
+						// 牙私膣腟丈紊眼cゃ
+						try {
+							$reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id );
+							if( $reserve->autorec ) {
+								reclog( "getepg::牙ID".$reserve->id.":".$reserve->type.$reserve->channel.$reserve->title."紊眼醇с篋膣羔" );
+								Reservation::cancel( $reserve->id );
+							}
 						}
-					}
-					catch( Exception $e ) {
-						// ∴
+						catch( Exception $e ) {
+							// ∴
+						}
+						// 腟
+						reclog( "getepg::冗茲榊腟ID".$rec->id." ".$rec->type.$rec->channel.$rec->title."" );
+						$rec->delete();
 					}
-					// 腟
-					reclog( "getepg::冗茲榊腟ID".$rec->id."" );
-					$rec->delete();
+				}
+				// //
+				$rec = new DBRecord( PROGRAM_TBL );
+				$rec->channel_disc = $channel_disc;
+				$rec->channel_id = $channel_rec->id;
+				$rec->type = $type;
+				$rec->channel = $channel_rec->channel;
+				$rec->title = $title;
+				$rec->description = $desc;
+				$rec->category_id = $cat_rec->id;
+				$rec->starttime = $starttime;
+				$rec->endtime = $endtime;
+				$rec->program_disc = $program_disc;
+			}
+			else {
+				// 腟絎号贋
+				$rec = new DBRecord( PROGRAM_TBL, "program_disc", $program_disc );
+				$rec->title = $title;
+				$rec->description = $desc;
+				$rec->category_id = $cat_rec->id;
+				
+				try {
+					$reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id );
+					if( $reserve->dirty == 0 ) {
+						$reserve->title = $title;
+						$reserve->description = $desc;
+						reclog( "getepg:: 篋膣ID".$reserve->id."EPG宴贋違" );
+					}
+				}
+				catch( Exception $e ) {
+					// ∴
 				}
 			}
-			// //
-			$rec = new DBRecord( PROGRAM_TBL );
-			$rec->channel_disc = $channel_disc;
-			$rec->channel_id = $channel_rec->id;
-			$rec->type = $type;
-			$rec->channel = $channel_rec->channel;
-			$rec->title = $title;
-			$rec->description = $desc;
-			$rec->category_id = $cat_rec->id;
-			$rec->starttime = $starttime;
-			$rec->endtime = $endtime;
-			$rec->program_disc = $program_disc;
-		 }
-		 else {
-			// 腟絎号贋
-			$rec = new DBRecord( PROGRAM_TBL, "program_disc", $program_disc );
-			$rec->title = $title;
-		 	$rec->description = $desc;
-			$rec->category_id = $cat_rec->id;
-		 }
 		}
 		catch(Exception $e) {
-			reclog( "getepg::DBュ阪馹罔≧", E_ERROR );
+			reclog( "getepg:: 違若馹罔≧", E_ERROR );
+			reclog( "getepg:: ".$e->getMessage()."" , E_ERROR);
 			exit( $e->getMessage() );
 		}
 	}