OSDN Git Service

add epgrec support file
authorHiroshi Yamashita <piro@users.sourceforge.jp>
Sun, 29 May 2011 08:01:22 +0000 (17:01 +0900)
committerHiroshi Yamashita <piro@users.sourceforge.jp>
Sun, 29 May 2011 08:01:22 +0000 (17:01 +0900)
epgrec/Cmcheck.class.php [new file with mode: 0644]
epgrec/README.epgrec [new file with mode: 0644]
epgrec/cmcheckExec.php [new file with mode: 0755]
epgrec/cmcheckTable.php [new file with mode: 0755]
epgrec/do-record.sh.sample [new file with mode: 0755]
epgrec/templates/cmcheckTable.html [new file with mode: 0755]
epgrec/templates/recordedTable.html [new file with mode: 0755]
epgrec/viewer.php [new file with mode: 0755]

diff --git a/epgrec/Cmcheck.class.php b/epgrec/Cmcheck.class.php
new file mode 100644 (file)
index 0000000..ac9e755
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+include_once('config.php');
+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" );
+
+// Cmcheckクラス
+
+class Cmcheck {
+protected $filename;
+protected $recfilename;
+protected $basefilename;
+protected $settings;
+protected $lines;
+protected $cmdata;
+protected $rrec;
+protected $totalline;
+
+protected $dbh;
+public $id;
+
+function __construct( $reserve_id = null ) {
+       $settings = Settings::factory();
+       $this->settings = Settings::factory();
+
+       try {
+               $this->rrec = new DBRecord( RESERVE_TBL, "id", $reserve_id );
+       }
+       catch( Exception $e ) {
+               throw $e;
+       }
+
+       $this->filename = INSTALL_PATH .$this->settings->spool . "/". $this->rrec->path . "-sh";
+       $this->recfilename = INSTALL_PATH .$this->settings->spool . "/". $this->rrec->path;
+
+
+       if( file_exists( $this->filename )) {
+               $this->cmdata = array();
+               $itmcnt=0;
+               $cmfileflg=0;
+               $lines=file($this->filename );
+
+                foreach ($lines as $line_num => $line) {
+                        if (strstr($line,"# cmcheckwave")) {
+                                $cmfileflg=1;
+                                $itm = Explode(" ",$line,3);
+                                $this->basefilename = trim($itm[2]);
+                                continue;
+                        }
+                        if ($cmfileflg>1) {
+                                if (strstr($line,"# total")) {
+                                       $this->totalline = trim($line);
+                                        break;
+                                }
+                                $itm = explode(" ",$line);
+                                $ary = array();
+                                $ary['id']=$itmcnt;
+                               $ary['start']=$itm[1];
+                                $ary['end']=$itm[2];
+                                $ary['diff']=$itm[4];
+                                $ary['cm']=trim($itm[5]);
+                               $ary['thumb']=$settings->install_url.$settings->spool. "/".$this->rrec->path."-".$itmcnt.".png";
+                                array_push($this->cmdata,$ary);
+                               $itmcnt++;
+                       }
+                       if ($cmfileflg==1) $cmfileflg++; //skip blank line
+
+               }
+
+       }
+       return;
+}
+function getlines() {
+       return $this->lines;
+}
+function getdata() {
+       return $this->cmdata;
+}
+function getbasefile() {
+       return $this->basefilename;
+}
+function getrecfilename() {
+       return $this->recfilename;
+}
+function getfilename() {
+       return $this->filename;
+}
+function putdata($newcm)
+{
+       $newary = explode(",",$newcm);
+
+       if (count($this->cmdata)!=count($newary)) return(0);
+
+       FILE *fp;
+       $fp = fopen($this->filename ,"w");
+       if (fp==NULL) return(0);
+       fprintf($fp,"#!/bin/sh\n");
+       fprintf($fp,"# cmcheckwave %s\n#\n",$this->basefilename);
+
+       $cnt=0;
+       foreach($this->cmdata as $data) {
+               if ($newary[$cnt]=="1")
+                       $cmval = "CM";
+               else
+                       $cmval = "";
+               fprintf($fp,"# %s %s diff %s %s\n",
+                       $data['start'],$data['end'],$data['diff'],$cmval);
+               $cnt++;
+       }
+       fprintf($fp,"%s\n",$this->totalline);
+       fclose($fp);
+
+       return(1);
+}
+
+}
+
+?>
diff --git a/epgrec/README.epgrec b/epgrec/README.epgrec
new file mode 100644 (file)
index 0000000..e75278b
--- /dev/null
@@ -0,0 +1,14 @@
+epgrec利用時にCMカットをwebインターフェースから実施するサンプル
+
+README.epgrec
+
+Cmcheck.class.php      CMチェックに使う簡単なクラス
+cmcheckTable.php       CMチェック用管理画面用ファイル
+cmcheckExec.php                CMチェックコマンド実行用スクリプト
+viewer.php             追加引数でCMカット済みファイル視聴
+do-record.sh.sample    録画コマンドサンプル
+
+templates/
+recordedTable.html     録画済み画面テンプレ(cmcheckリンクを追加)
+cmcheckTable.html      cmcheckリンク先のCMカット管理画面テンプレ
+
diff --git a/epgrec/cmcheckExec.php b/epgrec/cmcheckExec.php
new file mode 100755 (executable)
index 0000000..15d209f
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+include_once('config.php');
+include_once( INSTALL_PATH . "/DBRecord.class.php" );
+include_once( INSTALL_PATH . "/Settings.class.php" );
+include_once( INSTALL_PATH . "/Cmcheck.class.php" );
+
+$settings = Settings::factory();
+
+if( ! isset( $_POST['reserve_id'] )) {
+       exit("Error:idが指定されていません。");
+}
+$reserve_id = $_POST['reserve_id'];
+$cmcheckcomplete = $_POST['cmcheckcomplete'];
+$replace = $_POST['replace'];
+$newcmcheckval = $_POST['checkval'];
+$cmdvol = $_POST['optvol'];
+$cmddif = $_POST['optdif'];
+
+
+try{
+               $cm = new Cmcheck( $reserve_id );
+
+               //処理判定(再実行・CM判定場所変更・CMチェック完了)
+               if ($cmcheckcomplete == 1) {
+                       if ($replace == "true")
+                               $replace = 2; //録画ファイル置き換えを行わない
+                       else
+                               $replace = 1;
+                       
+                       $cmdbuf=sprintf("/usr/local/bin/cmcheckwave -t -c %d -x %s\n",$replace,escapeshellarg($cm->getfilename()));
+                       system($cmdbuf);
+               }
+
+
+               if ($newcmcheckval) {
+                       if (!$cm->getbasefile()) {
+                               exit( "Error:"."ファイルがありません");
+                       }
+                       if ($cm->putdata($newcmcheckval)==1) {
+                               $cmdbuf=sprintf("/usr/local/bin/cmcheckwave -t -x %s\n",escapeshellarg($cm->getfilename()));
+                               system($cmdbuf);
+                       }
+                       else
+                               exit("Error:putdatafailed");
+               }
+               if (($cmdvol>0) && ($cmddif>0)) {
+                               $cmdbuf=sprintf("/usr/local/bin/cmcheckwave -v %s -m %s -t -x %s > %s\n",escapeshellarg($cmdvol),escapeshellarg($cmddif),escapeshellarg($cm->getrecfilename()),escapeshellarg($cm->getfilename()));
+                               var_dump($cmdbuf);
+                               system($cmdbuf);
+               }
+
+}
+catch( Exception $e ) {
+       exit( "Error:".$e->getMessage() );
+}
+exit( "".$reserve_id );
+?>
diff --git a/epgrec/cmcheckTable.php b/epgrec/cmcheckTable.php
new file mode 100755 (executable)
index 0000000..d388f30
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+include_once('config.php');
+include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
+include_once( INSTALL_PATH . "/DBRecord.class.php" );
+include_once( INSTALL_PATH . "/reclib.php" );
+include_once( INSTALL_PATH . "/Reservation.class.php" );
+include_once( INSTALL_PATH . "/Keyword.class.php" );
+include_once( INSTALL_PATH . "/Cmcheck.class.php" );
+
+
+
+include_once(INSTALL_PATH . "/Settings.class.php" );
+
+$settings = Settings::factory();
+
+if( ! isset( $_GET['reserve_id'] )) jdialog("予約番号が指定されていません", "recordedTable.php");
+$reserve_id = $_GET['reserve_id'];
+
+$cmary=array();
+try{
+
+       $rrec = new DBRecord( RESERVE_TBL, "id", $reserve_id );
+
+       $start_time = toTimestamp($rrec->starttime);
+       $end_time = toTimestamp($rrec->endtime );
+       $duration = $end_time - $start_time + $settings->former_time;
+
+       $dh = $duration / 3600;
+       $duration = $duration % 3600;
+       $dm = $duration / 60;
+       $duration = $duration % 60;
+       $ds = $duration;
+       
+       $title = htmlspecialchars(str_replace(array("\r\n","\r","\n"), '', $rrec->title),ENT_QUOTES);
+       $abstract = htmlspecialchars(str_replace(array("\r\n","\r","\n"), '', $rrec->description),ENT_QUOTES);
+       
+       $cm = new Cmcheck( $reserve_id );
+
+}
+catch(exception $e ) {
+       exit( $e->getMessage() );
+}
+
+$optvol['7'] = '7';
+$optvol['8'] = '8';
+$optvol['9'] = '9';
+$optvol['10'] = '10';
+$optvol['11'] = '11';
+
+$optdul['100'] = '100';
+$optdul['150'] = '150';
+$optdul['200'] = '200';
+$optdul['250'] = '250';
+$optdul['300'] = '300';
+
+$smarty = new Smarty();
+
+$smarty->assign( "cmary", $cm->getdata() );
+$smarty->assign( "sitetitle", $title );
+$smarty->assign( "reserveid", $reserve_id );
+$smarty->assign( 'optvolArray' , $optvol);
+$smarty->assign( 'optdulArray' , $optdul);
+$smarty->assign( 'selectVol'   , '9');
+$smarty->assign( 'selectDul'   , '250');
+$smarty->assign( 'cmcheckbox'  , array('CM' => 'CM')); 
+
+$smarty->display( "cmcheckTable.html" );
+?>
diff --git a/epgrec/do-record.sh.sample b/epgrec/do-record.sh.sample
new file mode 100755 (executable)
index 0000000..8a39088
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+echo "CHANNEL : $CHANNEL"
+echo "DURATION: $DURATION"
+echo "OUTPUT  : $OUTPUT"
+echo "TUNER : $TUNER"
+echo "TYPE : $TYPE"
+echo "MODE : $MODE"
+echo "SID  : $SID"
+
+RECORDER=/usr/local/bin/recpt1
+
+# fail safe
+case $CHANNEL in
+    101|102|191|192|193)
+       if [ $SID = 'hd' ]; then
+           SID=$CHANNEL
+       fi ;;
+esac
+if [ -z $SID ]; then
+    SID='hd'
+fi
+
+if [ ${MODE} = 0 ]; then
+   # MODE=0では必ず無加工のTSを吐き出すこと
+   $RECORDER --b25 --strip $CHANNEL $DURATION ${OUTPUT} >/dev/null
+elif [ ${MODE} = 1 ]; then
+   # 目的のSIDのみ残す
+   $RECORDER --b25 --strip --sid $SID $CHANNEL $DURATION ${OUTPUT} >/dev/null
+elif [ ${MODE} = 2 ]; then
+   # CMカットmp4サンプル
+   $RECORDER $CHANNEL $DURATION ${OUTPUT}.tmp.ts --b25 --strip >/dev/null &
+   sleep 30
+   cat ${OUTPUT}.tmp.ts | nice -n 20 ffmpeg -i - -f mp4 -deinterlace -vcodec libx264 -vpre libx264-faster -r 30000/1001 -aspect 16:9 -s 768x432 -crf 28 -acodec copy  ${OUTPUT}
+   /usr/local/bin/cmcheckwave -t -x  ${OUTPUT} > ${OUTPUT}-sh
+   if [ -f ${OUTPUT} -a -s ${OUTPUT} ]; then
+       rm -f ${OUTPUT}.tmp.ts
+   fi
+fi
diff --git a/epgrec/templates/cmcheckTable.html b/epgrec/templates/cmcheckTable.html
new file mode 100755 (executable)
index 0000000..e9352c9
--- /dev/null
@@ -0,0 +1,258 @@
+<!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>CMカットチェック {$sitetitle}</title>
+<meta http-equiv="Content-Style-Type" content="text/css">
+
+{literal}
+<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
+<link rel="stylesheet" href="start/jquery-ui-1.7.2.custom.css" type="text/css">
+
+<script type="text/javascript">
+<!--
+       var PRG = {
+               
+               imgdialog:function(id,img){
+                       var str;
+                       str = '<img src="' + img +  '" />';
+                       $('#floatBox4Dialog').dialog({title:'確認'});
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open', 'center');
+                       
+               },
+               dialog:function(id, title, mode){
+                       $('#floatBox4Dialog').dialog({title:'確認'});
+                       var str;
+                       str  = '<div class="prg_title">' + title + '</div>';
+                       if (mode == 1) {
+                       str += '<input type="hidden" name="reserve_id" id="id_reserve_id" value="' + id +  '" />';
+                       str += '<input type="hidden" name="cmcheckval" id="id_cmcheckval" value=0 />';
+                       str += '<input type="hidden" name="optvol" id="id_optvol" value=0 />';
+                       str += '<input type="hidden" name="optdif" id="id_optdif" value=0 />';
+                       str += '<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.recut(1)" class="ui-state-default ui-corner-all ui-dialog-buttonpane button">CMチェックボックスの内容で再度分割を実施</a></div>';
+                       }
+                       else {
+                               str  = '<div class="prg_title">パラメータ再分割</div>';
+                               str += '<input type="hidden" name="reserve_id" id="id_reserve_id" value="' + id +  '" />';
+                               str += '<input type="hidden" name="cmcheckval" id="id_cmcheckval" value=0 />';
+                               str += '無音検知ボリューム(デフォルト9)<select name="optvol" id="id_optvol">';
+                               str += ' <option value="7">7</option>';
+                               str += ' <option value="8">8</option>';
+                               str += ' <option value="9" selected>9</option>';
+                               str += ' <option value="10">10</option>';
+                               str += ' <option value="11">11</option>';
+                               str += ' <option value="12">12</option>';
+                               str += '</select><BR>';
+                               str += '無音検知間隔(デフォルト250)<select name="optdif" id="id_optdif">';
+                               str += ' <option value="150">150</option>';
+                               str += ' <option value="200">200</option>';
+                               str += ' <option value="250" selected>250</option>';
+                               str += ' <option value="300">300</option>';
+                               str += '</select>ms<BR><BR>';
+                               str += '本編にCMが含まれてしまっている場合などに再指定し分割します<BR>';
+                               str += 'ボリュームを+するか間隔を短くすることで正常に検知されるようになると思われます。<BR>';
+                       str += '<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.recut(2)" class="ui-state-default ui-corner-all ui-dialog-buttonpane button">指定パラメータで元ファイルから再分割します。</a></div>';
+                       }
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open', 'center');
+               },
+               recut:function(mode){
+                       var id_reserve_id = $('#id_reserve_id').val();
+                       var tblstr="";
+                       if (mode == 1) {
+                               var elem = document.cmtbl.elements.length;
+                               for(i=0;i<elem;i++) {
+                                       if (tblstr!="")
+                                               tblstr=tblstr + ",";
+                                       if (document.cmtbl.elements[i].checked)
+                                               tblstr=tblstr + "1";
+                                       else
+                                               tblstr=tblstr + "0";
+                               }
+                       }
+                       var id_optvol = $('#id_optvol').val();
+                       var id_optdif = $('#id_optdif').val();
+                       var str;
+                       str  = '<div class="prg_title">再分割中・・・・</div>';
+                       str += '<div>しばらくお待ちください。(完了後自動でクローズします。)</div>';
+                       $('#floatBox4Dialog').dialog('close');
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open', 'center');
+                       $.post('cmcheckExec.php', { reserve_id: id_reserve_id, checkval: tblstr ,optvol: id_optvol,optdif: id_optdif } , function( data ) {
+                               if(data.match(/^error/i)){
+                                       $('#floatBox4Dialog').dialog('close');
+                                       alert(data);
+                               }
+                               else {
+//                                     alert(data);
+                                       //$('#resid_' + id ).hide();
+                                       $('#floatBox4Dialog').dialog('close');
+                                       location.reload(true);
+                               }
+                       });
+               },
+               editdialog:function(id,mode) {
+                       var str;
+                       if (mode == 1) {
+                       str  = '<div class="prg_title">録画ID:' + id + '</div>';
+                       str += 'ファイルの置き換えを実施しない。<input type="checkbox" id="id_replace" name="replace" value="1"><BR>';
+                       str += '<input type="hidden" name="reserve_id" id="id_reserve_id" value="' + id +  '" />';
+                       str += '<input type="hidden" name="cmcheckcomplete" id="id_cmcheckcomplete" value=1 />';
+                       str += '<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.edit()" class="ui-state-default ui-corner-all ui-dialog-buttonpane button"> cmcheck完了 </a></div>';
+                       }
+                       else {
+                       }
+                       
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open','center');
+               },
+               edit:function() {
+                       var id_reserve_id = $('#id_reserve_id').val();
+                       var id_cmcheckcomplete = $('#id_cmcheckcomplete').val();
+                       var id_replace = $('#id_replace').is(':checked');
+                       var str;
+
+                       $.post('cmcheckExec.php', { reserve_id: id_reserve_id,cmcheckcomplete: id_cmcheckcomplete,replace: id_replace } , function( data ) {
+                               if(data.match(/^error/i)){
+                                       alert(data);
+                                       $('#floatBox4Dialog').dialog('close');
+
+                               }
+                               else {
+                                       $('#floatBox4Dialog').dialog('close');
+                                       location.reload(true);
+                               }
+                       });
+            }
+
+       }
+       $(document).ready(function () {
+               var DG = $('#floatBox4Dialog');
+               DG.dialog({width:'auto'});
+               DG.dialog({modal:true});
+               DG.dialog('close');
+       });
+-->
+</script>
+
+
+<style type="text/css">
+<!--
+body {padding:4px;margin:0;font-size:10pt;}
+a {text-decoration:none;}
+
+table#reservation_table {
+    width: 800px;
+    border: 1px #BBB solid;
+    border-collapse: collapse;
+    border-spacing: 0;
+}
+
+table#cmcheck_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#reservation_table td {
+    padding: 5px;
+    border: 1px #BBB solid;
+    border-width: 0 0 1px 1px;
+    text-align: center;
+}
+
+table#reservation_table tr.ctg_news, #category_select a.ctg_news {background-color: #FFFFD8;}
+table#reservation_table tr.ctg_etc, #category_select a.ctg_etc {background-color: #FFFFFF;}
+table#reservation_table tr.ctg_information, #category_select a.ctg_information {background-color: #F2D8FF;}
+table#reservation_table tr.ctg_sports, #category_select a.ctg_sports {background-color: #D8FFFF;}
+table#reservation_table tr.ctg_cinema, #category_select a.ctg_cinema {background-color: #FFD8D8;}
+table#reservation_table tr.ctg_music, #category_select a.ctg_music {background-color: #D8D8FF;}
+table#reservation_table tr.ctg_drama, #category_select a.ctg_drama {background-color: #D8FFD8;}
+table#reservation_table tr.ctg_anime, #category_select a.ctg_anime {background-color: #FFE4C8;}
+table#reservation_table tr.ctg_variety, #category_select a.ctg_variety {background-color: #FFD2EB;}
+table#reservation_table tr.ctg_10, #category_select a.ctg_10 {background-color: #E4F4F4;}
+table#reservation_table tr.prg_rec  {background-color: #F55;color:#FEE}
+
+
+-->
+</style>
+{/literal}
+
+</head>
+
+<body>
+
+       <h2>{$sitetitle}</h2>
+
+       <div><a href="viewer.php?reserve_id={$reserveid}">録画済みファイルを視聴</a></div>
+{if count($cmary)}
+       <div><a href="viewer.php?reserve_id={$reserveid}&cmcheckext=1">CMカット済みファイルを視聴</a></div>
+{/if}
+       <BR>
+
+<div><a href="recordedTable.php">録画済一覧へ</a>/<a href="index.php">番組表へ</a></div>
+       <BR>
+
+{if count($cmary)}
+<div>
+       cmcheck完了:録画済みファイルを置き換え<input type="submit" value="cmcheck完了" onClick="javascript:PRG.editdialog('{$reserveid}',1)"/>
+</div>
+<BR>
+<div>
+       チェックボックスのチェック内容で再度分割します。<input type="submit" value="再分割実施" onClick="javascript:PRG.dialog('{$reserveid}','{$sitetitle}',1)"/>
+</div>
+<BR>
+<table id="cmcheck_table">
+ <tr>
+  <th>id</th>
+  <th>開始位置</th>
+  <th>間隔</th>
+  <th>CM</th>
+  <th>サムネイル</th>
+ </tr>
+
+{foreach from=$cmary item=keyword}
+<form name="cmtbl">
+ <tr id="keyid_{$keyword.id}">
+  <td>{$keyword.id}</td>
+  <td>{$keyword.start}</td>
+  <td>{$keyword.diff}</td>
+  <td><input type="checkbox" id="iscm" name="iscm" value="1" {if $keyword.cm == CM } checked {/if}/>{$keyword.cm}</td>
+  <td><img width="128" height="72" src="{$keyword.thumb}"  onClick="javascript:PRG.imgdialog('{$keyword.id}','{$keyword.thumb}')""/></td>
+ </tr>
+{/foreach}
+</table>
+</form>
+{else}
+  CMチェック用ファイルはありません
+{/if}
+<BR>
+<BR>
+<div>
+       分割パラメータを変更し再度分割します。<BR>CMが本編内に埋まっているなどチェックボックス設定では対応できない場合実施します。<BR><input type="submit" value="元ファイルから再分割" onClick="javascript:PRG.dialog('{$reserveid}','{$sitetitle}',2)"/>
+</div>
+<BR>
+
+<div id="floatBox4Dialog">jQuery UI Dialog</div>
+
+{literal}
+<script type="text/javascript">
+var INISet = {
+       prgRecordURL : 'xxrecord.php',                  // 簡易予約
+       prgRecordPlusURL : 'xxrecordp.php',             // 詳細予約
+       prgCancelURL : 'xxcancelReservation.php'                // 予約キャンセル
+}
+</script>
+{/literal}
+
+</body>
+</html>
+
+
diff --git a/epgrec/templates/recordedTable.html b/epgrec/templates/recordedTable.html
new file mode 100755 (executable)
index 0000000..806a95f
--- /dev/null
@@ -0,0 +1,212 @@
+<!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}
+<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
+<link rel="stylesheet" href="start/jquery-ui-1.7.2.custom.css" type="text/css">
+<script type="text/javascript">
+<!--
+       var PRG = {
+               
+               dialog:function(id, title){
+                       $('#floatBox4Dialog').dialog({title:'削除',width:500});
+                       var str = '<div class="prg_title">' + title + 'を削除します</div>';
+                       str += '<form><div style="text-align:center;">録画ファイルも削除する<input type="checkbox" id="delete_file" name="delete_file" value="1" /></div></form>';
+                       str +='<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.rec(' + id + ')" class="ui-state-default ui-corner-all ui-dialog-buttonpane button">この録画を本当に削除する</a></div>';
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open', 'center');
+               },
+               rec:function(id){
+                       var df = 0;
+                       if( $('#delete_file').attr('checked') ) {
+                               df = 1;
+                       }
+                       $('#floatBox4Dialog').dialog('close');
+                       $('#floatBox4Dialog').html('削除中.......');
+                       $('#floatBox4Dialog').dialog('open', 'center');
+                       $.get(INISet.prgCancelURL, { reserve_id: id, delete_file: df } ,function(data){
+                               if(data.match(/^error/i)){
+                                       $('#floatBox4Dialog').dialog('close');
+                                       alert(data);
+                               }
+                               else {
+//                                     alert(data);
+                                       $('#resid_' + id ).hide();
+                                       $('#floatBox4Dialog').dialog('close');
+                               }
+                       });
+               },
+               editdialog:function(id) {
+                       $('#floatBox4Dialog').dialog({title:'変更',width:500});
+                       var str;
+                       str  = '<div class="prg_title">録画ID:' + id + '</div>';
+                       str += '<input type="hidden" name="reserve_id" id="id_reserve_id" value="' + id +  '" />';
+                       str += '<div><span class="labelLeft">タイトル</span><input name="title" id="id_title" size="30"  value="'+ $('#tid_' + id ).html() + '" /></div>';
+                       str += '<div><span class="labelLeft">概要</span><textarea name="description" id="id_description" cols="30" rows="5" >' + $('#did_' + id ).html() + '</textarea></div>';
+                       str += '<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.edit()" class="ui-state-default ui-corner-all ui-dialog-buttonpane button">変更する</a></div>';
+                       
+                       $('#floatBox4Dialog').html(str);
+                       $('#floatBox4Dialog').dialog('open','center');
+               },
+               edit:function() {
+                       var id_reserve_id = $('#id_reserve_id').val();
+                       var id_title = $('#id_title').val();
+                       var id_description = $('#id_description').val();
+
+                       $.post('changeReservation.php', { reserve_id: id_reserve_id,
+                                                         title: id_title,
+                                                         description: id_description }, function( data ) {
+                               if(data.match(/^error/i)){
+                                       alert(data);
+                                       $('#floatBox4Dialog').dialog('close');
+
+                               }
+                               else {
+                                       $('#tid_' + id_reserve_id ).html( id_title );
+                                       $('#did_' + id_reserve_id ).html( id_description );
+                                       $('#floatBox4Dialog').dialog('close');
+                               }
+                       });
+               }
+       }
+       $(document).ready(function () {
+               var DG = $('#floatBox4Dialog');
+               DG.dialog({title:'変更',width:500});
+               DG.dialog('close');
+       });
+-->
+</script>
+<style type="text/css">
+<!--
+body {padding:4px;margin:0;font-size:10pt;}
+a {text-decoration:none;}
+
+.bold {font-weight:bold;}
+.small {font-size:75%;}
+
+a img {border:none; }
+
+table#reservation_table {
+    width: 960px;
+    border: 1px #BBB solid;
+    border-collapse: collapse;
+    border-spacing: 0;
+}
+
+table#reservation_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#reservation_table td {
+    padding: 5px;
+    border: 1px #BBB solid;
+    border-width: 0 0 1px 1px;
+    text-align: center;
+}
+
+table#reservation_table tr.ctg_news, #category_select a.ctg_news {background-color: #FFFFD8;}
+table#reservation_table tr.ctg_etc, #category_select a.ctg_etc {background-color: #FFFFFF;}
+table#reservation_table tr.ctg_information, #category_select a.ctg_information {background-color: #F2D8FF;}
+table#reservation_table tr.ctg_sports, #category_select a.ctg_sports {background-color: #D8FFFF;}
+table#reservation_table tr.ctg_cinema, #category_select a.ctg_cinema {background-color: #FFD8D8;}
+table#reservation_table tr.ctg_music, #category_select a.ctg_music {background-color: #D8D8FF;}
+table#reservation_table tr.ctg_drama, #category_select a.ctg_drama {background-color: #D8FFD8;}
+table#reservation_table tr.ctg_anime, #category_select a.ctg_anime {background-color: #FFE4C8;}
+table#reservation_table tr.ctg_variety, #category_select a.ctg_variety {background-color: #FFD2EB;}
+table#reservation_table tr.ctg_10, #category_select a.ctg_10 {background-color: #E4F4F4;}
+
+
+#floatBox4Dialog .prg_title{font-size:120%;font-weight:bold;padding:0.4em 0;text-align:center;}
+#floatBox4Dialog .prg_rec_cfg{background:#EEE;padding:1em 2em;margin:0.4em 0;}
+#floatBox4Dialog .labelLeft {width:8em;float:left;text-align:right;}
+#floatBox4Dialog .button {padding:0.4em 1em;}
+
+
+-->
+</style>
+{/literal}
+
+</head>
+
+<body>
+
+<h2>{$sitetitle}</h2>
+
+<p><a href="index.php">番組表に戻る</a></p>
+
+<div>
+絞り込み:
+<form method="post" action="recordedTable.php" >
+<input type="hidden" name="do_search" value="1" />
+検索語句<input type="text" size="20" name="search" value="{$search}" />
+局<select name="station">
+  {foreach from=$stations item=st}
+    <option value="{$st.id}" {$st.selected}>{$st.name}</option>
+  {/foreach}
+  </select>
+カテゴリ<select name="category_id">
+  {foreach from=$cats item=cat}
+  <option value="{$cat.id}" {$cat.selected}>{$cat.name}</option>
+  {/foreach}
+</select>
+<input type="submit" value="絞り込む" />
+</form>
+</div>
+
+タイトルや内容をクリックすると視聴できます(ブラウザの設定でASFとVLCを関連付けている必要があります)
+{if count($records)}
+<table id="reservation_table">
+ <tr>
+  <th>録画日時</th>
+  <th>ch</th>
+  <th>モード</th>
+  {if $use_thumbs == 1}<th>サムネール</th>{/if}
+  <th>タイトル</th>
+  <th>内容</th>
+  <th>変更</th>
+  <th>削除</th>
+ </tr>
+
+{foreach from=$records item=rec }
+ <tr id="resid_{$rec.id}" class="ctg_{$rec.cat}">
+  <td>{$rec.starttime}</td>
+  <td>{$rec.station_name}</td>
+  <td>{$rec.mode}</td>
+  {if $use_thumbs == 1}<td><a href="{$rec.asf}">{$rec.thumb}</a></td>{/if}
+  <td><a href="{$rec.asf}" id="tid_{$rec.id}">{$rec.title}</a> <a href="cmcheckTable.php?reserve_id={$rec.id}">(cmcheck)</a></td>
+  <td><a href="{$rec.asf}" id="did_{$rec.id}">{$rec.description}</a></td>
+  <td><input type="button" value="変更" onClick="javascript:PRG.editdialog('{$rec.id}')" /></td>
+  <td><input type="button" value="削除" onClick="javascript:PRG.dialog('{$rec.id}','{$rec.title}')" /></td>
+ </tr>
+{/foreach}
+</table>
+
+{else}
+  現在、録画済データはありません
+{/if}
+
+<div id="floatBox4Dialog">jQuery UI Dialog</div>
+
+{literal}
+<script type="text/javascript">
+var INISet = {
+       prgRecordURL : 'record.php',                    // 簡易予約
+       prgRecordPlusURL : 'recordp.php',               // 詳細予約
+       prgCancelURL : 'cancelReservation.php'          // 予約キャンセル
+}
+</script>
+{/literal}
+</body>
+</html>
diff --git a/epgrec/viewer.php b/epgrec/viewer.php
new file mode 100755 (executable)
index 0000000..cd833cf
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
+header("Last-Modified: ". gmdate("D, d M Y H:i:s"). " GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Cache-Control: post-check=0, pre-check=0", false);
+header("Pragma: no-cache");
+
+
+include_once("config.php");
+include_once(INSTALL_PATH . "/DBRecord.class.php" );
+include_once(INSTALL_PATH . "/reclib.php" );
+include_once(INSTALL_PATH . "/Settings.class.php" );
+
+$settings = Settings::factory();
+
+if( ! isset( $_GET['reserve_id'] )) jdialog("予約番号が指定されていません", "recordedTable.php");
+$reserve_id = $_GET['reserve_id'];
+$cmcheckext = $_GET['cmcheckext'];
+if ($cmcheckext) {
+       $cmcheckext="-new.mp4";
+}
+
+
+try{
+       $rrec = new DBRecord( RESERVE_TBL, "id", $reserve_id );
+
+       $start_time = toTimestamp($rrec->starttime);
+       $end_time = toTimestamp($rrec->endtime );
+       $duration = $end_time - $start_time + $settings->former_time;
+
+       $dh = $duration / 3600;
+       $duration = $duration % 3600;
+       $dm = $duration / 60;
+       $duration = $duration % 60;
+       $ds = $duration;
+       $pathex  = $rrec->path . $cmcheckext;
+       
+       $title = htmlspecialchars(str_replace(array("\r\n","\r","\n"), '', $rrec->title),ENT_QUOTES);
+       $abstract = htmlspecialchars(str_replace(array("\r\n","\r","\n"), '', $rrec->description),ENT_QUOTES);
+       
+       header("Content-type: video/x-ms-asf; charset=\"UTF-8\"");
+       header('Content-Disposition: inline; filename="'.$pathex.'.asx"');
+       echo "<ASX version = \"3.0\">";
+       echo "<PARAM NAME = \"Encoding\" VALUE = \"UTF-8\" />";
+       echo "<ENTRY>";
+       if( ! $rrec->complete ) echo "<REF HREF=\"".$settings->install_url."/sendstream.php?reserve_id=".$rrec->id ."\" />";
+       echo "<REF HREF=\"".$settings->install_url.$settings->spool."/".$pathex."\" />";
+       echo "<TITLE>".$title."</TITLE>";
+       echo "<ABSTRACT>".$abstract."</ABSTRACT>";
+       echo "<DURATION VALUE=";
+       echo '"'.sprintf( "%02d:%02d:%02d",$dh, $dm, $ds ).'" />';
+       echo "</ENTRY>";
+       echo "</ASX>";
+}
+catch(exception $e ) {
+       exit( $e->getMessage() );
+}
+?>