function b_search_bluesbb($queryarray, $andor, $limit, $offset, $userid) { $db =& Database::getInstance(); global $xoopsUser, $member_handler; $myts =& MyTextSanitizer::getInstance(); $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0; if ($showcontext == 1) { $sql = "SELECT b.topic_id,b.sread_id,b.res_id,b.title,b.message,b.post_time,b.uid FROM " . $db->prefix("bluesbb") . " b LEFT JOIN " . $db->prefix("bluesbb_topic") . " t ON t.topic_id=b.topic_id WHERE"; } else { $sql = "SELECT b.topic_id,b.sread_id,b.res_id,b.title,b.post_time,b.uid FROM " . $db->prefix("bluesbb") . " b LEFT JOIN " . $db->prefix("bluesbb_topic") . " t ON t.topic_id=b.topic_id WHERE"; } if (is_object($xoopsUser)) { $sql .= " (t.topic_access = 1 OR t.topic_access = 2 OR t.topic_access = 3 OR t.topic_access = 4 OR t.topic_access = 5"; $groups =& $member_handler->getGroupsByUser($xoopsUser->getVar('uid'), true); foreach ($groups as $group) { $sql .= " OR t.topic_group = " . $group->getVar('groupid'); } if ($xoopsUser->isAdmin()) { $sql .= " OR t.topic_access = 6"; } } else { $sql .= " (t.topic_access = 1 OR t.topic_access = 2 OR t.topic_access = 5"; } $sql .= ")"; if ($userid != 0) { $sql .= " AND b.uid=" . $userid . " "; } if (is_array($queryarray) && ($count = count($queryarray))) { $sql .= " AND ((b.name LIKE '%{$queryarray['0']}%' OR b.mail LIKE '%{$queryarray['0']}%' OR b.url LIKE '%{$queryarray['0']}%' OR b.title LIKE '%{$queryarray['0']}%' OR b.message LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(b.name LIKE '%{$queryarray[$i]}%' OR b.mail LIKE '%{$queryarray[$i]}%' OR b.url LIKE '%{$queryarray[$i]}%' OR b.title LIKE '%{$queryarray[$i]}%' OR b.message LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= "ORDER BY b.post_time DESC"; $result = $db->query($sql, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $db->fetchArray($result)) { ++$myrow['res_id']; $ret[$i]['link'] = "viewsread.php?topic=" . $myrow['topic_id'] . "&sread_id=" . $myrow['sread_id'] . "&number=" . $myrow['res_id']; $ret[$i]['title'] = $myts->htmlSpecialChars($myrow['title']); $ret[$i]['time'] = $myrow['post_time']; $ret[$i]['uid'] = $myrow['uid']; if (!empty($myrow['message'])) { $context = strip_tags($myts->displayTarea($myrow['message'], 0, 1, 1, 1, 1)); $ret[$i]['context'] = search_make_context($context, $queryarray); } $i++; } return $ret; }
function gnavi_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // not implemented for uid specifications //if( ! empty( $userid ) ) { // return array() ; //} $db =& Database::getInstance(); // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "t.description" : "'' AS description"; $sql = "SELECT l.lid,l.cid,l.title,l.caption,l.caption1,l.caption2,l.poster_name,l.submitter,l.date,{$select4con} FROM " . $db->prefix($mydirname . "_photos") . " l LEFT JOIN " . $db->prefix($mydirname . "_text") . " t ON t.lid=l.lid LEFT JOIN " . $db->prefix("users") . " u ON u.uid=l.submitter WHERE status>0"; if ($userid > 0) { $sql .= " AND l.submitter=" . $userid . " "; } $whr = ""; if (is_array($keywords) && count($keywords) > 0) { $whr = "AND ("; switch (strtolower($andor)) { case "and": foreach ($keywords as $keyword) { $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keyword}%' AND "; } $whr = substr($whr, 0, -5); break; case "or": foreach ($keywords as $keyword) { $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keyword}%' OR "; } $whr = substr($whr, 0, -4); break; default: $whr .= "CONCAT(l.title,' ',l.caption,' ',l.caption1,' ',l.caption2,' ',t.description,' ',t.addinfo,' ',IFNULL(u.uname,''),' ',l.poster_name) LIKE '%{$keywords[0]}%'"; break; } $whr .= ")"; } $sql = "{$sql} {$whr} ORDER BY l.date DESC"; $result = $db->query($sql, $limit, $offset); $ret = array(); $context = ''; while ($myrow = $db->fetchArray($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $full_context = strip_tags($myrow['description']); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } $ret[] = array("image" => "images/pict.gif", "link" => "index.php?lid=" . $myrow["lid"], "title" => $myrow["title"], "time" => $myrow["date"], "uid" => $myrow["submitter"], "context" => $context); } return $ret; }
function myalbum_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { global $xoopsDB; include XOOPS_ROOT_PATH . "/modules/{$mydirname}/include/read_configs.php"; // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "t.description" : "'' AS description"; $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,{$select4con} FROM {$table_photos} l LEFT JOIN {$table_text} t ON t.lid=l.lid LEFT JOIN " . $xoopsDB->prefix("users") . " u ON l.submitter=u.uid WHERE status>0"; if ($userid > 0) { $sql .= " AND l.submitter=" . $userid . " "; } $whr = ""; if (is_array($keywords) && count($keywords) > 0) { $whr = "AND ("; switch (strtolower($andor)) { case "and": foreach ($keywords as $keyword) { $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' AND "; } $whr = substr($whr, 0, -5); break; case "or": foreach ($keywords as $keyword) { $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keyword}%' OR "; } $whr = substr($whr, 0, -4); break; default: $whr .= "CONCAT(l.title,' ',t.description,' ',IFNULL(u.uname,'')) LIKE '%{$keywords[0]}%'"; break; } $whr .= ")"; } $sql = "{$sql} {$whr} ORDER BY l.date DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $ret = array(); $context = ''; include_once XOOPS_ROOT_PATH . "/modules/{$mydirname}/class/myalbum.textsanitizer.php"; $myts =& MyAlbumTextSanitizer::getInstance(); while ($myrow = $xoopsDB->fetchArray($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $full_context = strip_tags($myts->displayTarea($myrow['description'], 1, 1, 1, 1, 1)); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } $ret[] = array("image" => "images/pict.gif", "link" => "photo.php?lid=" . $myrow["lid"], "title" => $myrow["title"], "time" => $myrow["date"], "uid" => $myrow["submitter"], "context" => $context); } return $ret; }
function d3pipes_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // not implemented for uid specifications if (!empty($userid)) { return array(); } $db =& Database::getInstance(); // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "`data` AS text" : "'' AS text"; if (is_array($keywords) && count($keywords) > 0) { switch (strtolower($andor)) { case "and": $whr = ""; foreach ($keywords as $keyword) { $whr .= "`data` LIKE '%{$keyword}%' AND "; } $whr .= "1"; break; case "or": $whr = ""; foreach ($keywords as $keyword) { $whr .= "`data` LIKE '%{$keyword}%' OR "; } $whr .= "0"; break; default: $whr = "`data` LIKE '%{$keywords[0]}%'"; break; } } else { $whr = 1; } $sql = "SELECT `clipping_id`,`headline`,`pubtime`,{$select4con} FROM " . $db->prefix($mydirname . "_clippings") . " WHERE ({$whr}) AND can_search ORDER BY `pubtime` DESC"; $result = $db->query($sql, $limit, $offset); $ret = array(); $context = ''; while (list($clipping_id, $title, $mtime, $serialized_data) = $db->fetchRow($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $data = d3pipes_common_unserialize($serialized_data); $text = @$data['description']; $full_context = strip_tags($text); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } $ret[] = array("image" => "", "link" => "index.php?page=clipping&clipping_id=" . intval($clipping_id), "title" => $title, "time" => $mtime, "uid" => "0", "context" => $context); } return $ret; }
function xwords_search_base( $mydirname, $queryarray, $andor, $limit, $offset, $userid ) { include_once XOOPS_ROOT_PATH."/modules/$mydirname/class/xwords.textsanitizer.php" ; $myts =& XwordsTextSanitizer::getInstance(); $xoopsDB =& Database::getInstance(); $xoopsModule = XoopsModule::getByDirname("{$mydirname}"); $ret = array(); // XOOPS Search module $showcontext = empty( $_GET['showcontext'] ) ? 0 : 1 ; $select4con = $showcontext ? "definition, html, smiley, xcodes, breaks, " : "" ; $sql = "SELECT entryID, categoryID, term, $select4con uid, datesub FROM " . $xoopsDB -> prefix( "{$mydirname}_ent" ) . " WHERE datesub < '".time()."' AND datesub > '0' AND submit = '0' AND offline = '0' AND request = '0' "; if ( $userid != 0 && strlen($userid) < 9) { $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 $count = count( $queryarray ); if ( $count > 0 && is_array( $queryarray ) ) { $sql .= "AND ("; for ( $i = 0; $i < $count; $i++ ) { $binary = (preg_match('/^[[:alnum:]]+$/',$queryarray[$i])) ? "":"BINARY"; $sql .= ($i > 0) ? " $andor " : ""; $sql .= (strlen($userid) > 8) ? "(term LIKE $binary '%$queryarray[$i]%')" : "(term LIKE $binary '%$queryarray[$i]%' OR proc LIKE $binary '%,%$queryarray[$i]%' OR definition LIKE $binary '%$queryarray[$i]%')" ; } $sql .= ') '; } $sql .= 'ORDER BY entryID DESC'; $result = $xoopsDB -> query( $sql, $limit, $offset ); $ret = array() ; $context = '' ; $i = 0; while ( $myrow = $xoopsDB -> fetchArray( $result ) ) { $ret[$i]['image'] = 'images/xw.gif'; $ret[$i]['link'] = 'entry.php?entryID='.$myrow['entryID'].'&categoryID='.$myrow['categoryID']; $ret[$i]['title'] = $myrow['term']; $ret[$i]['time'] = $myrow['datesub']; $ret[$i]['uid'] = $myrow['uid']; if( function_exists( 'search_make_context' ) && $showcontext ) { $context = strip_tags($myts->displayTarea($myrow['definition'], intval($myrow['html']), intval($myrow['smiley']), intval($myrow['xcodes']), 1, intval($myrow['breaks']))); $ret[$i]['context'] = search_make_context($context,$queryarray); } $i++; } return $ret; }
function wraps_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // not implemented for uid specifications if (!empty($userid)) { return array(); } // check if .htaccess exists (mod_rewrite on/off) $rewrite_mode = file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/.htaccess'); $db =& Database::getInstance(); // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "`body` AS text" : "'' AS text"; if (is_array($keywords) && count($keywords) > 0) { switch (strtolower($andor)) { case "and": $whr = ""; foreach ($keywords as $keyword) { $whr .= "`body` LIKE '%{$keyword}%' AND "; } $whr .= "1"; break; case "or": $whr = ""; foreach ($keywords as $keyword) { $whr .= "`body` LIKE '%{$keyword}%' OR "; } $whr .= "0"; break; default: $whr = "`body` LIKE '%{$keywords[0]}%'"; break; } } else { $whr = 1; } $sql = "SELECT `filename`,`title`,`mtime`,{$select4con} FROM " . $db->prefix($mydirname . "_indexes") . " WHERE ({$whr}) ORDER BY 1"; $result = $db->query($sql, $limit, $offset); $ret = array(); $context = ''; while (list($filename, $title, $mtime, $text) = $db->fetchRow($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $full_context = strip_tags($text); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } $ret[] = array("image" => "", "link" => $rewrite_mode ? $filename : 'index.php/' . $filename, "title" => $title, "time" => $mtime, "uid" => "0", "context" => $context); } return $ret; }
function getResultArray(&$row) { // 追加で取得して貰ったフィールド qid を使ってリンク URL を作成します $row['link'] = "index.php?action=detail&qid=" . $row['qid']; // get context for module "search" if (function_exists('search_make_context') && !empty($_GET['showcontext'])) { $text = $row['body'] . ' ' . $row['for_search']; if (function_exists('easiestml')) { $text = easiestml($text); } $row['context'] = search_make_context(htmlspecialchars($text, ENT_QUOTES), $this->filter_->querys_); } return $row; }
function _wp_xoops_search($queryarray, $andor, $limit, $offset, $userid) { $now = current_time('mysql'); $where = '(post_status = \'publish\') AND (post_date <= \'' . $now . '\')'; if (is_array($queryarray) && ($count = count($queryarray))) { $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $where .= " {$andor} "; $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')"; } $where .= ') '; } if ($userid) { $userid = intval($userid); $where .= ' AND (post_author=' . $userid . ')'; } $request = 'SELECT * FROM ' . wp_table('posts') . ' WHERE ' . $where; $request .= ' ORDER BY post_date DESC'; $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $ret[$i]['link'] = str_replace(wp_siteurl() . '/', '', get_permalink($myrow['ID'])); $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES); $ret[$i]['image'] = 'wp-images/search.png'; $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 15, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = $myrow['post_author']; $ret[$i]['page'] = $myrow['post_title']; if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) { $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray); } if (!empty($myrow['post_content']) && function_exists('search_make_context')) { if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) { $ret[$i]['context'] = search_make_context(strip_tags($myrow['post_content']), $queryarray); } } $i++; } return $ret; }
function eguide_search_base($myprefix, $queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB; $sql = "SELECT eid,uid,title,edate,cdate, summary FROM " . $xoopsDB->prefix($myprefix) . " WHERE status=0"; //$sql .= " AND expire>".time(); 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 ((summary LIKE '%{$queryarray['0']}%' OR body LIKE '%{$queryarray['0']}%' OR title LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(summary LIKE '%{$queryarray[$i]}%' OR body LIKE '%{$queryarray[$i]}%' OR title LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= " ORDER BY edate DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $ret = array(); // XOOPS Search module $showcontext = function_exists('search_make_context') && (empty($_GET['showcontext']) ? 0 : 1); if ($showcontext) { include_once XOOPS_ROOT_PATH . "/class/module.textsanitizer.php"; $myts =& MyTextSanitizer::getInstance(); } $i = 0; while ($myrow = $xoopsDB->fetchArray($result)) { //$ret[$i]['image'] = "images/forum.gif"; $ret[$i]['link'] = "event.php?eid=" . $myrow['eid'] . ""; $ret[$i]['title'] = formatTimestamp($myrow['edate'], 's') . ' ' . $myrow['title']; $ret[$i]['time'] = $myrow['cdate']; $ret[$i]['uid'] = $myrow['uid']; $ret[$i]['description'] = $myrow['summary']; $i++; // get context for module "search" if ($showcontext) { $full_context = strip_tags($myts->displayTarea($myrow['summary'], 1, 1, 1, 1, 1)); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $ret[$i]['context'] = search_make_context($full_context, $queryarray); } } return $ret; }
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; }
function b_search_xoopsfaq($queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB; $ret = array(); if ($userid != 0) { return $ret; } $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0; if ($showcontext == 1) { $sql = "SELECT contents_id, category_id, contents_title, contents_contents, contents_time FROM " . $xoopsDB->prefix("xoopsfaq_contents") . " WHERE contents_visible=1 "; } else { $sql = "SELECT contents_id, category_id, contents_title, contents_time FROM " . $xoopsDB->prefix("xoopsfaq_contents") . " WHERE contents_visible=1 "; } // because count() returns 1 even if a supplied variable // is not an array, we must check if $querryarray is really an array $count = count($queryarray); if ($count > 0 && is_array($queryarray)) { $sql .= "AND ((contents_title LIKE '%{$queryarray['0']}%' OR contents_contents LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(contents_title LIKE '%{$queryarray[$i]}%' OR contents_contents LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= "ORDER BY contents_id DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $i = 0; //本文のサニタイズ用に追記 $myts =& MyTextSanitizer::getInstance(); while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['image'] = "images/question2.gif"; $ret[$i]['link'] = "index.php?cat_id=" . $myrow['category_id'] . "#" . $myrow['contents_id']; $ret[$i]['title'] = $myrow['contents_title']; $ret[$i]['time'] = $myrow['contents_time']; //$ret[$i]['uid'] = $myrow['contents_uid']; if (!empty($myrow['contents_contents'])) { //本文始め $context = $myrow['contents_contents']; $context = strip_tags($myts->displayTarea(strip_tags($context))); $ret[$i]['context'] = search_make_context($context, $queryarray); //本文終わり } $i++; } return $ret; }
function b_search_mylinks($queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB; $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0; if ($showcontext == 1) { $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,t.description FROM " . $xoopsDB->prefix("mylinks_links") . " l LEFT JOIN " . $xoopsDB->prefix("mylinks_text") . " t ON t.lid=l.lid WHERE status>0"; } else { $sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date FROM " . $xoopsDB->prefix("mylinks_links") . " l LEFT JOIN " . $xoopsDB->prefix("mylinks_text") . " t ON t.lid=l.lid WHERE status>0"; } if ($userid != 0) { $sql .= " AND l.submitter=" . $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 ((l.title LIKE '%{$queryarray['0']}%' OR t.description LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(l.title LIKE '%{$queryarray[$i]}%' OR t.description LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= "ORDER BY l.date DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $ret = array(); $i = 0; //本文のサニタイズ用に追記 $myts =& MyTextSanitizer::getInstance(); while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['image'] = "images/home.gif"; $ret[$i]['link'] = "singlelink.php?cid=" . $myrow['cid'] . "&lid=" . $myrow['lid'] . ""; $ret[$i]['title'] = $myrow['title']; $ret[$i]['time'] = $myrow['date']; $ret[$i]['uid'] = $myrow['submitter']; if (!empty($myrow['description'])) { //本文始め $context = $myrow['description']; $context = strip_tags($myts->displayTarea(strip_tags($context))); $ret[$i]['context'] = search_make_context($context, $queryarray); //本文終わり } $i++; } return $ret; }
function b_search_comment_search($queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB; $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0; if ($showcontext == 1) { $sql = "SELECT c.com_id, c.com_modified, c.com_uid, c.com_title, c.com_text, m.name FROM " . $xoopsDB->prefix("xoopscomments") . " c," . $xoopsDB->prefix("modules") . " m WHERE com_status=2 AND c.com_modid=m.mid "; } else { $sql = "SELECT c.com_id, c.com_modified, c.com_uid, c.com_title, m.name FROM " . $xoopsDB->prefix("xoopscomments") . " c," . $xoopsDB->prefix("modules") . " m WHERE com_status=2 AND c.com_modid=m.mid "; } if ($userid != 0) { $sql .= " AND c.com_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 ((com_title LIKE '%{$queryarray['0']}%' OR com_text LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(com_title LIKE '%{$queryarray[$i]}%' OR com_text LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= "ORDER BY com_modified DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $ret = array(); $i = 0; //本文のサニタイズ用に追記 $myts =& MyTextSanitizer::getInstance(); while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['link'] = "index.php?com_id=" . $myrow['com_id']; $ret[$i]['title'] = "[" . $myrow['name'] . "] " . $myrow['com_title']; $ret[$i]['time'] = $myrow['com_modified']; $ret[$i]['uid'] = $myrow['com_uid']; if (!empty($myrow['com_text'])) { //本文始め $context = $myrow['com_text']; $context = strip_tags($myts->displayTarea(strip_tags($context))); $ret[$i]['context'] = search_make_context($context, $queryarray); //本文終わり } $i++; } return $ret; }
function b_search_xwords($queryarray, $andor, $limit, $offset, $userid) { $xoopsDB =& Database::getInstance(); $xoopsModule = XoopsModule::getByDirname("xwords"); $ret = array(); if ($userid != 0) { return $ret; } $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0; if ($showcontext == 1) { $sql = "SELECT entryID, term, proc, definition, uid, datesub FROM " . $xoopsDB->prefix("xwords_ent") . " WHERE submit = 0 AND offline = 0 "; } else { $sql = "SELECT entryID, term, proc, uid, datesub FROM " . $xoopsDB->prefix("xwords_ent") . " WHERE submit = 0 AND offline = 0 "; } // because count() returns 1 even if a supplied variable // is not an array, we must check if $querryarray is really an array $count = count($queryarray); if ($count > 0 && is_array($queryarray)) { $sql .= "AND ((term LIKE '%{$queryarray['0']}%' OR proc LIKE '%,%{$queryarray['0']}%' OR definition LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $sql .= " {$andor} "; $sql .= "(term LIKE '%{$queryarray[$i]}%' OR proc LIKE '%,%{$queryarray[$i]}%' OR definition LIKE '%{$queryarray[$i]}%')"; } $sql .= ") "; } $sql .= "ORDER BY entryID DESC"; $result = $xoopsDB->query($sql, $limit, $offset); $i = 0; $myts =& MyTextSanitizer::getInstance(); while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['image'] = 'images/wb.png'; $ret[$i]['link'] = 'entry.php?entryID=' . $myrow['entryID']; $ret[$i]['title'] = $myrow['term']; $ret[$i]['time'] = $myrow['datesub']; $ret[$i]['uid'] = $myrow['uid']; if (!empty($myrow['definition'])) { $context = $myrow['definition']; $context = strip_tags($myts->displayTarea(strip_tags($context))); $ret[$i]['context'] = search_make_context($context, $queryarray); } $i++; } return $ret; }
function b_search_news($queryarray, $andor, $limit, $offset, $userid){ global $xoopsDB; $showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ; if( $showcontext == 1){ $sql = "SELECT storyid,uid,title,created,hometext,bodytext,nohtml,nosmiley FROM ".$xoopsDB->prefix("stories")." WHERE published>0 AND published<=".time().""; }else{ $sql = "SELECT storyid,uid,title,created,nohtml,nosmiley FROM ".$xoopsDB->prefix("stories")." WHERE published>0 AND published<=".time().""; } 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 created 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'] = "article.php?storyid=".$myrow['storyid'].""; $ret[$i]['title'] = $myrow['title']; $ret[$i]['time'] = $myrow['created']; $ret[$i]['uid'] = $myrow['uid']; if( !empty( $myrow['hometext'] ) ){ $context = $myrow['hometext'].$myrow['bodytext']; $context = strip_tags($myts->displayTarea(strip_tags($context),$myrow['nohtml'],$myrow['nosmiley'],1)); $ret[$i]['context'] = search_make_context($context,$queryarray); } $i++; } return $ret; }
function b_search_newbb($queryarray, $andor, $limit, $offset, $userid){ global $xoopsDB; $showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ; if( $showcontext == 1){ $sql = "SELECT p.post_id,p.topic_id,p.forum_id,p.post_time,p.uid,p.subject,p.nohtml,p.nosmiley,t.post_text 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"; }else{ $sql = "SELECT p.post_id,p.topic_id,p.forum_id,p.post_time,p.uid,p.subject,p.nohtml,p.nosmiley 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; $myts =& MyTextSanitizer::getInstance(); 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']; if( !empty($myrow['post_text']) ){ $context =strip_tags($myts->displayTarea($myrow['post_text'],$myrow['nohtml'],$myrow['nosmiley'],1)); $ret[$i]['context'] = search_make_context($context,$queryarray); } $i++; } return $ret; }
function search(&$environment, $queryarray, $andor, $limit, $offset, $userid) { $ret = array(); $markerHandler =& NBFrame::getHandler('MyGmapMarker', $environment); if (is_array($queryarray) && ($count = count($queryarray))) { $criteria0 = new CriteriaCompo(new Criteria('mygmap_marker_title', '%' . $queryarray[0] . '%', 'LIKE')); $criteria0->add(new Criteria('mygmap_marker_desc', '%' . $queryarray[0] . '%', 'LIKE'), 'OR'); $criteria =& new CriteriaCompo($criteria0); for ($i = 1; $i < $count; $i++) { $criteria0 = new CriteriaCompo(new Criteria('mygmap_marker_title', '%' . $queryarray[$i] . '%', 'LIKE')); $criteria0->add(new Criteria('mygmap_marker_desc', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); $criteria->add($criteria0, $andor); } } else { $criteria =& new CriteriaCompo(new CriteriaElement()); } if ($userid) { $criteria->add(new Criteria('_NBsys_create_user', $userid)); } $criteria->setLimit($limit); $criteria->setStart($offset); $markerObjects = $markerHandler->getObjects($criteria); foreach ($markerObjects as $markerObject) { $desc = $markerObject->getVar('mygmap_marker_desc'); if (!empty($desc) && function_exists('xoops_make_context')) { $context = xoops_make_context(strip_tags($desc), $queryarray); } else { if (!empty($desc) && function_exists('search_make_context')) { if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) { $context = search_make_context(strip_tags($desc), $queryarray); } } else { $context = ''; } } $ret[] = array('title' => $markerObject->getVar('mygmap_marker_title'), 'uid' => $markerObject->getVar('_NBsys_create_user'), 'time' => $markerObject->getVar('_NBsys_update_time'), 'page' => $markerObject->getVar('mygmap_marker_title'), 'link' => $environment->getActionUrl('MyGmapMain', array('cat' => $markerObject->getVar('mygmap_marker_category_id'), 'id' => $markerObject->getVar('mygmap_marker_id')), 'html', true), 'context' => $context); } return $ret; }
function d3forum_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { $myts =& MyTextsanitizer::getInstance(); $db =& Database::getInstance(); $andor = strtoupper($andor); $userid = intval($userid); // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "p.post_text" : "'' AS post_text"; require_once dirname(__FILE__) . '/include/common_functions.php'; $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")"; $whr_uid = $userid > 0 ? "p.uid={$userid}" : "1"; $whr_query = $andor == 'OR' ? '0' : '1'; if (is_array($keywords)) { foreach ($keywords as $word) { // I know this is not a right escaping, but I can't believe $keywords :-) $word4sql = addslashes(stripslashes($word)); $whr_query .= $andor == 'EXACT' ? ' AND' : ' ' . $andor; $whr_query .= " (p.subject LIKE '%{$word4sql}%' OR p.post_text LIKE '%{$word4sql}%')"; } } $sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,{$select4con} FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON t.topic_id=p.topic_id WHERE ({$whr_forum}) AND ({$whr_uid}) AND ({$whr_query}) AND ! topic_invisible ORDER BY p.post_time DESC"; $result = $db->query($sql, $limit, $offset); $ret = array(); $context = ''; while (list($post_id, $topic_id, $post_time, $uid, $subject, $html, $smiley, $xcode, $br, $text) = $db->fetchRow($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { if (function_exists('easiestml')) { $text = easiestml($text); } $full_context = strip_tags($myts->displayTarea($text, $html, $smiley, $xcode, 1, $br)); $context = search_make_context($full_context, $keywords); } $ret[] = array('link' => "index.php?post_id={$post_id}", 'title' => $subject, 'time' => $post_time, 'uid' => $uid, "context" => $context); } return $ret; }
function xpress_global_search_base($mydirname, $queryarray, $andor, $limit, $offset, $userid) { global $xoopsDB, $myts; require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/general_functions.php'; $myts =& MyTextSanitizer::getInstance(); $xp_prefix = preg_replace('/wordpress/', 'wp', $mydirname); if ($userid) { $wp_uid = xoops_uid_to_wp_uid(intval($userid), $mydirname); } $prefix = XOOPS_DB_PREFIX . '_' . $xp_prefix; $posts_tables = get_table_list($prefix, 'posts'); $i = 0; $ret = array(); foreach ($posts_tables as $views_table) { $mid_prefix = get_multi_mid_prefix($prefix, 'posts', $views_table); $option_table = $prefix . $mid_prefix . 'options'; $time_difference = get_blog_option($option_table, 'gmt_offset'); $blog_url = get_blog_option($option_table, 'siteurl'); $pattern = '/.*' . $mydirname . '/'; $mid_url = preg_replace($pattern, '', $blog_url); $mid_url = preg_replace('/\\//', '', $mid_url); if (!empty($mid_url)) { $mid_url = $mid_url . '/'; } $blog_name = get_blog_option($option_table, 'blogname'); if (empty($mid_url)) { $blog_name = ''; } else { $blog_name = $blog_name . ':: '; } $now = date('Y-m-d H:i:s', time() + $time_difference * 3600); $where = "(post_status = 'publish') AND (post_date <= '" . $now . "') AND (post_type <> 'revision') AND (post_type <> 'nav_menu_item') "; if (is_array($queryarray) && ($count = count($queryarray))) { $str_query = array(); for ($j = 0; $j < $count; $j++) { $str_query[] = "(post_title LIKE '%" . $queryarray[$j] . "%' OR post_content LIKE '%" . $queryarray[$j] . "%')"; } $where .= " AND " . implode(" {$andor} ", $str_query); } if ($userid) { if ($wp_uid) { $where .= " AND (post_author=" . $wp_uid . ")"; } else { $where .= " AND 0 "; } } $request = "SELECT * FROM " . $views_table . " WHERE " . $where; $request .= " ORDER BY post_date DESC"; $result = $xoopsDB->query($request, $limit, $offset); while ($myrow = $xoopsDB->fetchArray($result)) { if ($myrow['post_type'] !== 'revision' && $myrow['post_type'] !== 'nav_menu_item') { switch ($myrow['post_type']) { case 'page': $ret[$i]['link'] = $mid_url . '?page_id=' . $myrow['ID']; break; case 'post': case '': $ret[$i]['link'] = $mid_url . '?p=' . $myrow['ID']; break; default: $ret[$i]['link'] = $mid_url . '?' . $myrow['post_type'] . '=' . $myrow['post_name']; } } $ret[$i]['title'] = $blog_name . $myts->htmlSpecialChars($myrow['post_title']); $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 14, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'], $mydirname); $context = ''; $text = $myrow['post_content']; // get context for module "search" $showcontext = empty($_GET['showcontext']) ? 0 : 1; if (function_exists('search_make_context') && $showcontext) { if (function_exists('easiestml')) { $text = easiestml($text); } $full_context = strip_tags($text); $context = search_make_context($full_context, $queryarray); } $ret[$i]['context'] = $context; $i++; } } return $ret; }
function get_xoops_search_result($keywords, $andor, $limit, $offset, $uid) { // 時差計算 $tzoffset = ($this->user_TZ - $this->server_TZ) * 3600; // カテゴリー関連のWHERE条件取得 $whr_categories = $this->get_where_about_categories(); // CLASS関連のWHERE条件取得 $whr_class = $this->get_where_about_class(); // 文字列指定 if (!empty($keywords)) { switch (strtolower($andor)) { case 'and': $whr_text = ''; foreach ($keywords as $keyword) { $whr_text .= "CONCAT(summary,' ',description) LIKE '%{$keyword}%' AND "; } $whr_text = substr($whr_text, 0, -5); break; case 'or': $whr_text = ''; foreach ($keywords as $keyword) { $whr_text .= "CONCAT(summary,' ',description) LIKE '%{$keyword}%' OR "; } $whr_text = substr($whr_text, 0, -4); break; default: $whr_text = "CONCAT(summary,' ',description) LIKE '%{$keywords[0]}%'"; break; } } else { $whr_text = '1'; } // ユーザID指定 if ($uid > 0) { $whr_uid = "uid={$uid}"; } else { $whr_uid = '1'; } // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "description" : "'' AS description"; // SQL文生成 $sql = "SELECT id,uid,summary,UNIX_TIMESTAMP(dtstamp) AS udtstamp, start, end, allday, start_date, end_date, {$select4con} FROM {$this->table} WHERE admission>0 AND (rrule_pid=0 OR rrule_pid=id) AND ({$whr_categories}) AND ({$whr_class}) AND ({$whr_text}) AND ({$whr_uid}) ORDER BY dtstamp DESC LIMIT {$offset},{$limit}"; // クエリ $rs = mysql_query($sql, $this->conn); $ret = array(); $context = ''; $myts =& MyTextSanitizer::getInstance(); while ($event = mysql_fetch_object($rs)) { if (isset($event->start_date)) { $start_str = $event->start_date; } else { if ($event->allday) { $start_str = $this->get_long_ymdn($event->start); } else { $start_str = $this->get_long_ymdn($event->start + $tzoffset); } } if (isset($event->end_date)) { $end_str = $event->end_date; } else { if ($event->allday) { $end_str = $this->get_long_ymdn($event->end - 300); } else { $end_str = $this->get_long_ymdn($event->end + $tzoffset); } } $date_desc = $start_str == $end_str ? $start_str : "{$start_str} - {$end_str}"; // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $full_context = strip_tags($myts->displayTarea($event->description, 1, 1, 1, 1, 1)); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } $ret[] = array('image' => "images/pical.gif", 'link' => "index.php?action=View&event_id={$event->id}", 'title' => "[{$date_desc}] {$event->summary}", 'time' => $event->udtstamp, 'uid' => $uid, "context" => $context); } return $ret; }
function tinyd_search_base($mydirname, $mydirnumber, $keywords, $andor, $limit, $offset, $userid) { // get my config $module_handler =& xoops_gethandler('module'); $config_handler =& xoops_gethandler('config'); $module =& $module_handler->getByDirname($mydirname); $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); $myts =& TinyDTextSanitizer::getInstance(); $db =& Database::getInstance(); // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $select4con = $showcontext ? "text" : "'' AS text"; $sql = "SELECT storyid,title,link,UNIX_TIMESTAMP(last_modified),{$select4con} FROM " . $db->prefix("tinycontent{$mydirnumber}") . " WHERE visible AND ! (nohtml & 8) "; if (!empty($userid)) { $sql .= " AND 0 "; } $whr = ""; if (is_array($keywords) && count($keywords) > 0) { $whr = "AND ("; switch (strtolower($andor)) { case "and": foreach ($keywords as $keyword) { $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' AND "; } $whr = substr($whr, 0, -5); break; case "or": foreach ($keywords as $keyword) { $whr .= "CONCAT(title,' ',text) LIKE '%{$keyword}%' OR "; } $whr = substr($whr, 0, -4); break; default: $whr .= "CONCAT(title,' ',text) LIKE '%{$keywords[0]}%'"; break; } $whr .= ")"; } $sql = "{$sql} {$whr} ORDER BY storyid ASC"; $result = $db->query($sql, $limit, $offset); $ret = array(); $context = ''; while (list($id, $title, $link, $timestamp, $text) = $db->fetchRow($result)) { // get context for module "search" if (function_exists('search_make_context') && $showcontext) { $full_context = strip_tags($myts->displayTarea($text, 1, 1, 1, 1, 1)); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } if (!empty($config['tc_force_mod_rewrite'])) { if (!empty($config['tc_modulesless_dir'])) { $href = '../../' . $config['tc_modulesless_dir'] . '/' . sprintf(TC_REWRITE_FILENAME_FMT, $id); } else { $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id); } } else { if ($link == TC_WRAPTYPE_USEREWRITE) { $href = TC_REWRITE_DIR . sprintf(TC_REWRITE_FILENAME_FMT, $id); } else { if ($link == TC_WRAPTYPE_CONTENTBASE) { $href = "content/index.php?id={$id}"; } else { $href = "index.php?id={$id}"; } } } $ret[] = array("image" => "images/content.gif", "link" => $href, "title" => $title, "time" => $timestamp, "uid" => "0", "context" => $context); } return $ret; }
function none_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // not implemented for uid specifications //if ! empty($userid)) { //return array(); //} $chandler =& xoops_gethandler('config'); $config =& $chandler->getConfigsByDirname($mydirname); $config['dirname'] = $mydirname; if (empty($config['search_comment'])) { $config = array(); } $tpl = new Legacy_XoopsTpl(); $tpl->assign('config', $config); $content = strip_tags($tpl->fetch("db:{$mydirname}_index.tpl")); if (!is_array($keywords)) { $keywords = array(); } if (strtolower($andor) === 'exact') { $keyword = current($keywords); if (false !== mb_stripos($content, $keyword)) { $found = true; } else { $found = false; } } else { $found = 0; foreach ($keywords as $keyword) { if (false !== mb_stripos($content, $keyword)) { $found++; } } if ($found > 0) { if (strtolower($andor) === 'or') { $found = true; } else if ((strtolower($andor) === 'and') and ($found == count($keywords))) { $found = true; } else { $found = false; } } else { $found = false; } } // get time from tpl_lastmodified. if ($found) { $db =& Database::getInstance(); $sql = <<<SQL_DESU SELECT tpl_lastmodified FROM {$db->prefix('tplfile')} WHERE tpl_file = '{$mydirname}_index.tpl' ORDER BY tpl_lastmodified DESC SQL_DESU; $result = $db->query($sql, 1); $time = array_pop(array_values($db->fetchRow($result))); unset($result); } if (empty($time)) { $time = null; } // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? false : true; if ($showcontext && $found) { $context = str_replace(array("\r", "\t", "\f"), ' ', $content); $context = trim(preg_replace('/\n\s*\n/', "\n", $context)); $context = search_make_context($context, $keywords); } else { $context = ''; } $ret = array( array( 'link' => 'index.php', 'title' => $mydirname, 'time' => $time, 'uid' => null, 'context' => $context, ) ); return $found ? $ret : array(); }
function d3downloads_global_search_base( $mydirname, $keywords, $andor, $limit, $offset, $userid ) { require_once dirname( __FILE__ ).'/class/d3downloads.textsanitizer.php' ; include_once dirname( __FILE__ ).'/class/mydownload.php' ; include_once dirname( __FILE__ ).'/class/user_access.php' ; $myts =& d3downloadsTextSanitizer::getInstance() ; $db =& Database::getInstance() ; $showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : 0 ; $mydownload = new MyDownload( $mydirname ) ; $user_access = new user_access( $mydirname ) ; $whr = "cid IN ( ".implode( ",", $user_access->can_read() )." )" ; if( $showcontext == 1 ){ $sql = "SELECT lid, cid, title, description, submitter, date FROM ".$db->prefix( $mydirname."_downloads" )."" ; } else { $sql = "SELECT lid, cid, title, submitter, date, title FROM ".$db->prefix( $mydirname."_downloads" )."" ; } $sql .= " WHERE ".$mydownload->whr_append( 'Single' )." AND ( $whr )" ; if ( $userid != 0 ) $sql .= " AND submitter=".$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( $keywords ) && $count = count( $keywords ) ) { $sql .= " AND ( ( title LIKE '%$keywords[0]%' OR description LIKE '%$keywords[0]%' )" ; for( $i=1; $i<$count; $i++ ){ $sql .= " $andor " ; $sql .= "( title LIKE '%$keywords[$i]%' OR description LIKE '%$keywords[$i]%' )" ; } $sql .= ") " ; } $sql .= "ORDER BY date DESC" ; $result = $db->query( $sql, $limit, $offset ) ; $ret = array(); while( $myrow = $db->fetchArray( $result ) ) { $lid = intval( $myrow['lid'] ) ; $cid = intval( $myrow['cid'] ) ; $title = $myts->makeTboxData4Show( $myrow['title'] ) ; $date = intval( $myrow['date'] ) ; $submitter = intval( $myrow['submitter'] ) ; $context = '' ; // get context for module "search" if( function_exists( 'search_make_context' ) && $showcontext ) { $body = $myts->displayTarea( $myrow['description'], 0, 1, 1, 1, 1 ) ; if ( strstr ( $body , '[pagebreak]' ) ){ $str = explode( '[pagebreak]', $body , 2 ) ; $body = $str[0] ; } $full_context = strip_tags( $body ) ; if( function_exists( 'easiestml' ) ) $full_context = easiestml( $full_context ) ; $context = search_make_context( $full_context , $keywords ) ; } $ret[] = array( 'link' => "index.php?page=singlefile&cid=$cid&lid=$lid" , 'title' => $title , 'time' => $date , 'uid' => $submitter , 'context' => $context , ) ; } return $ret ; }
function pico_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $uid) { // get this module's config $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname($mydirname); $config_handler =& xoops_gethandler('config'); $configs = $config_handler->getConfigList($module->mid()); // check xmobile or not $is_xmobile = false; if (function_exists('debug_backtrace') && ($backtrace = debug_backtrace())) { if (strstr($backtrace[2]['file'], '/xmobile/actions/')) { $is_xmobile = true; } } // XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; // where by uid if (!empty($uid)) { if (empty($configs['search_by_uid'])) { return array(); } $whr_uid = 'o.poster_uid=' . intval($uid); } else { $whr_uid = '1'; } // where by keywords if (is_array($keywords) && count($keywords) > 0) { switch (strtolower($andor)) { case "and": $whr_kw = ""; foreach ($keywords as $keyword) { $whr_kw .= "(`for_search` LIKE '%{$keyword}%') AND "; } $whr_kw .= "1"; break; case "or": $whr_kw = ""; foreach ($keywords as $keyword) { $whr_kw .= "(`for_search` LIKE '%{$keyword}%') OR "; } $whr_kw .= "0"; break; default: $whr_kw = "(`for_search` LIKE '%{$keywords['0']}%')"; break; } } else { $whr_kw = 1; } $content_handler =& new PicoContentHandler($mydirname); $contents4assign = $content_handler->getContents4assign("({$whr_kw}) AND ({$whr_uid})", 'created_time DESC', $offset, $limit, false); $ret = array(); foreach ($contents4assign as $content) { // get context for module "search" if (function_exists('search_make_context') && $showcontext && $content['can_readfull']) { $full_context = strip_tags(@$content['body_cached']); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = search_make_context($full_context, $keywords); } else { $context = ''; } $ret[] = array('image' => '', 'link' => $is_xmobile ? 'index.php?cat_id=' . $content['cat_id'] . '&content_id=' . $content['content_id'] : pico_common_make_content_link4html($configs, $content), 'title' => $content['subject'], 'time' => $content['created_time'], 'uid' => empty($configs['search_by_uid']) ? 0 : $content['poster_uid'], 'context' => $context); } return $ret; }