changeset 152:784e3c82926e

mod: yazucchi¤µ¤ó¤Î¥Ñ¥Ã¥Á¼è¤ê¹þ¤ß
author [email protected] <[email protected]>
date Sun, 28 Mar 2010 22:13:52 +0900
parents 5b192e94f49d
children 4099ae0393eb
files Keyword.class.php config.php.sample do-record.sh.pt1 do-record.sh.sample getepg.old.php getepg.php
diffstat 6 files changed, 71 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/Keyword.class.php	Sat Mar 27 16:04:54 2010 +0900
+++ b/Keyword.class.php	Sun Mar 28 22:13:52 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/config.php.sample	Sat Mar 27 16:04:54 2010 +0900
+++ b/config.php.sample	Sun Mar 28 22:13:52 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	Sat Mar 27 16:04:54 2010 +0900
+++ b/do-record.sh.pt1	Sun Mar 28 22:13:52 2010 +0900
@@ -5,7 +5,29 @@
 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
+# mode 2 example is as follows
+#elif [ ${MODE} = 2 ]; then
+#   $RECORDER $CHANNEL $DURATION ${OUTPUT}.tmp.ts --b25 --strip
+#   ffmpeg -i ${OUTPUT}.tmp.ts ... 適当なオプション ${OUTPUT}
+fi
--- a/do-record.sh.sample	Sat Mar 27 16:04:54 2010 +0900
+++ b/do-record.sh.sample	Sun Mar 28 22:13:52 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
--- a/getepg.old.php	Sat Mar 27 16:04:54 2010 +0900
+++ b/getepg.old.php	Sun Mar 28 22:13:52 2010 +0900
@@ -19,7 +19,7 @@
   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 ) {
+	if( $num < $settings->bs_tuners ) {
 	 	$cmdline = "CHANNEL=211 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." ".$settings->temp_xml;
@@ -32,7 +32,7 @@
 	// 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 ) {
+		if( $num < $settings->bs_tuners ) {
 			$cmdline = "CHANNEL=CS8 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." ".$settings->temp_xml;
@@ -42,7 +42,7 @@
 			if( file_exists( $settings->temp_xml ) ) @unlink( $settings->temp_xml );
 		}
 		$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 ) {
+		if( $num < $settings->bs_tuners ) {
 			$cmdline = "CHANNEL=CS24 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." ".$settings->temp_xml;
@@ -59,7 +59,7 @@
 	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 ) {
+		if( $num < $settings->gr_tuners ) {
 			$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." ".$settings->temp_xml;
--- a/getepg.php	Sat Mar 27 16:04:54 2010 +0900
+++ b/getepg.php	Sun Mar 28 22:13:52 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;
@@ -86,7 +87,7 @@
 			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
 		}
 		$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_cs2) ) {
+		if( ($num < $settings->bs_tuners) && check_file($temp_xml_cs2) ) {
 			$cmdline = "CHANNEL=".CS2_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_cs2;
@@ -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
+?>