Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

knowledgebase.php 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. // Connect to database
  19. hesk_load_database_functions();
  20. hesk_dbConnect();
  21. // Are we in maintenance mode?
  22. hesk_check_maintenance();
  23. define('PAGE_TITLE', 'CUSTOMER_KB');
  24. // Is Knowledgebase enabled?
  25. if (!$hesk_settings['kb_enable']) {
  26. hesk_error($hesklang['kbdis']);
  27. }
  28. // Do we have any public articles at all?
  29. $res = hesk_dbQuery("SELECT `t1`.`id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
  30. LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
  31. WHERE `t1`.`type`='0' AND `t2`.`type`='0' LIMIT 1");
  32. // If yes, load KB functions; if not, disable and hide the KB
  33. if (hesk_dbNumRows($res) < 1) {
  34. hesk_error($hesklang['noa']);
  35. }
  36. // Load KB functions
  37. require(HESK_PATH . 'inc/knowledgebase_functions.inc.php');
  38. /* Rating? */
  39. if (isset($_GET['rating'])) {
  40. // Detect and block robots
  41. if (hesk_detect_bots()) {
  42. ?>
  43. <html>
  44. <head>
  45. <meta name="robots" content="noindex, nofollow">
  46. </head>
  47. <body>
  48. </body>
  49. </html>
  50. <?php
  51. }
  52. // Rating
  53. $rating = intval(hesk_GET('rating'));
  54. // Rating value may only be 1 or 5
  55. if ($rating != 1 && $rating != 5) {
  56. die($hesklang['attempt']);
  57. }
  58. // Article ID
  59. $artid = intval(hesk_GET('id', 0)) or die($hesklang['kb_art_id']);
  60. // Check cookies for already rated, rate and set cookie if not already
  61. $_COOKIE['hesk_kb_rate'] = hesk_COOKIE('hesk_kb_rate');
  62. if (strpos($_COOKIE['hesk_kb_rate'], 'a' . $artid . '%') === false) {
  63. // Update rating, make sure it's a public article in a public category
  64. hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` AS `t1`
  65. LEFT JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS `t2` ON t1.`catid` = t2.`id`
  66. SET `rating`=((`rating`*`votes`)+{$rating})/(`votes`+1), t1.`votes`=t1.`votes`+1
  67. WHERE t1.`id`='{$artid}' AND t1.`type`='0' AND t2.`type`='0'
  68. ");
  69. }
  70. hesk_setcookie('hesk_kb_rate', $_COOKIE['hesk_kb_rate'] . 'a' . $artid . '%', time() + 2592000);
  71. header('Location: knowledgebase.php?article=' . $artid . '&rated=1');
  72. exit();
  73. }
  74. /* Any category ID set? */
  75. $catid = intval(hesk_GET('category', 1));
  76. $artid = intval(hesk_GET('article', 0));
  77. if (isset($_GET['search'])) {
  78. $query = hesk_input(hesk_GET('search'));
  79. } else {
  80. $query = 0;
  81. }
  82. $hesk_settings['kb_link'] = ($artid || $catid != 1 || $query) ? '<a href="knowledgebase.php" class="smaller">' . $hesklang['kb_text'] . '</a>' : $hesklang['kb_text'];
  83. if ($hesk_settings['kb_search'] && $query) {
  84. hesk_kb_search($query);
  85. } elseif ($artid) {
  86. // Get article from DB, make sure that article and category are public
  87. $result = hesk_dbQuery("SELECT t1.*, t2.`name` AS `cat_name`
  88. FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` AS `t1`
  89. LEFT JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
  90. WHERE `t1`.`id` = '{$artid}'
  91. AND `t1`.`type` = '0'
  92. AND `t2`.`type` = '0'
  93. ");
  94. $article = hesk_dbFetchAssoc($result) or hesk_error($hesklang['kb_art_id']);
  95. hesk_show_kb_article($artid);
  96. } else {
  97. hesk_show_kb_category($catid);
  98. }
  99. echo '</div>';
  100. require_once(HESK_PATH . 'inc/footer.inc.php');
  101. exit();
  102. /*** START FUNCTIONS ***/
  103. function hesk_kb_header($kb_link) {
  104. global $hesk_settings, $hesklang;
  105. ?>
  106. <ol class="breadcrumb">
  107. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  108. <li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
  109. <li class="active"><?php echo $hesklang['kb_text']; ?></li>
  110. </ol>
  111. <?php
  112. $columnWidth = 'col-md-8';
  113. $showRs = hesk_dbQuery("SELECT `show` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` WHERE `id` = 4");
  114. $show = hesk_dbFetchAssoc($showRs);
  115. if (!$show['show']) {
  116. $columnWidth = 'col-md-10 col-md-offset-1';
  117. }
  118. ?>
  119. <div class="row">
  120. <?php if ($columnWidth == 'col-md-8'): ?>
  121. <div class="col-md-4">
  122. <div class="panel panel-default">
  123. <div class="panel-heading">
  124. <?php echo $hesklang['quick_help']; ?>
  125. </div>
  126. <div class="panel-body">
  127. <p style="text-align: justify;"><?php echo $hesklang['kb_is']; ?></p>
  128. </div>
  129. </div>
  130. </div>
  131. <?php endif; ?>
  132. <div class="<?php echo $columnWidth; ?>">
  133. <?php
  134. /* Print small search box */
  135. hesk_kbSearchSmall();
  136. /* Print large search box */
  137. hesk_kbSearchLarge();
  138. } // END hesk_kb_header()
  139. function hesk_kb_search($query)
  140. {
  141. global $hesk_settings, $hesklang;
  142. define('HESK_NO_ROBOTS', 1);
  143. /* Print header */
  144. $hesk_settings['tmp_title'] = $hesklang['sr'] . ': ' . substr(hesk_htmlspecialchars(stripslashes($query)), 0, 20);
  145. require_once(HESK_PATH . 'inc/header.inc.php');
  146. hesk_kb_header($hesk_settings['kb_link']);
  147. $res = hesk_dbQuery('SELECT t1.`id`, t1.`subject`, LEFT(`t1`.`content`, ' . max(200, $hesk_settings['kb_substrart'] * 2) . ') AS `content`, t1.`rating` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1
  148. LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id`
  149. WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "') LIMIT " . intval($hesk_settings['kb_search_limit']));
  150. $num = hesk_dbNumRows($res);
  151. ?>
  152. <h4><?php echo $hesklang['sr']; ?> (<?php echo $num; ?>)</h4>
  153. <div class="footerWithBorder blankSpace"></div>
  154. <?php
  155. if ($num == 0) {
  156. echo '<p><i>' . $hesklang['nosr'] . '</i></p>
  157. <p>&nbsp;</p>
  158. ';
  159. hesk_show_kb_category(1, 1);
  160. } else {
  161. ?>
  162. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  163. <tr>
  164. <td class="roundcornersleft">&nbsp;</td>
  165. <td>
  166. <div align="center">
  167. <table border="0" cellspacing="1" cellpadding="3" width="100%">
  168. <?php
  169. while ($article = hesk_dbFetchAssoc($res)) {
  170. $txt = hesk_kbArticleContentPreview($article['content']);
  171. if ($hesk_settings['kb_rating']) {
  172. $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
  173. $rat = '<td width="1" valign="top"><img src="img/star_' . (hesk_round_to_half($article['rating']) * 10) . '.png" width="85" height="16" alt="' . $alt . '" border="0" style="vertical-align:text-bottom" /></td>';
  174. } else {
  175. $rat = '';
  176. }
  177. echo '
  178. <tr>
  179. <td>
  180. <table border="0" width="100%" cellspacing="0" cellpadding="1">
  181. <tr>
  182. <td width="1" valign="top"><span class="glyphicon glyphicon-file"></span></td>
  183. <td valign="top"><a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a></td>
  184. ' . $rat . '
  185. </tr>
  186. </table>
  187. <table border="0" width="100%" cellspacing="0" cellpadding="1">
  188. <tr>
  189. <td width="1" valign="top"><img src="img/blank.gif" width="16" height="10" style="vertical-align:middle" alt="" /></td>
  190. <td><span class="article_list">' . $txt . '</span></td>
  191. </tr>
  192. </table>
  193. </td>
  194. </tr>';
  195. }
  196. ?>
  197. </table>
  198. </div>
  199. </td>
  200. </tr>
  201. </table>
  202. <p>&nbsp;<br/>&laquo; <a href="javascript:history.go(-1)"><?php echo $hesklang['back']; ?></a></p>
  203. <?php
  204. } // END else
  205. } // END hesk_kb_search()
  206. function hesk_show_kb_article($artid)
  207. {
  208. global $hesk_settings, $hesklang, $article;
  209. // Print header
  210. $hesk_settings['tmp_title'] = $article['subject'];
  211. require_once(HESK_PATH . 'inc/header.inc.php');
  212. hesk_kb_header($hesk_settings['kb_link']);
  213. // Update views by 1 - exclude known bots and reloads because of ratings
  214. if (!isset($_GET['rated']) && !hesk_detect_bots()) {
  215. hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid}");
  216. }
  217. if (!isset($_GET['suggest'])) {
  218. $historyNumber = isset($_GET['rated']) ? '-2' : '-1';
  219. $goBackText = '<a href="javascript:history.go(' . $historyNumber . ')">
  220. <i class="fa fa-arrow-circle-left" data-toggle="tooltip" data-placement="top" title="' . $hesklang['back'] . '"></i></a>';
  221. } else {
  222. $goBackText = '';
  223. }
  224. echo '<h3 class="text-left">' . $goBackText . '&nbsp;' . $article['subject'] . '</h3>
  225. <div class="footerWithBorder blankSpace"></div>
  226. <h4 class="text-left">' . $hesklang['as'] . '</h4>
  227. <div class="kbContent">'
  228. . $article['content'] . '</div>';
  229. if (!empty($article['attachments'])) {
  230. echo '<p><b>' . $hesklang['attachments'] . ':</b><br />';
  231. $att = explode(',', substr($article['attachments'], 0, -1));
  232. foreach ($att as $myatt) {
  233. list($att_id, $att_name) = explode('#', $myatt);
  234. echo '<img src="img/clip.png" width="16" height="16" alt="' . $att_name . '" style="align:text-bottom" /> <a href="download_attachment.php?kb_att=' . $att_id . '" rel="nofollow">' . $att_name . '</a><br />';
  235. }
  236. echo '</p>';
  237. }
  238. // Article rating
  239. if ($hesk_settings['kb_rating'] && strpos(hesk_COOKIE('hesk_kb_rate'), 'a' . $artid . '%') === false) {
  240. echo '
  241. <div id="rating" class="rate" align="right">&nbsp;<br />' . $hesklang['rart'] . '
  242. <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=5&amp;id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['yes']) . '</a> /
  243. <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=1&amp;id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['no']) . '</a>
  244. </div>
  245. ';
  246. }
  247. // Related articles
  248. if ($hesk_settings['kb_related']) {
  249. $showRelated = false;
  250. $column = 'col-md-12';
  251. require(HESK_PATH . 'inc/mail/email_parser.php');
  252. $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content']));
  253. // Get relevant articles from the database
  254. $res = hesk_dbQuery("SELECT t1.`id`, t1.`subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1 LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id` WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT " . intval($hesk_settings['kb_related'] + 1));
  255. // Array with related articles
  256. $related_articles = array();
  257. while ($related = hesk_dbFetchAssoc($res)) {
  258. // Get base match score from the first article
  259. if (!isset($base_score)) {
  260. $base_score = $related['score'];
  261. }
  262. // Ignore this article
  263. if ($related['id'] == $artid) {
  264. continue;
  265. }
  266. // Stop when articles reach less than 10% of base score
  267. if ($related['score'] / $base_score < 0.10) {
  268. break;
  269. }
  270. // This is a valid related article
  271. $related_articles[$related['id']] = $related['subject'];
  272. }
  273. // Print related articles if we have any valid matches
  274. if (count($related_articles)) {
  275. $column = 'col-md-6';
  276. $showRelated = true;
  277. }
  278. }
  279. if ($article['catid'] == 1) {
  280. $link = 'knowledgebase.php';
  281. } else {
  282. $link = 'knowledgebase.php?category=' . $article['catid'];
  283. }
  284. ?>
  285. <div class="row">
  286. <div class="<?php echo $column; ?> col-sm-12">
  287. <h4 class="text-left"><?php echo $hesklang['ad']; ?></h4>
  288. <div class="text-left">
  289. <p><?php echo $hesklang['aid']; ?>: <?php echo $article['id']; ?></p>
  290. <p><?php echo $hesklang['category']; ?>: <a
  291. href="<?php echo $link; ?>"><?php echo $article['cat_name']; ?></a></p>
  292. <?php
  293. if ($hesk_settings['kb_date']) {
  294. ?>
  295. <p><?php echo $hesklang['dta']; ?>: <?php echo hesk_date($article['dt'], true); ?></p>
  296. <?php
  297. }
  298. if ($hesk_settings['kb_views']) {
  299. ?>
  300. <p><?php echo $hesklang['views']; ?>
  301. : <?php echo(isset($_GET['rated']) ? $article['views'] : $article['views'] + 1); ?></p>
  302. <?php
  303. }
  304. if ($hesk_settings['kb_rating']) {
  305. $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
  306. echo '
  307. <p>' . $hesklang['rating'] . ' (' . $hesklang['votes'] . '): <img src="img/star_' . (hesk_round_to_half($article['rating']) * 10) . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /> (' . $article['votes'] . ')</p>
  308. ';
  309. }
  310. ?>
  311. </div>
  312. </div>
  313. <?php if ($showRelated) { ?>
  314. <div class="col-md-6 col-sm-12">
  315. <h4 class="text-left"><?php echo $hesklang['relart']; ?></h4>
  316. <div class="text-left">
  317. <?php
  318. foreach ($related_articles as $id => $subject) {
  319. echo '<span class="glyphicon glyphicon-file icon-link"></span> <a href="knowledgebase.php?article=' . $id . '">' . $subject . '</a><br />';
  320. }
  321. ?>
  322. </div>
  323. </div>
  324. <?php } ?>
  325. </div>
  326. <?php
  327. hesk_kbFooter();
  328. } // END hesk_show_kb_article()
  329. function hesk_show_kb_category($catid, $is_search = 0)
  330. {
  331. global $hesk_settings, $hesklang;
  332. $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
  333. $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
  334. if ($is_search == 0) {
  335. /* Print header */
  336. $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
  337. require_once(HESK_PATH . 'inc/header.inc.php');
  338. hesk_kb_header($hesk_settings['kb_link']);
  339. }
  340. // If we are in "Knowledgebase only" mode show system messages
  341. if ($catid == 1 && hesk_check_kb_only(false)) {
  342. // Service messages
  343. $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
  344. while ($sm = hesk_dbFetchAssoc($res)) {
  345. hesk_service_message($sm);
  346. }
  347. }
  348. if ($thiscat['parent']) {
  349. $link = ($thiscat['parent'] == 1) ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
  350. echo '<h3 class="text-left"><a href="javascript:history.go(-1)"><i class="fa fa-arrow-circle-left" data-toggle="tooltip" data-placement="top" title="' . $hesklang['back'] . '"></i></a>&nbsp;' . $hesklang['kb_cat'] . ': ' . $thiscat['name'] . ' </h3>
  351. <div class="footerWithBorder blankSpace"></div>
  352. <div class="blankSpace"></div>
  353. ';
  354. }
  355. $result = hesk_dbQuery("SELECT `id`,`name`,`articles` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `parent`='{$catid}' AND `type`='0' ORDER BY `cat_order` ASC");
  356. if (hesk_dbNumRows($result) > 0) {
  357. ?>
  358. <div class="panel panel-default">
  359. <div class="panel-heading">
  360. <h4 class="text-left"><?php echo $hesklang['kb_cat_sub']; ?></h4>
  361. </div>
  362. <table class="table table-striped">
  363. <?php
  364. $per_col = $hesk_settings['kb_cols'];
  365. $i = 1;
  366. while ($cat = hesk_dbFetchAssoc($result)) {
  367. if ($i == 1) {
  368. echo '<tr>';
  369. }
  370. echo '
  371. <td width="50%" valign="top">
  372. <table border="0">
  373. <tr><td><i class="fa fa-folder"></i>&nbsp;<a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></td></tr>
  374. ';
  375. /* Print most popular/sticky articles */
  376. if ($hesk_settings['kb_numshow'] && $cat['articles']) {
  377. $res = hesk_dbQuery("SELECT `id`,`subject`, `sticky` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$cat['id']}' AND `type`='0' ORDER BY `sticky` DESC, `views` DESC, `art_order` ASC LIMIT " . (intval($hesk_settings['kb_numshow']) + 1));
  378. $num = 1;
  379. while ($art = hesk_dbFetchAssoc($res)) {
  380. $icon = 'glyphicon glyphicon-file';
  381. $style = '';
  382. if ($art['sticky']) {
  383. $icon = 'glyphicon glyphicon-pushpin';
  384. $style = 'style="color: #FF0000"';
  385. }
  386. echo '
  387. <tr>
  388. <td ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="' . $icon . '"></span>
  389. <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a></td>
  390. </tr>';
  391. if ($num == $hesk_settings['kb_numshow']) {
  392. break;
  393. } else {
  394. $num++;
  395. }
  396. }
  397. if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
  398. echo '<tr><td>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></td></tr>';
  399. }
  400. }
  401. echo '
  402. </table>
  403. </td>
  404. ';
  405. if ($i == $per_col) {
  406. echo '</tr>';
  407. $i = 0;
  408. }
  409. $i++;
  410. }
  411. /* Finish the table if needed */
  412. if ($i != 1) {
  413. for ($j = 1; $j <= $per_col; $j++) {
  414. echo '<td width="50%">&nbsp;</td>';
  415. if ($i == $per_col) {
  416. echo '</tr>';
  417. break;
  418. }
  419. $i++;
  420. }
  421. }
  422. ?>
  423. </table>
  424. </div>
  425. <?php
  426. } // END if NumRows > 0
  427. ?>
  428. <div class="panel panel-default">
  429. <div class="panel-heading">
  430. <h4 class="text-left"><?php echo $hesklang['ac_no_colon']; ?></h4>
  431. </div>
  432. <table class="table table-striped">
  433. <tbody>
  434. <?php
  435. $res = hesk_dbQuery("SELECT `id`, `subject`, `sticky`, LEFT(`content`, " . max(200, $hesk_settings['kb_substrart'] * 2) . ") AS `content`, `rating` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
  436. if (hesk_dbNumRows($res) == 0) {
  437. echo '<tr><td><i>' . $hesklang['noac'] . '</i></td></tr>';
  438. } else {
  439. while ($article = hesk_dbFetchAssoc($res)) {
  440. $icon = 'fa fa-file';
  441. $color = '';
  442. $style = '';
  443. $txt = hesk_kbArticleContentPreview($article['content']);
  444. if ($article['sticky']) {
  445. $icon = 'glyphicon glyphicon-pushpin';
  446. $style = 'style="color: #FF0000"';
  447. }
  448. if ($hesk_settings['kb_rating']) {
  449. $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
  450. $rat = '<td><img src="img/star_' . (hesk_round_to_half($article['rating']) * 10) . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /></td>';
  451. } else {
  452. $rat = '';
  453. }
  454. echo '
  455. <tr>
  456. <td>
  457. <i class="' . $icon . '" ' . $style . '></i>
  458. <a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a>
  459. <br>
  460. <span class="indent-15">' . $txt . '</span>
  461. </td>
  462. ' . $rat . '
  463. </tr>';
  464. }
  465. }
  466. ?>
  467. </tbody>
  468. </table>
  469. </div>
  470. <?php
  471. /* On the main KB page print out top and latest articles if needed */
  472. if ($catid == 1) {
  473. /* Get list of top articles */
  474. hesk_kbTopArticles($hesk_settings['kb_popart'], 0);
  475. /* Get list of latest articles */
  476. hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
  477. }
  478. hesk_kbFooter();
  479. } // END hesk_show_kb_category()
  480. function hesk_kbFooter()
  481. {
  482. global $hesk_settings;
  483. $showRs = hesk_dbQuery("SELECT `show` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` WHERE `id` = 4");
  484. $show = hesk_dbFetchAssoc($showRs);
  485. if (!$show['show']) {
  486. echo '<div class="col-md-1">&nbsp;</div></div>';
  487. }
  488. }
  489. ?>