Mercurial > epgrec.yaz
annotate programTable.php @ 57:73350e16077a
fix: bug
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Wed, 29 Jul 2009 10:51:38 +0900 |
parents | 8965ef108821 |
children | a2c4665b310c |
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 |
10 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + 300 )."'"; | |
11 | |
12 $search = ""; | |
13 $use_regexp = 0; | |
14 $type = "*"; | |
15 $category_id = 0; | |
16 $station = 0; | |
17 | |
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
18 // mysql_real_escape_stringより先に接続しておく必要がある |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
19 $dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass ); |
1 | 20 |
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
21 // パラメータの処理 |
1 | 22 if(isset( $_POST['do_search'] )) { |
23 if( isset($_POST['search'])){ | |
24 if( $_POST['search'] != "" ) { | |
25 $search = $_POST['search']; | |
26 if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) { | |
27 $use_regexp = $_POST['use_regexp']; | |
28 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($search)."'"; | |
29 } | |
30 else { | |
31 $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($search)."%'"; | |
32 } | |
33 } | |
34 } | |
35 if( isset($_POST['type'])){ | |
36 if( $_POST['type'] != "*" ) { | |
37 $type = $_POST['type']; | |
38 $options .= " AND type = '".$_POST['type']."'"; | |
39 } | |
40 } | |
41 if( isset($_POST['category_id'])) { | |
42 if( $_POST['category_id'] != 0 ) { | |
43 $category_id = $_POST['category_id']; | |
44 $options .= " AND category_id = '".$_POST['category_id']."'"; | |
45 } | |
46 } | |
47 if( isset($_POST['station'])) { | |
48 if( $_POST['station'] != 0 ) { | |
49 $station = $_POST['station']; | |
50 $options .= " AND channel_id = '".$_POST['station']."'"; | |
51 } | |
52 } | |
53 } | |
54 $options .= " ORDER BY starttime ASC LIMIT 300"; | |
55 $do_keyword = 0; | |
56 if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) ) | |
57 $do_keyword = 1; | |
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
58 |
1 | 59 try{ |
10
152b146bd276
fixed: mysql_connect before mysql_real_escape_string
Sushi-k <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
60 |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
61 $precs = DBRecord::createRecords(PROGRAM_TBL, $options ); |
1 | 62 |
63 $programs = array(); | |
64 foreach( $precs as $p ) { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
65 $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
|
66 $cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id ); |
1 | 67 $arr = array(); |
68 $arr['type'] = $p->type; | |
69 $arr['station_name'] = $ch->name; | |
70 $arr['starttime'] = $p->starttime; | |
71 $arr['endtime'] = $p->endtime; | |
72 $arr['title'] = $p->title; | |
73 $arr['description'] = $p->description; | |
74 $arr['id'] = $p->id; | |
75 $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
|
76 $arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'"); |
1 | 77 |
78 array_push( $programs, $arr ); | |
79 } | |
80 | |
81 $k_category_name = ""; | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
82 $crecs = DBRecord::createRecords(CATEGORY_TBL ); |
1 | 83 $cats = array(); |
84 $cats[0]['id'] = 0; | |
85 $cats[0]['name'] = "すべて"; | |
86 $cats[0]['selected'] = $category_id == 0 ? "selected" : ""; | |
87 foreach( $crecs as $c ) { | |
88 $arr = array(); | |
89 $arr['id'] = $c->id; | |
90 $arr['name'] = $c->name_jp; | |
91 $arr['selected'] = $c->id == $category_id ? "selected" : ""; | |
92 if( $c->id == $category_id ) $k_category_name = $c->name_jp; | |
93 array_push( $cats, $arr ); | |
94 } | |
95 | |
96 $types = array(); | |
97 $types[0]['name'] = "すべて"; | |
98 $types[0]['value'] = "*"; | |
99 $types[0]['selected'] = $type == "*" ? "selected" : ""; | |
57 | 100 if( $settings->gr_tuners != 0 ) { |
1 | 101 $arr = array(); |
102 $arr['name'] = "GR"; | |
103 $arr['value'] = "GR"; | |
104 $arr['selected'] = $type == "GR" ? "selected" : ""; | |
105 array_push( $types, $arr ); | |
106 } | |
57 | 107 if( $settings->bs_tuners != 0 ) { |
1 | 108 $arr = array(); |
109 $arr['name'] = "BS"; | |
110 $arr['value'] = "BS"; | |
111 $arr['selected'] = $type == "BS" ? "selected" : ""; | |
112 array_push( $types, $arr ); | |
113 } | |
114 | |
115 $k_station_name = ""; | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
10
diff
changeset
|
116 $crecs = DBRecord::createRecords(CHANNEL_TBL); |
1 | 117 $stations = array(); |
118 $stations[0]['id'] = 0; | |
119 $stations[0]['name'] = "すべて"; | |
120 $stations[0]['selected'] = (! $station) ? "selected" : ""; | |
121 foreach( $crecs as $c ) { | |
122 $arr = array(); | |
123 $arr['id'] = $c->id; | |
124 $arr['name'] = $c->name; | |
125 $arr['selected'] = $station == $c->id ? "selected" : ""; | |
126 if( $station == $c->id ) $k_station_name = $c->name; | |
127 array_push( $stations, $arr ); | |
128 } | |
129 | |
130 $smarty = new Smarty(); | |
131 $smarty->assign("sitetitle","番組検索"); | |
132 $smarty->assign("do_keyword", $do_keyword ); | |
133 $smarty->assign( "programs", $programs ); | |
134 $smarty->assign( "cats", $cats ); | |
135 $smarty->assign( "k_category", $category_id ); | |
136 $smarty->assign( "k_category_name", $k_category_name ); | |
137 $smarty->assign( "types", $types ); | |
138 $smarty->assign( "k_type", $type ); | |
139 $smarty->assign( "search" , $search ); | |
140 $smarty->assign( "use_regexp", $use_regexp ); | |
141 $smarty->assign( "stations", $stations ); | |
142 $smarty->assign( "k_station", $station ); | |
143 $smarty->assign( "k_station_name", $k_station_name ); | |
144 $smarty->display("programTable.html"); | |
145 } | |
146 catch( exception $e ) { | |
147 exit( $e->getMessage() ); | |
148 } | |
57 | 149 ?> |