function hesk_stray_article($id)
{
    global $hesk_settings, $hesklang, $article;
    // Set article to category ID 1
    $article['catid'] = 1;
    // Update database
    hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `catid`=1 WHERE `id`='" . intval($id) . "' LIMIT 1");
    // Update count of articles in categories
    update_count();
    // Return new category ID
    return 1;
}
Пример #2
0
        if (mysql_num_rows($query_run) >= 1) {
            return true;
        }
    }
}
function ip_add($ip)
{
    $query = "INSERT INTO `hits_ip` VALUES ('{$ip}')";
    $query_run = mysql_query($query);
}
function update_count()
{
    $query = "SELECT `count` FROM `hits_count`";
    if ($query_run = mysql_query($query)) {
        $count = mysql_result($query_run, 0, 'count');
        $count_inc = $count + 1;
        $query_update = "UPDATE `hits_count` SET `count` = '{$count_inc}'";
        $query_update_run = mysql_query($query_update);
    }
}
if (!ip_exists($user_ip)) {
    update_count();
    ip_add($user_ip);
    echo $user_ip . ' Does not exist written to ' . '<br>';
} else {
    echo $user_ip . ' Already Exists!!' . '<br>';
}
?>


Пример #3
0
function save_article()
{
    global $hesk_settings, $hesklang, $hesk_error_buffer;
    /* A security check */
    hesk_token_check('POST');
    $hesk_error_buffer = array();
    $id = intval(hesk_POST('id')) or hesk_error($hesklang['kb_art_id']);
    $catid = intval(hesk_POST('catid', 1));
    $type = intval(hesk_POST('type'));
    $type = $type < 0 || $type > 2 ? 0 : $type;
    $html = $hesk_settings['kb_wysiwyg'] ? 1 : (empty($_POST['html']) ? 0 : 1);
    $now = hesk_date();
    $old_catid = intval(hesk_POST('old_catid'));
    $old_type = intval(hesk_POST('old_type'));
    $old_type = $old_type < 0 || $old_type > 2 ? 0 : $old_type;
    $subject = hesk_input(hesk_POST('subject')) or $hesk_error_buffer[] = $hesklang['kb_e_subj'];
    if ($html) {
        if (empty($_POST['content'])) {
            $hesk_error_buffer[] = $hesklang['kb_e_cont'];
        }
        $content = hesk_getHTML(hesk_POST('content'));
    } else {
        $content = hesk_input(hesk_POST('content')) or $hesk_error_buffer[] = $hesklang['kb_e_cont'];
        $content = nl2br($content);
        $content = hesk_makeURL($content);
    }
    $sticky = isset($_POST['sticky']) ? 1 : 0;
    $keywords = hesk_input(hesk_POST('keywords'));
    $extra_sql = '';
    if (hesk_POST('resetviews') == 'Y') {
        $extra_sql .= ',`views`=0 ';
    }
    if (hesk_POST('resetvotes') == 'Y') {
        $extra_sql .= ',`votes`=0, `rating`=0 ';
    }
    /* Article attachments */
    define('KB', 1);
    require_once HESK_PATH . 'inc/posting_functions.inc.php';
    require_once HESK_PATH . 'inc/attachments.inc.php';
    $attachments = array();
    for ($i = 1; $i <= 3; $i++) {
        $att = hesk_uploadFile($i);
        if (!empty($att)) {
            $attachments[$i] = $att;
        }
    }
    $myattachments = '';
    /* Any errors? */
    if (count($hesk_error_buffer)) {
        // Remove any successfully uploaded attachments
        if ($hesk_settings['attachments']['use']) {
            hesk_removeAttachments($attachments);
        }
        $_SESSION['edit_article'] = array('type' => $type, 'html' => $html, 'subject' => $subject, 'content' => hesk_input(hesk_POST('content')), 'keywords' => $keywords, 'catid' => $catid, 'sticky' => $sticky, 'resetviews' => isset($_POST['resetviews']) ? 'Y' : 0, 'resetvotes' => isset($_POST['resetvotes']) ? 'Y' : 0);
        $tmp = '';
        foreach ($hesk_error_buffer as $error) {
            $tmp .= "<li>{$error}</li>\n";
        }
        $hesk_error_buffer = $tmp;
        $hesk_error_buffer = $hesklang['rfm'] . '<br /><br /><ul>' . $hesk_error_buffer . '</ul>';
        hesk_process_messages($hesk_error_buffer, './manage_knowledgebase.php?a=edit_article&id=' . $id);
    }
    /* Add to database */
    if (!empty($attachments)) {
        foreach ($attachments as $myatt) {
            hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_attachments` (`saved_name`,`real_name`,`size`) VALUES ('" . hesk_dbEscape($myatt['saved_name']) . "', '" . hesk_dbEscape($myatt['real_name']) . "', '" . intval($myatt['size']) . "')");
            $myattachments .= hesk_dbInsertID() . '#' . $myatt['real_name'] . ',';
        }
        $extra_sql .= ", `attachments` = CONCAT(`attachments`, '" . $myattachments . "') ";
    }
    /* Update article in the database */
    $revision = sprintf($hesklang['revision2'], $now, $_SESSION['name'] . ' (' . $_SESSION['user'] . ')');
    hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET\r\n    `catid`=" . intval($catid) . ",\r\n    `subject`='" . hesk_dbEscape($subject) . "',\r\n    `content`='" . hesk_dbEscape($content) . "',\r\n    `keywords`='" . hesk_dbEscape($keywords) . "' {$extra_sql} ,\r\n    `type`='" . intval($type) . "',\r\n    `html`='" . intval($html) . "',\r\n    `sticky`='" . intval($sticky) . "',\r\n    `history`=CONCAT(`history`,'" . hesk_dbEscape($revision) . "')\r\n    WHERE `id`='" . intval($id) . "' LIMIT 1");
    $_SESSION['artord'] = $id;
    // Update proper category article count
    // (just do them all to be sure, don't compliate...)
    update_count();
    // Update article order
    update_article_order($catid);
    hesk_process_messages($hesklang['your_kb_mod'], './manage_knowledgebase.php?a=manage_cat&catid=' . $catid, 'SUCCESS');
}