changeset 37:e5f9aa34d06f

change: modify all script for web base setting
author yoneda <epgrec@park.mda.or.jp>
date Tue, 28 Jul 2009 00:00:04 +0900
parents c2522d1df005
children 2bc96d657ba1
files DBRecord.class.php Keyword.class.php cancelReservation.php changeReservation.php customReservation.php epgrec_upgrade.php getepg.php index.php keywordTable.php mediatomb.php programTable.php recomplete.php
diffstat 12 files changed, 120 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/DBRecord.class.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/DBRecord.class.php	Tue Jul 28 00:00:04 2009 +0900
@@ -11,7 +11,7 @@
     function __construct( $table, $property = null, $value = null ) {
 		$settings = Settings::factory();
 		
-		$this->table = $table;
+		$this->table = $settings->tbl_prefix.$table;
 		
 		$this->dbh = @mysql_connect( $settings->db_host , $settings->db_user, $settings->db_pass );
 		if( $this->dbh === FALSE ) throw new exception( "construct:データベースに接続できない" );
--- a/Keyword.class.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/Keyword.class.php	Tue Jul 28 00:00:04 2009 +0900
@@ -3,12 +3,17 @@
 include_once( INSTALL_PATH . "/DBRecord.class.php" );
 include_once( INSTALL_PATH . "/reclib.php" );
 include_once( INSTALL_PATH . "/Reservation.class.php" );
+include_once( INSTALL_PATH . '/Settings.class.php' );
 
 class Keyword extends DBRecord {
 	
+	protected $settings;
+	
 	public function __construct($property = null, $value = null ) {
+		$this->settings = Settings::factory();
+		
 		try {
-			parent::__construct(TBL_PREFIX.KEYWORD_TBL, $property, $value );
+			parent::__construct(KEYWORD_TBL, $property, $value );
 		}
 		catch( Exception $e ) {
 			throw $e;
@@ -19,7 +24,7 @@
 		if( $this->id == 0 ) return false;
 		
 		// ちょっと先を検索する
-		$options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + PADDING_TIME + 120 )."'";
+		$options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $this->settings->padding_time + 120 )."'";
 		
 		if( $this->keyword != "" ) {
 			if( $this->use_regexp ) {
@@ -46,7 +51,7 @@
 		
 		$recs = array();
 		try {
-			$recs = DBRecord::createRecords( TBL_PREFIX.PROGRAM_TBL, $options );
+			$recs = DBRecord::createRecords( PROGRAM_TBL, $options );
 		}
 		catch( Exception $e ) {
 			throw $e;
@@ -98,7 +103,7 @@
 		// 一気にキャンセル
 		foreach( $precs as $rec ) {
 			try {
-				$reserve = new DBRecord( TBL_PREFIX.RESERVE_TBL, "program_id", $rec->id );
+				$reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id );
 				// 自動予約されたもののみ削除
 				if( $reserve->autorec ) {
 					Reservation::cancel( $reserve->id );
--- a/cancelReservation.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/cancelReservation.php	Tue Jul 28 00:00:04 2009 +0900
@@ -3,9 +3,11 @@
 include_once( INSTALL_PATH . '/DBRecord.class.php' );
 include_once( INSTALL_PATH . '/Reservation.class.php' );
 include_once( INSTALL_PATH . '/reclib.php' );
+include_once( INSTALL_PATH . '/Settings.class.php' );
 
 $program_id = 0;
 $reserve_id = 0;
+$settings = Settings::factory();
 
 if( isset($_GET['program_id'])) {
 	$program_id = $_GET['program_id'];
@@ -13,14 +15,14 @@
 else if(isset($_GET['reserve_id'])) {
 	$reserve_id = $_GET['reserve_id'];
 	try {
-		$rec = new DBRecord( TBL_PREFIX.RESERVE_TBL, "id" , $reserve_id );
+		$rec = new DBRecord( RESERVE_TBL, "id" , $reserve_id );
 		$program_id = $rec->program_id;
 		
 		if( isset( $_GET['delete_file'] ) ) {
 			if( $_GET['delete_file'] == 1 ) {
 				// ファイルを削除
-				if( file_exists( INSTALL_PATH."/".SPOOL."/".$rec->path ) ) {
-					@unlink(INSTALL_PATH."/".SPOOL."/".$rec->path);
+				if( file_exists( INSTALL_PATH."/".$settings->spool."/".$rec->path ) ) {
+					@unlink(INSTALL_PATH."/".$settings->spool."/".$rec->path);
 				}
 			}
 		}
@@ -35,7 +37,7 @@
 // 手動取り消しのときには、その番組を自動録画対象から外す
 if( $program_id ) {
 	try {
-		$rec = new DBRecord(TBL_PREFIX.PROGRAM_TBL, "id", $program_id );
+		$rec = new DBRecord(PROGRAM_TBL, "id", $program_id );
 		$rec->autorec = 0;
 	}
 	catch( Exception $e ) {
--- a/changeReservation.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/changeReservation.php	Tue Jul 28 00:00:04 2009 +0900
@@ -2,6 +2,9 @@
 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( $_POST['reserve_id'] ) ) {
 	exit("Error: IDが指定されていません" );
@@ -9,20 +12,18 @@
 $reserve_id = $_POST['reserve_id'];
 
 $dbh = false;
-if( defined("MEDIATOMB_UPDATE") ) {
-	if( MEDIATOMB_UPDATE ) {
-		$dbh = @mysql_connect( DB_HOST, DB_USER, DB_PASS );
-		if( $dbh !== false ) {
-			$sqlstr = "use ".DB_NAME;
-			@mysql_query( $sqlstr );
-			$sqlstr = "set NAME utf8";
-			@mysql_query( $sqlstr );
-		}
+if( $settings->mediatomb_update ) {
+	$dbh = @mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
+	if( $dbh !== false ) {
+		$sqlstr = "use ".$settings->db_name;
+		@mysql_query( $sqlstr );
+		$sqlstr = "set NAME utf8";
+		@mysql_query( $sqlstr );
 	}
 }
 
 try {
-	$rec = new DBRecord(TBL_PREFIX.RESERVE_TBL, "id", $reserve_id );
+	$rec = new DBRecord(RESERVE_TBL, "id", $reserve_id );
 	
 	if( isset( $_POST['title'] ) ) {
 		$rec->title = trim( $_POST['title'] );
@@ -30,7 +31,7 @@
 			$title = trim( mysql_real_escape_string($_POST['title']));
 			$title .= "(".date("Y/m/d", toTimestamp($rec->starttime)).")";
 			$sqlstr = "update mt_cds_object set dc_title='".$title."' where metadata regexp 'epgrec:id=".$reserve_id."$'";
-			mysql_query( $sqlstr );
+			@mysql_query( $sqlstr );
 		}
 	}
 	
--- a/customReservation.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/customReservation.php	Tue Jul 28 00:00:04 2009 +0900
@@ -3,6 +3,10 @@
 include_once( INSTALL_PATH . "/DBRecord.class.php" );
 include_once( INSTALL_PATH . "/reclib.php" );
 include_once( INSTALL_PATH . "/Reservation.class.php" );
+include_once( INSTALL_PATH . "/Settings.class.php" );
+
+$settings = Settings::factory();
+
 
 $program_id = 0;
 if( isset( $_POST['program_id'] ) ) $program_id = $_POST['program_id'];
--- a/epgrec_upgrade.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/epgrec_upgrade.php	Tue Jul 28 00:00:04 2009 +0900
@@ -1,11 +1,14 @@
 #!/usr/bin/php
 <?php
 include_once('config.php');
+include_once(INSTALL_PATH . '/Settings.class.php' );
 
- $dbh = mysql_connect( DB_HOST, DB_USER, DB_PASS );
+$settings = Settings::factory();
+
+ $dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
  if( $dbh !== false ) {
 	
-	$sqlstr = "use ".DB_NAME;
+	$sqlstr = "use ".$settings->db_name;
 	mysql_query( $sqlstr );
 	
 	$sqlstr = "set NAMES 'utf8'";
@@ -13,15 +16,15 @@
 	
 	// RESERVE_TBL
 	// description -> text
-	$sqlstr = "alter table ".TBL_PREFIX.RESERVE_TBL." modify description text default null;";
+	$sqlstr = "alter table ".RESERVE_TBL." modify description text default null;";
 	mysql_query( $sqlstr );
 	// path -> blob
-	$sqlstr = "alter table ".TBL_PREFIX.RESERVE_TBL." modify path blob default null;";
+	$sqlstr = "alter table ".RESERVE_TBL." modify path blob default null;";
 	mysql_query( $sqlstr );
 	
 	// PROGRAM_TBL
 	// descripton -> text
-	$sqlstr = "alter table ".TBL_PREFIX.PROGRAM_TBL." modify description text default null;";
+	$sqlstr = "alter table ".PROGRAM_TBL." modify description text default null;";
 	mysql_query( $sqlstr );
  }
  else exit( "Can't connect DB\n");
--- a/getepg.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/getepg.php	Tue Jul 28 00:00:04 2009 +0900
@@ -4,38 +4,41 @@
   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' );
   
-  if( file_exists( TEMP_DATA ) ) @unlink( TEMP_DATA );
-  if( file_exists( TEMP_XML ) ) @unlink( TEMP_XML );
+  $settings = Settings::factory();
+  
+  if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
+  if( file_exists( $settings->temp_xml ) ) @unlink( $settings->temp_xml );
 
   // BSを処理する
-  if( BS_TUNERS ) {
+  if( $settings->bs_tuners ) {
 	// 録画重複チェック
-	$num = DBRecord::countRecords( TBL_PREFIX . RESERVE_TBL, "WHERE complete = '0' AND type = 'BS' AND endtime > now() AND starttime < addtime( now(), '00:03:05')" );
+	$num = DBRecord::countRecords(  RESERVE_TBL, "WHERE complete = '0' AND type = 'BS' AND endtime > now() AND starttime < addtime( now(), '00:03:05')" );
 	if( $num == 0 ) {
-	 	$cmdline = "CHANNEL=211 DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".TEMP_DATA." ".DO_RECORD . " >/dev/null 2>&1";
+	 	$cmdline = "CHANNEL=211 DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
   		exec( $cmdline );
-  		$cmdline = EPGDUMP." /BS ".TEMP_DATA." ".TEMP_XML;
+  		$cmdline = EPGDUMP." /BS ".$settings->temp_data." ".$settings->temp_xml;
   		exec( $cmdline );
-  		storeProgram( "BS", TEMP_XML );
-  		if( file_exists( TEMP_DATA ) ) @unlink( TEMP_DATA );
-  		if( file_exists( TEMP_XML ) ) @unlink( TEMP_XML );
+  		storeProgram( "BS", $settings->temp_xml );
+  		if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
+  		if( file_exists( $settings->temp_xml ) ) @unlink( $settings->temp_xml );
   	}
   }
   
   // 地上波を処理する
-  if( GR_TUNERS ) {
+  if( $settings->gr_tuners ) {
 	foreach( $GR_CHANNEL_MAP as $key=>$value ){
 		// 録画重複チェック
-		$num = DBRecord::countRecords( TBL_PREFIX . RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" );
+		$num = DBRecord::countRecords(  RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" );
 		if( $num == 0 ) {
-			$cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".TEMP_DATA." ".DO_RECORD . " >/dev/null 2>&1";
+			$cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
 			exec( $cmdline );
-			$cmdline = EPGDUMP." ".$key." ".TEMP_DATA." ".TEMP_XML;
+			$cmdline = EPGDUMP." ".$key." ".$settings->temp_data." ".$settings->temp_xml;
 			exec( $cmdline );
-			storeProgram( "GR", TEMP_XML );
- 			if( file_exists( TEMP_DATA ) ) @unlink( TEMP_DATA );
-  			if( file_exists( TEMP_XML ) ) @unlink( TEMP_XML );
+			storeProgram( "GR", $settings->temp_xml );
+ 			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
+  			if( file_exists( $settings->temp_xml ) ) @unlink( $settings->temp_xml );
   		}
   	}
   }
@@ -43,12 +46,12 @@
   // 不要なプログラムの削除
   // 8日以上前のプログラムを消す
   $arr = array();
-  $arr = DBRecord::createRecords( TBL_PREFIX . PROGRAM_TBL, "WHERE endtime < subdate( now(), 8 )" );
+  $arr = DBRecord::createRecords(  PROGRAM_TBL, "WHERE endtime < subdate( now(), 8 )" );
   foreach( $arr as $val ) $val->delete();
 	
   // 8日以上先のデータがあれば消す
   $arr = array();
-  $arr = DBRecord::createRecords( TBL_PREFIX . PROGRAM_TBL, "WHERE starttime  > adddate( now(), 8 )" );
+  $arr = DBRecord::createRecords(  PROGRAM_TBL, "WHERE starttime  > adddate( now(), 8 )" );
   foreach( $arr as $val ) $val->delete();
   
   // キーワード自動録画予約
@@ -82,10 +85,10 @@
 		$disc = $ch['id'];
 	 try {
 		// チャンネルデータを探す
-		$num = DBRecord::countRecords( TBL_PREFIX . CHANNEL_TBL , "WHERE channel_disc = '" . $disc ."'" );
+		$num = DBRecord::countRecords( CHANNEL_TBL , "WHERE channel_disc = '" . $disc ."'" );
 		if( $num == 0 ) {
 			// チャンネルデータがないなら新規作成
-			$rec = new DBRecord( TBL_PREFIX . CHANNEL_TBL );
+			$rec = new DBRecord(  CHANNEL_TBL );
 			$rec->type = $type;
 			$rec->channel = $map["$disc"];
 			$rec->channel_disc = $disc;
@@ -93,7 +96,7 @@
 		}
 		else {
 			// 存在した場合も、とりあえずチャンネル名は更新する
-			$rec = new DBRecord(TBL_PREFIX.CHANNEL_TBL, "channel_disc", $disc );
+			$rec = new DBRecord(CHANNEL_TBL, "channel_disc", $disc );
 			$rec->name = $ch->{'display-name'};
 		}
 	 }
@@ -123,33 +126,33 @@
 		try {
 		 // カテゴリを処理する
 		 $category_disc = md5( $cat_ja . $cat_en );
-		 $num = DBRecord::countRecords( TBL_PREFIX . CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" );
+		 $num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '".$category_disc."'" );
 		 $cat_rec = null;
 		 if( $num == 0 ) {
 			// 新規カテゴリの追加
-			$cat_rec = new DBRecord( TBL_PREFIX . CATEGORY_TBL );
+			$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( TBL_PREFIX . CATEGORY_TBL, "category_disc" , $category_disc );
+			$cat_rec = new DBRecord(CATEGORY_TBL, "category_disc" , $category_disc );
 		  //
-		 $channel_rec = new DBRecord( TBL_PREFIX . CHANNEL_TBL, "channel_disc", $channel_disc );
-		 $num = DBRecord::countRecords( TBL_PREFIX . PROGRAM_TBL, "WHERE program_disc = '".$program_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( TBL_PREFIX.PROGRAM_TBL, $options );
+			$battings = DBRecord::countRecords(PROGRAM_TBL, $options );
 			if( $battings > 0 ) {
 				// 重複発生=おそらく放映時間の変更
-				$records = DBRecord::createRecords( TBL_PREFIX.PROGRAM_TBL, $options );
+				$records = DBRecord::createRecords(PROGRAM_TBL, $options );
 				foreach( $records as $rec ) {
 					// 自動録画予約された番組は放映時間変更と同時にいったん削除する
 					try {
-						$reserve = new DBRecord(TBL_PREFIX.RESERVE_TBL, "program_id", $rec->id );
+						$reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id );
 						if( $reserve->autorec ) {
 							Reservation::cancel( $reserve->id );
 						}
@@ -162,7 +165,7 @@
 				}
 			}
 			// //
-			$rec = new DBRecord( TBL_PREFIX.PROGRAM_TBL );
+			$rec = new DBRecord( PROGRAM_TBL );
 			$rec->channel_disc = $channel_disc;
 			$rec->channel_id = $channel_rec->id;
 			$rec->type = $type;
@@ -176,7 +179,7 @@
 		 }
 		 else {
 			// 番組内容更新
-			$rec = new DBRecord( TBL_PREFIX . PROGRAM_TBL, "program_disc", $program_disc );
+			$rec = new DBRecord( PROGRAM_TBL, "program_disc", $program_disc );
 			$rec->title = $title;
 		 	$rec->description = $desc;
 			$rec->category_id = $cat_rec->id;
--- a/index.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/index.php	Tue Jul 28 00:00:04 2009 +0900
@@ -48,11 +48,11 @@
  if( $type == "BS" ) $channel_map = $BS_CHANNEL_MAP;
  else if( $type == "GR" ) $channel_map = $GR_CHANNEL_MAP;
  $st = 0;
- $prec = new DBRecord($settings->tbl_prefix.PROGRAM_TBL);
+ $prec = new DBRecord(PROGRAM_TBL);
  foreach( $channel_map as $channel_disc => $channel ) {
 	$prev_end = $top_time;
  	try {
-		$crec = new DBRecord( $settings->tbl_prefix . CHANNEL_TBL, "channel_disc", $channel_disc );
+		$crec = new DBRecord( CHANNEL_TBL, "channel_disc", $channel_disc );
 		$programs[$st]["station_name"]  = $crec->name;
 		
 		$reca = $prec->fetch_array( "channel_disc", $channel_disc,
@@ -90,7 +90,7 @@
 			}
 			
 			// プログラムを埋める
-			$cat = new DBRecord( $settings->tbl_prefix . CATEGORY_TBL, "id", $prg['category_id'] );
+			$cat = new DBRecord( CATEGORY_TBL, "id", $prg['category_id'] );
 			$programs[$st]['list'][$num]['category_name'] = $cat->name_en;
 			$programs[$st]['list'][$num]['height'] = $height;
 			$programs[$st]['list'][$num]['title'] = $prg['title'];
@@ -100,7 +100,7 @@
 			$programs[$st]['list'][$num]['duration'] = "" . (toTimestamp($prg['endtime']) - toTimestamp($prg['starttime']));
 			$programs[$st]['list'][$num]['channel'] = ($prg['type'] == "GR" ? "地上D" : "BS" ) . ":". $prg['channel'] . "ch";
 			$programs[$st]['list'][$num]['id'] = "" . ($prg['id']);
-			$programs[$st]['list'][$num]['rec'] = DBRecord::countRecords( $settings->tbl_prefix.RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" );
+			$programs[$st]['list'][$num]['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" );
 			$num++;
 		}
 	}
@@ -135,7 +135,7 @@
  $smarty = new Smarty();
  
  // カテゴリ一覧
- $crec = DBRecord::createRecords( $settings->tbl_prefix . CATEGORY_TBL );
+ $crec = DBRecord::createRecords( CATEGORY_TBL );
  $cats = array();
  $num = 0;
  foreach( $crec as $val ) {
--- a/keywordTable.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/keywordTable.php	Tue Jul 28 00:00:04 2009 +0900
@@ -30,7 +30,7 @@
 
 $keywords = array();
 try {
-	$recs = Keyword::createRecords(TBL_PREFIX.KEYWORD_TBL);
+	$recs = Keyword::createRecords(KEYWORD_TBL);
 	foreach( $recs as $rec ) {
 		$arr = array();
 		$arr['id'] = $rec->id;
@@ -38,13 +38,13 @@
 		$arr['type'] = $rec->type == "*" ? "すべて" : $rec->type;
 		
 		if( $rec->channel_id ) {
-			$crec = new DBRecord(TBL_PREFIX.CHANNEL_TBL, "id", $rec->channel_id );
+			$crec = new DBRecord(CHANNEL_TBL, "id", $rec->channel_id );
 			$arr['channel'] = $crec->name;
 		}
 		else $arr['channel'] = 'すべて';
 		
 		if( $rec->category_id ) {
-			$crec = new DBRecord(TBL_PREFIX.CATEGORY_TBL, "id", $rec->category_id );
+			$crec = new DBRecord(CATEGORY_TBL, "id", $rec->category_id );
 			$arr['category'] = $crec->name_jp;
 		}
 		else $arr['category'] = 'すべて';
--- a/mediatomb.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/mediatomb.php	Tue Jul 28 00:00:04 2009 +0900
@@ -4,15 +4,18 @@
 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();
 
 try {
 
-  $recs = DBRecord::createRecords(TBL_PREFIX.RESERVE_TBL );
+  $recs = DBRecord::createRecords(RESERVE_TBL );
 
 // DB接続
-  $dbh = mysql_connect( DB_HOST, DB_USER, DB_PASS );
+  $dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
   if( $dbh === false ) exit( "mysql connection fail" );
-  $sqlstr = "use ".DB_NAME;
+  $sqlstr = "use ".$settings->db_name;
   mysql_query( $sqlstr );
   $sqlstr = "set NAME utf8";
   mysql_query( $sqlstr );
--- a/programTable.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/programTable.php	Tue Jul 28 00:00:04 2009 +0900
@@ -2,6 +2,10 @@
 include_once('config.php');
 include_once( INSTALL_PATH . '/DBRecord.class.php' );
 include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
+include_once( INSTALL_PATH . '/Settings.class.php' );
+
+$settings = Settings::factory();
+
 
 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + 300 )."'";
 
@@ -12,7 +16,7 @@
 $station = 0;
 
 // mysql_real_escape_stringより先に接続しておく必要がある
-$dbh = @mysql_connect(DB_HOST, DB_USER, DB_PASS );
+$dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass );
 
 	// パラメータの処理
 if(isset( $_POST['do_search'] )) {
@@ -54,12 +58,12 @@
 	
 try{
 	
-	$precs = DBRecord::createRecords(TBL_PREFIX.PROGRAM_TBL, $options );
+	$precs = DBRecord::createRecords(PROGRAM_TBL, $options );
 	
 	$programs = array();
 	foreach( $precs as $p ) {
-		$ch  = new DBRecord(TBL_PREFIX.CHANNEL_TBL, "id", $p->channel_id );
-		$cat = new DBRecord(TBL_PREFIX.CATEGORY_TBL, "id", $p->category_id );
+		$ch  = new DBRecord(CHANNEL_TBL, "id", $p->channel_id );
+		$cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id );
 		$arr = array();
 		$arr['type'] = $p->type;
 		$arr['station_name'] = $ch->name;
@@ -69,13 +73,13 @@
 		$arr['description'] = $p->description;
 		$arr['id'] = $p->id;
 		$arr['cat'] = $cat->name_en;
-		$arr['rec'] = DBRecord::countRecords(TBL_PREFIX.RESERVE_TBL, "WHERE program_id='".$p->id."'");
+		$arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'");
 		
 		array_push( $programs, $arr );
 	}
 	
 	$k_category_name = "";
-	$crecs = DBRecord::createRecords(TBL_PREFIX.CATEGORY_TBL );
+	$crecs = DBRecord::createRecords(CATEGORY_TBL );
 	$cats = array();
 	$cats[0]['id'] = 0;
 	$cats[0]['name'] = "すべて";
@@ -109,7 +113,7 @@
 	}
 	
 	$k_station_name = "";
-	$crecs = DBRecord::createRecords(TBL_PREFIX.CHANNEL_TBL );
+	$crecs = DBRecord::createRecords(CHANNEL_TBL);
 	$stations = array();
 	$stations[0]['id'] = 0;
 	$stations[0]['name'] = "すべて";
--- a/recomplete.php	Mon Jul 27 22:27:54 2009 +0900
+++ b/recomplete.php	Tue Jul 28 00:00:04 2009 +0900
@@ -2,32 +2,34 @@
 <?php
 include_once( "config.php" );
 include_once( INSTALL_PATH . "/DBRecord.class.php" );
+include_once( INSTALL_PATH . "/Settings.class.php" );
+
+$settings = Settings::factory();
+
 
 $reserve_id = $argv[1];
 
 try{
-	$rrec = new DBRecord( TBL_PREFIX.RESERVE_TBL, "id" , $reserve_id );
+	$rrec = new DBRecord( RESERVE_TBL, "id" , $reserve_id );
 	
-	if( file_exists( INSTALL_PATH . SPOOL . "/". $rrec->path ) ) {
+	if( file_exists( INSTALL_PATH .$settings->spool . "/". $rrec->path ) ) {
 		// 予約完了
 		$rrec->complete = '1';
-		if( defined("MEDIATOMB_UPDATE") ) {
-			if( MEDIATOMB_UPDATE ) {
-				// ちょっと待った方が確実っぽい
-				@exec("sync");
-				sleep(15);
-				$dbh = mysql_connect( DB_HOST, DB_USER, DB_PASS );
-				if( $dbh !== false ) {
-					$sqlstr = "use ".DB_NAME;
-					mysql_query( $sqlstr );
-					// 別にやらなくてもいいが
-					$sqlstr = "set NAME utf8";
-					mysql_query( $sqlstr );
-					$sqlstr = "update mt_cds_object set metadata='dc:description=".mysql_real_escape_string($rrec->description)."&epgrec:id=".$reserve_id."' where dc_title='".$rrec->path."'";
-					mysql_query( $sqlstr );
-					$sqlstr = "update mt_cds_object set dc_title='".mysql_real_escape_string($rrec->title)."(".date("Y/m/d").")' where dc_title='".$rrec->path."'";
-					mysql_query( $sqlstr );
-				}
+		if( $settings->mediatomb_update ) {
+			// ちょっと待った方が確実っぽい
+			@exec("sync");
+			sleep(15);
+			$dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
+			if( $dbh !== false ) {
+				$sqlstr = "use ".$settings->db_name;
+				@mysql_query( $sqlstr );
+				// 別にやらなくてもいいが
+				$sqlstr = "set NAME utf8";
+				@mysql_query( $sqlstr );
+				$sqlstr = "update mt_cds_object set metadata='dc:description=".mysql_real_escape_string($rrec->description)."&epgrec:id=".$reserve_id."' where dc_title='".$rrec->path."'";
+				@mysql_query( $sqlstr );
+				$sqlstr = "update mt_cds_object set dc_title='".mysql_real_escape_string($rrec->title)."(".date("Y/m/d").")' where dc_title='".$rrec->path."'";
+				@mysql_query( $sqlstr );
 			}
 		}
 	}