function hesk_show_kb_article($artid) { global $hesk_settings, $hesklang, $article; // Print header $hesk_settings['tmp_title'] = $article['subject']; require_once HESK_PATH . 'inc/header.inc.php'; hesk_kb_header($hesk_settings['kb_link']); // Update views by 1 - exclude known bots and reloads because of ratings if (!isset($_GET['rated']) && !hesk_detect_bots()) { hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1"); } echo '<h1>' . $article['subject'] . '</h1> <fieldset> <legend>' . $hesklang['as'] . '</legend> ' . $article['content']; if (!empty($article['attachments'])) { echo '<p><b>' . $hesklang['attachments'] . ':</b><br />'; $att = explode(',', substr($article['attachments'], 0, -1)); foreach ($att as $myatt) { list($att_id, $att_name) = explode('#', $myatt); 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 />'; } echo '</p>'; } // Article rating if ($hesk_settings['kb_rating'] && strpos(hesk_COOKIE('hesk_kb_rate'), 'a' . $artid . '%') === false) { echo ' <div id="rating" class="rate" align="right"> <br />' . $hesklang['rart'] . ' <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=5&id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['yes']) . '</a> / <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=1&id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['no']) . '</a> </div> '; } echo '</fieldset>'; // Related articles if ($hesk_settings['kb_related']) { require HESK_PATH . 'inc/mail/email_parser.php'; $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content'])); // Get relevant articles from the database $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)); // Array with related articles $related_articles = array(); while ($related = hesk_dbFetchAssoc($res)) { // Get base match score from the first article if (!isset($base_score)) { $base_score = $related['score']; } // Ignore this article if ($related['id'] == $artid) { continue; } // Stop when articles reach less than 10% of base score if ($related['score'] / $base_score < 0.1) { break; } // This is a valid related article $related_articles[$related['id']] = $related['subject']; } // Print related articles if we have any valid matches if (count($related_articles)) { echo '<fieldset><legend>' . $hesklang['relart'] . '</legend>'; foreach ($related_articles as $id => $subject) { echo '<img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle;padding:2px;" /> <a href="knowledgebase.php?article=' . $id . '">' . $subject . '</a><br />'; } echo '</fieldset>'; } } if ($article['catid'] == 1) { $link = 'knowledgebase.php'; } else { $link = 'knowledgebase.php?category=' . $article['catid']; } ?> <fieldset> <legend><?php echo $hesklang['ad']; ?> </legend> <table border="0"> <tr> <td><?php echo $hesklang['aid']; ?> : </td> <td><?php echo $article['id']; ?> </td> </tr> <tr> <td><?php echo $hesklang['category']; ?> : </td> <td><a href="<?php echo $link; ?> "><?php echo $article['cat_name']; ?> </a></td> </tr> <?php if ($hesk_settings['kb_date']) { ?> <tr> <td><?php echo $hesklang['dta']; ?> : </td> <td><?php echo hesk_date($article['dt'], true); ?> </td> </tr> <?php } if ($hesk_settings['kb_views']) { ?> <tr> <td><?php echo $hesklang['views']; ?> : </td> <td><?php echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1; ?> </td> </tr> <?php } if ($hesk_settings['kb_rating']) { $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated']; echo ' <tr> <td>' . $hesklang['rating'] . ' (' . $hesklang['votes'] . '):</td> <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" /> (' . $article['votes'] . ')</td> </tr> '; } ?> </table> </fieldset> <?php if (!isset($_GET['suggest'])) { ?> <p> <br />« <a href="javascript:history.go(<?php echo isset($_GET['rated']) ? '-2' : '-1'; ?> )"><?php echo $hesklang['back']; ?> </a></p> <?php } else { ?> <p> </p> <?php } }
function hesk_show_kb_article($artid) { global $hesk_settings, $hesklang, $article; // Print header $hesk_settings['tmp_title'] = $article['subject']; require_once HESK_PATH . 'inc/header.inc.php'; hesk_kb_header($hesk_settings['kb_link']); // Update views by 1 - exclude known bots and reloads because of ratings if (!isset($_GET['rated']) && !hesk_detect_bots()) { hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`='" . intval($artid) . "' LIMIT 1"); } echo '<h1>' . $article['subject'] . '</h1> <fieldset> <legend>' . $hesklang['as'] . '</legend> ' . $article['content']; if (!empty($article['attachments'])) { echo '<p><b>' . $hesklang['attachments'] . ':</b><br />'; $att = explode(',', substr($article['attachments'], 0, -1)); foreach ($att as $myatt) { list($att_id, $att_name) = explode('#', $myatt); 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 />'; } echo '</p>'; } if ($hesk_settings['kb_rating'] && strpos(hesk_COOKIE('hesk_kb_rate'), 'a' . $artid . '%') === false) { echo ' <div id="rating" class="rate" align="right"> <br />' . $hesklang['rart'] . ' <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=5&id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['yes']) . '</a> / <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=1&id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['no']) . '</a> </div> '; } echo '</fieldset>'; if ($article['catid'] == 1) { $link = 'knowledgebase.php'; } else { $link = 'knowledgebase.php?category=' . $article['catid']; } ?> <fieldset> <legend><?php echo $hesklang['ad']; ?> </legend> <table border="0"> <tr> <td><?php echo $hesklang['aid']; ?> : </td> <td><?php echo $article['id']; ?> </td> </tr> <tr> <td><?php echo $hesklang['category']; ?> : </td> <td><a href="<?php echo $link; ?> "><?php echo $article['cat_name']; ?> </a></td> </tr> <?php if ($hesk_settings['kb_date']) { ?> <tr> <td><?php echo $hesklang['dta']; ?> : </td> <td><?php echo hesk_date($article['dt']); ?> </td> </tr> <?php } if ($hesk_settings['kb_views']) { ?> <tr> <td><?php echo $hesklang['views']; ?> : </td> <td><?php echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1; ?> </td> </tr> <?php } if ($hesk_settings['kb_rating']) { $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated']; echo ' <tr> <td>' . $hesklang['rating'] . ' (' . $hesklang['votes'] . '):</td> <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" /> (' . $article['votes'] . ')</td> </tr> '; } ?> </table> </fieldset> <?php if (!isset($_GET['suggest'])) { ?> <p> <br />« <a href="javascript:history.go(<?php echo isset($_GET['rated']) ? '-2' : '-1'; ?> )"><?php echo $hesklang['back']; ?> </a></p> <?php } else { ?> <p> </p> <?php } }