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