# HG changeset patch # User Yoshiki Yazawa # Date 1269279451 -32400 # Node ID 4afd353b45079130e1c981f3845b350c9c1d678e # Parent d1681f891462c3283381bbfd4e0840bf160b71f3# Parent 2cb414518ccd8aa162a50b5dd79de81d7e757352 merged with upstream diff -r d1681f891462 -r 4afd353b4507 Keyword.class.php --- a/Keyword.class.php Sun Mar 21 05:51:19 2010 +0900 +++ b/Keyword.class.php Tue Mar 23 02:37:31 2010 +0900 @@ -4,6 +4,7 @@ include_once( INSTALL_PATH . "/reclib.php" ); include_once( INSTALL_PATH . "/Reservation.class.php" ); include_once( INSTALL_PATH . '/Settings.class.php' ); +include_once( INSTALL_PATH . '/recLog.inc.php' ); class Keyword extends DBRecord { @@ -99,6 +100,7 @@ try { if( $rec->autorec ) { Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); + reclog( "Keyword.class::キーワードID".$this->id."の録画が予約された"); usleep( 100 ); // あんまり時間を空けないのもどう? } } diff -r d1681f891462 -r 4afd353b4507 Reservation.class.php --- a/Reservation.class.php Sun Mar 21 05:51:19 2010 +0900 +++ b/Reservation.class.php Tue Mar 23 02:37:31 2010 +0900 @@ -43,7 +43,8 @@ $category_id = 0, // カテゴリID $program_id = 0, // 番組ID $autorec = 0, // 自動録画 - $mode = 0 // 録画モード + $mode = 0, // 録画モード + $dirty = 0 // ダーティフラグ ) { global $RECORD_MODE; $settings = Settings::factory(); @@ -130,7 +131,8 @@ $prev_endtime = $trecs[$i]->endtime; $prev_autorec = $trecs[$i]->autorec; $prev_mode = $trecs[$i]->mode; - + $prev_dirty = $trecs[$i]->dirty; + $prev_start_time = toTimestamp($prev_starttime); // 始まっていない予約? if( $prev_start_time > (time() + PADDING_TIME + $settings->former_time) ) { @@ -153,7 +155,8 @@ $prev_category_id, // カテゴリID $prev_program_id, // 番組ID $prev_autorec, // 自動録画 - $prev_mode ); + $prev_mode, + $prev_dirty ); } catch( Exception $e ) { throw new Exception( "重複予約を解消できません" ); diff -r d1681f891462 -r 4afd353b4507 cancelReservation.php --- a/cancelReservation.php Sun Mar 21 05:51:19 2010 +0900 +++ b/cancelReservation.php Tue Mar 23 02:37:31 2010 +0900 @@ -23,6 +23,7 @@ // ファイルを削除 if( file_exists( INSTALL_PATH."/".$settings->spool."/".$rec->path ) ) { @unlink(INSTALL_PATH."/".$settings->spool."/".$rec->path); + @unlink(INSTALL_PATH."/".$settings->thumbs."/".$rec->path.".jpg"); } } } diff -r d1681f891462 -r 4afd353b4507 changeReservation.php --- a/changeReservation.php Sun Mar 21 05:51:19 2010 +0900 +++ b/changeReservation.php Tue Mar 23 02:37:31 2010 +0900 @@ -27,6 +27,7 @@ if( isset( $_POST['title'] ) ) { $rec->title = trim( $_POST['title'] ); + $rec->dirty = 1; if( ($dbh !== false) && ($rec->complete == 1) ) { $title = trim( mysql_real_escape_string($_POST['title'])); $title .= "(".date("Y/m/d", toTimestamp($rec->starttime)).")"; @@ -37,6 +38,7 @@ if( isset( $_POST['description'] ) ) { $rec->description = trim( $_POST['description'] ); + $rec->dirty = 1; if( ($dbh !== false) && ($rec->complete == 1) ) { $desc = "dc:description=".trim( mysql_real_escape_string($_POST['description'])); $desc .= "&epgrec:id=".$reserve_id; @@ -51,4 +53,4 @@ exit("complete"); -?> +?> \ No newline at end of file diff -r d1681f891462 -r 4afd353b4507 config.php.sample --- a/config.php.sample Sun Mar 21 05:51:19 2010 +0900 +++ b/config.php.sample Tue Mar 23 02:37:31 2010 +0900 @@ -214,6 +214,16 @@ include_once( INSTALL_PATH."/settings/gr_channel.php" ); } +// +// settings/site_conf.phpがあればそれを優先する +// +if( file_exists( INSTALL_PATH."/settings/site_conf.php" ) ) { + unset($GR_CHANNEL_MAP); + unset($RECORD_MODE); + include_once( INSTALL_PATH."/settings/site_conf.php" ); +} + +// Deprecated // カスタマイズした設定をロードし、デフォルト設定をオーバライドする // unsetはカスタム設定ファイルの責任で行う if( file_exists( INSTALL_PATH."/settings/config_custom.php" ) ) { diff -r d1681f891462 -r 4afd353b4507 customReservation.php --- a/customReservation.php Sun Mar 21 05:51:19 2010 +0900 +++ b/customReservation.php Tue Mar 23 02:37:31 2010 +0900 @@ -60,7 +60,8 @@ $category_id, $program_id, 0, // 自動録画 - $mode // 録画モード + $mode, // 録画モード + 1 // ダーティフラグ ); } catch( Exception $e ) { diff -r d1681f891462 -r 4afd353b4507 envSetting.php --- a/envSetting.php Sun Mar 21 05:51:19 2010 +0900 +++ b/envSetting.php Tue Mar 23 02:37:31 2010 +0900 @@ -11,7 +11,7 @@ $smarty->assign( "install_path", INSTALL_PATH ); $smarty->assign( "post_to", "postsettings.php" ); $smarty->assign( "sitetitle", "環境設定設定" ); -$smarty->assign( "message", '設定せずに番組表に戻る/システム設定へ' ); +$smarty->assign( "message", '設定せずに番組表に戻る/システム設定へ/動作ログを見る' ); $smarty->display("envSetting.html"); -?> \ No newline at end of file +?> diff -r d1681f891462 -r 4afd353b4507 getepg.php --- a/getepg.php Sun Mar 21 05:51:19 2010 +0900 +++ b/getepg.php Tue Mar 23 02:37:31 2010 +0900 @@ -8,7 +8,8 @@ include_once( INSTALL_PATH . '/Keyword.class.php' ); include_once( INSTALL_PATH . '/Settings.class.php' ); include_once( INSTALL_PATH . '/storeProgram.inc.php' ); - + include_once( INSTALL_PATH . '/recLog.inc.php' ); + // 後方互換性 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); @@ -30,8 +31,13 @@ // 並列化が可能か執念深く調べる $use_para = false; $use_para = (function_exists( "pcntl_fork" ) && function_exists( "posix_setsid" ) && function_exists( "pcntl_signal" ) && function_exists("pcntl_setpriority")); - - + if( ! $use_para ) { + reclog("getepg:: 並列実行が行えないPHP環境です" ); + } + else { + reclog("getepg:: 並列実行を使用します" ); + } + $settings = Settings::factory(); $temp_xml_bs = $settings->temp_xml."_bs"; diff -r d1681f891462 -r 4afd353b4507 logViewer.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/logViewer.php Tue Mar 23 02:37:31 2010 +0900 @@ -0,0 +1,15 @@ +assign( "sitetitle" , "epgrec動作ログ" ); +$smarty->assign( "logs", $arr ); + +$smarty->display( "logTable.html" ); +?> \ No newline at end of file diff -r d1681f891462 -r 4afd353b4507 recomplete.php --- a/recomplete.php Sun Mar 21 05:51:19 2010 +0900 +++ b/recomplete.php Tue Mar 23 02:37:31 2010 +0900 @@ -5,6 +5,7 @@ include_once( $script_path . '/config.php'); include_once( INSTALL_PATH . "/DBRecord.class.php" ); include_once( INSTALL_PATH . "/Settings.class.php" ); +include_once( INSTALL_PATH . "/recLog.inc.php" ); $settings = Settings::factory(); @@ -12,10 +13,12 @@ try{ $rrec = new DBRecord( RESERVE_TBL, "id" , $reserve_id ); + $rrec->complete = '1'; if( file_exists( INSTALL_PATH .$settings->spool . "/". $rrec->path ) ) { // 予約完了 - $rrec->complete = '1'; + reclog( "recomplete:: 予約ID". $rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画が完了" ); + if( $settings->mediatomb_update == 1 ) { // ちょっと待った方が確実っぽい @exec("sync"); @@ -36,10 +39,13 @@ } else { // 予約失敗 + reclog( "recomplete:: 予約ID". $rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画に失敗した模様", E_ERROR ); $rrec->delete(); } } catch( exception $e ) { + reclog( "recomplete:: 予約テーブルのアクセスに失敗した模様", E_ERROR ); + reclog( "recomplete:: ".$e->getMessage()."" , E_ERROR ); exit( $e->getMessage() ); } diff -r d1681f891462 -r 4afd353b4507 storeProgram.inc.php --- a/storeProgram.inc.php Sun Mar 21 05:51:19 2010 +0900 +++ b/storeProgram.inc.php Tue Mar 23 02:37:31 2010 +0900 @@ -12,9 +12,9 @@ $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 ) "); foreach( $arr as $val ) $val->delete(); - // 8日以上前のログを消す + // 10日以上前のログを消す $arr = array(); - $arr = DBRecord::createRecords( LOG_TBL, "WHERE endtime < subdate( now(), 8 )" ); + $arr = DBRecord::createRecords( LOG_TBL, "WHERE logtime < subdate( now(), 10 )" ); 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."が作成されなかった模様", E_ERROR ); + reclog( "getepg:: 正常な".$xmlfile."が作成されなかった模様(放送間帯でないなら問題ありません)" ); return; // XMLが読み取れないなら何もしない } // channel抽出 @@ -89,7 +89,7 @@ $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" ); } catch( Exception $e ) { - reclog( "getepg::チャンネルレコードが発見できない", E_ERROR ); + reclog( "getepg::チャンネルレコード $channel_disc が発見できない", E_ERROR ); } if( $channel_rec == null ) continue; // あり得ないことが起きた if( $channel_rec->skip == 1 ) continue; // 受信しないチャンネル @@ -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 ) { - // 自動録画予約された番組は放映時間変更と同時にいったん削除する - 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 ) { + // 自動録画予約された番組は放映時間変更と同時にいったん削除する + 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() ); } } diff -r d1681f891462 -r 4afd353b4507 tableStruct.inc.php --- a/tableStruct.inc.php Sun Mar 21 05:51:19 2010 +0900 +++ b/tableStruct.inc.php Tue Mar 23 02:37:31 2010 +0900 @@ -21,6 +21,7 @@ "reserve_disc varchar(128) not null default 'none',". // 識別用hash "autorec integer not null default '0',". // キーワードID "mode integer not null default '0',". // 録画モード + "dirty boolean not null default '0',". // ダーティフラグ "index reserve_ch_idx (channel_disc),". // インデックス "index reserve_st_idx (starttime)". "" @@ -74,8 +75,8 @@ "category_id integer not null default '0',". // カテゴリID "use_regexp boolean not null default '0',". // 正規表現を使用するなら1 "autorec_mode integer not null default '0',". // 自動録画のモード02/23/2010追加 - "weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'".// 曜日、同追加 - ",prgtime enum ('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24') default '24'". // 時間 03/13/2010追加 + "weekofday enum ('0','1','2','3','4','5','6','7' ) not null default '7'".// 曜日、同追加 + ",prgtime enum ('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24') not null default '24'". // 時間 03/13/2010追加 "" ); @@ -87,4 +88,4 @@ "" ); -?> \ No newline at end of file +?> diff -r d1681f891462 -r 4afd353b4507 templates/logTable.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/logTable.html Tue Mar 23 02:37:31 2010 +0900 @@ -0,0 +1,74 @@ + + + + + +{$sitetitle} + + +{literal} + +{/literal} + + + + + +

