function hesk_kb_search($query)
{
    global $hesk_settings, $hesklang;
    define('HESK_NO_ROBOTS', 1);
    /* Print header */
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link']);
    $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 LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_categories` AS t2 ON t1.`catid` = t2.`id` ' . " WHERE t1.`type` IN ('0','1') AND MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "') LIMIT " . intval($hesk_settings['kb_search_limit']));
    $num = hesk_dbNumRows($res);
    ?>
	<p>&raquo; <b><?php 
    echo $hesklang['sr'];
    ?>
 (<?php 
    echo $num;
    ?>
)</b></p>

	<?php 
    if ($num == 0) {
        echo '<p><i>' . $hesklang['nosr'] . '</i></p>';
        hesk_show_kb_category(1, 1);
    } else {
        ?>

<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>
		<div align="center">
        <table border="0" cellspacing="1" cellpadding="3" width="100%">
        <?php 
        while ($article = hesk_dbFetchAssoc($res)) {
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $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>';
            } else {
                $rat = '';
            }
            echo '
				<tr>
				<td>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="../img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" /></td>
	                <td valign="top"><a href="knowledgebase_private.php?article=' . $article['id'] . '">' . $article['subject'] . '</a></td>
	                ' . $rat . '
                    </tr>
	                </table>
	                <table border="0" width="100%" cellspacing="0" cellpadding="1">
	                <tr>
	                <td width="1" valign="top"><img src="../img/blank.gif" width="16" height="10" style="vertical-align:middle" alt="" /></td>
	                <td><span class="article_list">' . $txt . '</span></td>
                    </tr>
	                </table>

	            </td>
				</tr>';
        }
        ?>
    	</table>
        </div>
	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>

    <p>&nbsp;<br />&laquo; <a href="javascript:history.go(-1)"><?php 
        echo $hesklang['back'];
        ?>
</a></p>
    <?php 
    }
    // END else
}
示例#2
0
function hesk_kb_search($query)
{
    global $hesk_settings, $hesklang;
    define('HESK_NO_ROBOTS', 1);
    /* Print header */
    $hesk_settings['tmp_title'] = $hesklang['sr'] . ': ' . substr(hesk_htmlspecialchars(stripslashes($query)), 0, 20);
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link']);
    $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
    					LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id`\n\t\t\t\t\t\tWHERE t1.`type`='0' AND t2.`type`='0' AND  MATCH(`subject`,`content`,`keywords`) AGAINST ('" . hesk_dbEscape($query) . "') LIMIT " . intval($hesk_settings['kb_search_limit']));
    $num = hesk_dbNumRows($res);
    ?>
	<div class="container serach_result_kb"><b><?php 
    echo $hesklang['sr'];
    ?>
 (<?php 
    echo $num;
    ?>
)</b></div>

	<?php 
    if ($num == 0) {
        echo '<div class="container"><i>' . $hesklang['nosr'] . '</i></div>
        ';
        hesk_show_kb_category(1, 1);
    } else {
        ?>

<div class="serach_result_kb_table">
        <?php 
        while ($article = hesk_dbFetchAssoc($res)) {
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $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>';
            } else {
                $rat = '';
            }
            echo '
				<div id="content-kb">
	                <div class="form-inline">
	                <span class="col-sm-10"><img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" />
					<a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a></span>' . '<span>' . $rat . '</span>
	                </div>
	                <div class="form-inline">
	                <span class="col-sm-10"><img src="img/blank.gif" width="16" height="10" style="vertical-align:middle" alt="" /></span>
	                <span class="article_list">' . $txt . '</span>
	                </div><br/>
				</div>';
        }
        ?>
</div>

    <div class="container"><a href="javascript:history.go(-1)"><button type="submit" class="btn btn-default goback-btn"><?php 
        echo $hesklang['back'];
        ?>
</button></a></div>
    <?php 
    }
    // END else
}