Example #1
0
*  Removing any of the copyright notices without purchasing a license
*  is expressly forbidden. To remove HESK copyright notice you must purchase
*  a license for this script. For more information on how to obtain
*  a license please visit the page below:
*  https://www.hesk.com/buy.php
*******************************************************************************/
define('IN_SCRIPT', 1);
define('HESK_PATH', './');
// Get all the required files and functions
require HESK_PATH . 'hesk_settings.inc.php';
require HESK_PATH . 'inc/common.inc.php';
// Are we in maintenance mode?
hesk_check_maintenance();
// Are we in "Knowledgebase only" mode?
hesk_check_kb_only();
// What should we do?
$action = hesk_REQUEST('a');
switch ($action) {
    case 'add':
        hesk_session_start();
        print_add_ticket();
        break;
    case 'forgot_tid':
        hesk_session_start();
        forgot_tid();
        break;
    default:
        print_start();
}
// Print footer
		}*/
if (hesk_checkPermission('can_man_settings', 0)) {
    echo '
						<a href="admin_settings.php"><button type="submit" class="btn btn-default ico-button" id="ico-button-settings"><label id="menu-settings">' . $hesklang['settings'] . '</label></button></a>
						';
}
?>
				
				<a href="index.php?a=logout&amp;token=<?php 
echo hesk_token_echo();
?>
"><button type="submit" class="btn btn-default ico-button" id="ico-button-logout"><label id="menu-logout"><?php 
echo $hesklang['logout'];
?>
</label></button></a>
			</div>
		</div><!-- end menu-links-header -->
    <!-- END MENU LINKS -->


<?php 
// Show a notice if we are in maintenance mode
if (hesk_check_maintenance(false)) {
    echo '<br />';
    hesk_show_notice($hesklang['mma2'], $hesklang['mma1'], false);
}
// Show a notice if we are in "Knowledgebase only" mode
if (hesk_check_kb_only(false)) {
    echo '<br />';
    hesk_show_notice($hesklang['kbo2'], $hesklang['kbo1'], false);
}
Example #3
0
function hesk_show_kb_category($catid, $is_search = 0)
{
    global $hesk_settings, $hesklang;
    $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
    $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
    if ($is_search == 0) {
        /* Print header */
        $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
        require_once HESK_PATH . 'inc/header.inc.php';
        hesk_kb_header($hesk_settings['kb_link']);
    }
    // If we are in "Knowledgebase only" mode show system messages
    if ($catid == 1 && hesk_check_kb_only(false)) {
        // Service messages
        $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
        while ($sm = hesk_dbFetchAssoc($res)) {
            hesk_service_message($sm);
        }
    }
    if ($thiscat['parent']) {
        $link = $thiscat['parent'] == 1 ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
        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>
        <div class="footerWithBorder blankSpace"></div>
        <div class="blankSpace"></div>
		';
    }
    $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");
    if (hesk_dbNumRows($result) > 0) {
        ?>

        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="text-left"><?php 
        echo $hesklang['kb_cat_sub'];
        ?>
</h4>
            </div>
            <table class="table table-striped">

                <?php 
        $per_col = $hesk_settings['kb_cols'];
        $i = 1;
        while ($cat = hesk_dbFetchAssoc($result)) {
            if ($i == 1) {
                echo '<tr>';
            }
            echo '
                    <td width="50%" valign="top">
                    <table border="0">
                    <tr><td><i class="fa fa-folder"></i>&nbsp;<a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></td></tr>
                    ';
            /* Print most popular/sticky articles */
            if ($hesk_settings['kb_numshow'] && $cat['articles']) {
                $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));
                $num = 1;
                while ($art = hesk_dbFetchAssoc($res)) {
                    $icon = 'glyphicon glyphicon-file';
                    $style = '';
                    if ($art['sticky']) {
                        $icon = 'glyphicon glyphicon-pushpin';
                        $style = 'style="color: #FF0000"';
                    }
                    echo '
                            <tr>
                            <td ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="' . $icon . '"></span>
                            <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a></td>
                            </tr>';
                    if ($num == $hesk_settings['kb_numshow']) {
                        break;
                    } else {
                        $num++;
                    }
                }
                if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
                    echo '<tr><td>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></td></tr>';
                }
            }
            echo '
			</table>
		    </td>
			';
            if ($i == $per_col) {
                echo '</tr>';
                $i = 0;
            }
            $i++;
        }
        /* Finish the table if needed */
        if ($i != 1) {
            for ($j = 1; $j <= $per_col; $j++) {
                echo '<td width="50%">&nbsp;</td>';
                if ($i == $per_col) {
                    echo '</tr>';
                    break;
                }
                $i++;
            }
        }
        ?>
            </table>
        </div>

	<?php 
    }
    // END if NumRows > 0
    ?>

    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="text-left"><?php 
    echo $hesklang['ac_no_colon'];
    ?>
