* v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2011-2015 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2011-08-24
 */
if (!defined('IS_VALID_PHPMYFAQ')) {
    $protocol = 'http';
    if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') {
        $protocol = 'https';
    }
    header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$ajaxAction = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING);
$searchTerm = PMF_Filter::filterInput(INPUT_GET, 'searchterm', FILTER_SANITIZE_STRING);
$search = new PMF_Search($faqConfig);
switch ($ajaxAction) {
    case 'delete_searchterm':
        if ($search->deleteSearchTerm($searchTerm)) {
            print true;
        } else {
            print false;
        }
        break;
}
Exemple #2
0
} else {
    $allLanguages = false;
    $languages = '';
}
// HACK: (re)evaluate the Category object w/o passing the user language
//       so the result set of a Search will have the Category Path
//       for any of the multilanguage faq records and the Category list
//       on the left pane will not be affected
if ($allLanguages) {
    $category = new PMF_Category();
    $category->transform(0);
}
if (is_null($user)) {
    $user = new PMF_User_CurrentUser();
}
$faqSearch = new PMF_Search($db, $Language);
$faqSearchResult = new PMF_Search_Resultset($user, $faq);
$tagSearch = false;
//
// Handle the Tagging ID
//
if (!is_null($inputTag)) {
    $tagSearch = true;
    $tagging = new PMF_Tags($db, $Language);
    $recordIds = $tagging->getRecordsByTagId($inputTag);
    $searchResult = $faq->showAllRecordsByIds($recordIds);
} else {
    $searchResult = '';
}
//
// Handle the full text search stuff
Exemple #3
0
    require 'lang/language_en.php';
}
$plr = new PMF_Language_Plurals($PMF_LANG);
PMF_String::init($language);
// Set empty result
$result = array();
// Handle actions
switch ($action) {
    case 'getVersion':
        $result = array('version' => $faqconfig->get('main.currentVersion'));
        break;
    case 'getApiVersion':
        $result = array('apiVersion' => (int) $faqconfig->get('main.currentApiVersion'));
        break;
    case 'search':
        $search = new PMF_Search($db, $Language);
        $searchString = PMF_Filter::filterInput(INPUT_GET, 'q', FILTER_SANITIZE_STRIPPED);
        $result = $search->search($searchString, false);
        $url = $faqconfig->get('main.referenceURL') . '/index.php?action=artikel&cat=%d&id=%d&artlang=%s';
        foreach ($result as &$data) {
            $data->answer = html_entity_decode(strip_tags($data->answer), ENT_COMPAT, 'utf-8');
            $data->answer = PMF_Utils::makeShorterText($data->answer, 12);
            $data->link = sprintf($url, $data->category_id, $data->id, $data->lang);
        }
        break;
    case 'getCategories':
        $category = new PMF_Category($current_user, $current_groups, true);
        $result = $category->categories;
        break;
    case 'getFaqs':
        $faq = new PMF_Faq($current_user, $current_groups);
Exemple #4
0
 $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()) {
             $response = sprintf('<p>%s</p>', $plr->GetMsg('plmsgSearchAmount', $faqSearchResult->getNumberOfResults()));
             $response .= '<ul>';
Exemple #5
0
    if (!is_null($num)) {
        $bar = new PMF_Bar($num);
        $bar->renderImage();
        exit;
    }
}
if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
if ($permission['viewlog']) {
    printf('<header><h2>%s</h2></header>', $PMF_LANG['ad_menu_searchstats']);
    $perpage = 15;
    $pages = PMF_Filter::filterInput(INPUT_GET, 'pages', FILTER_VALIDATE_INT);
    $page = PMF_Filter::filterInput(INPUT_GET, 'page', FILTER_VALIDATE_INT, 1);
    $search = new PMF_Search($db, $Language);
    $searchesCount = $search->getSearchesCount();
    $searchesList = $search->getMostPopularSearches($searchesCount + 1, true);
    if (is_null($pages)) {
        $pages = round((count($searchesList) + $perpage / 3) / $perpage, 0);
    }
    $start = ($page - 1) * $perpage;
    $ende = $start + $perpage;
    $PageSpan = PageSpan("<a href=\"?action=searchstats&amp;pages=" . $pages . "&amp;page=<NUM>\">", 1, $pages, $page);
    ?>
        <div id="ajaxresponse"></div>
        <table class="list" style="width: 100%">
        <thead>
        <tr>
            <th><?php 
    print $PMF_LANG['ad_searchstats_search_term'];
Exemple #6
0
 /**
  * Tests PMF_Search->setCategory()
  * 
  */
 public function testSetCategory()
 {
     $this->PMF_Search->setCategory(23);
     $categoryId = $this->PMF_Search->getCategory();
     $this->assertEquals(23, $categoryId);
 }
echo $PMF_LANG['ad_searchterm_del'];
?>
                        </a>
                    </div>
                </h2>
            </div>
        </header>

        <div class="row">
            <div class="col-lg-12">
<?php 
if ($user->perm->checkRight($user->getUserId(), 'viewlog')) {
    $perpage = 15;
    $pages = PMF_Filter::filterInput(INPUT_GET, 'pages', FILTER_VALIDATE_INT);
    $page = PMF_Filter::filterInput(INPUT_GET, 'page', FILTER_VALIDATE_INT, 1);
    $search = new PMF_Search($faqConfig);
    if ('truncatesearchterms' === $action) {
        if ($search->deleteAllSearchTerms()) {
            printf('<p class="alert alert-success">%s</p>', $PMF_LANG["ad_searchterm_del_suc"]);
        } else {
            printf('<p class="alert alert-success">%s</p>', $PMF_LANG["ad_searchterm_del_err"]);
        }
    }
    $searchesCount = $search->getSearchesCount();
    $searchesList = $search->getMostPopularSearches($searchesCount + 1, true);
    if (is_null($pages)) {
        $pages = round((count($searchesList) + $perpage / 3) / $perpage, 0);
    }
    $start = ($page - 1) * $perpage;
    $ende = $start + $perpage;
    $baseUrl = sprintf('%s?action=searchstats&amp;page=%d', PMF_Link::getSystemRelativeUri(), $page);
Exemple #8
0
    header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$faqsession->userTracking('fulltext_search', 0);
// Get possible user input
$inputLanguage = PMF_Filter::filterInput(INPUT_GET, 'langs', FILTER_SANITIZE_STRING);
$inputCategory = PMF_Filter::filterInput(INPUT_GET, 'searchcategory', FILTER_VALIDATE_INT, '%');
$inputTag = PMF_Filter::filterInput(INPUT_GET, 'tagging_id', FILTER_VALIDATE_INT);
$inputSearchTerm = PMF_Filter::filterInput(INPUT_GET, 'suchbegriff', FILTER_SANITIZE_STRIPPED);
$search = PMF_Filter::filterInput(INPUT_GET, 'search', FILTER_SANITIZE_STRIPPED);
// Search only on current language (default)
$allLanguages = false;
if (!is_null($inputLanguage)) {
    $allLanguages = true;
}
$faqsearch = new PMF_Search();
$printResult = '';
$tagSearch = false;
$mostPopularSearches = 'n/a';
// to be implemented
//
// Handle the Tagging ID
//
if (!is_null($inputTag)) {
    $tagSearch = true;
    $tagging = new PMF_Tags();
    $record_ids = $tagging->getRecordsByTagId($inputTag);
    $printResult = $faq->showAllRecordsByIds($record_ids);
}
//
// Handle the full text search stuff
Exemple #9
0
    $current_user = $user->getUserId();
    if ($user->perm instanceof PMF_Perm_PermMedium) {
        $current_groups = $user->perm->getUserGroups($current_user);
    } else {
        $current_groups = array(-1);
    }
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $user = new PMF_User_CurrentUser();
    $current_user = -1;
    $current_groups = array(-1);
}
$faq = new PMF_Faq();
$faqSearch = new PMF_Search($db, $language);
$faqSearchResult = new PMF_Search_Resultset($user, $faq);
$categoryData = new PMF_Category_Tree_DataProvider_SingleQuery($LANGCODE);
$categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData)));
//
// Handle the search requests
//
if (!is_null($searchString)) {
    $faqSearch->setCategory($categoryId);
    $searchResult = $faqSearch->search($searchString, false);
    $faqSearchResult->reviewResultset($searchResult);
    $faqSearchHelper = PMF_Helper_Search::getInstance();
    $faqSearchHelper->setSearchterm($searchString);
    $faqSearchHelper->setCategoryLayout($categoryLayout);
    $faqSearchHelper->setPlurals($plr);
    print $faqSearchHelper->renderInstantResponseResult($faqSearchResult);
Exemple #10
0
        $mail->setFrom($questionData['email'], $questionData['username']);
        $mail->addTo($mainAdminEmail);
        // Let the category owner get a copy of the message
        if ($userEmail && $mainAdminEmail != $userEmail) {
            $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($db, $Language);
    $search_result = array();
    $counter = 0;
    foreach ($search_stuff as $word) {
        $tmp = $search->search($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();
             foreach ($items as $item) {
                 if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) {
                     echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'sticky');
                 }
             }
         }
     } else {
         echo $PMF_LANG['err_NotAuth'];
     }
     break;
     // search FAQs for suggestions
 // search FAQs for suggestions
 case 'search_records':
     if ($permission['editbt']) {
         $faq = new PMF_Faq($faqConfig);
         $faqSearch = new PMF_Search($faqConfig);
         $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig);
         $searchResult = '';
         $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED);
         if (!is_null($searchString)) {
             $searchResult = $faqSearch->search($searchString, false);
             $faqSearchResult->reviewResultset($searchResult);
             $searchHelper = new PMF_Helper_Search($faqConfig);
             $searchHelper->setSearchterm($searchString);
             echo $searchHelper->renderAdminSuggestionResult($faqSearchResult);
         }
     } else {
         echo $PMF_LANG['err_NotAuth'];
     }
     break;
     // delete FAQs
