}
}
- private function getPrograms() {
- if( $this->id == 0 ) return false;
+ static public function search( $keyword = "",
+ $use_regexp = false,
+ $type = "*",
+ $category_id = 0,
+ $channel_id = 0,
+ $weekofday = 7,
+ $prgtime = 24,
+ $limit = 300 ) {
+ $sts = Settings::factory();
+
+ $dbh = @mysql_connect($sts->db_host, $sts->db_user, $sts->db_pass );
// ちょっと先を検索する
- $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $this->settings->padding_time + 120 )."'";
+ $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $sts->padding_time + 60 )."'";
- if( $this->keyword != "" ) {
- if( $this->use_regexp ) {
- $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($this->keyword)."'";
+ if( $keyword != "" ) {
+ if( $use_regexp ) {
+ $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'";
}
else {
- $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($this->keyword)."%'";
+ $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($keyword)."%'";
}
}
- if( $this->type != "*" ) {
- $options .= " AND type = '".$this->type."'";
+ if( $type != "*" ) {
+ $options .= " AND type = '".$type."'";
}
- if( $this->category_id != 0 ) {
- $options .= " AND category_id = '".$this->category_id."'";
+ if( $category_id != 0 ) {
+ $options .= " AND category_id = '".$category_id."'";
}
- if( $this->channel_id != 0 ) {
- $options .= " AND channel_id = '".$this->channel_id."'";
+ if( $channel_id != 0 ) {
+ $options .= " AND channel_id = '".$channel_id."'";
}
- if( $this->weekofday != 7 ) {
- $options .= " AND WEEKDAY(starttime) = '".$this->weekofday."'";
+ if( $weekofday != 7 ) {
+ $options .= " AND WEEKDAY(starttime) = '".$weekofday."'";
}
- if( $this->prgtime != 24 ) {
- $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $this->prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $this->prgtime)."' as time)";
+ if( $prgtime != 24 ) {
+ $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)";
}
- $options .= " ORDER BY starttime ASC";
+ $options .= " ORDER BY starttime ASC LIMIT ".$limit ;
$recs = array();
try {
return $recs;
}
+ private function getPrograms() {
+ if( $this->id == 0 ) return false;
+ $recs = array();
+ try {
+ $recs = self::search( trim($this->keyword), $this->use_regexp, $this->type, $this->category_id, $this->channel_id, $this->weekofday, $this->prgtime );
+ }
+ catch( Exception $e ) {
+ throw $e;
+ }
+ return $recs;
+ }
public function reservation() {
if( $this->id == 0 ) return;
catch( Exception $e ) {
throw $e;
}
- if( count($precs) < 300 ) {
- // 一気に録画予約
- foreach( $precs as $rec ) {
- try {
- if( $rec->autorec ) {
- Reservation::simple( $rec->id, $this->id, $this->autorec_mode );
- usleep( 100 ); // あんまり時間を空けないのもどう?
- }
- }
- catch( Exception $e ) {
- // 無視
+ // 一気に録画予約
+ foreach( $precs as $rec ) {
+ try {
+ if( $rec->autorec ) {
+ Reservation::simple( $rec->id, $this->id, $this->autorec_mode );
+ usleep( 100 ); // あんまり時間を空けないのもどう?
}
}
- }
- else {
- throw new Exception( "300件以上の自動録画は実行できません" );
+ catch( Exception $e ) {
+ // 無視
+ }
}
}
include_once( INSTALL_PATH . '/DBRecord.class.php' );
include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
include_once( INSTALL_PATH . '/Settings.class.php' );
+include_once( INSTALL_PATH . '/Keyword.class.php' );
$settings = Settings::factory();
$autorec_modes = $RECORD_MODE;
$autorec_modes[(int)($settings->autorec_mode)]['selected'] = "selected";
-$weekofday = 7;
$search = "";
$use_regexp = 0;
$type = "*";
$category_id = 0;
-$station = 0;
+$channel_id = 0;
+$weekofday = 7;
$prgtime = 24;
-
-// mysql_real_escape_stringより先に接続しておく必要がある
-$dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass );
-
- // パラメータの処理
+// パラメータの処理
if(isset( $_POST['do_search'] )) {
if( isset($_POST['search'])){
- if( $_POST['search'] != "" ) {
- $search = $_POST['search'];
- if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) {
- $use_regexp = $_POST['use_regexp'];
- $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($search)."'";
- }
- else {
- $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($search)."%'";
- }
+ $search = $_POST['search'];
+ if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) {
+ $use_regexp = (int)($_POST['use_regexp']);
}
}
if( isset($_POST['type'])){
- if( $_POST['type'] != "*" ) {
- $type = $_POST['type'];
- $options .= " AND type = '".$_POST['type']."'";
- }
+ $type = $_POST['type'];
}
if( isset($_POST['category_id'])) {
- if( $_POST['category_id'] != 0 ) {
- $category_id = $_POST['category_id'];
- $options .= " AND category_id = '".$_POST['category_id']."'";
- }
+ $category_id = (int)($_POST['category_id']);
}
if( isset($_POST['station'])) {
- if( $_POST['station'] != 0 ) {
- $station = $_POST['station'];
- $options .= " AND channel_id = '".$_POST['station']."'";
- }
+ $channel_id = (int)($_POST['station']);
}
if( isset($_POST['weekofday']) ) {
- $weekofday = $_POST['weekofday'];
- if( $weekofday != 7 ) {
- $options .= " AND WEEKDAY(starttime) = '".$weekofday."'";
- }
+ $weekofday = (int)($_POST['weekofday']);
}
if( isset($_POST['prgtime']) ) {
$prgtime = (int)($_POST['prgtime']);
- if( $prgtime != 24 ) {
- $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)";
- }
}
}
-$options .= " ORDER BY starttime ASC LIMIT 300";
-
$do_keyword = 0;
-if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) )
+if( ($search != "") || ($type != "*") || ($category_id != 0) || ($channel_id != 0) )
$do_keyword = 1;
try{
- $precs = DBRecord::createRecords(PROGRAM_TBL, $options );
+ $precs = Keyword::search( $search, $use_regexp, $type, $category_id, $channel_id, $weekofday, $prgtime );
$programs = array();
foreach( $precs as $p ) {
$stations = array();
$stations[0]['id'] = 0;
$stations[0]['name'] = "すべて";
- $stations[0]['selected'] = (! $station) ? "selected" : "";
+ $stations[0]['selected'] = (! $channel_id) ? "selected" : "";
foreach( $crecs as $c ) {
$arr = array();
$arr['id'] = $c->id;
$arr['name'] = $c->name;
- $arr['selected'] = $station == $c->id ? "selected" : "";
- if( $station == $c->id ) $k_station_name = $c->name;
+ $arr['selected'] = $channel_id == $c->id ? "selected" : "";
+ if( $channel_id == $c->id ) $k_station_name = $c->name;
array_push( $stations, $arr );
}
$weekofdays["$weekofday"]["selected"] = "selected" ;
$smarty->assign( "search" , $search );
$smarty->assign( "use_regexp", $use_regexp );
$smarty->assign( "stations", $stations );
- $smarty->assign( "k_station", $station );
+ $smarty->assign( "k_station", $channel_id );
$smarty->assign( "k_station_name", $k_station_name );
$smarty->assign( "weekofday", $weekofday );
$smarty->assign( "k_weekofday", $weekofdays["$weekofday"]["name"] );
catch( exception $e ) {
exit( $e->getMessage() );
}
-?>
+?>
\ No newline at end of file