changeset 135:9c5e597ef6c6

mod: ログ機能を追加
author epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
date Sat, 20 Mar 2010 23:59:01 +0900
parents 58791b90221b
children 6754b6aa50cf
files Keyword.class.php Reservation.class.php install/step3.php recLog.inc.php storeProgram.inc.php tableStruct.inc.php upgrade_db.php
diffstat 7 files changed, 74 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Keyword.class.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/Keyword.class.php	Sat Mar 20 23:59:01 2010 +0900
@@ -44,13 +44,13 @@
 				$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' ))."%'";
+					$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' ))."%'";
+					$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' ))."%'";
+					$options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN', "UTF-8" ))."%'";
 				}
 				$options .= ") ";
 			}
--- a/Reservation.class.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/Reservation.class.php	Sat Mar 20 23:59:01 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" );
 
 
 // 篋膣
@@ -178,7 +179,6 @@
 				throw new Exception( "腟ゃゃ/腟c腟с" );
 			}
 			
-			
 			// <ゃ
 /*
 			%TITLE%	腟帥ゃ
@@ -300,6 +300,7 @@
 			}
 			else {
 				$rrec->delete();
+				reclog( "Reservation::custom at絎茵紊掩罔≧", E_ERROR);
 				throw new Exception("AT絎茵");
 			}
 			// job垩冴
@@ -313,11 +314,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 ) {
@@ -349,13 +352,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 篋膣c潟祉DB・膓障≪祉鴻紊掩罔≧", E_ERROR );
 			throw $e;
 		}
 	}
--- a/install/step3.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/install/step3.php	Sat Mar 20 23:59:01 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" );
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/recLog.inc.php	Sat Mar 20 23:59:01 2010 +0900
@@ -0,0 +1,21 @@
+<?php
+
+define( "E_INFO" , 0 );
+define( "E_ERROR", 2 );
+
+
+function reclog( $message , $level = E_INFO ) {
+	
+	try {
+		$log = new DBRecord( LOG_TBL );
+		
+		$log->logtime = date("Y-m-d H:i:s");
+		$log->level = $level;
+		$log->message = $message;
+	}
+	catch( Exception $e ) {
+		// 
+	}
+}
+
+?>
--- a/storeProgram.inc.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/storeProgram.inc.php	Sat Mar 20 23:59:01 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,9 +25,10 @@
 	foreach( $arr as $val ) {
 		try {
 			$val->reservation();
+			reclog( "getepg::若若ID".$val->id."篋膣");
 		}
 		catch( Exception $e ) {
-		// ∴
+			// ∴
 		}
 	}
 }
@@ -39,6 +45,7 @@
 	// XML parse
   	$xml = @simplexml_load_file( $xmlfile );
 	if( $xml === false ) {
+		reclog( "getepg::".$xmlfile."篏c罔≧", E_ERROR );
 		return;	// XML茯水篏
 	}
 	// channel遵
@@ -64,7 +71,7 @@
 		}
 	 }
 	 catch( Exception $e ) {
-		// ∴
+		reclog( "getepg::DB・膓障c潟若吾莨若帥紊掩", E_ERROR );
 	 }
 	}
 	// channel 腟篋
@@ -82,7 +89,7 @@
 			$channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", "$channel_disc" );
 		}
 		catch( Exception $e ) {
-			// ∴
+			reclog( "getepg::c潟潟若肴с", E_ERROR );
 		}
 		if( $channel_rec == null ) continue;	// 緇莎激
 		if( $channel_rec->skip == 1 ) continue;	// 篆<c潟
@@ -129,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();
 				}
 			}
@@ -161,9 +170,10 @@
 		 }
 		}
 		catch(Exception $e) {
+			reclog( "getepg::DBュ阪馹罔≧", E_ERROR );
 			exit( $e->getMessage() );
 		}
 	}
 	// Programme緇絎篋
 }
-?>
\ No newline at end of file
+?>
--- a/tableStruct.inc.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/tableStruct.inc.php	Sat Mar 20 23:59:01 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
--- a/upgrade_db.php	Sat Mar 20 00:49:37 2010 +0900
+++ b/upgrade_db.php	Sat Mar 20 23:59:01 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" );