changeset 148:8f4f74463d08

merged with upstream
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 26 Mar 2010 15:41:36 +0900
parents 4afd353b4507 (diff) fadae5e39857 (current diff)
children 3a6ec345ab0c
files config.php.sample
diffstat 14 files changed, 166 insertions(+), 151 deletions(-) [+]
line wrap: on
line diff
--- a/DBRecord.class.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/DBRecord.class.php	Fri Mar 26 15:41:36 2010 +0900
@@ -5,18 +5,18 @@
 class DBRecord {
 	protected $table;
 	protected $settings;
-	
+
 	protected $dbh;
 	public $id;
-	
+
     function __construct( $table, $property = null, $value = null ) {
 		$this->settings = Settings::factory();
-		
+
 		$this->table = $this->settings->tbl_prefix.$table;
-		
+
 		$this->dbh = @mysql_connect( $this->settings->db_host , $this->settings->db_user, $this->settings->db_pass );
 		if( $this->dbh === FALSE ) throw new exception( "construct:データベースに接続できない" );
-		
+
 		$sqlstr = "use ".$this->settings->db_name;
 		$res = $this->__query($sqlstr);
 		if( $res === false ) throw new exception("construct: " . $sqlstr );
@@ -31,17 +31,17 @@
 			$sqlstr = "SELECT * FROM ".$this->table.
 			            " WHERE ".mysql_real_escape_string( $property ).
 			              "='".mysql_real_escape_string( $value )."'";
-			
+
 			$res = $this->__query( $sqlstr );
 			$arr = mysql_fetch_array( $res , MYSQL_ASSOC );
 			if( $arr === FALSE ) throw new exception( "construct:無効な行" );
 			// 最初にヒットした行のidを使用する
 			$this->id = $arr['id'];
 		}
-		
+
 		return;
 	}
-	
+
 	function createTable( $tblstring ) {
 		$sqlstr = "use ".$this->settings->db_name;
 		$res = $this->__query($sqlstr);
@@ -50,20 +50,20 @@
 		$result = $this->__query( $sqlstr );
 		if( $result === false ) throw new exception( "createTable:テーブル作成失敗" );
 	}
-	
+
 	protected function __query( $sqlstr ) {
 		$res = @mysql_query( $sqlstr, $this->dbh );
 		if( $res === FALSE ) throw new exception( "__query:DBクエリ失敗:".$sqlstr );
 		return $res;
 	}
-	
+
 	function fetch_array( $property , $value, $options = null ) {
 		$retval = array();
-		
+
 		$sqlstr = "SELECT * FROM ".$this->table.
 		            " WHERE ".mysql_real_escape_string( $property ).
 		              "='".mysql_real_escape_string( $value )."'";
-		
+
 		if( $options != null ) {
 			$sqlstr .= "AND ".$options;
 		}
@@ -71,10 +71,10 @@
 		while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
 			array_push( $retval, $row );
 		}
-		
+
 		return $retval;
 	}
-	
+
 	function __set( $property, $value ) {
 		if( $property == "id" ) throw new exception( "set:idの変更は不可" );
 		// id = 0なら空の新規レコード作成
@@ -89,27 +89,27 @@
 		$res = $this->__query( $sqlstr );
 		if( $res == FALSE )  throw new exception("set:セット失敗" );
 	}
-	
+
 	function __get( $property ) {
 		if( $this->id == 0 ) throw new exception( "get:無効なid" );
 		if( $property == "id" ) return $this->id;
-		
+
 		$sqlstr = "SELECT ".mysql_real_escape_string($property)." FROM ".$this->table." WHERE id='".$this->id."'";
 		$res = $this->__query($sqlstr);
 		$arr = mysql_fetch_row( $res );
 		if( $arr === FALSE ) throw new exception( "get:".$property."は存在しない" );
-		
+
 		return stripslashes($arr[0]);
 	}
-	
+
 	function delete() {
 		if( $this->id == 0 ) throw new exception( "delete:無効なid" );
-		
+
 		$sqlstr = "DELETE FROM ".$this->table." WHERE id='".$this->id."'";
 		$this->__query( $sqlstr );
 		$this->id = 0;
 	}
