Mercurial > epgrec.yaz
annotate programTable.php @ 114:f854f6606fa5
mod: DB???????config.php???????
| author | yoneda <epgrec@park.mda.or.jp> |
|---|---|
| date | Sat, 13 Mar 2010 21:37:27 +0900 |
| parents | 57676bb30f64 |
| children | 9b9e22be8407 7a64d5e3baee |
| 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 { | |
| 49 $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($search)."%'"; | |
| 50 } | |
| 51 } | |
| 52 } | |
| 53 if( isset($_POST['type'])){ | |
| 54 if( $_POST['type'] != "*" ) { | |
| 55 $type = $_POST['type']; | |
| 56 $options .= " AND type = '".$_POST['type']."'"; | |
| 57 } | |
| 58 } | |
| 59 if( isset($_POST['category_id'])) { | |
| 60 if( $_POST['category_id'] != 0 ) { | |
| 61 $category_id = $_POST['category_id']; | |
| 62 $options .= " AND category_id = '".$_POST['category_id']."'"; | |
| 63 } | |
| 64 } | |
| 65 if( isset($_POST['station'])) { | |
| 66 if( $_POST['station'] != 0 ) { | |
| 67 $station = $_POST['station']; | |
| 68 $options .= " AND channel_id = '".$_POST['station']."'"; | |
| 69 } | |
| 70 } | |
| 77 | 71 if( isset($_POST['weekofday']) ) { |
| 72 $weekofday = $_POST['weekofday']; | |
| 73 if( $weekofday != 7 ) { | |
| 74 $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; | |
| 75 } | |
| 76 } | |
| 106 | 77 if( isset($_POST['prgtime']) ) { |
| 78 $prgtime = (int)($_POST['prgtime']); | |
| 79 if( $prgtime != 24 ) { | |
| 80 $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; | |
| 81 } | |
| 82 } | |
| 1 | 83 } |
| 84 $options .= " ORDER BY starttime ASC LIMIT 300"; | |
| 106 | 85 |
| 86 | |
| 1 | 87 $do_keyword = 0; |
| 88 if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) ) | |
| 89 $do_keyword = 1; | |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
90 |
| 1 | 91 try{ |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
92 $precs = DBRecord::createRecords(PROGRAM_TBL, $options ); |
| 1 | 93 |
| 94 $programs = array(); | |
| 95 foreach( $precs as $p ) { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
96 $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
|
97 $cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id ); |
| 1 | 98 $arr = array(); |
| 99 $arr['type'] = $p->type; | |
| 100 $arr['station_name'] = $ch->name; | |
| 101 $arr['starttime'] = $p->starttime; | |
| 102 $arr['endtime'] = $p->endtime; | |
| 103 $arr['title'] = $p->title; | |
| 104 $arr['description'] = $p->description; | |
| 105 $arr['id'] = $p->id; | |
| 106 $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
|
107 $arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'"); |
| 1 | 108 |
| 109 array_push( $programs, $arr ); | |
| 110 } | |
| 111 | |
| 112 $k_category_name = ""; | |
| 77 | 113 $crecs = DBRecord::createRecords(CATEGORY_TBL); |
| 1 | 114 $cats = array(); |
| 115 $cats[0]['id'] = 0; | |
| 116 $cats[0]['name'] = "すべて"; | |
| 117 $cats[0]['selected'] = $category_id == 0 ? "selected" : ""; | |
| 118 foreach( $crecs as $c ) { | |
| 119 $arr = array(); | |
| 120 $arr['id'] = $c->id; | |
| 121 $arr['name'] = $c->name_jp; | |
| 122 $arr['selected'] = $c->id == $category_id ? "selected" : ""; | |
| 123 if( $c->id == $category_id ) $k_category_name = $c->name_jp; | |
| 124 array_push( $cats, $arr ); | |
| 125 } | |
| 126 | |
| 127 $types = array(); | |
| 128 $types[0]['name'] = "すべて"; | |
| 129 $types[0]['value'] = "*"; | |
| 130 $types[0]['selected'] = $type == "*" ? "selected" : ""; | |
| 57 | 131 if( $settings->gr_tuners != 0 ) { |
| 1 | 132 $arr = array(); |
| 133 $arr['name'] = "GR"; | |
| 134 $arr['value'] = "GR"; | |
| 135 $arr['selected'] = $type == "GR" ? "selected" : ""; | |
| 136 array_push( $types, $arr ); | |
| 137 } | |
| 57 | 138 if( $settings->bs_tuners != 0 ) { |
| 1 | 139 $arr = array(); |
| 140 $arr['name'] = "BS"; | |
| 141 $arr['value'] = "BS"; | |
| 142 $arr['selected'] = $type == "BS" ? "selected" : ""; | |
| 143 array_push( $types, $arr ); | |
|
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
144 |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
145 // CS |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
146 if ($settings->cs_rec_flg != 0) { |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
147 $arr = array(); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
148 $arr['name'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
149 $arr['value'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
150 $arr['selected'] = $type == "CS" ? "selected" : ""; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
151 array_push( $types, $arr ); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
152 } |
| 1 | 153 } |
| 154 | |
| 155 $k_station_name = ""; | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
156 $crecs = DBRecord::createRecords(CHANNEL_TBL); |
| 1 | 157 $stations = array(); |
| 158 $stations[0]['id'] = 0; | |
| 159 $stations[0]['name'] = "すべて"; | |
| 160 $stations[0]['selected'] = (! $station) ? "selected" : ""; | |
| 161 foreach( $crecs as $c ) { | |
| 162 $arr = array(); | |
| 163 $arr['id'] = $c->id; | |
| 164 $arr['name'] = $c->name; | |
| 165 $arr['selected'] = $station == $c->id ? "selected" : ""; | |
| 166 if( $station == $c->id ) $k_station_name = $c->name; | |
| 167 array_push( $stations, $arr ); | |
| 168 } | |
| 77 | 169 $weekofdays["$weekofday"]["selected"] = "selected" ; |
| 106 | 170 |
| 171 // 時間帯 | |
| 172 $prgtimes = array(); | |
| 173 for( $i=0; $i < 25; $i++ ) { | |
| 174 array_push( $prgtimes, | |
| 175 array( "name" => ( $i == 24 ? "なし" : sprintf("%0d時~",$i) ), | |
| 176 "value" => $i, | |
| 177 "selected" => ( $i == $prgtime ? "selected" : "" ) ) | |
| 178 ); | |
| 179 } | |
| 180 | |
| 181 | |
| 1 | 182 |
| 183 $smarty = new Smarty(); | |
| 184 $smarty->assign("sitetitle","番組検索"); | |
| 185 $smarty->assign("do_keyword", $do_keyword ); | |
| 186 $smarty->assign( "programs", $programs ); | |
| 187 $smarty->assign( "cats", $cats ); | |
| 188 $smarty->assign( "k_category", $category_id ); | |
| 189 $smarty->assign( "k_category_name", $k_category_name ); | |
| 190 $smarty->assign( "types", $types ); | |
| 191 $smarty->assign( "k_type", $type ); | |
| 192 $smarty->assign( "search" , $search ); | |
| 193 $smarty->assign( "use_regexp", $use_regexp ); | |
| 194 $smarty->assign( "stations", $stations ); | |
| 195 $smarty->assign( "k_station", $station ); | |
| 196 $smarty->assign( "k_station_name", $k_station_name ); | |
| 77 | 197 $smarty->assign( "weekofday", $weekofday ); |
| 198 $smarty->assign( "k_weekofday", $weekofdays["$weekofday"]["name"] ); | |
| 199 $smarty->assign( "weekofday", $weekofday ); | |
| 200 $smarty->assign( "weekofdays", $weekofdays ); | |
| 201 $smarty->assign( "autorec_modes", $autorec_modes ); | |
| 106 | 202 $smarty->assign( "prgtimes", $prgtimes ); |
| 203 $smarty->assign( "prgtime", $prgtime ); | |
| 1 | 204 $smarty->display("programTable.html"); |
| 205 } | |
| 206 catch( exception $e ) { | |
| 207 exit( $e->getMessage() ); | |
| 208 } | |
| 57 | 209 ?> |
