Mercurial > epgrec.yaz
annotate programTable.php @ 113:9b9e22be8407
added zenkaku query hack
| author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
|---|---|
| date | Sat, 13 Mar 2010 18:53:41 +0900 |
| parents | 57676bb30f64 |
| children | f5d58cf2842f |
| rev | line source |
|---|---|
| 1 | 1 <?php |
| 2 include_once('config.php'); | |
| 3 include_once( INSTALL_PATH . '/DBRecord.class.php' ); | |
| 4 include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' ); | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
5 include_once( INSTALL_PATH . '/Settings.class.php' ); |
|
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
6 |
|
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
7 $settings = Settings::factory(); |
|
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
8 |
| 1 | 9 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + 300 )."'"; |
| 10 | |
| 77 | 11 // 曜日 |
| 12 $weekofdays = array( | |
| 13 array( "name" => "月", "id" => 0, "selected" => "" ), | |
| 14 array( "name" => "火", "id" => 1, "selected" => "" ), | |
| 15 array( "name" => "水", "id" => 2, "selected" => "" ), | |
| 16 array( "name" => "木", "id" => 3, "selected" => "" ), | |
| 17 array( "name" => "金", "id" => 4, "selected" => "" ), | |
| 18 array( "name" => "土", "id" => 5, "selected" => "" ), | |
| 19 array( "name" => "日", "id" => 6, "selected" => "" ), | |
| 20 array( "name" => "なし", "id" => 7, "selected" => "" ), | |
| 21 ); | |
| 22 | |
| 106 | 23 |
| 77 | 24 $autorec_modes = $RECORD_MODE; |
| 25 $autorec_modes[(int)($settings->autorec_mode)]['selected'] = "selected"; | |
| 26 | |
| 27 $weekofday = 7; | |
| 1 | 28 $search = ""; |
| 29 $use_regexp = 0; | |
| 30 $type = "*"; | |
| 31 $category_id = 0; | |
| 32 $station = 0; | |
| 106 | 33 $prgtime = 24; |
| 34 | |
| 1 | 35 |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
36 // mysql_real_escape_stringより先に接続しておく必要がある |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
37 $dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass ); |
| 1 | 38 |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
39 // パラメータの処理 |
| 1 | 40 if(isset( $_POST['do_search'] )) { |
| 41 if( isset($_POST['search'])){ | |
| 42 if( $_POST['search'] != "" ) { | |
| 43 $search = $_POST['search']; | |
| 44 if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) { | |
| 45 $use_regexp = $_POST['use_regexp']; | |
| 46 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($search)."'"; | |
| 47 } | |
| 48 else { | |
|
113
9b9e22be8407
added zenkaku query hack
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
106
diff
changeset
|
49 $search = mb_convert_kana($search, "A", "UTF-8"); |
| 1 | 50 $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($search)."%'"; |
| 51 } | |
| 52 } | |
| 53 } | |
| 54 if( isset($_POST['type'])){ | |
| 55 if( $_POST['type'] != "*" ) { | |
| 56 $type = $_POST['type']; | |
| 57 $options .= " AND type = '".$_POST['type']."'"; | |
| 58 } | |
| 59 } | |
| 60 if( isset($_POST['category_id'])) { | |
| 61 if( $_POST['category_id'] != 0 ) { | |
| 62 $category_id = $_POST['category_id']; | |
| 63 $options .= " AND category_id = '".$_POST['category_id']."'"; | |
| 64 } | |
| 65 } | |
| 66 if( isset($_POST['station'])) { | |
| 67 if( $_POST['station'] != 0 ) { | |
| 68 $station = $_POST['station']; | |
| 69 $options .= " AND channel_id = '".$_POST['station']."'"; | |
| 70 } | |
| 71 } | |
| 77 | 72 if( isset($_POST['weekofday']) ) { |
| 73 $weekofday = $_POST['weekofday']; | |
| 74 if( $weekofday != 7 ) { | |
| 75 $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; | |
| 76 } | |
| 77 } | |
| 106 | 78 if( isset($_POST['prgtime']) ) { |
| 79 $prgtime = (int)($_POST['prgtime']); | |
| 80 if( $prgtime != 24 ) { | |
| 81 $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; | |
| 82 } | |
| 83 } | |
| 1 | 84 } |
| 85 $options .= " ORDER BY starttime ASC LIMIT 300"; | |
| 106 | 86 |
| 87 | |
| 1 | 88 $do_keyword = 0; |
| 89 if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) ) | |
| 90 $do_keyword = 1; | |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
91 |
| 1 | 92 try{ |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
93 $precs = DBRecord::createRecords(PROGRAM_TBL, $options ); |
| 1 | 94 |
| 95 $programs = array(); | |
| 96 foreach( $precs as $p ) { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
97 $ch = new DBRecord(CHANNEL_TBL, "id", $p->channel_id ); |
|
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
98 $cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id ); |
| 1 | 99 $arr = array(); |
| 100 $arr['type'] = $p->type; | |
| 101 $arr['station_name'] = $ch->name; | |
| 102 $arr['starttime'] = $p->starttime; | |
| 103 $arr['endtime'] = $p->endtime; | |
| 104 $arr['title'] = $p->title; | |
| 105 $arr['description'] = $p->description; | |
| 106 $arr['id'] = $p->id; | |
| 107 $arr['cat'] = $cat->name_en; | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
108 $arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'"); |
| 1 | 109 |
| 110 array_push( $programs, $arr ); | |
| 111 } | |
| 112 | |
| 113 $k_category_name = ""; | |
| 77 | 114 $crecs = DBRecord::createRecords(CATEGORY_TBL); |
| 1 | 115 $cats = array(); |
| 116 $cats[0]['id'] = 0; | |
| 117 $cats[0]['name'] = "すべて"; | |
| 118 $cats[0]['selected'] = $category_id == 0 ? "selected" : ""; | |
| 119 foreach( $crecs as $c ) { | |
| 120 $arr = array(); | |
| 121 $arr['id'] = $c->id; | |
| 122 $arr['name'] = $c->name_jp; | |
| 123 $arr['selected'] = $c->id == $category_id ? "selected" : ""; | |
| 124 if( $c->id == $category_id ) $k_category_name = $c->name_jp; | |
| 125 array_push( $cats, $arr ); | |
| 126 } | |
| 127 | |
| 128 $types = array(); | |
| 129 $types[0]['name'] = "すべて"; | |
| 130 $types[0]['value'] = "*"; | |
| 131 $types[0]['selected'] = $type == "*" ? "selected" : ""; | |
| 57 | 132 if( $settings->gr_tuners != 0 ) { |
| 1 | 133 $arr = array(); |
| 134 $arr['name'] = "GR"; | |
| 135 $arr['value'] = "GR"; | |
| 136 $arr['selected'] = $type == "GR" ? "selected" : ""; | |
| 137 array_push( $types, $arr ); | |
| 138 } | |
| 57 | 139 if( $settings->bs_tuners != 0 ) { |
| 1 | 140 $arr = array(); |
| 141 $arr['name'] = "BS"; | |
| 142 $arr['value'] = "BS"; | |
| 143 $arr['selected'] = $type == "BS" ? "selected" : ""; | |
| 144 array_push( $types, $arr ); | |
|
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
145 |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
146 // CS |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
147 if ($settings->cs_rec_flg != 0) { |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
148 $arr = array(); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
149 $arr['name'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
150 $arr['value'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
151 $arr['selected'] = $type == "CS" ? "selected" : ""; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
152 array_push( $types, $arr ); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
153 } |
| 1 | 154 } |
| 155 | |
| 156 $k_station_name = ""; | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
157 $crecs = DBRecord::createRecords(CHANNEL_TBL); |
| 1 | 158 $stations = array(); |
| 159 $stations[0]['id'] = 0; | |
| 160 $stations[0]['name'] = "すべて"; | |
| 161 $stations[0]['selected'] = (! $station) ? "selected" : ""; | |
| 162 foreach( $crecs as $c ) { | |
| 163 $arr = array(); | |
| 164 $arr['id'] = $c->id; | |
| 165 $arr['name'] = $c->name; | |
| 166 $arr['selected'] = $station == $c->id ? "selected" : ""; | |
| 167 if( $station == $c->id ) $k_station_name = $c->name; | |
| 168 array_push( $stations, $arr ); | |
| 169 } | |
| 77 | 170 $weekofdays["$weekofday"]["selected"] = "selected" ; |
| 106 | 171 |
| 172 // 時間帯 | |
| 173 $prgtimes = array(); | |
| 174 for( $i=0; $i < 25; $i++ ) { | |
| 175 array_push( $prgtimes, | |
| 176 array( "name" => ( $i == 24 ? "なし" : sprintf("%0d時~",$i) ), | |
| 177 "value" => $i, | |
| 178 "selected" => ( $i == $prgtime ? "selected" : "" ) ) | |
| 179 ); | |
| 180 } | |
| 181 | |
| 182 | |
| 1 | 183 |
| 184 $smarty = new Smarty(); | |
| 185 $smarty->assign("sitetitle","番組検索"); | |
| 186 $smarty->assign("do_keyword", $do_keyword ); | |
| 187 $smarty->assign( "programs", $programs ); | |
| 188 $smarty->assign( "cats", $cats ); | |
| 189 $smarty->assign( "k_category", $category_id ); | |
| 190 $smarty->assign( "k_category_name", $k_category_name ); | |
| 191 $smarty->assign( "types", $types ); | |
| 192 $smarty->assign( "k_type", $type ); | |
| 193 $smarty->assign( "search" , $search ); | |
| 194 $smarty->assign( "use_regexp", $use_regexp ); | |
| 195 $smarty->assign( "stations", $stations ); | |
| 196 $smarty->assign( "k_station", $station ); | |
| 197 $smarty->assign( "k_station_name", $k_station_name ); | |
| 77 | 198 $smarty->assign( "weekofday", $weekofday ); |
| 199 $smarty->assign( "k_weekofday", $weekofdays["$weekofday"]["name"] ); | |
| 200 $smarty->assign( "weekofday", $weekofday ); | |
| 201 $smarty->assign( "weekofdays", $weekofdays ); | |
| 202 $smarty->assign( "autorec_modes", $autorec_modes ); | |
| 106 | 203 $smarty->assign( "prgtimes", $prgtimes ); |
| 204 $smarty->assign( "prgtime", $prgtime ); | |
| 1 | 205 $smarty->display("programTable.html"); |
| 206 } | |
| 207 catch( exception $e ) { | |
| 208 exit( $e->getMessage() ); | |
| 209 } | |
| 57 | 210 ?> |
