1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* presenter module for xoops |
13
|
|
|
* |
14
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
15
|
|
|
* @license GPL 2.0 or later |
16
|
|
|
* @package presenter |
17
|
|
|
* @since 2.5.5 |
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <http://xoops.org> |
19
|
|
|
* @version $Id: 1.0 search.inc.php 11532 Wed 2013/08/28 4:00:27Z XOOPS Development Team $ |
20
|
|
|
* @param $queryarray |
21
|
|
|
* @param $andor |
22
|
|
|
* @param $limit |
23
|
|
|
* @param $offset |
24
|
|
|
* @param $userid |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
function presenter_search($queryarray, $andor, $limit, $offset, $userid) |
28
|
|
|
{ |
29
|
|
|
global $xoopsDB; |
|
|
|
|
30
|
|
|
|
31
|
|
|
$sql = "SELECT slides_id, slides_cid FROM " . $xoopsDB->prefix('slides') . " WHERE slides_online = 1"; |
32
|
|
|
|
33
|
|
|
if ($userid != 0) { |
34
|
|
|
$sql .= " AND slides_submitter=" . (int)($userid); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (is_array($queryarray) && $count = count($queryarray)) { |
38
|
|
|
$sql .= " AND ((slides_cid LIKE '%$queryarray[0]%' OR slides_uid LIKE '%$queryarray[0]%' OR slides_title LIKE '%$queryarray[0]%' OR slides_content LIKE '%$queryarray[0]%' OR slides_transition_x LIKE '%$queryarray[0]%' OR slides_transition_y LIKE '%$queryarray[0]%' OR slides_transition_z LIKE '%$queryarray[0]%' OR slides_rotation_x LIKE '%$queryarray[0]%' OR slides_rotation_y LIKE '%$queryarray[0]%' OR slides_rotation_z LIKE '%$queryarray[0]%' OR slides_scale_x LIKE '%$queryarray[0]%' OR slides_scale_y LIKE '%$queryarray[0]%' OR slides_scale_z LIKE '%$queryarray[0]%' OR slides_created LIKE '%$queryarray[0]%' OR slides_published LIKE '%$queryarray[0]%' OR slides_position LIKE '%$queryarray[0]%' OR slides_online LIKE '%$queryarray[0]%' OR slides_type LIKE '%$queryarray[0]%' OR slides_notes LIKE '%$queryarray[0]%' OR slides_mp3 LIKE '%$queryarray[0]%' OR slides_time LIKE '%$queryarray[0]%')"; |
39
|
|
|
|
40
|
|
|
for ($i = 1; $i < $count; ++$i) { |
41
|
|
|
$sql .= " $andor "; |
42
|
|
|
$sql .= "(slides_cid LIKE '%$queryarray[$i]%' OR slides_uid LIKE '%$queryarray[$i]%' OR slides_title LIKE '%$queryarray[$i]%' OR slides_content LIKE '%$queryarray[$i]%' OR slides_transition_x LIKE '%$queryarray[$i]%' OR slides_transition_y LIKE '%$queryarray[$i]%' OR slides_transition_z LIKE '%$queryarray[$i]%' OR slides_rotation_x LIKE '%$queryarray[$i]%' OR slides_rotation_y LIKE '%$queryarray[$i]%' OR slides_rotation_z LIKE '%$queryarray[$i]%' OR slides_scale_x LIKE '%$queryarray[$i]%' OR slides_scale_y LIKE '%$queryarray[$i]%' OR slides_scale_z LIKE '%$queryarray[$i]%' OR slides_created LIKE '%$queryarray[$i]%' OR slides_published LIKE '%$queryarray[$i]%' OR slides_position LIKE '%$queryarray[$i]%' OR slides_online LIKE '%$queryarray[$i]%' OR slides_type LIKE '%$queryarray[$i]%' OR slides_notes LIKE '%$queryarray[$i]%' OR slides_mp3 LIKE '%$queryarray[$i]%' OR slides_time LIKE '%$queryarray[0]%')"; |
43
|
|
|
} |
44
|
|
|
$sql .= ")"; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$sql .= " ORDER BY slides_id DESC"; |
48
|
|
|
$result = $xoopsDB->query($sql, $limit, $offset); |
49
|
|
|
$ret = array(); |
50
|
|
|
$i = 0; |
51
|
|
|
while ($myrow = $xoopsDB->fetchArray($result)) { |
52
|
|
|
$ret[$i]['image'] = 'images/icons/32/slides_search.png'; |
53
|
|
|
$ret[$i]['link'] = 'slides.php?slides_id=' . $myrow['slides_id']; |
54
|
|
|
$ret[$i]['title'] = $myrow['slides_cid']; |
55
|
|
|
++$i; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return $ret; |
59
|
|
|
} |
60
|
|
|
|
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state