-	
+
 	// countを実行する
 	static function countRecords( $table, $options = "" ) {
 		try{
@@ -124,7 +124,7 @@
 		$retval = mysql_fetch_row( $result );
 		return $retval[0];
 	}
-	
+
 	// DBRecordオブジェクトを返すstaticなメソッド
 	static function createRecords( $table, $options = "" ) {
 		$retval = array();
@@ -143,9 +143,9 @@
 		}
 		return $retval;
 	}
-	
+
 	function __destruct() {
 		$this->id = 0;
 	}
 }
-?>
\ No newline at end of file
+?>
--- a/Keyword.class.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/Keyword.class.php	Fri Mar 26 15:41:36 2010 +0900
@@ -37,23 +37,7 @@
 				$options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'";
 			}
 			else {
-				// 全角半角
-				// 場当たり的に対応
-				$f_zennum = preg_match('/[0-9]/u', $keyword );
-				$f_zenal  = preg_match('/[a-zA-Z]/u', $keyword );
-				
-				$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',"UTF-8" ))."%'";
-				}
-				if( $f_zenal ) {
-					$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', "UTF-8" ))."%'";
-				}
-				$options .= ") ";
+				$options .= " AND CONCAT(title,description) like _utf8'%".mysql_real_escape_string($keyword)."%' collate utf8_unicode_ci";
 			}
 		}
 		
--- a/Reservation.class.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/Reservation.class.php	Fri Mar 26 15:41:36 2010 +0900
@@ -9,13 +9,13 @@
 // 予約クラス
 
 class Reservation {
-	
+
 	public static function simple( $program_id , $autorec = 0, $mode = 0) {
 		$settings = Settings::factory();
 		$rval = 0;
 		try {
 			$prec = new DBRecord( PROGRAM_TBL, "id", $program_id );
-			
+
 			$rval = self::custom(
 				$prec->starttime,
 				$prec->endtime,
@@ -26,14 +26,14 @@
 				$program_id,
 				$autorec,
 				$mode );
-				
+
 		}
 		catch( Exception $e ) {
 			throw $e;
 		}
 		return $rval;
 	}
-	
+
 	public static function custom(
 		$starttime,				// 開始時間Datetime型
 		$endtime,				// 終了時間Datetime型
@@ -52,20 +52,20 @@
 		// 時間を計算
 		$start_time = toTimestamp( $starttime );
 		$end_time = toTimestamp( $endtime ) + $settings->extra_time;
-		
+
 		if( $start_time < (time() + PADDING_TIME + 10) ) {	// 現在時刻より3分先より小さい=すでに開始されている番組
 			$start_time = time() + PADDING_TIME + 10;		// 録画開始時間を3分10秒先に設定する
 		}
 		$at_start = $start_time - PADDING_TIME;
 		$sleep_time = PADDING_TIME - $settings->former_time;
 		$rec_start = $start_time - $settings->former_time;
-		
+
 		// durationを計算しておく
 		$duration = $end_time - $rec_start;
 		if( $duration < ($settings->former_time + 60) ) {	// 60秒以下の番組は弾く
 			throw new Exception( "終わりつつある/終わっている番組です" );
 		}
-		
+
 		$rrec = null;
 		try {
 			// 同一番組予約チェック
@@ -75,19 +75,19 @@
 					throw new Exception("同一の番組が録画予約されています");
 				}
 			}
-			
+
 			$crec = new DBRecord( CHANNEL_TBL, "id", $channel_id );
-			
+
 			// 既存予約数 = TUNER番号
 			$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' ".
 															  "AND ".$type_str.
 															  "AND starttime < '".toDatetime($end_time) ."' ".
 															  "AND endtime > '".toDatetime($rec_start)."'"
 			);
-			
+
 			if( $battings >= $tuners ) {
 				// 重複を発見した
 				if( $settings->force_cont_rec == 1 ) {
@@ -96,15 +96,15 @@
 					$nexts = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
 																	"AND ".$type_str.
 																	"AND starttime = '".toDatetime($end_time - $settings->former_time)."'");
-					
+
 					$prevs = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
 																"AND ".$type_str.
 																"AND endtime = '".$starttime."'"  );
