-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
66 lines (57 loc) · 2.46 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
eval( '
function '.$mydirname.'_global_search( $keywords , $andor , $limit , $offset , $userid )
{
return bulletin_search_base( "'.$mydirname.'" , $keywords , $andor , $limit , $offset , $userid ) ;
}
' ) ;
if( ! function_exists( 'bulletin_search_base' ) ) {
//ver3.0
include_once XOOPS_TRUST_PATH."/modules/bulletin/class/bulletingp.php";
function bulletin_search_base( $mydirname , $queryarray , $andor , $limit , $offset , $userid ){
global $xoopsDB;
$showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ;
if( $showcontext == 1 && function_exists('search_make_context')){
$sql = "SELECT storyid,uid,title,published,hometext,bodytext,html,smiley FROM ".$xoopsDB->prefix($mydirname."_stories")." WHERE published > 0 AND published <= ".time()." AND (expired = 0 OR expired >= ".time()." )";
}else{
$sql = "SELECT storyid,uid,title,published FROM ".$xoopsDB->prefix($mydirname."_stories")." WHERE published > 0 AND published <= ".time()." AND (expired = 0 OR expired >= ".time()." )";
}
//ver3.0
$gperm =& BulletinGP::getInstance($mydirname) ;
$can_read_topic_ids = $gperm->makeOnTopics('can_read');
$sql .= " AND topicid IN (".implode(',',$can_read_topic_ids).")";
if ( $userid != 0 ) {
$sql .= " AND uid=".$userid." ";
}
// because count() returns 1 even if a supplied variable
// is not an array, we must check if $querryarray is really an array
if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= " AND ((hometext LIKE '%$queryarray[0]%' OR bodytext LIKE '%$queryarray[0]%' OR title LIKE '%$queryarray[0]%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "(hometext LIKE '%$queryarray[$i]%' OR bodytext LIKE '%$queryarray[$i]%' OR title LIKE '%$queryarray[$i]%')";
}
$sql .= ") ";
}
$sql .= "ORDER BY published DESC";
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
$myts =& MyTextSanitizer::getInstance();
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = 'images/forum.gif';
$ret[$i]['link'] = 'index.php?page=article&storyid='.$myrow['storyid'];
$ret[$i]['title'] = $myrow['title'];
$ret[$i]['time'] = $myrow['published'];
$ret[$i]['uid'] = $myrow['uid'];
if( !empty( $myrow['hometext'] ) ){
$context = $myrow['hometext'].$myrow['bodytext'];
$context = strip_tags($myts->displayTarea(strip_tags($context),$myrow['html'],$myrow['smiley'],1));
$ret[$i]['context'] = search_make_context($context,$queryarray);
}
$i++;
}
return $ret;
}
}
?>