Mercurial > epgrec.yaz
changeset 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 | 6754b6aa50cf |
children | 42f6eb738567 |
files | Reservation.class.php changeReservation.php customReservation.php envSetting.php getepg.php logViewer.php recomplete.php storeProgram.inc.php tableStruct.inc.php templates/logTable.html upgrade_db.php |
diffstat | 11 files changed, 224 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/Reservation.class.php Sun Mar 21 00:00:58 2010 +0900 +++ b/Reservation.class.php Sun Mar 21 16:42:58 2010 +0900 @@ -43,7 +43,8 @@ $category_id = 0, // 眼ID $program_id = 0, // 腟ID $autorec = 0, // 牙 - $mode = 0 // 牙祉≪若 + $mode = 0, // 牙祉≪若 + $dirty = 0 // 若c ) { global $RECORD_MODE; $settings = Settings::factory(); @@ -130,6 +131,7 @@ $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); // 紮障c篋膣鐚 @@ -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( "茲篋膣茹fс障" );
--- a/changeReservation.php Sun Mar 21 00:00:58 2010 +0900 +++ b/changeReservation.php Sun Mar 21 16:42:58 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
--- a/customReservation.php Sun Mar 21 00:00:58 2010 +0900 +++ b/customReservation.php Sun Mar 21 16:42:58 2010 +0900 @@ -60,7 +60,8 @@ $category_id, $program_id, 0, // 牙 - $mode // 牙祉≪若 + $mode, // 牙祉≪若 + 1 // 若c ); } catch( Exception $e ) {
--- a/envSetting.php Sun Mar 21 00:00:58 2010 +0900 +++ b/envSetting.php Sun Mar 21 16:42:58 2010 +0900 @@ -11,7 +11,7 @@ $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 +?>
--- a/getepg.php Sun Mar 21 00:00:58 2010 +0900 +++ b/getepg.php Sun Mar 21 16:42:58 2010 +0900 @@ -8,6 +8,7 @@ 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" ); @@ -30,7 +31,12 @@ // 筝純桁慎羞宴顄帥鴻 $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 Thu Jan 01 00:00:00 1970 +0000 +++ b/logViewer.php Sun Mar 21 16:42:58 2010 +0900 @@ -0,0 +1,15 @@ +<?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
--- a/recomplete.php Sun Mar 21 00:00:58 2010 +0900 +++ b/recomplete.php Sun Mar 21 16:42:58 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 ) { // <c緇c鴻腆阪c純 @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() ); }
--- 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() ); } }
--- a/tableStruct.inc.php Sun Mar 21 00:00:58 2010 +0900 +++ b/tableStruct.inc.php Sun Mar 21 16:42:58 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',". // 若c "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',". // 罩h頫憗篏睡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 +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/logTable.html Sun Mar 21 16:42:58 2010 +0900 @@ -0,0 +1,74 @@ +<!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>
--- a/upgrade_db.php Sun Mar 21 00:00:58 2010 +0900 +++ b/upgrade_db.php Sun Mar 21 16:42:58 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 "dirtyc若с絖篏障\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"; }