$category_id = 0, // カテゴリID
$program_id = 0, // 番組ID
$autorec = 0, // 自動録画
- $mode = 0 // 録画モード
+ $mode = 0, // 録画モード
+ $dirty = 0 // ダーティフラグ
) {
global $RECORD_MODE;
$settings = Settings::factory();
$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);
// 始まっていない予約?
$prev_category_id, // カテゴリID
$prev_program_id, // 番組ID
$prev_autorec, // 自動録画
- $prev_mode );
+ $prev_mode,
+ $prev_dirty );
}
catch( Exception $e ) {
throw new Exception( "重複予約を解消できません" );
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)).")";
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;
exit("complete");
-?>
+?>
\ No newline at end of file
$category_id,
$program_id,
0, // 自動録画
- $mode // 録画モード
+ $mode, // 録画モード
+ 1 // ダーティフラグ
);
}
catch( Exception $e ) {
$smarty->assign( "install_path", INSTALL_PATH );
$smarty->assign( "post_to", "postsettings.php" );
$smarty->assign( "sitetitle", "環境設定設定" );
-$smarty->assign( "message", '<a href="index.php">設定せずに番組表に戻る</a>/<a href="systemSetting.php">システム設定へ</a>' );
+$smarty->assign( "message", '<a href="index.php">設定せずに番組表に戻る</a>/<a href="systemSetting.php">システム設定へ</a>/<a href="logViewer.php">動作ログを見る</a>' );
$smarty->display("envSetting.html");
-?>
\ No newline at end of file
+?>
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" );
// 並列化が可能か執念深く調べる
$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();
--- /dev/null
+<?php
+include_once('config.php');
+include_once( INSTALL_PATH . '/DBRecord.class.php' );
+include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
+
+
+$arr = DBRecord::createRecords( LOG_TBL, " ORDER BY logtime DESC" );
+
+$smarty = new Smarty();
+
+$smarty->assign( "sitetitle" , "epgrec動作ログ" );
+$smarty->assign( "logs", $arr );
+
+$smarty->display( "logTable.html" );
+?>
\ No newline at end of file
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();
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");
}
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() );
}
$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();
}
foreach( $arr as $val ) {
try {
$val->reservation();
- reclog( "getepg::ã\82ã\83¼ã\83¯ã\83¼ã\83\89ID".$val->id."ã\82\92äº\88ç´\84");
+ reclog( "getepg::ã\82ã\83¼ã\83¯ã\83¼ã\83\89ID".$val->id."ã\81®é\8c²ç\94»ã\81\8cäº\88ç´\84ã\81\95ã\82\8cã\81\9f");
}
catch( Exception $e ) {
// 無視
// XML parse
$xml = @simplexml_load_file( $xmlfile );
if( $xml === false ) {
- reclog( "getepg::".$xmlfile."が作成されなかった模様", E_ERROR );
+ reclog( "getepg:: 正常な".$xmlfile."が作成されなかった模様(放送間帯でないなら問題ありません)" );
return; // XMLが読み取れないなら何もしない
}
// channel抽出
$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; // 受信しないチャンネル
}
$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 ) {
+ // 無視
+ }
+ // 番組削除
+ reclog( "getepg::放送時間重複が発生した番組ID".$rec->id." ".$rec->type.$rec->channel.$rec->title."を削除" );
+ $rec->delete();
}
- 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;
+
+ 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情報が更新された" );
}
- // 番組削除
- reclog( "getepg::放送時間重複が発生した番組ID".$rec->id."を削除" );
- $rec->delete();
+ }
+ 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() );
}
}
"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)".
""
"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追加
""
);
""
);
-?>
\ No newline at end of file
+?>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>{$sitetitle}</title>
+<meta http-equiv="Content-Style-Type" content="text/css">
+
+{literal}
+<style type="text/css">
+<!--
+body {padding:4px;margin:0;font-size:10pt;}
+a {text-decoration:none;}
+
+table#log_table {
+ width: 800px;
+ border: 1px #BBB solid;
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+table#log_table th {
+ padding: 5px;
+ border: #E3E3E3 solid;
+ border-width: 0 0 1px 1px;
+ background: #BBB;
+ font-weight: bold;
+ line-height: 120%;
+ text-align: center;
+}
+table#log_table td {
+ padding: 5px;
+ border: 1px #BBB solid;
+ border-width: 0 0 1px 1px;
+ text-align: center;
+}
+
+table#log_table td.errorlevel0 {background-color: #FFFFFF;}
+table#log_table td.errorlevel1 {background-color: red;}
+
+
+-->
+</style>
+{/literal}
+
+</head>
+
+<body>
+
+<h2>{$sitetitle}</h2>
+
+<div><a href="index.php">番組表に戻る</a></div>
+
+<table id="log_table">
+ <tr>
+ <th>レベル</th>
+ <th>日時</th>
+ <th>内容</th>
+ </tr>
+
+{foreach from=$logs item=log}
+ <tr>
+ <td class="errorlevel{$log->level}">
+ {if $log->level == 0}情報
+ {elseif $log->level == 1}エラー
+ {/if}
+ </td>
+ <td>{$log->logtime}</td>
+ <td>{$log->message|escape}</td>
+ </tr>
+{/foreach}
+</body>
+</html>
"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";
}
}
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";
}