{$sitetitle}

+ +
番組表に戻る
+ + + + + + + + +{foreach from=$logs item=log} + + + + + +{/foreach} + + diff -r d1681f891462 -r 4afd353b4507 upgrade_db.php --- a/upgrade_db.php Sun Mar 21 05:51:19 2010 +0900 +++ b/upgrade_db.php Tue Mar 23 02:37:31 2010 +0900 @@ -66,6 +66,13 @@ "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify mode integer not null default '0';", //録画モード ); + if( index_exists( $settings->tbl_prefix.RESERVE_TBL, "dirty", $dbh) ) { + echo "dirtyフィールドはすでに存在しているため作成しません\n"; + } + else { + array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.RESERVE_TBL." add dirty boolean not null default '0';" ); + } + if( multi_query( $sqlstrs, $dbh ) ) { echo "予約テーブルのアップデートに失敗\n"; } @@ -178,31 +185,35 @@ } if( column_exists( $settings->tbl_prefix.KEYWORD_TBL, "weekofday", $dbh ) ) { echo "weekofdayは存在しているので作成しません\n"; + array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify weekofday enum ('0','1','2','3','4','5','6','7' ) not null default '7'" ); } else { - array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'" ); + array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add weekofday enum ('0','1','2','3','4','5','6','7' ) not null default '7'" ); } if( column_exists( $settings->tbl_prefix.KEYWORD_TBL, "prgtime", $dbh ) ) { echo "prgtimeは存在しているので作成しません\n"; + array_push( $sqlstrs, + "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify prgtime enum ('0','1','2','3','4','5','6','7','8','9','10','11','12',". + "'13','14','15','16','17','18','19','20','21','22','23','24') not null default '24'" ); } else { array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add prgtime enum ('0','1','2','3','4','5','6','7','8','9','10','11','12',". - "'13','14','15','16','17','18','19','20','21','22','23','24') default '24'" ); + "'13','14','15','16','17','18','19','20','21','22','23','24') not null default '24'" ); } if( multi_query( $sqlstrs, $dbh ) ) { echo "キーワードテーブルのアップデートに失敗\n"; } - // ログテーブル + // ログテーブル新規作成 try { $log = new DBRecord( LOG_TBL ); $log->createTable( LOG_STRUCT ); } catch( Exception $e ) { - echo $e->message; + echo $e->getMessage(); echo "\n"; }
レベル日時内容
+ {if $log->level == 0}情報 + {elseif $log->level == 1}エラー + {/if} + {$log->logtime}{$log->message|escape}