Exemple #12
0
$inputSearchTerm = PMF_Filter::filterInput(INPUT_GET, 'suchbegriff', FILTER_SANITIZE_STRIPPED);
$search = PMF_Filter::filterInput(INPUT_GET, 'search', FILTER_SANITIZE_STRIPPED);
// Search only on current language (default)
$allLanguages = false;
if (!is_null($inputLanguage)) {
    $allLanguages = true;
}
// HACK: (re)evaluate the Category object w/o passing the user language
//       so the result set of a Search will have the Category Path
//       for any of the multilanguage faq records and the Category list
//       on the left pane will not be affected
if ($allLanguages) {
    $category = new PMF_Category();
    $category->transform(0);
}
$faqsearch = new PMF_Search();
$inputSearchTerm = '';
$printResult = $PMF_LANG['help_search'];
$tagSearch = false;
$mostPopularSearches = 'n/a';
// to be implemented
//
// Handle the Tagging ID
//
if (!is_null($inputTag)) {
    $tagSearch = true;
    $tagging = new PMF_Tags();
    $record_ids = $tagging->getRecordsByTagId($inputTag);
    $printResult = $faq->showAllRecordsByIds($record_ids);
}
//
Exemple #13
0
// Handle actions
switch ($action) {
    case 'getVersion':
        $result = array('version' => $faqConfig->get('main.currentVersion'));
        break;
    case 'getApiVersion':
        $result = array('apiVersion' => (int) $faqConfig->get('main.currentApiVersion'));
        break;
    case 'getCount':
        $faq = new PMF_Faq($faqConfig);
        $result = array('faqCount' => $faq->getNumberOfRecords($language));
        break;
    case 'search':
        $faq = new PMF_Faq($faqConfig);
        $user = new PMF_User($faqConfig);
        $search = new PMF_Search($faqConfig);
        $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig);
        $searchString = PMF_Filter::filterInput(INPUT_GET, 'q', FILTER_SANITIZE_STRIPPED);
        $searchResults = $search->search($searchString, false);
        $url = $faqConfig->get('main.referenceURL') . '/index.php?action=artikel&cat=%d&id=%d&artlang=%s';
        $faqSearchResult->reviewResultset($searchResults);
        $result = array();
        foreach ($faqSearchResult->getResultset() as $data) {
            $data->answer = html_entity_decode(strip_tags($data->answer), ENT_COMPAT, 'utf-8');
            $data->answer = PMF_Utils::makeShorterText($data->answer, 12);
            $data->link = sprintf($url, $data->category_id, $data->id, $data->lang);
            $result[] = $data;
        }
        break;
    case 'getCategories':
        $category = new PMF_Category($faqConfig, $currentGroups, true);
Exemple #14
0
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2011-2014 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2011-08-24
 */
use Symfony\Component\HttpFoundation\JsonResponse;
if (!defined('IS_VALID_PHPMYFAQ')) {
    $protocol = 'http';
    if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') {
        $protocol = 'https';
    }
    header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
    exit;
}
$ajaxAction = PMF_Filter::filterInput(INPUT_GET, 'ajaxaction', FILTER_SANITIZE_STRING);
$searchTerm = PMF_Filter::filterInput(INPUT_GET, 'searchterm', FILTER_SANITIZE_STRING);
$search = new PMF_Search($faqConfig);
$response = new JsonResponse();
switch ($ajaxAction) {
    case 'delete_searchterm':
        $response->setData($search->deleteSearchTerm($searchTerm));
        break;
}
$response->send();