| 18 | | // A single search string passed in |
| 19 | | if ($_GET['searchstr'] || $_POST['searchstr']) { |
| | 18 | $program_search_fields = array('title', 'subtitle', 'descr', 'category', 'category_type', 'originalairdate', 'name'); |
| | 19 | |
| | 20 | // A single search string passed in, OR search |
| | 21 | if (array_key_exists('searchstr', $_REQUEST)) { |
| 21 | | $_SESSION['search']['searchstr'] = _or($_GET['searchstr'], $_POST['searchstr']); |
| 22 | | $_SESSION['search']['search_title'] = _or($_GET['search_title'], $_POST['search_title']); |
| 23 | | $_SESSION['search']['search_subtitle'] = _or($_GET['search_subtitle'], $_POST['search_subtitle']); |
| 24 | | $_SESSION['search']['search_description'] = _or($_GET['search_description'], $_POST['search_description']); |
| 25 | | $_SESSION['search']['search_category'] = _or($_GET['search_category'], $_POST['search_category']); |
| 26 | | $_SESSION['search']['search_category_type'] = _or($_GET['search_category_type'], $_POST['search_category_type']); |
| | 23 | $_SESSION['search']['searchstr'] = $_REQUEST['searchstr']; |
| | 24 | foreach ($program_search_fields as $e) { |
| | 25 | $e = "search_$e"; |
| | 26 | if (array_key_exists($e, $_REQUEST)) { |
| | 27 | $_SESSION['search'][$e] = $_REQUEST[$e]; |
| | 28 | } |
| | 29 | } |
| 29 | | |
| 30 | | // Individual search strings for different fields |
| 31 | | elseif ($_GET['title'] || $_GET['subtitle'] || $_GET['description'] || $_GET['category'] || $_GET['category_type'] || $_GET['originalairdate'] |
| 32 | | || $_POST['title'] || $_POST['subtitle'] || $_POST['description'] || $_POST['category'] || $_POST['category_type'] || $_POST['originalairdate'] ) { |
| 33 | | unset($_SESSION['search']); |
| 34 | | $_SESSION['search']['title'] = _or($_GET['title'], $_POST['title']); |
| 35 | | $_SESSION['search']['subtitle'] = _or($_GET['subtitle'], $_POST['subtitle']); |
| 36 | | $_SESSION['search']['description'] = _or($_GET['description'], $_POST['description']); |
| 37 | | $_SESSION['search']['category'] = _or($_GET['category'], $_POST['category']); |
| 38 | | $_SESSION['search']['category_type'] = _or($_GET['category_type'], $_POST['category_type']); |
| 39 | | $_SESSION['search']['originalairdate'] = _or($_GET['originalairdate'], $_POST['originalairdate']); |
| | 32 | // Individual search strings for different fields, AND search |
| | 33 | else { |
| | 34 | $first = 1; |
| | 35 | foreach ($program_search_fields as $e) { |
| | 36 | if (array_key_exists($e, $_REQUEST)) { |
| | 37 | if ($first) { |
| | 38 | unset($_SESSION['search']); |
| | 39 | $first = 0; |
| | 40 | } |
| | 41 | $_SESSION['search'][$e] = $_REQUEST[$e]; |
| | 42 | } |
| | 43 | } |
| 42 | | if ($_GET['search_exact'] || $_POST['search_exact']) |
| 43 | | $_SESSION['search']['search_exact'] = _or($_GET['search_exact'], $_POST['search_exact']); |
| 44 | | if ($_GET['search_hd'] || $_POST['search_hd']) |
| 45 | | $_SESSION['search']['search_hd'] = _or($_GET['search_hd'], $_POST['search_hd']); |
| | 46 | if ($_REQUEST['search_exact']) |
| | 47 | $_SESSION['search']['search_exact'] = $_REQUEST['search_exact']; |
| | 48 | if ($_REQUEST['search_hd']) |
| | 49 | $_SESSION['search']['search_hd'] = $_REQUEST['search_hd']; |
| 102 | | if ($_SESSION['search']['search_title']) |
| 103 | | $query[] = "program.title$compare$search"; |
| 104 | | if ($_SESSION['search']['search_subtitle']) |
| 105 | | $query[] = "program.subtitle$compare$search"; |
| 106 | | if ($_SESSION['search']['search_description']) |
| 107 | | $query[] = "program.description$compare$search"; |
| 108 | | if ($_SESSION['search']['search_category']) |
| 109 | | $query[] = "program.category$compare$search"; |
| 110 | | if ($_SESSION['search']['search_category_type']) |
| 111 | | $query[] = "program.category_type$compare$search"; |
| | 109 | foreach ($program_search_fields as $e) { |
| | 110 | if (array_key_exists("search_$e", $_SESSION['search'])) { |
| | 111 | $query[] = "program.$e$compare$search"; |
| | 112 | } |
| | 113 | } |
| 124 | | if ($_SESSION['search']['title']) |
| 125 | | $query[] = "program.title$compare".search_escape($_SESSION['search']['title']); |
| 126 | | if (isset($_SESSION['search']['subtitle'])) |
| 127 | | $query[] = "program.subtitle$compare".search_escape($_SESSION['search']['subtitle']); |
| 128 | | if (isset($_SESSION['search']['description'])) |
| 129 | | $query[] = "program.description$compare".search_escape($_SESSION['search']['description']); |
| 130 | | if (isset($_SESSION['search']['category'])) |
| 131 | | $query[] = "program.category$compare".search_escape($_SESSION['search']['category']); |
| 132 | | if (isset($_SESSION['search']['category_type'])) |
| 133 | | $query[] = "program.category_type$compare".search_escape($_SESSION['search']['category_type']); |
| 134 | | if (isset($_SESSION['search']['originalairdate'])) |
| 135 | | $query[] = "program.originalairdate > NOW()"; |
| | 126 | $search_name_list = array(); |
| | 127 | foreach ($program_search_fields as $e) { |
| | 128 | if (isset($_SESSION['search'][$e])) { |
| | 129 | if ($e == 'originalairdate') { |
| | 130 | $search_name_list[] = "originally aired " . $_SESSION['search'][$e]; |
| | 131 | if (strstr($_SESSION['search']['originalairdate'], '-')) { |
| | 132 | $query[] = "program.originalairdate = '".$_SESSION['search'][$e]."'"; |
| | 133 | } else { |
| | 134 | $query[] = "program.originalairdate LIKE '".$_SESSION['search'][$e]."-%'"; |
| | 135 | } |
| | 136 | } elseif ($e == 'name') { |
| | 137 | $query[] = "people.$e$compare".search_escape($_SESSION['search'][$e]); |
| | 138 | $search_name_list[] = "cast or crew includes " . $_SESSION['search'][$e]; |
| | 139 | } else { |
| | 140 | $query[] = "program.$e$compare".search_escape($_SESSION['search'][$e]); |
| | 141 | $search_name_list[] = "$e is " . $_SESSION['search'][$e]; |
| | 142 | } |
| | 143 | } |
| | 144 | } |
| | 145 | $search_name = implode(', ', $search_name_list); |