예제 #1
0
$ajaxAction = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING);
$stopwordId = PMF_Filter::filterInput(INPUT_GET, 'stopword_id', FILTER_VALIDATE_INT);
$stopword = PMF_Filter::filterInput(INPUT_GET, 'stopword', FILTER_SANITIZE_STRING);
$stopwordsLang = PMF_Filter::filterInput(INPUT_GET, 'stopwords_lang', FILTER_SANITIZE_STRING);
switch ($ajaxAction) {
    case 'load_stop_words_by_lang':
        if (PMF_Language::isASupportedLanguage($stopwordsLang)) {
            $stopwordsList = PMF_Stopwords::getInstance()->getByLang($stopwordsLang);
            header('Content-Type: application/json');
            print json_encode($stopwordsList);
        }
        break;
    case 'delete_stop_word':
        if (null != $stopwordId && PMF_Language::isASupportedLanguage($stopwordsLang)) {
            $oStopwords = PMF_Stopwords::getInstance();
            $oStopwords->setLanguage($stopwordsLang);
            $oStopwords->remove($stopwordId);
        }
        break;
    case 'save_stop_word':
        if (null != $stopword && PMF_Language::isASupportedLanguage($stopwordsLang)) {
            $oStopwords = PMF_Stopwords::getInstance();
            $oStopwords->setLanguage($stopwordsLang);
            if (null !== $stopwordId && -1 < $stopwordId) {
                $oStopwords->update($stopwordId, $stopword);
            } elseif (!$oStopwords->match($stopword)) {
                $oStopwords->add($stopword);
            }
        }
        break;
}
예제 #2
0
$stopword = PMF_Filter::filterInput(INPUT_GET, 'stopword', FILTER_SANITIZE_STRING);
$stopwords_lang = PMF_Filter::filterInput(INPUT_GET, 'stopwords_lang', FILTER_SANITIZE_STRING);
switch ($ajax_action) {
    case 'load_stop_words_by_lang':
        if (PMF_Language::isASupportedLanguage($stopwords_lang)) {
            $stop_words_list = PMF_Stopwords::getInstance()->getByLang($stopwords_lang);
            header('Content-Type: application/json');
            print json_encode($stop_words_list);
        }
        break;
    case 'delete_stop_word':
        if (null != $stopword_id && PMF_Language::isASupportedLanguage($stopwords_lang)) {
            $pmf_sw = PMF_Stopwords::getInstance();
            $pmf_sw->setLanguage($stopwords_lang);
            $pmf_sw->remove($stopword_id);
        }
        break;
    case 'save_stop_word':
        if (null != $stopword && PMF_Language::isASupportedLanguage($stopwords_lang)) {
            $pmf_sw = PMF_Stopwords::getInstance();
            $pmf_sw->setLanguage($stopwords_lang);
            if (null !== $stopword_id && -1 < $stopword_id) {
                $pmf_sw->update($stopword_id, $stopword);
            } else {
                if (!$pmf_sw->match($stopword)) {
                    $pmf_sw->add($stopword);
                }
            }
        }
        break;
}
예제 #3
0
 $email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
 $ucategory = PMF_Filter::filterInput(INPUT_POST, 'category', FILTER_VALIDATE_INT);
 $question = PMF_Filter::filterInput(INPUT_POST, 'question', FILTER_SANITIZE_STRIPPED);
 $save = PMF_Filter::filterInput(INPUT_POST, 'save', FILTER_VALIDATE_INT, 0);
 // If e-mail address is set to optional
 if (!PMF_Configuration::getInstance()->get('main.optionalMailAddress') && is_null($email)) {
     $email = PMF_Configuration::getInstance()->get('main.administrationMail');
 }
 if (!is_null($name) && !empty($name) && !is_null($email) && !empty($email) && !is_null($question) && !empty($question) && checkBannedWord(PMF_String::htmlspecialchars($question))) {
     if (PMF_Configuration::getInstance()->get('records.enableVisibilityQuestions')) {
         $visibility = 'N';
     } else {
         $visibility = 'Y';
     }
     if (1 != $save) {
         $cleanQuestion = PMF_Stopwords::getInstance()->clean($question);
         $user = new PMF_User_CurrentUser();
         $faqSearch = new PMF_Search($db, $Language);
         $faqSearchResult = new PMF_Search_Resultset($user, $faq);
         $searchResult = array();
         $mergedResult = array();
         foreach ($cleanQuestion as $word) {
             $searchResult[] = $faqSearch->search($word);
         }
         foreach ($searchResult as $resultSet) {
             foreach ($resultSet as $result) {
                 $mergedResult[] = $result;
             }
         }
         $faqSearchResult->reviewResultset($mergedResult);
         if (0 < $faqSearchResult->getNumberOfResults()) {