Beispiel #1
0
function mysearch_search($queryarray, $andor, $limit, $offset, $userid)
{
    global $xoopsUser;
    include_once XOOPS_ROOT_PATH . '/modules/mysearch/include/functions.php';
    include_once XOOPS_ROOT_PATH . '/modules/mysearch/class/blacklist.php';
    $mysearch_handler =& xoops_getmodulehandler('searches', 'mysearch');
    $banned = array();
    $banned = mysearch_getmoduleoption('bannedgroups');
    $uid = 0;
    $datesearch = date('Y-m-d H:i:s');
    if (is_object($xoopsUser)) {
        $groups = $xoopsUser->getGroups();
        $uid = $xoopsUser->getVar('uid');
    } else {
        $groups = array(XOOPS_GROUP_ANONYMOUS);
    }
    $blacklist = new mysearch_blacklist();
    $blacklist->getAllKeywords();
    // Load keywords from blacklist
    $queryarray = $blacklist->remove_blacklisted($queryarray);
    $count = count($queryarray);
    if (count(array_intersect($groups, $banned)) == 0 && $userid == 0) {
        // If it's not a banned user and if we are not viewing someone's profile
        if (is_array($queryarray) && $count > 0) {
            for ($i = 0; $i < $count; $i++) {
                $mysearch = $mysearch_handler->create(true);
                $mysearch->setVar('uid', $uid);
                $mysearch->setVar('datesearch', $datesearch);
                $mysearch->setVar('keyword', $queryarray[$i]);
                $res = $mysearch_handler->insert($mysearch);
            }
        }
    }
    return '';
}