Exemplo n.º 1
0
            $mail->addCc($userEmail);
        }
        $mail->subject = '%sitename%';
        $mail->message = $questionMail;
        $retval = $mail->send();
    }
    return $retval;
}
if (!is_null($username) && !empty($usermail) && !empty($content) && IPCheck($_SERVER['REMOTE_ADDR']) && checkBannedWord(PMF_String::htmlspecialchars($content)) && $captcha->checkCaptchaCode($code)) {
    $pmf_sw = PMF_Stopwords::getInstance();
    $search_stuff = $pmf_sw->clean($content);
    $search = new PMF_Search();
    $search_result = array();
    $counter = 0;
    foreach ($search_stuff as $word) {
        $tmp = getSearchData($word);
        foreach ($tmp as $foundItem) {
            if (!isset($foundItem->id, $search_result[$foundItem->category_id])) {
                $counter++;
                $foundItem->searchterm = PMF_String::htmlspecialchars(stripslashes($word), ENT_QUOTES, 'utf-8');
                $search_result[$foundItem->category_id][$foundItem->id] = $foundItem;
            }
        }
    }
    if ($search_result) {
        $faqUser = new PMF_Faq_User();
        $faqGroup = new PMF_Faq_Group();
        $search_result_html = '<p>' . $plr->GetMsg('plmsgSearchAmount', count($search_result)) . "</p>\n";
        $counter = 0;
        foreach ($search_result as $cat_id => $cat_contents) {
            $tmp_result_html = '';
Exemplo n.º 2
0
function getContext($om, $ds, $fdata, $forumid, $access_token, $forum, $postid, $searchid)
{
    global $environment;
    global $logService;
    try {
        $secret_key = $environment['secret_key'];
        $more = true;
        while ($more) {
            $endpoint = 'https://disqus.com/api/3.0/posts/getContext.json?post=' . $postid . '&';
            //$par='post='.$id.'&';
            $par = '';
            $res = getSearchData($om, $ds, $fdata, $forumid, $endpoint, $secret_key, $access_token, $par, 0, false, $searchid);
            // $logService->log('DEBUG','getContext',var_log($res,'$res'),'');
            //kludge as it seems that disqus context returns only one parent
            /*  if(empty($res)
                    break;
                if(is_array($res)){
                    if(sizeof($res)==1)
                        $post=$res[0];
                    else 
                        break;
                }
                else
                    $post=$res;
                if($post->parent==null)
                    break;
                $postid=$post->parent;*/
            break;
        }
        return $res;
    } catch (Exception $x) {
        $logService->log('Exception', 'getContext', fe($x), $forumid);
    }
}
Exemplo n.º 3
0
/**
 * The main search function for the full text search
 *
 * TODO: add filter for (X)HTML tag names and attributes!
 *
 * @param   string  Text/Number (solution id)
 * @param   string  '%' to avoid any category filtering
 * @param   boolean true to search over all languages
 * @param   boolean true to disable the results paging
 * @param   boolean true to use it for Instant Response
 * @return  string
 * @access  public
 * @author  Thorsten Rinne <*****@*****.**>
 * @author  Matteo Scaramuccia <*****@*****.**>
 * @author  Adrianna Musiol <*****@*****.**>
 * @since   2002-09-16
 */
function searchEngine($searchterm, $cat = '%', $allLanguages = true, $hasMore = false, $instantRespnse = false)
{
    global $sids, $PMF_LANG, $plr, $LANGCODE, $faq, $current_user, $current_groups, $categoryLayout;
    $_searchterm = PMF_htmlentities(stripslashes($searchterm), ENT_QUOTES, 'utf-8');
    $seite = 1;
    $output = '';
    $num = 0;
    $searchItems = array();
    $langs = true == $allLanguages ? '&amp;langs=all' : '';
    $seite = PMF_Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
    $db = PMF_Db::getInstance();
    $faqconfig = PMF_Configuration::getInstance();
    $result = getSearchData(htmlentities($searchterm, ENT_COMPAT, 'utf-8'), true, $cat, $allLanguages);
    $num = $db->numRows($result);
    if (0 == $num) {
        $output = $PMF_LANG['err_noArticles'];
    }
    $confPerPage = $faqconfig->get('main.numberOfRecordsPerPage');
    $pages = ceil($num / $confPerPage);
    $last = $seite * $confPerPage;
    $first = $last - $confPerPage;
    if ($last > $num) {
        $last = $num;
    }
    if ($num > 0) {
        $output .= '<p>' . $plr->GetMsg('plmsgSearchAmount', $num);
        if ($hasMore && $pages > 1) {
            $output .= sprintf($PMF_LANG['msgInstantResponseMaxRecords'], $confPerPage);
        }
        $output .= "</p>\n";
        if (!$hasMore && $pages > 1) {
            $output .= "<p><strong>" . $PMF_LANG["msgPage"] . $seite . " " . $PMF_LANG["msgVoteFrom"] . " " . $plr->GetMsg('plmsgPagesTotal', $pages) . "</strong></p>";
        }
        $output .= "<ul class=\"phpmyfaq_ul\">\n";
        $faqUser = new PMF_Faq_User();
        $faqGroup = new PMF_Faq_Group();
        $counter = $displayedCounter = 0;
        while (($row = $db->fetchObject($result)) && $displayedCounter < $confPerPage) {
            $counter++;
            if ($counter <= $first) {
                continue;
            }
            $displayedCounter++;
            $b_permission = false;
            //Groups Permission Check
            if ($faqconfig->get('main.permLevel') == 'medium') {
                $perm_group = $faqGroup->fetch($row->id);
                foreach ($current_groups as $value) {
                    if ($value == $perm_group->group_id) {
                        $b_permission = true;
                    }
                }
            }
            if ($faqconfig->get('main.permLevel') == 'basic' || $b_permission) {
                $perm_user = $faqUser->fetch($row->id);
                foreach ($perm_user as $value) {
                    if ($value == -1) {
                        $b_permission = true;
                        break;
                    } elseif ((int) $value == $current_user) {
                        $b_permission = true;
                        break;
                    } else {
                        $b_permission = false;
                    }
                }
            }
            if ($b_permission) {
                $rubriktext = $categoryLayout->renderBreadcrumb(array($row->category_id));
                $thema = chopString($row->thema, 15);
                $content = chopString(strip_tags($row->content), 25);
                $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $searchterm);
                $searchterm = preg_quote($searchterm, '/');
                $searchItems = explode(' ', $searchterm);
                if (PMF_String::strlen($searchItems[0]) > 1) {
                    foreach ($searchItems as $item) {
                        if (PMF_String::strlen($item) > 2) {
                            $thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $thema);
                            $content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $content);
                        }
                    }
                }
                // Print the link to the faq record
                $url = sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s&amp;highlight=%s', $sids, $row->category_id, $row->id, $row->lang, urlencode($_searchterm));
                if ($instantRespnse) {
                    $currentUrl = PMF_Link::getSystemRelativeUri('ajaxresponse.php') . 'index.php';
                } else {
                    $currentUrl = PMF_Link::getSystemRelativeUri();
                }
                $oLink = new PMF_Link($currentUrl . $url);
                $oLink->itemTitle = $row->thema;
                $oLink->text = $thema;
                $oLink->tooltip = $row->thema;
                $output .= '<li><strong>' . $rubriktext . '</strong>: ' . $oLink->toHtmlAnchor() . '<br />' . '<div class="searchpreview"><strong>' . $PMF_LANG['msgSearchContent'] . '</strong> ' . $content . '...</div>' . '<br /></li>' . "\n";
            }
        }
        $output .= "</ul>\n";
    } else {
        $output = $PMF_LANG["err_noArticles"];
    }
    if (!$hasMore && $num > $confPerPage) {
        if ($faqconfig->get('main.enableRewriteRules')) {
            $baseUrl = sprintf("search.html?search=%s&amp;seite=%d%s&amp;searchcategory=%d", urlencode($_searchterm), $seite, $langs, $cat);
        } else {
            $baseUrl = PMF_Link::getSystemRelativeUri() . '?' . (empty($sids) ? '' : "{$sids}&amp;") . 'action=search&amp;search=' . urlencode($_searchterm) . '&amp;seite=' . $seite . $langs . "&amp;searchcategory=" . $cat;
        }
        $options = array('baseUrl' => $baseUrl, 'total' => $num, 'perPage' => $confPerPage, 'pageParamName' => 'seite', 'nextPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgNext"] . '</a>', 'prevPageLinkTpl' => '<a href="{LINK_URL}">' . $PMF_LANG["msgPrevious"] . '</a>', 'layoutTpl' => '<p align="center"><strong>{LAYOUT_CONTENT}</strong></p>');
        $pagination = new PMF_Pagination($options);
        $output .= $pagination->render();
    }
    return $output;
}
Exemplo n.º 4
0
function getThread($ds, $fdata, $forumid, $access_token, $forum, $thread, $searchid)
{
    global $environment;
    $secret_key = $environment['secret_key'];
    $endpoint = 'https://disqus.com/api/3.0/threads/listPosts.json?thread=' . $thread . '&limit=100&';
    //$par='post='.$id.'&';
    $par = '';
    $res = getSearchData($ds, $fdata, $forumid, $endpoint, $secret_key, $access_token, $par, 0, true, $searchid, $thread);
    // has_context=true!
    return $res;
}