-					
+
 					// 前後を引いてもチューナー数と同数以上なら重複の解消は無理
 					if( ($battings - $nexts - $prevs) >= $tuners )
 						throw new Exception( "重複予約を解消できません" );
-					
+
 					// 直後の番組はあるか?
 					if( $nexts ) {
 						// この番組の終わりをちょっとだけ早める
@@ -112,7 +112,7 @@
 						$duration = $end_time - $rec_start;		// durationを計算しなおす
 					}
 					$battings -= $nexts;
-					
+
 					// 直前の録画予約を見付ける
 					$trecs = DBRecord::createRecords(RESERVE_TBL, "WHERE complete = '0' ".
 																		 "AND ".$type_str.
@@ -140,13 +140,13 @@
 							$prev_starttime = toDatetime( $prev_start_time + $settings->former_time );
 							// 終わりをちょっとだけずらす
 							$prev_endtime   = toDatetime( toTimestamp($prev_endtime) - $settings->former_time - $settings->rec_switch_time );
-							
+
 							// tryのネスト
 							try {
 								// いったん予約取り消し
 								self::cancel( $prev_id );
 								// 再予約
-								self::custom( 
+								self::custom(
 									$prev_starttime,			// 開始時間Datetime型
 									$prev_endtime,				// 終了時間Datetime型
 									$prev_channel_id,			// チャンネルID
@@ -176,7 +176,7 @@
 			}
 			// チューナー番号
 			$tuner = $battings;
-			
+
 			// 改めてdurationをチェックしなおす
 			if( $duration < ($settings->former_time + 60) ) {	// 60秒以下の番組は弾く
 				throw new Exception( "終わりつつある/終わっている番組です" );
@@ -242,14 +242,14 @@
 			
 			$filename .= $RECORD_MODE["$mode"]['suffix'];
 			$thumbname = $filename.".jpg";
-			
+
 			// サムネール
 			$gen_thumbnail = INSTALL_PATH."/gen-thumbnail.sh";
-			if( defined("GEN_THUMBNAIL") ) 
+			if( defined("GEN_THUMBNAIL") )
 				$gen_thumbnail = GEN_THUMBNAIL;
-			
+
 			// ファイル名生成終了
-			
+
 			// 予約レコードを埋める
 			$rrec = new DBRecord( RESERVE_TBL );
 			$rrec->channel_disc = $crec->channel_disc;
@@ -266,7 +266,7 @@
 			$rrec->autorec = $autorec;
 			$rrec->mode = $mode;
 			$rrec->reserve_disc = md5( $crec->channel_disc . toDatetime( $start_time ). toDatetime( $end_time ) );
-			
+
 			// 予約実行
 			$cmdline = $settings->at." ".date("H:i m/d/Y", $at_start);
 			$descriptor = array( 0 => array( "pipe", "r" ),
@@ -284,7 +284,7 @@
 			              "FFMPEG"   => "".$settings->ffmpeg,
 			              "SID"      => $crec->sid,
 			);
-			
+
 			// ATで予約する
 			$process = proc_open( $cmdline , $descriptor, $pipes, INSTALL_PATH.$settings->spool, $env );
 			if( is_resource( $process ) ) {
@@ -297,7 +297,7 @@
 				fclose($pipes[0]);
 				// 標準エラーを取る
 				$rstring = stream_get_contents( $pipes[2]);
-				
+
 			    fclose( $pipes[2] );
 			    proc_close( $process );
 			}
@@ -337,12 +337,12 @@
 		}
 	}
 	// custom 終了
-	
+
 	// 取り消し
 	public static function cancel( $reserve_id = 0, $program_id = 0 ) {
 		$settings = Settings::factory();
 		$rec = null;
-		
+
 		try {
 			if( $reserve_id ) {
 				$rec = new DBRecord( RESERVE_TBL, "id" , $reserve_id );
--- a/Settings.class.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/Settings.class.php	Fri Mar 26 15:41:36 2010 +0900
@@ -2,17 +2,17 @@
 include_once('config.php');
 
 class Settings extends SimpleXMLElement {
-	
+
 	const CONFIG_XML = "/settings/config.xml";
-	
+
 	public static function factory() {
-		
+
 		if( file_exists( INSTALL_PATH . self::CONFIG_XML ) ) {
 			$xmlfile = file_get_contents(INSTALL_PATH . self::CONFIG_XML);
 			$obj = new self($xmlfile);
-			
+
 			// 8月14日以降に追加した設定項目の自動生成
-			
+
 			// キーワード自動録画の録画モード
 			if( $obj->exists("autorec_mode") == 0 ) {
 				$obj->autorec_mode = 0;
@@ -29,86 +29,86 @@
 			// 初回起動
 			$xmlfile = '<?xml version="1.0" encoding="UTF-8" ?><epgrec></epgrec>';
 			$xml = new self($xmlfile);
-			
+
 			// 旧config.phpを読み取って設定
 			if(defined("SPOOL") ) $xml->spool = SPOOL;
 			else $xml->spool = "/video";
-			
+
 			if(defined("THUMBS") ) $xml->thumbs = THUMBS;
 			else $xml->thumbs = "/thumbs";
-			
+
 			if(defined("INSTALL_URL")) $xml->install_url = INSTALL_URL;
 			else $xml->install_url = "http://localhost/epgrec";
-			
+
 			if(defined("BS_TUNERS")) $xml->bs_tuners = BS_TUNERS;
 			else $xml->bs_tuners = 0;
-			
+
 			if(defined("GR_TUNERS")) $xml->gr_tuners = GR_TUNERS;
 			else $xml->gr_tuners = 1;
 
 			if(defined("CS_REC_FLG")) $xml->cs_rec_flg = CS_REC_FLG;
 			else $xml->cs_rec_flg = 0;
-			
+
 			if(defined("USE_KUROBON")) $xml->use_kurobon = USE_KUROBON ? 1 : 0;
 			else $xml->use_kurobon = 0;
-			
+
 			if(defined("FORMER_TIME")) $xml->former_time = FORMER_TIME;
 			else $xml->former_time = 20;
-			
+
 			if(defined("EXTRA_TIME")) $xml->extra_time = EXTRA_TIME;
 			else $xml->extra_time = 0;
-			
+
 			if(defined("FORCE_CONT_REC")) $xml->force_cont_rec = FORCE_CONT_REC ? 1 : 0;
 			else $xml->force_cont_rec = 0;
-			
+
 			if(defined("REC_SWITCH_TIME")) $xml->rec_switch_time = REC_SWITCH_TIME;
 			else $xml->rec_switch_time = 5;
-			
+
 			if(defined("USE_THUMBS")) $xml->use_thumbs = USE_THUMBS ? 1 : 0;
 			else $xml->use_thumbs = 0;
-			
+
 			if(defined("MEDIATOMB_UPDATE")) $xml->mediatomb_update = MEDIATOMB_UPDATE ? 1 : 0;
 			else $xml->mediatomb_update = 0;
-			
+
 			if(defined("FILENAME_FORMAT")) $xml->filename_format = FILENAME_FORMAT;
 			else $xml->filename_format = "%TYPE%%CH%_%ST%_%ET%";
-			
+
 			if(defined("DB_HOST")) $xml->db_host = DB_HOST;
 			else $xml->db_host = "localhost";
-			
+
 			if(defined("DB_NAME")) $xml->db_name = DB_NAME;
 			else $xml->db_name = "yourdbname";
-			
+
 			if(defined("DB_USER")) $xml->db_user = DB_USER;
 			else $xml->db_user = "yourname";
-			
+
 			if(defined("DB_PASS")) $xml->db_pass = DB_PASS;
 			else $xml->db_pass = "yourpass";
-			
+
 			if(defined("TBL_PREFIX")) $xml->tbl_prefix = TBL_PREFIX;
 			else $xml->tbl_prefix = "Recorder_";
 
 			if(defined("EPGDUMP")) $xml->epgdump = EPGDUMP;
 			else $xml->epgdump = "/usr/local/bin/epgdump";
-			
+
 			if(defined("AT")) $xml->at = AT;
 			else $xml->at = "/usr/bin/at";
-			
+
 			if(defined( "ATRM" )) $xml->atrm = ATRM;
 			else $xml->atrm = "/usr/bin/atrm";
 
 			if(defined( "SLEEP" )) $xml->sleep = SLEEP;
 			else $xml->sleep = "/bin/sleep";
-			
+
 			if(defined( "FFMPEG" )) $xml->ffmpeg = FFMPEG;
 			else $xml->ffmpeg = "/usr/bin/ffmpeg";
-			
+
 			if(defined("TEMP_DATA" )) $xml->temp_data = TEMP_DATA;
 			else $xml->temp_data = "/tmp/__temp.ts";
-			
+
 			if(defined("TEMP_XML")) $xml->temp_xml = TEMP_XML;
 			else $xml->temp_xml = "/tmp/__temp.xml";
-			
+
 			// index.phpで使う設定値
 			// 表示する番組表の長さ(時間)
 			$xml->program_length = 8;
@@ -116,9 +116,9 @@
 			$xml->ch_set_width = 150;
 			// 1分あたりの高さ
 			$xml->height_per_hour = 120;
-			
+
 			// 8月14日版以降に追加した設定項目
-			
+
 			// キーワード自動録画の録画モード
 			$xml->autorec_mode = 0;
 			
@@ -126,26 +126,26 @@
 			$xml->cs_rec_flg = 0;
 			
 			$xml->save();
-			
+
 			return $xml;
 		}
 	}
-	
+
 	public function exists( $property ) {
 		return (int)count( $this->{$property} );
 	}
-	
+
 	public function post() {
 		global $_POST;
-		
+
 		foreach( $_POST as $key => $value ) {
-			
+
 			if( $this->exists($key) ) {
 				$this->{$key} = trim($value);
 			}
 		}
 	}
-	
+
 	public function save() {
 		$this->asXML(INSTALL_PATH . self::CONFIG_XML);
 	}
--- a/config.php.sample	Mon Mar 22 22:43:11 2010 +0900
+++ b/config.php.sample	Fri Mar 26 15:41:36 2010 +0900
@@ -85,24 +85,6 @@
 define( "CS1_EPG_CHANNEL", "CS8"  );	// CS1
 define( "CS2_EPG_CHANNEL", "CS24" );	// CS2
 
-
-// 地上デジタルチャンネルテーブルsettings/gr_channel.phpが存在するならそれを
-// 優先する
-if( file_exists( INSTALL_PATH."/settings/gr_channel.php" ) ) {
-	unset($GR_CHANNEL_MAP);
-	include_once( INSTALL_PATH."/settings/gr_channel.php" );
-}
-
-//
-// settings/site_conf.phpがあればそれを優先する
-//
-if( file_exists( INSTALL_PATH."/settings/site_conf.php" ) ) {
-	unset($GR_CHANNEL_MAP);
-	unset($RECORD_MODE);
-	include_once( INSTALL_PATH."/settings/site_conf.php" );
-}
-
-
 // 全国用BSデジタルチャンネルマップ
 $BS_CHANNEL_MAP = array(
         "3001.ontvjapan.com" => "101",
@@ -225,6 +207,31 @@
 	*/
 );
 
+
+// 地上デジタルチャンネルテーブルsettings/gr_channel.phpが存在するならそれを
+// 優先する
+if( file_exists( INSTALL_PATH."/settings/gr_channel.php" ) ) {
+	unset($GR_CHANNEL_MAP);
+	include_once( INSTALL_PATH."/settings/gr_channel.php" );
+}
+
+//
+// settings/site_conf.phpがあればそれを優先する
+//
+if( file_exists( INSTALL_PATH."/settings/site_conf.php" ) ) {
+	unset($GR_CHANNEL_MAP);
+	unset($RECORD_MODE);
+	include_once( INSTALL_PATH."/settings/site_conf.php" );
+}
+
+// Deprecated
+// カスタマイズした設定をロードし、デフォルト設定をオーバライドする
+// unsetはカスタム設定ファイルの責任で行う
+if( file_exists( INSTALL_PATH."/settings/config_custom.php" ) ) {
+	include_once( INSTALL_PATH."/settings/config_custom.php" );
+}
+
+
 // DBテーブル情報 以下は変更しないでください
 
 define( "RESERVE_TBL",  "reserveTbl" );						// 予約テーブル
--- a/do-record.sh.pt1	Mon Mar 22 22:43:11 2010 +0900
+++ b/do-record.sh.pt1	Fri Mar 26 15:41:36 2010 +0900
@@ -5,7 +5,28 @@
 echo "TUNER : $TUNER"
 echo "TYPE : $TYPE"
 echo "MODE : $MODE"
+echo "SID  : $SID"
 
 RECORDER=/usr/local/bin/recpt1
 
-$RECORDER --b25 --strip $CHANNEL $DURATION ${OUTPUT} >/dev/null
+# 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
+   $RECORDER $CHANNEL $DURATION ${OUTPUT}.tmp.ts --b25 --strip
+   ffmpeg -i ${OUTPUT}.tmp.ts ... 適当なオプション ${OUTPUT}
+fi
--- a/do-record.sh.sample	Mon Mar 22 22:43:11 2010 +0900
+++ b/do-record.sh.sample	Fri Mar 26 15:41:36 2010 +0900
@@ -9,13 +9,13 @@
 RECORDER=/usr/local/bin/recfriio
 B25=/usr/local/bin/b25_bcas
 
-if [ ${MODE} == 0 ]; then
+if [ ${MODE} = 0 ]; then
    # MODE=0では必ず無加工のTSを吐き出すこと
    $RECORDER $CHANNEL $DURATION ${OUTPUT} --b25 --strip
-elif [ ${MODE} == 1 ]; then
+elif [ ${MODE} = 1 ]; then
    # MODE=0以外はどう手を加えても構いません
    $RECORDER $CHANNEL $DURATION --b25 --strip | 何か加工 >${OUTPUT}
-elif [ ${MODE} == 2 ]; then
+elif [ ${MODE} = 2 ]; then
    $RECORDER $CHANNEL $DURATION ${OUTPUT}.tmp.ts --b25 --strip
    ffmpeg -i ${OUTPUT}.tmp.ts ... 適当なオプション ${OUTPUT}
 fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fix_permission.sh	Fri Mar 26 15:41:36 2010 +0900
@@ -0,0 +1,3 @@
+#!/bin/sh
+chmod 777 cache settings templates templates_c thumbs
+chmod -f 666 settings/config.xml
--- a/getepg.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/getepg.php	Fri Mar 26 15:41:36 2010 +0900
@@ -14,20 +14,20 @@
   if( ! defined( "BS_EPG_CHANNEL" )  ) define( "BS_EPG_CHANNEL",  "211"  );
   if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8"  );
   if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" );
-  
+
   function check_file( $file ) {
 	// ファイルがないなら無問題
 	if( ! file_exists( $file ) ) return true;
-	
+
 	// 1時間以上前のファイルなら削除してやり直す
 	if( (time() - filemtime( $file )) > 3600 ) {
 		@unlink( $file );
 		return true;
 	}
-	
+
 	return false;
   }
-  
+
   // 並列化が可能か執念深く調べる
   $use_para = false;
   $use_para = (function_exists( "pcntl_fork" ) && function_exists( "posix_setsid" ) && function_exists( "pcntl_signal" ) && function_exists("pcntl_setpriority"));
@@ -39,19 +39,19 @@
   }
   
   $settings = Settings::factory();
-  
+
   $temp_xml_bs  = $settings->temp_xml."_bs";
   $temp_xml_cs1 = $settings->temp_xml."_cs1";
   $temp_xml_cs2 = $settings->temp_xml."_cs2";
   $temp_xml_gr  = $settings->temp_xml."_gr";
-  
+
   if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
-  
+
   // BSを処理する
   if( $settings->bs_tuners != 0 ) {
 	// 録画重複チェック
 	$num = DBRecord::countRecords(  RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" );
-	if( ($num == 0) && check_file($temp_xml_bs) ) {
+	if($num < $settings->bs_tuners && check_file($temp_xml_bs)) {
 	 	$cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
   		exec( $cmdline );
   		$cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs;
@@ -70,7 +70,8 @@
 	// CS
 	if ($settings->cs_rec_flg != 0) {
 		$num = DBRecord::countRecords(  RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" );
-		if( ($num == 0) && check_file($temp_xml_cs1) ) {
+		if($num < $settings->bs_tuners && check_file($temp_xml_cs1)) {
+
 			$cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
 			exec( $cmdline );
 			$cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1;
@@ -103,13 +104,13 @@
 	  	}
   	}
   }
-  
+
   // 地上波を処理する
   if( $settings->gr_tuners != 0 ) {
 	foreach( $GR_CHANNEL_MAP as $key=>$value ){
 		// 録画重複チェック
 		$num = DBRecord::countRecords(  RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" );
-		if( ($num == 0) && check_file($temp_xml_gr.$value."") ) {
+		if($num < $settings->gr_tuners && check_file($temp_xml_gr.$value."")) {
 			$cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
 			exec( $cmdline );
 			$cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value."";
@@ -128,8 +129,8 @@
   }
   // 並列ならこれで終わりにする
   if( $use_para ) exit();
-  
+
   garbageClean();			//  不要プログラム削除
   doKeywordReservation();	// キーワード予約
   exit();
-?>
\ No newline at end of file
+?>
--- a/programTable.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/programTable.php	Fri Mar 26 15:41:36 2010 +0900
@@ -180,4 +180,4 @@
 catch( exception $e ) {
 	exit( $e->getMessage() );
 }
-?>
\ No newline at end of file
+?>
--- a/simpleReservation.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/simpleReservation.php	Fri Mar 26 15:41:36 2010 +0900
@@ -11,9 +11,9 @@
 $settings = Settings::factory();
 
 try {
-	Reservation::simple( $program_id , 0, $settings->autorec_mode);
+	Reservation::simple( $program_id, 0, $settings->autorec_mode);
 }
 catch( Exception $e ) {
 	exit( "Error:". $e->getMessage() );
 }
-?>
\ No newline at end of file
+?>
--- a/storeProgram.php	Mon Mar 22 22:43:11 2010 +0900
+++ b/storeProgram.php	Fri Mar 26 15:41:36 2010 +0900
@@ -6,7 +6,7 @@
 
   $type = $argv[1];	// BS CS GR
   $file = $argv[2];	// XMLファイル
-  
+
   // SIGTERMシグナル
   function handler( $signo = 0 ) {
 	global $file;
@@ -15,7 +15,7 @@
 	}
 	exit();
   }
-  
+
   // デーモン化
   function daemon() {
 	if( pcntl_fork() != 0 )
@@ -25,24 +25,24 @@
 		exit;
 	pcntl_signal(SIGTERM, "handler");
   }
-  
+
   // デーモン化
   daemon();
   // プライオリティ低に
   pcntl_setpriority(20);
-  
+
   include_once( INSTALL_PATH . '/DBRecord.class.php' );
   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();
-  
+
   if( file_exists( $file ) ) {
 	storeProgram( $type, $file );
 	@unlink( $file );
   }
   garbageClean();			//  不要プログラム削除
   doKeywordReservation();	// キーワード予約
-?>
\ No newline at end of file
+?>
--- a/templates/envSetting.html	Mon Mar 22 22:43:11 2010 +0900
+++ b/templates/envSetting.html	Fri Mar 26 15:41:36 2010 +0900
@@ -176,7 +176,7 @@
 <h3>ページに表示する番組表の長さ(時間)</h3>
 <div class="setting">
 <div class="caption">1ページに表示する番組表の長さを時間で設定します。標準は8時間分です。</div>
-<input type="text" name="program_length" value="{$settings->program_length}" size="2" class="required digits" min="2" max="24" />
+<input type="text" name="program_length" value="{$settings->program_length}" size="2" class="required digits" min="2" />
 </div>
 
 
--- a/video/index.html	Mon Mar 22 22:43:11 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<html></html>