</h4>
        </div>
        <table class="table table-striped">
            <tbody>
            <?php 
    $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");
    if (hesk_dbNumRows($res) == 0) {
        echo '<tr><td><i>' . $hesklang['noac'] . '</i></td></tr>';
    } else {
        while ($article = hesk_dbFetchAssoc($res)) {
            $icon = 'fa fa-file';
            $color = '';
            $style = '';
            $txt = hesk_kbArticleContentPreview($article['content']);
            if ($article['sticky']) {
                $icon = 'glyphicon glyphicon-pushpin';
                $style = 'style="color: #FF0000"';
            }
            if ($hesk_settings['kb_rating']) {
                $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
                $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>';
            } else {
                $rat = '';
            }
            echo '
                        <tr>
                            <td>
                                <i class="' . $icon . '" ' . $style . '></i>
                                <a href="knowledgebase.php?article=' . $article['id'] . '">' . $article['subject'] . '</a>
                                <br>
                                <span class="indent-15">' . $txt . '</span>
                            </td>
                            ' . $rat . '
                        </tr>';
        }
    }
    ?>
            </tbody>
        </table>
    </div>

	<?php 
    /* On the main KB page print out top and latest articles if needed */
    if ($catid == 1) {
        /* Get list of top articles */
        hesk_kbTopArticles($hesk_settings['kb_popart'], 0);
        /* Get list of latest articles */
        hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
    }
    hesk_kbFooter();
}
Example #4
0
function hesk_show_kb_category($catid, $is_search = 0)
{
    global $hesk_settings, $hesklang;
    $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
    $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
    if ($is_search == 0) {
        /* Print header */
        $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
        require_once HESK_PATH . 'inc/header.inc.php';
        hesk_kb_header($hesk_settings['kb_link']);
        // If we are in "Knowledgebase only" mode show system messages
        if ($catid == 1 && hesk_check_kb_only(false)) {
            // Service messages
            $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
            while ($sm = hesk_dbFetchAssoc($res)) {
                hesk_service_message($sm);
            }
        }
    }
    if ($thiscat['parent']) {
        $link = $thiscat['parent'] == 1 ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
        echo '<span class="homepageh3">&raquo; ' . $hesklang['kb_cat'] . ': ' . $thiscat['name'] . '</span>
        &nbsp;(<a href="javascript:history.go(-1)">' . $hesklang['back'] . '</a>)
		';
    }
    $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");
    if (hesk_dbNumRows($result) > 0) {
        ?>

		<p>&raquo; <b><?php 
        echo $hesklang['kb_cat_sub'];
        ?>
:</b></p>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornerstop"></td>
	<td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
</tr>
<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>

		<table border="0" cellspacing="1" cellpadding="3" width="100%">

		<?php 
        $per_col = $hesk_settings['kb_cols'];
        $i = 1;
        while ($cat = hesk_dbFetchAssoc($result)) {
            if ($i == 1) {
                echo '<tr>';
            }
            echo '
		    <td width="50%" valign="top">
			<table border="0">
			<tr><td><img src="img/folder.gif" width="20" height="20" alt="" style="vertical-align:middle" /><a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></td></tr>
			';
            /* Print most popular/sticky articles */
            if ($hesk_settings['kb_numshow'] && $cat['articles']) {
                $res = hesk_dbQuery("SELECT `id`,`subject` 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));
                $num = 1;
                while ($art = hesk_dbFetchAssoc($res)) {
                    echo '
		            <tr>
		            <td><img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" />
		            <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a></td>
		            </tr>';
                    if ($num == $hesk_settings['kb_numshow']) {
                        break;
                    } else {
                        $num++;
                    }
                }
                if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
                    echo '<tr><td>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></td></tr>';
                }
            }
            echo '
			</table>
		    </td>
			';
            if ($i == $per_col) {
                echo '</tr>';
                $i = 0;
            }
            $i++;
        }
        /* Finish the table if needed */
        if ($i != 1) {
            for ($j = 1; $j <= $per_col; $j++) {
                echo '<td width="50%">&nbsp;</td>';
                if ($i == $per_col) {
                    echo '</tr>';
                    break;
                }
                $i++;
            }
        }
        ?>
		</table>

	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>
<tr>
	<td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornersbottom"></td>
	<td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
</tr>
</table>

	<?php 
    }
    // END if NumRows > 0
    ?>

	<p>&raquo; <b><?php 
    echo $hesklang['ac'];
    ?>
</b></p>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornerstop"></td>
	<td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
</tr>
<tr>
	<td class="roundcornersleft">&nbsp;</td>
	<td>

	<?php 
    $res = hesk_dbQuery("SELECT `id`, `subject`, 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");
    if (hesk_dbNumRows($res) == 0) {
        echo '<p><i>' . $hesklang['noac'] . '</i></p>';
    } else {
        echo '<div align="center"><table border="0" cellspacing="1" cellpadding="3" width="100%">';
        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 . '" title="' . $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.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>';
        }
        echo '</table></div>';
    }
    ?>

	</td>
	<td class="roundcornersright">&nbsp;</td>
