Mercurial > epgrec.yaz
annotate programTable.php @ 77:cb7da56c4198
modified: Keyword.class.php
modified: config.php.sample
modified: index.php
modified: install/step1.php
modified: keywordTable.php
modified: programTable.php
modified: simpleReservation.php
modified: templates/index.html
modified: templates/keywordTable.html
modified: templates/programTable.html
| author | Sushi-k <epgrec@park.mda.or.jp> |
|---|---|
| date | Wed, 24 Feb 2010 20:22:19 +0900 |
| parents | a2c4665b310c |
| children | 57676bb30f64 |
| 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 | |
| 23 $autorec_modes = $RECORD_MODE; | |
| 24 $autorec_modes[(int)($settings->autorec_mode)]['selected'] = "selected"; | |
| 25 | |
| 26 $weekofday = 7; | |
| 1 | 27 $search = ""; |
| 28 $use_regexp = 0; | |
| 29 $type = "*"; | |
| 30 $category_id = 0; | |
| 31 $station = 0; | |
| 32 | |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
33 // mysql_real_escape_stringより先に接続しておく必要がある |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
34 $dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass ); |
| 1 | 35 |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
36 // パラメータの処理 |
| 1 | 37 if(isset( $_POST['do_search'] )) { |
| 38 if( isset($_POST['search'])){ | |
| 39 if( $_POST['search'] != "" ) { | |
| 40 $search = $_POST['search']; | |
| 41 if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) { | |
| 42 $use_regexp = $_POST['use_regexp']; | |
| 43 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($search)."'"; | |
| 44 } | |
| 45 else { | |
| 46 $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($search)."%'"; | |
| 47 } | |
| 48 } | |
| 49 } | |
| 50 if( isset($_POST['type'])){ | |
| 51 if( $_POST['type'] != "*" ) { | |
| 52 $type = $_POST['type']; | |
| 53 $options .= " AND type = '".$_POST['type']."'"; | |
| 54 } | |
| 55 } | |
| 56 if( isset($_POST['category_id'])) { | |
| 57 if( $_POST['category_id'] != 0 ) { | |
| 58 $category_id = $_POST['category_id']; | |
| 59 $options .= " AND category_id = '".$_POST['category_id']."'"; | |
| 60 } | |
| 61 } | |
| 62 if( isset($_POST['station'])) { | |
| 63 if( $_POST['station'] != 0 ) { | |
| 64 $station = $_POST['station']; | |
| 65 $options .= " AND channel_id = '".$_POST['station']."'"; | |
| 66 } | |
| 67 } | |
| 77 | 68 if( isset($_POST['weekofday']) ) { |
| 69 $weekofday = $_POST['weekofday']; | |
| 70 if( $weekofday != 7 ) { | |
| 71 $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; | |
| 72 } | |
| 73 } | |
| 1 | 74 } |
| 75 $options .= " ORDER BY starttime ASC LIMIT 300"; | |
| 76 $do_keyword = 0; | |
| 77 if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) ) | |
| 78 $do_keyword = 1; | |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
79 |
| 1 | 80 try{ |
|
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
81 |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
82 $precs = DBRecord::createRecords(PROGRAM_TBL, $options ); |
| 1 | 83 |
| 84 $programs = array(); | |
| 85 foreach( $precs as $p ) { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
86 $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
|
87 $cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id ); |
| 1 | 88 $arr = array(); |
| 89 $arr['type'] = $p->type; | |
| 90 $arr['station_name'] = $ch->name; | |
| 91 $arr['starttime'] = $p->starttime; | |
| 92 $arr['endtime'] = $p->endtime; | |
| 93 $arr['title'] = $p->title; | |
| 94 $arr['description'] = $p->description; | |
| 95 $arr['id'] = $p->id; | |
| 96 $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
|
97 $arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'"); |
| 1 | 98 |
| 99 array_push( $programs, $arr ); | |
| 100 } | |
| 101 | |
| 102 $k_category_name = ""; | |
| 77 | 103 $crecs = DBRecord::createRecords(CATEGORY_TBL); |
| 1 | 104 $cats = array(); |
| 105 $cats[0]['id'] = 0; | |
| 106 $cats[0]['name'] = "すべて"; | |
| 107 $cats[0]['selected'] = $category_id == 0 ? "selected" : ""; | |
| 108 foreach( $crecs as $c ) { | |
| 109 $arr = array(); | |
| 110 $arr['id'] = $c->id; | |
| 111 $arr['name'] = $c->name_jp; | |
| 112 $arr['selected'] = $c->id == $category_id ? "selected" : ""; | |
| 113 if( $c->id == $category_id ) $k_category_name = $c->name_jp; | |
| 114 array_push( $cats, $arr ); | |
| 115 } | |
| 116 | |
| 117 $types = array(); | |
| 118 $types[0]['name'] = "すべて"; | |
| 119 $types[0]['value'] = "*"; | |
| 120 $types[0]['selected'] = $type == "*" ? "selected" : ""; | |
| 57 | 121 if( $settings->gr_tuners != 0 ) { |
| 1 | 122 $arr = array(); |
| 123 $arr['name'] = "GR"; | |
| 124 $arr['value'] = "GR"; | |
| 125 $arr['selected'] = $type == "GR" ? "selected" : ""; | |
| 126 array_push( $types, $arr ); | |
| 127 } | |
| 57 | 128 if( $settings->bs_tuners != 0 ) { |
| 1 | 129 $arr = array(); |
| 130 $arr['name'] = "BS"; | |
| 131 $arr['value'] = "BS"; | |
| 132 $arr['selected'] = $type == "BS" ? "selected" : ""; | |
| 133 array_push( $types, $arr ); | |
|
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
134 |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
135 // CS |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
136 if ($settings->cs_rec_flg != 0) { |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
137 $arr = array(); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
138 $arr['name'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
139 $arr['value'] = "CS"; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
140 $arr['selected'] = $type == "CS" ? "selected" : ""; |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
141 array_push( $types, $arr ); |
|
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
57
diff
changeset
|
142 } |
| 1 | 143 } |
| 144 | |
| 145 $k_station_name = ""; | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
146 $crecs = DBRecord::createRecords(CHANNEL_TBL); |
| 1 | 147 $stations = array(); |
| 148 $stations[0]['id'] = 0; | |
| 149 $stations[0]['name'] = "すべて"; | |
| 150 $stations[0]['selected'] = (! $station) ? "selected" : ""; | |
| 151 foreach( $crecs as $c ) { | |
| 152 $arr = array(); | |
| 153 $arr['id'] = $c->id; | |
| 154 $arr['name'] = $c->name; | |
| 155 $arr['selected'] = $station == $c->id ? "selected" : ""; | |
| 156 if( $station == $c->id ) $k_station_name = $c->name; | |
| 157 array_push( $stations, $arr ); | |
| 158 } | |
| 77 | 159 $weekofdays["$weekofday"]["selected"] = "selected" ; |
| 1 | 160 |
| 161 $smarty = new Smarty(); | |
| 162 $smarty->assign("sitetitle","番組検索"); | |
| 163 $smarty->assign("do_keyword", $do_keyword ); | |
| 164 $smarty->assign( "programs", $programs ); | |
| 165 $smarty->assign( "cats", $cats ); | |
| 166 $smarty->assign( "k_category", $category_id ); | |
| 167 $smarty->assign( "k_category_name", $k_category_name ); | |
| 168 $smarty->assign( "types", $types ); | |
| 169 $smarty->assign( "k_type", $type ); | |
| 170 $smarty->assign( "search" , $search ); | |
| 171 $smarty->assign( "use_regexp", $use_regexp ); | |
| 172 $smarty->assign( "stations", $stations ); | |
| 173 $smarty->assign( "k_station", $station ); | |
| 174 $smarty->assign( "k_station_name", $k_station_name ); | |
| 77 | 175 $smarty->assign( "weekofday", $weekofday ); |
| 176 $smarty->assign( "k_weekofday", $weekofdays["$weekofday"]["name"] ); | |
| 177 $smarty->assign( "weekofday", $weekofday ); | |
| 178 $smarty->assign( "weekofdays", $weekofdays ); | |
| 179 $smarty->assign( "autorec_modes", $autorec_modes ); | |
| 1 | 180 $smarty->display("programTable.html"); |
| 181 } | |
| 182 catch( exception $e ) { | |
| 183 exit( $e->getMessage() ); | |
| 184 } | |
| 57 | 185 ?> |
