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