Mercurial > epgrec.yaz
changeset 135:9c5e597ef6c6
mod: ???????
| author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
|---|---|
| date | Sat, 20 Mar 2010 23:59:01 +0900 |
| parents | 58791b90221b |
| children | 6754b6aa50cf |
| files | Keyword.class.php Reservation.class.php install/step3.php recLog.inc.php storeProgram.inc.php tableStruct.inc.php upgrade_db.php |
| diffstat | 7 files changed, 74 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Keyword.class.php Sat Mar 20 00:49:37 2010 +0900 +++ b/Keyword.class.php Sat Mar 20 23:59:01 2010 +0900 @@ -44,13 +44,13 @@ $options .= " AND ( CONCAT(title,' ',description) like '%".mysql_real_escape_string($keyword)."%'"; if( $f_zennum ) { - $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVN' ))."%'"; + $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVN',"UTF-8" ))."%'"; } if( $f_zenal ) { - $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVR' ))."%'"; + $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVR', "UTF-8" ))."%'"; } if( $f_zenal && $f_zennum ) { - $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN' ))."%'"; + $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN', "UTF-8" ))."%'"; } $options .= ") "; }
--- a/Reservation.class.php Sat Mar 20 00:49:37 2010 +0900 +++ b/Reservation.class.php Sat Mar 20 23:59:01 2010 +0900 @@ -3,6 +3,7 @@ include_once( INSTALL_PATH . "/DBRecord.class.php" ); include_once( INSTALL_PATH . "/reclib.php" ); include_once( INSTALL_PATH . "/Settings.class.php" ); +include_once( INSTALL_PATH . "/recLog.inc.php" ); // 予約クラス @@ -178,7 +179,6 @@ throw new Exception( "終わりつつある/終わっている番組です" ); } - // ここからファイル名生成 /* %TITLE% 番組タイトル @@ -300,6 +300,7 @@ } else { $rrec->delete(); + reclog( "Reservation::custom atの実行に失敗した模様", E_ERROR); throw new Exception("AT実行エラー"); } // job番号を取り出す @@ -313,11 +314,13 @@ if( $key !== false ) { if( is_numeric( $rarr[$key+1]) ) { $rrec->job = $rarr[$key+1]; + reclog( "Reservation::custom ジョブ番号".$rrec->job."に録画ジョブを登録"); return $rrec->job; // 成功 } } // エラー $rrec->delete(); + reclog( "Reservation::custom job番号の取得に失敗",E_ERROR ); throw new Exception( "job番号の取得に失敗" ); } catch( Exception $e ) { @@ -349,13 +352,16 @@ } if( ! $rec->complete ) { // 未実行の予約である - if( toTimestamp($rec->starttime) < (time() + PADDING_TIME + $settings->former_time) ) - throw new Exception("過去の録画予約です"); + if( toTimestamp($rec->starttime) < (time() + PADDING_TIME + $settings->former_time) ) { + reclog("Reservation::cancel 未実行の予約の取り消しが実行された", E_ERROR ); + } exec( $settings->atrm . " " . $rec->job ); + reclog("Reservation::cancel ジョブ番号".$rec->job."を削除"); } $rec->delete(); } catch( Exception $e ) { + reclog("Reservation::cancel 予約キャンセルでDB接続またはアクセスに失敗した模様", E_ERROR ); throw $e; } }
--- a/install/step3.php Sat Mar 20 00:49:37 2010 +0900 +++ b/install/step3.php Sat Mar 20 23:59:01 2010 +0900 @@ -41,6 +41,9 @@ $rec = new DBRecord( KEYWORD_TBL ); $rec->createTable( KEYWORD_STRUCT ); + + $rec = new DBRecord( LOG_TBL ); + $rec->createTable( LOG_STRUCT ); } catch( Exception $e ) { jdialog("テーブルの作成に失敗しました。データベースに権限がない等の理由が考えられます。", "step2.php" );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/recLog.inc.php Sat Mar 20 23:59:01 2010 +0900 @@ -0,0 +1,21 @@ +<?php + +define( "E_INFO" , 0 ); +define( "E_ERROR", 2 ); + + +function reclog( $message , $level = E_INFO ) { + + try { + $log = new DBRecord( LOG_TBL ); + + $log->logtime = date("Y-m-d H:i:s"); + $log->level = $level; + $log->message = $message; + } + catch( Exception $e ) { + // + } +} + +?>
--- a/storeProgram.inc.php Sat Mar 20 00:49:37 2010 +0900 +++ b/storeProgram.inc.php Sat Mar 20 23:59:01 2010 +0900 @@ -9,7 +9,12 @@ // 8日以上先のデータがあれば消す $arr = array(); - $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 )" ); + $arr = DBRecord::createRecords( PROGRAM_TBL, "WHERE starttime > adddate( now(), 8 ) "); + foreach( $arr as $val ) $val->delete(); + + // 8日以上前のログを消す + $arr = array(); + $arr = DBRecord::createRecords( LOG_TBL, "WHERE endtime < subdate( now(), 8 )" ); foreach( $arr as $val ) $val->delete(); } @@ -20,9 +25,10 @@ foreach( $arr as $val ) { try { $val->reservation(); + reclog( "getepg::キーワードID".$val->id."を予約"); } catch( Exception $e ) { - // 無視 + // 無視 } } } @@ -39,6 +45,7 @@ // XML parse $xml = @simplexml_load_file( $xmlfile ); if( $xml === false ) { + reclog( "getepg::".$xmlfile."が作成されなかった模様", E_ERROR ); return; // XMLが読み取れないなら何もしない } // channel抽出 @@ -64,7 +71,7 @@ } } catch( Exception $e ) { - // 無視 + reclog( "getepg::DBの接続またはチャンネルテーブルの書き込みに失敗", E_ERROR ); } } // channel 終了 @@ -82,7 +89,7 @@ $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" ); } catch( Exception $e ) { - // 無視 + reclog( "getepg::チャンネルレコードが発見できない", E_ERROR ); } if( $channel_rec == null ) continue; // あり得ないことが起きた if( $channel_rec->skip == 1 ) continue; // 受信しないチャンネル @@ -129,13 +136,15 @@ try { $reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id ); if( $reserve->autorec ) { + reclog( "getepg::録画ID".$reserve->id."は時間変更の可能性あり予約を取り消し"); Reservation::cancel( $reserve->id ); } } catch( Exception $e ) { - //無視 + // 無視 } // 番組削除 + reclog( "getepg::放送時間重複が発生した番組ID".$rec->id."を削除" ); $rec->delete(); } } @@ -161,9 +170,10 @@ } } catch(Exception $e) { + reclog( "getepg::DBの入出力に問題が生じた模様", E_ERROR ); exit( $e->getMessage() ); } } // Programme取得完了 } -?> \ No newline at end of file +?>
--- a/tableStruct.inc.php Sat Mar 20 00:49:37 2010 +0900 +++ b/tableStruct.inc.php Sat Mar 20 23:59:01 2010 +0900 @@ -79,4 +79,12 @@ "" ); +define( "LOG_STRUCT", + "id integer not null auto_increment primary key". // ID + ",logtime datetime not null default '1970-01-01 00:00:00'". // 記録日時 + ",level integer not null default '0'". // エラーレベル + ",message varchar(512) not null default ''". + "" +); + ?> \ No newline at end of file
--- a/upgrade_db.php Sat Mar 20 00:49:37 2010 +0900 +++ b/upgrade_db.php Sat Mar 20 23:59:01 2010 +0900 @@ -4,7 +4,8 @@ chdir( $script_path ); include_once($script_path . '/config.php'); include_once(INSTALL_PATH . '/Settings.class.php' ); - +include_once(INSTALL_PATH . '/DBRecord.class.php' ); +include_once(INSTALL_PATH . '/tableStruct.inc.php' ); // mysqli::multi_queryは動作がいまいちなので使わない @@ -193,6 +194,18 @@ if( multi_query( $sqlstrs, $dbh ) ) { echo "キーワードテーブルのアップデートに失敗\n"; } + + // ログテーブル + + try { + $log = new DBRecord( LOG_TBL ); + $log->createTable( LOG_STRUCT ); + } + catch( Exception $e ) { + echo $e->message; + echo "\n"; + } + } else exit( "DBの接続に失敗\n" );
