# HG changeset patch # User Yoshiki Yazawa # Date 1267565062 -32400 # Node ID f7b6ae03a2a71b70ed178ddbf31faec049a43eb7 # Parent ee348c378f2de213e49699eee6d30c2cda3095e0 removed trailing whitespace diff -r ee348c378f2d -r f7b6ae03a2a7 storeProgram.php --- a/storeProgram.php Wed Mar 03 05:12:57 2010 +0900 +++ b/storeProgram.php Wed Mar 03 06:24:22 2010 +0900 @@ -3,8 +3,8 @@ $type = $argv[1]; // BS CS GR $file = $argv[2]; // XMLファイル - - + + // SIGTERMシグナル function handler( $signo = 0 ) { global $file; @@ -13,7 +13,7 @@ } exit(); } - + // デーモン化 function daemon() { if( pcntl_fork() != 0 ) @@ -23,37 +23,37 @@ exit; pcntl_signal(SIGTERM, "handler"); } - - + + // デーモン化 daemon(); // プライオリティ低に pcntl_setpriority(20); - + include_once('config.php'); include_once( INSTALL_PATH . '/DBRecord.class.php' ); include_once( INSTALL_PATH . '/Reservation.class.php' ); include_once( INSTALL_PATH . '/Keyword.class.php' ); include_once( INSTALL_PATH . '/Settings.class.php' ); - + $settings = Settings::factory(); - + if( file_exists( $file ) ) { storeProgram( $type, $file ); @unlink( $file ); } - + // 不要なプログラムの削除 // 8日以上前のプログラムを消す $arr = array(); $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE endtime < subdate( now(), 8 )" ); foreach( $arr as $val ) $val->delete(); - + // 8日以上先のデータがあれば消す $arr = array(); $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 )" ); foreach( $arr as $val ) $val->delete(); - + // キーワード自動録画予約 $arr = array(); $arr = Keyword::createKeywords(); @@ -66,7 +66,7 @@ } } exit(); - + function storeProgram( $type, $xmlfile ) { global $BS_CHANNEL_MAP, $GR_CHANNEL_MAP, $CS_CHANNEL_MAP; // チャンネルマップファイルの準備 @@ -74,7 +74,7 @@ if( $type == "BS" ) $map = $BS_CHANNEL_MAP; else if( $type == "GR") $map = $GR_CHANNEL_MAP; else if( $type == "CS") $map = $CS_CHANNEL_MAP; - + // XML parse $xml = @simplexml_load_file( $xmlfile ); if( $xml === false ) { @@ -107,13 +107,13 @@ } } // channel 終了 - + // programme 取得 - + foreach( $xml->programme as $program ) { - $channel_disc = $program['channel']; + $channel_disc = $program['channel']; if( ! array_key_exists( "$channel_disc", $map ) ) continue; - + $channel = $map["$channel_disc"]; $starttime = str_replace(" +0900", '', $program['start'] ); $endtime = str_replace( " +0900", '', $program['stop'] ); @@ -194,4 +194,4 @@ } } } -?> \ No newline at end of file +?>