|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TDMDownload |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright Gregory Mage (Aka Mage) |
|
13
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
14
|
|
|
* @author Gregory Mage (Aka Mage) |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
function tdmdownloads_search($queryarray, $andor, $limit, $offset, $userid) |
|
18
|
|
|
{ |
|
19
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
$sql = "SELECT lid, cid, title, description, submitter, date FROM ".$xoopsDB->prefix("tdmdownloads_downloads")." WHERE status != 0"; |
|
22
|
|
|
|
|
23
|
|
|
if ( $userid != 0 ) { |
|
24
|
|
|
$sql .= " AND submitter=".intval($userid)." "; |
|
25
|
|
|
} |
|
26
|
|
|
require_once XOOPS_ROOT_PATH.'/modules/TDMDownloads/include/functions.php'; |
|
27
|
|
|
$categories = TDMDownloads_MygetItemIds('tdmdownloads_view', 'TDMDownloads'); |
|
28
|
|
|
if(is_array($categories) && count($categories) > 0) { |
|
29
|
|
|
$sql .= ' AND cid IN ('.implode(',', $categories).') '; |
|
30
|
|
|
} else { |
|
31
|
|
|
return null; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if ( is_array($queryarray) && $count = count($queryarray) ) |
|
35
|
|
|
{ |
|
36
|
|
|
$sql .= " AND ((title LIKE '%$queryarray[0]%' OR description LIKE '%$queryarray[0]%')"; |
|
37
|
|
|
|
|
38
|
|
|
for($i=1;$i<$count;$i++) |
|
39
|
|
|
{ |
|
40
|
|
|
$sql .= " $andor "; |
|
41
|
|
|
$sql .= "(title LIKE '%$queryarray[$i]%' OR description LIKE '%$queryarray[$i]%')"; |
|
42
|
|
|
} |
|
43
|
|
|
$sql .= ")"; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$sql .= " ORDER BY date DESC"; |
|
47
|
|
|
$result = $xoopsDB->query($sql,$limit,$offset); |
|
48
|
|
|
$ret = array(); |
|
49
|
|
|
$i = 0; |
|
50
|
|
|
while($myrow = $xoopsDB->fetchArray($result)) |
|
51
|
|
|
{ |
|
52
|
|
|
$ret[$i]["image"] = "images/deco/tdmdownloads_search.png"; |
|
53
|
|
|
$ret[$i]["link"] = "singlefile.php?cid=".$myrow["cid"]."&lid=".$myrow["lid"].""; |
|
54
|
|
|
$ret[$i]["title"] = $myrow["title"]; |
|
55
|
|
|
$ret[$i]["time"] = $myrow["date"]; |
|
56
|
|
|
$ret[$i]["uid"] = $myrow["submitter"]; |
|
57
|
|
|
$i++; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return $ret; |
|
61
|
|
|
} |
|
62
|
|
|
|
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state