Changeset 2090 in ExiteCMS for trunk/includes/search/search.downloads.php
- Timestamp:
- 12/04/08 14:28:48 (3 years ago)
- File:
-
- 1 edited
-
trunk/includes/search/search.downloads.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/search/search.downloads.php
r1935 r2090 32 32 } else { 33 33 34 // get the required variables (could be POST or GET vars!) 35 if (isset($stext)) { 36 $stext = stripinput($stext); 34 // make sure the sub search ID is defined 35 if (!isset($sub_search_id)) $sub_search_id = 0; 36 37 // retrieve the search criteria 38 if (isset($_SESSION['search'])) { 39 // from the session store (used when paging through the results) 40 $stext = $_SESSION['search']['stext']; 41 $qtype = $_SESSION['search']['qtype']; 42 $datelimit = $_SESSION['search']['datelimit']; 43 $boolean = $_SESSION['search']['boolean']; 44 $sortby = $_SESSION['search']['sortby']; 45 $order = $_SESSION['search']['order']; 46 $limit = $_SESSION['search']['limit']; 47 $contentfilter_forums = $_SESSION['search']['contentfilter_forums']; 48 $contentfilter_users = $_SESSION['search']['contentfilter_users']; 37 49 } else { 50 // from the search form 38 51 $stext = isset($_POST['stext']) ? stripinput($_POST['stext']) : ""; 52 $stext = str_replace(',', ' ', $stext); 53 $boolean = isset($_POST['boolean']) ? 0 : 1; 54 $qtype = isset($_POST['qtype']) ? stripinput($_POST['qtype']) : "AND"; 55 if ($qtype != "OR" && $qtype != "AND") { 56 $qtype = "AND"; 57 } 58 $sortby = isset($_POST['sortby']) ? stripinput($_POST['sortby']) : "score"; 59 if (!in_array($sortby, $select_filters)) { 60 $sortby = $select_filters[0]; 61 } 62 $order = isset($_POST['order']) && isNum($_POST['order']) ? $_POST['order'] : 1; 63 $limit = isset($_POST['limit']) && isNum($_POST['limit']) ? $_POST['limit'] : 0; 64 $datelimit = isset($_POST['datelimit']) && isNum($_POST['datelimit']) ? $_POST['datelimit'] : 0; 65 // add a forum filter if requested 66 if (isset($_POST['contentfilter_forums']) && isNum($_POST['contentfilter_forums']) && $_POST['contentfilter_forums'] > 0 ) { 67 $contentfilter_forums = stripinput($_POST['contentfilter_forums']); 68 } 69 // add an author if requested 70 if (isset($_POST['contentfilter_users']) && isNum($_POST['contentfilter_users']) && $_POST['contentfilter_users'] > 0 ) { 71 $contentfilter_users = stripinput($_POST['contentfilter_users']); 72 } 39 73 } 40 $stext = str_replace(',', ' ', $stext);41 74 $variables['stext'] = $stext; 42 75 43 // note: qtype not used because of a fulltext query 44 if (!isset($qtype)) { 45 $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : "AND"; 46 } 47 if ($qtype != "OR" && $qtype != "AND") { 48 $qtype = "AND"; 49 } 50 51 if (!isset($datelimit)) { 52 $datelimit = isset($_POST['datelimit']) ? $_POST['datelimit'] : 0; 53 } 54 if (!isNum($datelimit)) { 55 $datelimit = 0; 56 } 57 if (!isset($sortby)) { 58 $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : "score"; 59 } 60 if (!in_array($sortby, $select_filters)) { 61 $sortby = $select_filters[0]; 62 } 63 if (!isset($order)) { 64 $order = isset($_POST['order']) ? $_POST['order'] : 1; 65 } 66 if (!isNum($order)) { 67 $order = 1; 68 } 69 if (!isset($limit)) { 70 $limit = isset($_POST['limit']) ? $_POST['limit'] : 0; 71 } 72 if (!isNum($limit)) { 73 $limit = 0; 74 } 75 if (!isset($boolean)) { 76 $boolean = isset($_POST['boolean']) ? 0 : 1; 77 } 78 79 if (!isset($sub_search_id)) $sub_search_id = 0; 80 81 // construct the page navigator URL to allow paging 82 $variables['pagenav_url'] = FUSION_SELF."?action=search&search_id=".$search_id."&"; 83 $variables['pagenav_url'] .= "stext=".urlencode($stext)."&"; 84 $variables['pagenav_url'] .= "boolean=".$boolean."&"; 85 $variables['pagenav_url'] .= "datelimit=".$datelimit."&"; 86 $variables['pagenav_url'] .= "sortby=".$sortby."&"; 87 $variables['pagenav_url'] .= "order=".$order."&"; 88 $variables['pagenav_url'] .= "limit=".$limit."&"; 76 // store the search parameters in the session record 77 $_SESSION['search'] = array('stext' => $stext, 78 'qtype' => $qtype, 79 'datelimit' => $datelimit, 80 'boolean' => $boolean, 81 'sortby' => $sortby, 82 'order' => $order, 83 'limit' => $limit, 84 'contentfilter_forums' => $contentfilter_forums, 85 'contentfilter_users' => $contentfilter_users 86 ); 89 87 90 88 // basis of the query for this search … … 104 102 foreach($stext as $sstring) { 105 103 if (!empty($sstring)) { 106 $searchstring .= ($searchstring==""?"":(" ".$qtype))." ( download_title LIKE '%".trim($sstring)."%' ORdownload_description LIKE '%".trim($sstring)."%') ";104 $searchstring .= ($searchstring==""?"":(" ".$qtype))." (td.download_title LIKE '%".trim($sstring)."%' OR td.download_description LIKE '%".trim($sstring)."%') "; 107 105 } 108 106 } … … 115 113 // add a datelimit if requested 116 114 if ($datelimit) { 117 $sql .= " AND download_datestamp >= ".(time() - $datelimit);115 $sql .= " AND td.download_datestamp >= ".(time() - $datelimit); 118 116 } 119 117 … … 127 125 break; 128 126 case "subject": 129 $sql .= " ORDER BY download_title ".($order?"ASC":"DESC");127 $sql .= " ORDER BY td.download_title ".($order?"ASC":"DESC"); 130 128 break; 131 129 case "datestamp": 132 $sql .= " ORDER BY download_datestamp ".($order?"ASC":"DESC");130 $sql .= " ORDER BY td.download_datestamp ".($order?"ASC":"DESC"); 133 131 break; 134 132 case "count":
Note: See TracChangeset
for help on using the changeset viewer.
