# HG changeset patch # User Yoshiki Yazawa # Date 1269108900 -32400 # Node ID a18df712fc7e3c9fbc1946dd3b73df1732be4d6e # Parent b172a0b1ea48aa670e8e45d7b580a2f35c65bfa6# Parent 6754b6aa50cfede0e32f9ff140d7e063c3db391f merged with upstream diff -r b172a0b1ea48 -r a18df712fc7e Keyword.class.php diff -r b172a0b1ea48 -r a18df712fc7e Reservation.class.php --- a/Reservation.class.php Mon Mar 15 01:39:14 2010 +0900 +++ b/Reservation.class.php Sun Mar 21 03:15:00 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" ); // 予約クラス @@ -77,7 +78,7 @@ $crec = new DBRecord( CHANNEL_TBL, "id", $channel_id ); // 既存予約数 = TUNER番号 - $tuners = ($crec->type == "GR") ? $settings->gr_tuners : $settings->bs_tuners; + $tuners = ($crec->type == "GR") ? (int)($settings->gr_tuners) : (int)($settings->bs_tuners); $type_str = ($crec->type == "GR") ? "type = 'GR' " : "(type = 'BS' OR type = 'CS') "; $battings = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". @@ -177,8 +178,7 @@ if( $duration < ($settings->former_time + 60) ) { // 60秒以下の番組は弾く throw new Exception( "終わりつつある/終わっている番組です" ); } - - + // ここからファイル名生成 /* %TITLE% 番組タイトル @@ -203,7 +203,7 @@ $fn_title = mb_ereg_replace("[ \./\*:<>\?\\|()\'\"&]","_", trim($title) ); // %TITLE% - $filename = str_replace("%TITLE%", $fn_title, $filename); + $filename = mb_str_replace("%TITLE%", trim($title), $filename); // %ST% 開始日時 $filename = str_replace("%ST%",date("YmdHis", $start_time), $filename ); // %ET% 終了日時 @@ -229,13 +229,17 @@ // %SEC% 開始秒 $filename = str_replace("%SEC%",date("s", $start_time), $filename ); // %DURATION% 録画時間(秒) - $filename = str_replace("%DURATION%","".$duration, $filename ); - + $filename = mb_str_replace("%DURATION%","".$duration, $filename ); + + // あると面倒くさそうな文字を全部_に + $filename = preg_replace("/[ \.\/\*:<>\?\\|()\'\"&]/u","_", trim($filename) ); + // 文字コード変換 if( defined("FILESYSTEM_ENCODING") ) { // $filename = mb_convert_encoding( $filename, FILESYSTEM_ENCODING, "UTF-8" ); $filename = mb_convert_encoding( $filename, FILESYSTEM_ENCODING, "auto" ); } + $filename .= $RECORD_MODE["$mode"]['suffix']; $thumbname = $filename.".jpg"; @@ -299,6 +303,7 @@ } else { $rrec->delete(); + reclog( "Reservation::custom atの実行に失敗した模様", E_ERROR); throw new Exception("AT実行エラー"); } // job番号を取り出す @@ -312,11 +317,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 ) { @@ -348,13 +355,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; } } diff -r b172a0b1ea48 -r a18df712fc7e Settings.class.php --- a/Settings.class.php Mon Mar 15 01:39:14 2010 +0900 +++ b/Settings.class.php Sun Mar 21 03:15:00 2010 +0900 @@ -121,7 +121,10 @@ // キーワード自動録画の録画モード $xml->autorec_mode = 0; - + + // CS録画 + $xml->cs_rec_flg = 0; + $xml->save(); return $xml; diff -r b172a0b1ea48 -r a18df712fc7e channelInfo.php --- a/channelInfo.php Mon Mar 15 01:39:14 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -'; - echo $crec->name . ""; - - // 種別 - echo '
種別:'; - echo $crec->type; - echo '
'; - - // チャンネル - echo '
物理チャンネル:'; - echo $crec->channel; - echo '
'; - - // フォーム - echo '
'; - echo '
サービスID:'; - echo ''; - echo ''; - echo '
'; - echo '
'; - } - catch( Exception $e ) { - echo "error:チャンネル情報の取得に失敗"; - } -} -?> \ No newline at end of file diff -r b172a0b1ea48 -r a18df712fc7e channelSetSID.php --- a/channelSetSID.php Mon Mar 15 01:39:14 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -sid = trim($_POST['sid']); - } - catch( Exception $e ) { - // 無視 - } -} -?> diff -r b172a0b1ea48 -r a18df712fc7e config.php.sample --- a/config.php.sample Mon Mar 15 01:39:14 2010 +0900 +++ b/config.php.sample Sun Mar 21 03:15:00 2010 +0900 @@ -222,6 +222,6 @@ define( "CHANNEL_TBL", "channelTbl" ); // チャンネルテーブル define( "CATEGORY_TBL", "categoryTbl" ); // カテゴリテーブル define( "KEYWORD_TBL", "keywordTbl" ); // キーワードテーブル - - +// ログテーブル +define( "LOG_TBL", "logTbl" ); ?> \ No newline at end of file diff -r b172a0b1ea48 -r a18df712fc7e getepg.old.php --- a/getepg.old.php Mon Mar 15 01:39:14 2010 +0900 +++ b/getepg.old.php Sun Mar 21 03:15:00 2010 +0900 @@ -7,6 +7,8 @@ include_once( INSTALL_PATH . '/Reservation.class.php' ); include_once( INSTALL_PATH . '/Keyword.class.php' ); include_once( INSTALL_PATH . '/Settings.class.php' ); + include_once( INSTALL_PATH . '/storeProgram.inc.php' ); + $settings = Settings::factory(); @@ -69,157 +71,7 @@ } } - // 不要なプログラムの削除 - // 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(); - foreach( $arr as $val ) { - try { - $val->reservation(); - } - catch( Exception $e ) { - // 無視 - } - } - + garbageClean(); // 不要プログラム削除 + doKeywordReservation(); // キーワード予約 exit(); - - function storeProgram( $type, $xmlfile ) { - global $BS_CHANNEL_MAP, $GR_CHANNEL_MAP, $CS_CHANNEL_MAP; - // チャンネルマップファイルの準備 - $map = array(); - 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 ) { - return; // XMLが読み取れないなら何もしない - } - // channel抽出 - foreach( $xml->channel as $ch ) { - $disc = $ch['id']; - try { - // チャンネルデータを探す - $num = DBRecord::countRecords( CHANNEL_TBL , "WHERE channel_disc = '" . $disc ."'" ); - if( $num == 0 ) { - // channel discがないようなら飛ばす - if( array_key_exists( "$disc", $map ) ) { - // チャンネルデータがないなら新規作成 - $rec = new DBRecord( CHANNEL_TBL ); - $rec->type = $type; - $rec->channel = $map["$disc"]; - $rec->channel_disc = $disc; - $rec->name = $ch->{'display-name'}; - } - } - else { - // 存在した場合も、とりあえずチャンネル名は更新する - $rec = new DBRecord(CHANNEL_TBL, "channel_disc", $disc ); - $rec->name = $ch->{'display-name'}; - } - } - catch( Exception $e ) { - // 無視 - } - } - // channel 終了 - - // programme 取得 - - foreach( $xml->programme as $program ) { - $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'] ); - $title = $program->title; - $desc = $program->desc; - $cat_ja = ""; - $cat_en = ""; - foreach( $program->category as $cat ) { - if( $cat['lang'] == "ja_JP" ) $cat_ja = $cat; - if( $cat['lang'] == "en" ) $cat_en = $cat; - } - $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 ); - 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 ); - // - $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", $channel_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 ) { - Reservation::cancel( $reserve->id ); - } - } - catch( Exception $e ) { - //無視 - } - // 番組削除 - $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; - } - } - catch(Exception $e) { - exit( $e->getMessage() ); - } - } - } -?> +?> \ No newline at end of file diff -r b172a0b1ea48 -r a18df712fc7e index.php --- a/index.php Mon Mar 15 01:39:14 2010 +0900 +++ b/index.php Sun Mar 21 03:15:00 2010 +0900 @@ -37,31 +37,36 @@ } $last_time = $top_time + 3600 * $program_length; - // 時刻欄 - for( $i = 0 ; $i < $program_length; $i++ ) { +// 時刻欄 +for( $i = 0 ; $i < $program_length; $i++ ) { $tvtimes[$i] = date("H", $top_time + 3600 * $i ); - } - - - // 番組表 - $programs = array(); - if( $type == "BS" ) $channel_map = $BS_CHANNEL_MAP; - else if( $type == "GR" ) $channel_map = $GR_CHANNEL_MAP; - else if( $type == "CS" ) $channel_map = $CS_CHANNEL_MAP; - $st = 0; - $prec = null; - try { - $prec = new DBRecord(PROGRAM_TBL); - } - catch( Exception $e ) { +} + + +// 番組表 +$programs = array(); +if( $type == "BS" ) $channel_map = $BS_CHANNEL_MAP; +else if( $type == "GR" ) $channel_map = $GR_CHANNEL_MAP; +else if( $type == "CS" ) $channel_map = $CS_CHANNEL_MAP; +$st = 0; +$prec = null; +try { + $prec = new DBRecord(PROGRAM_TBL); +} +catch( Exception $e ) { exit('プログラムテーブルが存在しないようです。インストールをやり直してください.'); - } - foreach( $channel_map as $channel_disc => $channel ) { +} +$num_ch = 0; +foreach( $channel_map as $channel_disc => $channel ) { $prev_end = $top_time; try { $crec = new DBRecord( CHANNEL_TBL, "channel_disc", $channel_disc ); + $programs[$st]["skip"] = $crec->skip; + if( $crec->skip == 0 ) $num_ch++; + $programs[$st]["channel_disc"] = $channel_disc; $programs[$st]["station_name"] = $crec->name; - $programs[$st]["channel_disc"] = $crec->channel_disc; + $programs[$st]["sid"] = $crec->sid; + $programs[$st]["ch_hash"] = md5($channel_disc); $reca = $prec->fetch_array( "channel_disc", $channel_disc, "endtime > '".toDatetime($top_time)."' ". @@ -126,36 +131,35 @@ $num++; } $st++; - } - $prec = null; - - // 局の幅 - $ch_set_width = $settings->ch_set_width; - // 全体の幅 - $chs_width = $ch_set_width * count( $channel_map ); +} +$prec = null; - // GETパラメタ - $get_param = $_SERVER['SCRIPT_NAME'] . "?type=".$type."&length=".$program_length.""; - - $smarty = new Smarty(); - - // カテゴリ一覧 - $crec = DBRecord::createRecords( CATEGORY_TBL ); - $cats = array(); - $num = 0; - foreach( $crec as $val ) { +// 局の幅 +$ch_set_width = (int)($settings->ch_set_width); +// 全体の幅 +$chs_width = $ch_set_width * $num_ch; + +// GETパラメタ +$get_param = $_SERVER['SCRIPT_NAME'] . "?type=".$type."&length=".$program_length.""; + +$smarty = new Smarty(); + +// カテゴリ一覧 +$crec = DBRecord::createRecords( CATEGORY_TBL ); +$cats = array(); +$num = 0; +foreach( $crec as $val ) { $cats[$num]['name_en'] = $val->name_en; $cats[$num]['name_jp'] = $val->name_jp; $num++; - } - $smarty->assign( "cats", $cats ); - +} +$smarty->assign( "cats", $cats ); - // タイプ選択 - $types = array(); - $i = 0; - if( $settings->bs_tuners != 0 ) { +// タイプ選択 +$types = array(); +$i = 0; +if( $settings->bs_tuners != 0 ) { $types[$i]['selected'] = $type == "BS" ? 'class="selected"' : ""; $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=BS&length=".$program_length."&time=".date( "YmdH", $top_time); $types[$i]['name'] = "BS"; @@ -168,65 +172,67 @@ $types[$i]['name'] = "CS"; $i++; } - } - if( $settings->gr_tuners != 0 ) { +} +if( $settings->gr_tuners != 0 ) { $types[$i]['selected'] = $type == "GR" ? 'class="selected"' : ""; $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=GR&length=".$program_length."&time=".date( "YmdH", $top_time); $types[$i]['name'] = "地上デジタル"; $i++; - } - $smarty->assign( "types", $types ); - - // 日付選択 - $days = array(); - $day = array(); - $day['d'] = "昨日"; - $day['link'] = $get_param . "&time=". date( "YmdH", time() - 3600 *24 ); - $day['ofweek'] = ""; - $day['selected'] = $top_time < mktime( 0, 0 , 0) ? 'class="selected"' : ''; - - array_push( $days , $day ); - $day['d'] = "現在"; - $day['link'] = $get_param; - $day['ofweek'] = ""; - $day['selected'] = ""; - array_push( $days, $day ); - for( $i = 0 ; $i < 8 ; $i++ ) { +} +$smarty->assign( "types", $types ); + +// 日付選択 +$days = array(); +$day = array(); +$day['d'] = "昨日"; +$day['link'] = $get_param . "&time=". date( "YmdH", time() - 3600 *24 ); +$day['ofweek'] = ""; +$day['selected'] = $top_time < mktime( 0, 0 , 0) ? 'class="selected"' : ''; + +array_push( $days , $day ); +$day['d'] = "現在"; +$day['link'] = $get_param; +$day['ofweek'] = ""; +$day['selected'] = ""; +array_push( $days, $day ); +for( $i = 0 ; $i < 8 ; $i++ ) { $day['d'] = "".date("d", time() + 24 * 3600 * $i ) . "日"; $day['link'] = $get_param . "&time=".date( "Ymd", time() + 24 * 3600 * $i) . date("H" , $top_time ); $day['ofweek'] = $DAY_OF_WEEK[(int)date( "w", time() + 24 * 3600 * $i )]; $day['selected'] = date("d", $top_time) == date("d", time() + 24 * 3600 * $i ) ? 'class="selected"' : ''; array_push( $days, $day ); - } - $smarty->assign( "days" , $days ); - - // 時間選択 - $toptimes = array(); - for( $i = 0 ; $i < 24; $i+=4 ) { +} +$smarty->assign( "days" , $days ); + +// 時間選択 +$toptimes = array(); +for( $i = 0 ; $i < 24; $i+=4 ) { $tmp = array(); $tmp['hour'] = sprintf( "%02d:00", $i ); $tmp['link'] = $get_param . "&time=".date("Ymd", $top_time ) . sprintf("%02d", $i ); array_push( $toptimes, $tmp ); - } - $smarty->assign( "toptimes" , $toptimes ); - - $smarty->assign( "tvtimes", $tvtimes ); - $smarty->assign( "programs", $programs ); - $smarty->assign( "ch_set_width", $settings->ch_set_width ); - $smarty->assign( "chs_width", $chs_width ); - $smarty->assign( "height_per_hour", $settings->height_per_hour ); - $smarty->assign( "height_per_min", $settings->height_per_hour / 60 ); +} +$smarty->assign( "toptimes" , $toptimes ); + +$smarty->assign( "tvtimes", $tvtimes ); +$smarty->assign( "programs", $programs ); +$smarty->assign( "ch_set_width", (int)($settings->ch_set_width) ); +$smarty->assign( "chs_width", $chs_width ); +$smarty->assign( "height_per_hour", $settings->height_per_hour ); +$smarty->assign( "height_per_min", $settings->height_per_hour / 60 ); +$smarty->assign( "num_ch", $num_ch ); +$smarty->assign( "num_all_ch" , count( $channel_map ) ); // date("Y-m-d H:i:s", $timestamp); - - $sitetitle = date( "Y", $top_time ) . "年" . date( "m", $top_time ) . "月" . date( "d", $top_time ) . "日". date( "H", $top_time ) . + +$sitetitle = date( "Y", $top_time ) . "年" . date( "m", $top_time ) . "月" . date( "d", $top_time ) . "日". date( "H", $top_time ) . "時~".( $type == "GR" ? "地上デジタル" : "BSデジタル" )."番組表"; - - $smarty->assign("sitetitle", $sitetitle ); - - $smarty->assign("top_time", str_replace( "-", "/" ,toDatetime($top_time)) ); - $smarty->assign("last_time", str_replace( "-", "/" ,toDatetime($last_time)) ); - - - $smarty->display("index.html"); + +$smarty->assign("sitetitle", $sitetitle ); + +$smarty->assign("top_time", str_replace( "-", "/" ,toDatetime($top_time)) ); +$smarty->assign("last_time", str_replace( "-", "/" ,toDatetime($last_time)) ); + + +$smarty->display("index.html"); ?> diff -r b172a0b1ea48 -r a18df712fc7e install/step3.php --- a/install/step3.php Mon Mar 15 01:39:14 2010 +0900 +++ b/install/step3.php Sun Mar 21 03:15:00 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" ); diff -r b172a0b1ea48 -r a18df712fc7e recLog.inc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/recLog.inc.php Sun Mar 21 03:15:00 2010 +0900 @@ -0,0 +1,21 @@ +logtime = date("Y-m-d H:i:s"); + $log->level = $level; + $log->message = $message; + } + catch( Exception $e ) { + // + } +} + +?> diff -r b172a0b1ea48 -r a18df712fc7e setChannelInfo.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setChannelInfo.php Sun Mar 21 03:15:00 2010 +0900 @@ -0,0 +1,18 @@ +sid = trim($_POST['sid']); + $crec->skip = (int)(trim($_POST['skip'])); + } + catch( Exception $e ) { + exit("Error: チャンネル情報更新失敗" ); + } +} +?> \ No newline at end of file diff -r b172a0b1ea48 -r a18df712fc7e storeProgram.inc.php --- a/storeProgram.inc.php Mon Mar 15 01:39:14 2010 +0900 +++ b/storeProgram.inc.php Sun Mar 21 03:15:00 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,15 +25,17 @@ foreach( $arr as $val ) { try { $val->reservation(); + reclog( "getepg::キーワードID".$val->id."を予約"); } catch( Exception $e ) { - // 無視 + // 無視 } } } function storeProgram( $type, $xmlfile ) { global $BS_CHANNEL_MAP, $GR_CHANNEL_MAP, $CS_CHANNEL_MAP; + // チャンネルマップファイルの準備 $map = array(); if( $type == "BS" ) $map = $BS_CHANNEL_MAP; @@ -38,6 +45,7 @@ // XML parse $xml = @simplexml_load_file( $xmlfile ); if( $xml === false ) { + reclog( "getepg::".$xmlfile."が作成されなかった模様", E_ERROR ); return; // XMLが読み取れないなら何もしない } // channel抽出 @@ -63,7 +71,7 @@ } } catch( Exception $e ) { - // 無視 + reclog( "getepg::DBの接続またはチャンネルテーブルの書き込みに失敗", E_ERROR ); } } // channel 終了 @@ -71,10 +79,21 @@ // programme 取得 foreach( $xml->programme as $program ) { + $channel_rec = null; + $channel_disc = $program['channel']; if( ! array_key_exists( "$channel_disc", $map ) ) continue; + $channel = $map["$channel_disc"]; - $channel = $map["$channel_disc"]; + try { + $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; // 受信しないチャンネル + $starttime = str_replace(" +0900", '', $program['start'] ); $endtime = str_replace( " +0900", '', $program['stop'] ); $title = $program->title; @@ -101,8 +120,7 @@ } else $cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc ); - // - $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", $channel_disc ); + // $num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '".$program_disc."'" ); if( $num == 0 ) { // 新規番組 @@ -118,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(); } } @@ -150,9 +170,10 @@ } } catch(Exception $e) { + reclog( "getepg::DBの入出力に問題が生じた模様", E_ERROR ); exit( $e->getMessage() ); } } // Programme取得完了 } -?> \ No newline at end of file +?> diff -r b172a0b1ea48 -r a18df712fc7e tableStruct.inc.php --- a/tableStruct.inc.php Mon Mar 15 01:39:14 2010 +0900 +++ b/tableStruct.inc.php Sun Mar 21 03:15:00 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 diff -r b172a0b1ea48 -r a18df712fc7e templates/index.html --- a/templates/index.html Mon Mar 15 01:39:14 2010 +0900 +++ b/templates/index.html Sun Mar 21 03:15:00 2010 +0900 @@ -79,28 +79,88 @@ ); } var PRG = { - chdialog:function(disc){ + chdialog:function(chash){ $('#channelDialog').dialog('close'); - $.get('channelInfo.php', { channel_disc: disc },function(data) { + var skip = $('#ch_title_'+chash+' .ch_skip').html(); + var st_name = $('#ch_title_'+chash+' .ch_name').html(); + var sid = $('#ch_title_'+chash+' .ch_sid').html(); + var disc = $('#ch_title_'+chash+' .ch_disc').html(); + + var str = '
'; + str += st_name; + str += '
'; + str += '
'; + // スキップ + str += '
視聴しない:'; + str += ''; + if( skip == 1 ) { + str += ''; + } + else { + str += ''; + } + str += '
'; + // サービスID + str += '
サービスID:'; + str += '
'; + + str += ''; + str += ''; + + + str += '
'; + + str += '
更新
'; + + $('#channelDialog').html(str); + $('#channelDialog').dialog('open', 'center'); + }, + chupdate:function() { + var v_sid = $('#id_sid').val(); + var v_channel_disc = $('#id_disc').val(); + var v_hash = $('#id_hash').val(); + var v_skip = $('#id_ch_skip').attr('checked'); + var n_skip = v_skip ? 1 : 0; + + $.post('setChannelInfo.php', { channel_disc: v_channel_disc, + sid: v_sid, + skip: n_skip + }, function(data) { if(data.match(/^error/i)){ alert(data); } else { - var str = data; - str += '
更新
'; - $('#channelDialog').html(str); - $('#channelDialog').dialog('open', 'center'); - + var old_skip = $('#ch_title_'+v_hash+' .ch_skip').html(); + if( old_skip != n_skip ) { + if( v_skip ) { + (INISet.num_ch)--; + $('#ch_title_'+v_hash ).addClass('ch_title_skip'); + $('#tv_chs_'+v_hash ).addClass('ch_set_skip'); + $('#ch_title_str_'+v_hash ).addClass('ch_skip_color'); + $('#ch_title_'+v_hash+' .ch_skip').html('1'); + } + else { + (INISet.num_ch)++; + $('#ch_title_'+v_hash ).removeClass('ch_title_skip'); + $('#tv_chs_'+v_hash ).removeClass('ch_set_skip'); + $('#ch_title_str_'+v_hash ).removeClass('ch_skip_color'); + $('#ch_title_'+v_hash+' .ch_skip').html('0'); + } + if( PRG.F_Skip == 1 ) { + PRG.chSkipHide(); + } + else { + $('#ch_title_bar div.ch_title_skip').show(); + $('#tv_chs div.ch_set_skip').show(); + } + } } - }); - - }, - chupdate:function() { - var v_sid = $('#id_sid').val(); - var v_channel_disc = $('#id_disc').val(); - $.post('channelSetSID.php', { channel_disc: v_channel_disc, - sid: v_sid }, function(data) { - $('#channelDialog').dialog('close'); }); }, @@ -189,6 +249,35 @@ $('#floatBox4Dialog').dialog('close'); } }); + }, + F_Skip: 1, + chSkipShow:function() { + $('#float_titles').width(INISet.num_all_ch * INISet.ch_width + 80); + $('#tv_chs').width(INISet.num_all_ch * INISet.ch_width ); + $('#tvtimes2').css( { left: INISet.num_all_ch * INISet.ch_width + 40 } ).show(); + tvtimes_scroll(); + $('#ch_title_bar div.ch_title_skip').show(); + $('#tv_chs div.ch_set_skip').show(); + nowBar.INI(); + }, + chSkipHide:function() { + $('#ch_title_bar div.ch_title_skip').hide(); + $('#tv_chs div.ch_set_skip').hide(); + $('#float_titles').width( INISet.num_ch * INISet.ch_width + 80 ); + $('#tv_chs').width( INISet.num_ch * INISet.ch_width ); + $('#tvtimes2').css( { left: INISet.num_ch * INISet.ch_width + 40 }).show(); + tvtimes_scroll(); + nowBar.INI(); + }, + toggle:function() { + if( this.F_Skip ) { + this.chSkipShow(); + this.F_Skip = 0; + } + else { + this.chSkipHide(); + this.F_Skip = 1; + } } } var CTG = { @@ -316,9 +405,11 @@ DG.dialog('close'); var DG2 = $('#channelDialog'); - DG2.dialog({title:'チャンネル情報',width:600}); + DG2.dialog({title:'チャンネル情報',width:480}); DG2.dialog('close'); +// PRG.toggle(); + nowBar.INI(); CTG.INI(); MDA.SCR.INI(); // 番組表の位置保存 @@ -368,10 +459,20 @@ #tvtable div.tvtimetop {padding:8px 0px;} #tvtable div.ch_set {width:{/literal}{$ch_set_width}{literal}px;float:left;background-color:#BBB;} +.ch_set_skip { display: none; } #tvtable div.ch_title, #tvtable div.prg {margin-right:2px;} #tvtable div.ch_title {padding:8px 0px;background-color:#333;color:#DDD;font-weight:bold;text-align:center} +.ch_title_skip { display: none;} +.ch_skip_color { color: red;} + +.ch_disc {display :none;} +.ch_skip {display :none;} +.ch_sid {display :none;} +.ch_name {display :none;} +.ch_hash {display :none;} + #tvtable div.prg { overflow:hidden; color:#444; @@ -412,6 +513,7 @@ #float_titles div.ch_title {width:{/literal}{$ch_set_width}{literal}px;float:left;color:#FFF;font-weight:bold;text-align:center} #float_titles div.ch_title div{padding:8px 0px;margin:0 6px 0 4px;background-image: url(imgs/trancBG50.png);} + #float_follows {position:absolute;} #prg_info { display:none; @@ -453,7 +555,7 @@

{$sitetitle}

-
+
@@ -490,6 +592,11 @@ {/foreach}
+ + +
@@ -515,12 +622,22 @@
test
-
+ + +
 
{foreach from=$programs item=program } -
{$program.station_name}
+
+
{$program.ch_hash}
+
{$program.channel_disc}
+
{$program.skip}
+
{$program.sid}
+
{$program.station_name}
+
{$program.station_name}
+
{/foreach}
+
 
@@ -538,8 +655,8 @@
{foreach from=$programs item=program } -
-
+
+
{foreach from=$program.list item=item }
@@ -573,12 +690,17 @@ {literal} {/literal} diff -r b172a0b1ea48 -r a18df712fc7e upgrade_db.php --- a/upgrade_db.php Mon Mar 15 01:39:14 2010 +0900 +++ b/upgrade_db.php Sun Mar 21 03:15:00 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" );