$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; }
$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; }
/** * Returns the single instance * * @access static * @return PMF_Stopwords */ public static function getInstance() { if (null == self::$instance) { $className = __CLASS__; self::$instance = new $className(); } return self::$instance; }
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 * @link http://www.phpmyfaq.de * @since 2009-04-01 */ if (!defined('IS_VALID_PHPMYFAQ') || !$permission['editconfig']) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } $ajaxAction = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING); $instanceId = PMF_Filter::filterInput(INPUT_GET, 'instanceId', FILTER_VALIDATE_INT); $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); $csrfToken = PMF_Filter::filterInput(INPUT_GET, 'csrf', FILTER_SANITIZE_STRING); $http = new PMF_Helper_Http(); $stopwords = new PMF_Stopwords($faqConfig); switch ($ajaxAction) { case 'add_instance': $url = PMF_Filter::filterInput(INPUT_GET, 'url', FILTER_SANITIZE_STRING); $instance = PMF_Filter::filterInput(INPUT_GET, 'instance', FILTER_SANITIZE_STRING); $comment = PMF_Filter::filterInput(INPUT_GET, 'comment', FILTER_SANITIZE_STRING); $email = PMF_Filter::filterInput(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL); $admin = PMF_Filter::filterInput(INPUT_GET, 'admin', FILTER_SANITIZE_STRING); $password = PMF_Filter::filterInput(INPUT_GET, 'password', FILTER_SANITIZE_STRING); $data = array('url' => 'http://' . $url . '.' . $_SERVER['SERVER_NAME'], 'instance' => $instance, 'comment' => $comment); $faqInstance = new PMF_Instance($faqConfig); $instanceId = $faqInstance->addInstance($data); $faqInstanceClient = new PMF_Instance_Client($faqConfig); $faqInstanceClient->createClient($faqInstance); $urlParts = parse_url($data['url']); $hostname = $urlParts['host'];
$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()) {
$plr = new PMF_Language_Plurals($PMF_LANG); // // Initalizing static string wrapper // PMF_String::init($languageCode); // Check captcha $captcha = new PMF_Captcha($faqConfig); $captcha->setSessionId(PMF_Filter::filterInput(INPUT_COOKIE, PMF_Session::PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT)); // Prepare response $response = new JsonResponse(); $responseWrapper = new ResponseWrapper($response); $responseWrapper->addCommonHeaders(); // Set session $faqsession = new PMF_Session($faqConfig); $network = new PMF_Network($faqConfig); $stopwords = new PMF_Stopwords($faqConfig); if (!$network->checkIp($_SERVER['REMOTE_ADDR'])) { $message = array('error' => $PMF_LANG['err_bannedIP']); } // Check, if user is logged in $user = PMF_User_CurrentUser::getFromSession($faqConfig); if ($user instanceof PMF_User_CurrentUser) { $isLoggedIn = true; } else { $isLoggedIn = false; } if ('savevoting' !== $action && 'saveuserdata' !== $action && 'changepassword' !== $action && !$captcha->checkCaptchaCode($code) && !$isLoggedIn) { $message = array('error' => $PMF_LANG['msgCaptcha']); } if (isset($message['error'])) { $response->setData($message)->send();