Mercurial > epgrec.yaz
annotate Keyword.class.php @ 145:2cb414518ccd
mod: キーワード予約のログの位置を変えた
author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
---|---|
date | Mon, 22 Mar 2010 15:11:31 +0900 |
parents | 9c5e597ef6c6 |
children | 4afd353b4507 784e3c82926e |
rev | line source |
---|---|
1 | 1 <?php |
2 include_once('config.php'); | |
3 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | |
4 include_once( INSTALL_PATH . "/reclib.php" ); | |
5 include_once( INSTALL_PATH . "/Reservation.class.php" ); | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
6 include_once( INSTALL_PATH . '/Settings.class.php' ); |
145
2cb414518ccd
mod: キーワード予約のログの位置を変えた
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
7 include_once( INSTALL_PATH . '/recLog.inc.php' ); |
1 | 8 |
9 class Keyword extends DBRecord { | |
10 | |
11 public function __construct($property = null, $value = null ) { | |
12 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
13 parent::__construct(KEYWORD_TBL, $property, $value ); |
1 | 14 } |
15 catch( Exception $e ) { | |
16 throw $e; | |
17 } | |
18 } | |
19 | |
115 | 20 static public function search( $keyword = "", |
21 $use_regexp = false, | |
22 $type = "*", | |
23 $category_id = 0, | |
24 $channel_id = 0, | |
25 $weekofday = 7, | |
26 $prgtime = 24, | |
27 $limit = 300 ) { | |
28 $sts = Settings::factory(); | |
29 | |
30 $dbh = @mysql_connect($sts->db_host, $sts->db_user, $sts->db_pass ); | |
1 | 31 |
32 // <c罎膣≪ | |
115 | 33 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $sts->padding_time + 60 )."'"; |
1 | 34 |
115 | 35 if( $keyword != "" ) { |
36 if( $use_regexp ) { | |
37 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'"; | |
1 | 38 } |
39 else { | |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
40 // 茹茹 |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
41 // 翫絲上 |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
42 $f_zennum = preg_match('/[0-9]/u', $keyword ); |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
43 $f_zenal = preg_match('/[a-zA-Z]/u', $keyword ); |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
44 |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
45 $options .= " AND ( CONCAT(title,' ',description) like '%".mysql_real_escape_string($keyword)."%'"; |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
46 |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
47 if( $f_zennum ) { |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
130
diff
changeset
|
48 $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVN',"UTF-8" ))."%'"; |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
49 } |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
50 if( $f_zenal ) { |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
130
diff
changeset
|
51 $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVR', "UTF-8" ))."%'"; |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
52 } |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
53 if( $f_zenal && $f_zennum ) { |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
130
diff
changeset
|
54 $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN', "UTF-8" ))."%'"; |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
55 } |
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
56 $options .= ") "; |
1 | 57 } |
58 } | |
59 | |
115 | 60 if( $type != "*" ) { |
61 $options .= " AND type = '".$type."'"; | |
1 | 62 } |
63 | |
115 | 64 if( $category_id != 0 ) { |
65 $options .= " AND category_id = '".$category_id."'"; | |
1 | 66 } |
67 | |
115 | 68 if( $channel_id != 0 ) { |
69 $options .= " AND channel_id = '".$channel_id."'"; | |
1 | 70 } |
71 | |
115 | 72 if( $weekofday != 7 ) { |
73 $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; | |
77 | 74 } |
75 | |
115 | 76 if( $prgtime != 24 ) { |
77 $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; | |
106 | 78 } |
79 | |
115 | 80 $options .= " ORDER BY starttime ASC LIMIT ".$limit ; |
1 | 81 |
82 $recs = array(); | |
83 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
84 $recs = DBRecord::createRecords( PROGRAM_TBL, $options ); |
1 | 85 } |
86 catch( Exception $e ) { | |
87 throw $e; | |
88 } | |
89 return $recs; | |
90 } | |
91 | |
115 | 92 private function getPrograms() { |
93 if( $this->id == 0 ) return false; | |
94 $recs = array(); | |
95 try { | |
96 $recs = self::search( trim($this->keyword), $this->use_regexp, $this->type, $this->category_id, $this->channel_id, $this->weekofday, $this->prgtime ); | |
97 } | |
98 catch( Exception $e ) { | |
99 throw $e; | |
100 } | |
101 return $recs; | |
102 } | |
1 | 103 |
104 public function reservation() { | |
105 if( $this->id == 0 ) return; | |
106 | |
107 $precs = array(); | |
108 try { | |
109 $precs = $this->getPrograms(); | |
110 } | |
111 catch( Exception $e ) { | |
112 throw $e; | |
113 } | |
115 | 114 // 筝羂牙私膣 |
115 foreach( $precs as $rec ) { | |
116 try { | |
117 if( $rec->autorec ) { | |
118 Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); | |
145
2cb414518ccd
mod: キーワード予約のログの位置を変えた
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
119 reclog( "Keyword.class::若若ID".$this->id."牙祉篋膣"); |
115 | 120 usleep( 100 ); // 障腥冴? |
1 | 121 } |
122 } | |
115 | 123 catch( Exception $e ) { |
124 // ∴ | |
125 } | |
1 | 126 } |
127 } | |
128 | |
129 public function delete() { | |
130 if( $this->id == 0 ) return; | |
131 | |
132 $precs = array(); | |
133 try { | |
134 $precs = $this->getPrograms(); | |
135 } | |
136 catch( Exception $e ) { | |
137 throw $e; | |
138 } | |
139 // 筝羂c潟祉 | |
140 foreach( $precs as $rec ) { | |
141 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
142 $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id ); |
1 | 143 // 篋膣水 |
144 if( $reserve->autorec ) { | |
145 Reservation::cancel( $reserve->id ); | |
146 usleep( 100 ); // 障腥冴? | |
147 } | |
148 } | |
149 catch( Exception $e ) { | |
150 // ∴ | |
151 } | |
152 } | |
153 try { | |
154 parent::delete(); | |
155 } | |
156 catch( Exception $e ) { | |
157 throw $e; | |
158 } | |
159 } | |
160 | |
161 // static<潟激с潟若若ゃс | |
162 static function createKeywords( $options = "" ) { | |
163 $retval = array(); | |
164 $arr = array(); | |
165 try{ | |
166 $tbl = new self(); | |
167 $sqlstr = "SELECT * FROM ".$tbl->table." " .$options; | |
168 $result = $tbl->__query( $sqlstr ); | |
169 } | |
170 catch( Exception $e ) { | |
171 throw $e; | |
172 } | |
173 if( $result === false ) throw new exception("潟若絖障"); | |
174 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | |
175 array_push( $retval, new self('id', $row['id']) ); | |
176 } | |
177 return $retval; | |
178 } | |
179 | |
180 public function __destruct() { | |
181 parent::__destruct(); | |
182 } | |
183 } | |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
184 ?> |