Esempio n. 1
0
/**
 * Reset the spam log.
 */
function reset_spamlog()
{
    // check against unauthorised direct access.
    check_csrf();
    PageHeader(lang('adminbar', 'viewspamlog_title'), 1);
    PageAnkeiler(lang('userbar', 'admin') . ' » ' . lang('adminbar', 'viewspamlog_title'));
    set_spamlog();
    echo "<p>" . lang('spam', 'reset_log_done') . "<p>\n";
    PageFooter();
}
Esempio n. 2
0
/**
 * Display 'spamlog' page.
 */
function pageSpamlog()
{
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Spam Log'));
    $PIVOTX['template']->assign('heading', __('View and Reset the Spam Log.'));
    $form = getResetSpamLogForm();
    $result = $form->validate();
    if ($result != FORM_NOTPOSTED) {
        set_spamlog();
        $PIVOTX['messages']->addMessage(__("Spam log reset."));
    }
    $spamlog = get_spamlog();
    $PIVOTX['template']->assign('html', $spamlog);
    $PIVOTX['template']->assign('form', $form->fetch());
    renderTemplate('generic.tpl');
}
/**
 * This function trims the spamlog file down, if needed.
 *
 * The spam logfile can easily become very large.. So large that it can't be
 * read by common PHP installs without going over the amount of allocated
 * memory. This function checks the filesize, and trims the file if it
 * becomes to large.
 *
 * It trims off about 1/3 of the entire file. This is to prevent that it has to
 * be trimmed too often, since that would be very server-unfriendly.
 *
 * @return void
 */
function trim_spamlog()
{
    global $spamkiller_log;
    // If it exists, and is larger than ~ 1mb, we will have to remove it,
    // because trying to read it, may cause a Fatal error..
    if (file_exists($spamkiller_log) && filesize($spamkiller_log) > 1000000) {
        unlink($spamkiller_log);
    }
    // If it exists, and is larger than ~ 250kb.
    if (file_exists($spamkiller_log) && filesize($spamkiller_log) > 250000) {
        // Read the file.
        $logfile = file($spamkiller_log);
        // Slice off 1/3 of the file.
        $lines = count($logfile);
        $logfile = array_slice($logfile, intval($lines / 3));
        // Save it again.
        set_spamlog(implode("", $logfile));
    }
}