onokazu
onoka****@users*****
2005年 5月 31日 (火) 12:58:51 JST
Index: xoops2jp/html/modules/newbb/include/search.inc.php diff -u xoops2jp/html/modules/newbb/include/search.inc.php:1.2 xoops2jp/html/modules/newbb/include/search.inc.php:1.2.6.1 --- xoops2jp/html/modules/newbb/include/search.inc.php:1.2 Fri Mar 18 21:52:25 2005 +++ xoops2jp/html/modules/newbb/include/search.inc.php Tue May 31 12:58:51 2005 @@ -1,5 +1,5 @@ <?php -// $Id: search.inc.php,v 1.2 2005/03/18 12:52:25 onokazu Exp $ +// $Id: search.inc.php,v 1.2.6.1 2005/05/31 03:58:51 onokazu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -30,32 +30,32 @@ // ------------------------------------------------------------------------- // function newbb_search($queryarray, $andor, $limit, $offset, $userid){ - global $xoopsDB; - $sql = "SELECT p.post_id,p.topic_id,p.forum_id,p.post_time,p.uid,p.subject FROM ".$xoopsDB->prefix("bb_posts")." p LEFT JOIN ".$xoopsDB->prefix("bb_posts_text")." t ON t.post_id=p.post_id LEFT JOIN ".$xoopsDB->prefix("bb_forums")." f ON f.forum_id=p.forum_id WHERE f.forum_type=0"; - if ( $userid != 0 ) { - $sql .= " AND p.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 ((p.subject LIKE '%$queryarray[0]%' OR t.post_text LIKE '%$queryarray[0]%')"; - for($i=1;$i<$count;$i++){ - $sql .= " $andor "; - $sql .= "(p.subject LIKE '%$queryarray[$i]%' OR t.post_text LIKE '%$queryarray[$i]%')"; - } - $sql .= ") "; - } - $sql .= "ORDER BY p.post_time DESC"; - $result = $xoopsDB->query($sql,$limit,$offset); - $ret = array(); - $i = 0; - while($myrow = $xoopsDB->fetchArray($result)){ - $ret[$i]['link'] = "viewtopic.php?topic_id=".$myrow['topic_id']."&forum=".$myrow['forum_id']."#forumpost".$myrow['post_id']; - $ret[$i]['title'] = $myrow['subject']; - $ret[$i]['time'] = $myrow['post_time']; - $ret[$i]['uid'] = $myrow['uid']; - $i++; - } - return $ret; + global $xoopsDB; + $sql = "SELECT p.post_id,p.topic_id,p.forum_id,p.post_time,p.uid,p.subject FROM ".$xoopsDB->prefix("bb_posts")." p LEFT JOIN ".$xoopsDB->prefix("bb_posts_text")." t ON t.post_id=p.post_id LEFT JOIN ".$xoopsDB->prefix("bb_forums")." f ON f.forum_id=p.forum_id WHERE f.forum_type=0"; + if ( $userid != 0 ) { + $sql .= " AND p.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 ((p.subject LIKE '%$queryarray[0]%' OR t.post_text LIKE '%$queryarray[0]%')"; + for($i=1;$i<$count;$i++){ + $sql .= " $andor "; + $sql .= "(p.subject LIKE '%$queryarray[$i]%' OR t.post_text LIKE '%$queryarray[$i]%')"; + } + $sql .= ") "; + } + $sql .= "ORDER BY p.post_time DESC"; + $result = $xoopsDB->query($sql,$limit,$offset); + $ret = array(); + $i = 0; + while($myrow = $xoopsDB->fetchArray($result)){ + $ret[$i]['link'] = "viewtopic.php?topic_id=".$myrow['topic_id']."&forum=".$myrow['forum_id']."&post_id=".$myrow['post_id']."#forumpost".$myrow['post_id']; + $ret[$i]['title'] = $myrow['subject']; + $ret[$i]['time'] = $myrow['post_time']; + $ret[$i]['uid'] = $myrow['uid']; + $i++; + } + return $ret; } ?> \ No newline at end of file