Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

suggest_articles.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. *
  4. * This file is part of HESK - PHP Help Desk Software.
  5. *
  6. * (c) Copyright Klemen Stirn. All rights reserved.
  7. * https://www.hesk.com
  8. *
  9. * For the full copyright and license agreement information visit
  10. * https://www.hesk.com/eula.php
  11. *
  12. */
  13. define('IN_SCRIPT', 1);
  14. define('HESK_PATH', './');
  15. /* Get all the required files and functions */
  16. require(HESK_PATH . 'hesk_settings.inc.php');
  17. require(HESK_PATH . 'inc/common.inc.php');
  18. hesk_load_database_functions();
  19. /* Print XML header */
  20. header('Content-Type: text/html; charset=' . $hesklang['ENCODING']);
  21. /* Get the search query composed of the subject and message */
  22. $query = strip_tags(html_entity_decode(hesk_REQUEST('q'))) or die('');
  23. hesk_dbConnect();
  24. /* Get relevant articles from the database */
  25. $res = hesk_dbQuery("SELECT t1.`id`, t1.`subject`, LEFT(t1.`content`, " . max(200, $hesk_settings['kb_substrart'] * 2) . ") AS `content`, MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "') AS `score`
  26. FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1
  27. LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id`
  28. WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "')
  29. LIMIT " . intval($hesk_settings['kb_search_limit']));
  30. $num = hesk_dbNumRows($res);
  31. /* Solve some spacing issues */
  32. if (hesk_isREQUEST('p')) {
  33. echo '&nbsp;<br />';
  34. }
  35. /* Return found articles */
  36. ?>
  37. <div class="alert alert-info">
  38. <span style="font-size:12px;font-weight:bold"><?php echo $hesklang['sc']; ?>:</span><br/>&nbsp;<br/>
  39. <?php
  40. if (!$num) {
  41. echo '<i>' . $hesklang['nsfo'] . '</i>';
  42. } else {
  43. $max_score = 0;
  44. while ($article = hesk_dbFetchAssoc($res)) {
  45. if ($article['score'] > $max_score) {
  46. $max_score = $article['score'];
  47. }
  48. if ($max_score && ($article['score'] / $max_score) < 0.25) {
  49. break;
  50. }
  51. $txt = strip_tags($article['content']);
  52. if (strlen($txt) > $hesk_settings['kb_substrart']) {
  53. $txt = substr($txt, 0, $hesk_settings['kb_substrart']) . '...';
  54. }
  55. echo '
  56. <a href="knowledgebase.php?article=' . $article['id'] . '&amp;suggest=1" target="_blank">' . $article['subject'] . '</a>
  57. <input type="hidden" name="suggested[]" value="' . $article['id'] . '|' . stripslashes(hesk_input($article['subject'])) . '">
  58. <br />' . $txt . '<br /><br />';
  59. }
  60. }
  61. ?>
  62. </div>