</tr>
<tr>
	<td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
	<td class="roundcornersbottom"></td>
	<td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
</tr>
</table>

	<?php 
    /* On the main KB page print out top and latest articles if needed */
    if ($catid == 1) {
        /* Get list of top articles */
        hesk_kbTopArticles($hesk_settings['kb_popart'], 0);
        /* Get list of latest articles */
        hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
    }
}
function hesk_show_kb_category($catid, $is_search = 0)
{
    global $hesk_settings, $hesklang;
    $res = hesk_dbQuery("SELECT `name`,`parent` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
    $thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
    if ($is_search == 0) {
        /* Print header */
        $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . hesk_htmlspecialchars($thiscat['name']);
        require_once HESK_PATH . 'inc/header.inc.php';
        hesk_kb_header($hesk_settings['kb_link']);
        // If we are in "Knowledgebase only" mode show system messages
        if ($catid == 1 && hesk_check_kb_only(false)) {
            // Service messages
            $res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` WHERE `type`='0' ORDER BY `order` ASC");
            while ($sm = hesk_dbFetchAssoc($res)) {
                hesk_service_message($sm);
            }
        }
    }
    if ($thiscat['parent']) {
        $link = $thiscat['parent'] == 1 ? 'knowledgebase.php' : 'knowledgebase.php?category=' . $thiscat['parent'];
        echo '<div class="container homepageh3">' . $hesklang['kb_cat'] . ': ' . $thiscat['name'] . '</div>
        <div class="container"><a href="javascript:history.go(-1)">' . '<button type="submit" class="btn btn-default goback-btn">' . $hesklang['back'] . '</button>' . '</a></div>
		';
    }
    $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");
    if (hesk_dbNumRows($result) > 0) {
        ?>

	<div class="container"><b><?php 
        echo $hesklang['kb_cat_sub'];
        ?>
:</b></div>
	<br/>
	<div class="container">

		<?php 
        $per_col = $hesk_settings['kb_cols'];
        $i = 1;
        while ($cat = hesk_dbFetchAssoc($result)) {
            if ($i == 1) {
                echo '<div>';
            }
            echo '
			<div class="form-group">
			<div class="form-inline"><img src="img/folder.gif" width="20" height="20" alt="" style="vertical-align:middle" /><a href="knowledgebase.php?category=' . $cat['id'] . '">' . $cat['name'] . '</a></div>
			';
            /* Print most popular/sticky articles */
            if ($hesk_settings['kb_numshow'] && $cat['articles']) {
                $res = hesk_dbQuery("SELECT `id`,`subject` 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));
                $num = 1;
                while ($art = hesk_dbFetchAssoc($res)) {
                    echo '
		            <div class="form-inline">
		            <img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle" />
		            <a href="knowledgebase.php?article=' . $art['id'] . '" class="article">' . $art['subject'] . '</a>
		            </div>';
                    if ($num == $hesk_settings['kb_numshow']) {
                        break;
                    } else {
                        $num++;
                    }
                }
                if (hesk_dbNumRows($res) > $hesk_settings['kb_numshow']) {
                    echo '<div>&raquo; <a href="knowledgebase.php?category=' . $cat['id'] . '"><i>' . $hesklang['m'] . '</i></a></div>';
                }
            }
            echo '
			</div>
			';
            if ($i == $per_col) {
                echo '</div>';
                $i = 0;
            }
            $i++;
        }
        /* Finish the table if needed */
        if ($i != 1) {
            for ($j = 1; $j <= $per_col; $j++) {
                echo '';
                if ($i == $per_col) {
                    echo '</div>';
                    break;
                }
                $i++;
            }
        }
        ?>
	</div>

	<?php 
    }
    // END if NumRows > 0
    if ($catid == 1) {
        print "<div class='col-sm-8 col-sm-offset-2 conatiner kb-popart-latest'>";
        /* Get list of top articles */
        hesk_kbTopArticles($hesk_settings['kb_popart'], 0, false);
        /* Get list of latest articles */
        hesk_kbLatestArticles($hesk_settings['kb_latest'], 0);
        print "</div>";
    }
    ?>
	
<?php 
}