Пример #1
0
/**
 * Enter description here...
 *
 */
function handlePostTrackback($uri, $date)
{
    global $PIVOTX;
    $message = "";
    // Using our integrated Trackback Spam Killer
    killtrackbackspam();
    // Initialise the IP blocklist.
    $blocklist = new IPBlock();
    // checking if IP address of trackbacking site is blocked
    if ($blocklist->isBlocked($_SERVER['REMOTE_ADDR'])) {
        debug("Blocked user from " . $_SERVER['REMOTE_ADDR'] . " tried to trackback");
        respondExit("Your IP-address has been blocked, so you are not" . " allowed to leave trackbacks on this site. We know IP-adresses can easily be faked," . " but it helps.", 1);
    }
    // Get the entry from the DB..
    $entry = $PIVOTX['db']->read_entry($uri, $date);
    // Exit if non-existing ID supplied
    if (empty($entry['code'])) {
        respondExit('Entry not found', 1);
    }
    // Keep original excerpt for spam checks ...
    $orig_excerpt = $_POST['excerpt'];
    // Strip out HTML from input and convert to utf-8.
    $_POST['blog_name'] = i18n_str_to_utf8(strip_tags($_POST['blog_name']));
    $_POST['title'] = i18n_str_to_utf8(strip_tags($_POST['title']));
    $_POST['url'] = strip_tags($_POST['url']);
    if ($PIVOTX['config']->get('allow_html_in_comments') == 1) {
        $_POST['excerpt'] = stripTagsAttributes($_POST['excerpt'], "*");
    } else {
        $_POST['excerpt'] = stripTagsAttributes($_POST['excerpt'], "<b><em><i><strong>");
    }
    $_POST['excerpt'] = i18n_str_to_utf8($_POST['excerpt']);
    $my_trackback = array('entry_uid' => intval($entry['code']), 'name' => $_POST['blog_name'], 'title' => $_POST['title'], 'url' => trim($_POST['url']), 'ip' => $_SERVER['REMOTE_ADDR'], 'date' => formatDate("", "%year%-%month%-%day%-%hour24%-%minute%"), 'excerpt' => trimText($_POST['excerpt'], 255, false, true, false));
    // Exit if no URL is given - need to know URL to foreign entry that
    // trackbacked us.
    if (empty($my_trackback['url'])) {
        respondExit('No URL (url) parameter given', 1);
    }
    //here we do a check to prevent double entries...
    $duplicate = FALSE;
    if (isset($entry['trackbacks']) && count($entry['trackbacks']) > 0) {
        foreach ($entry['trackbacks'] as $loop_trackback) {
            $diff = 1 / (min(strlen($loop_trackback['excerpt']), 200) / (levenshtein(substr($loop_trackback['excerpt'], 0, 200), substr($my_trackback['excerpt'], 0, 200)) + 1));
            if ($diff < 0.25 && $loop_trackback['ip'] == $my_trackback['ip']) {
                $duplicate = TRUE;
                break;
            }
        }
    }
    if (!$duplicate) {
        // update the current entry
        $entry['trackbacks'][] = $my_trackback;
        $post = TRUE;
    } else {
        $message = 'Your trackback has not been stored, because it seems to be a duplicate';
        $post = FALSE;
    }
    if ($PIVOTX['config']->get('maxhrefs') > 0) {
        $low_excerpt = strtolower(trackbackFormat($orig_excerpt));
        if (substr_count($low_excerpt, "href=") > $PIVOTX['config']->get('maxhrefs')) {
            $message = 'The maximum number of hyperlinks was exceeded. Are you spamming us?';
            $post = FALSE;
        }
    }
    if ($post) {
        $PIVOTX['db']->set_entry($entry);
        $PIVOTX['db']->save_entry(FALSE);
        // do not update the index.
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        // send mail..
        sendMailTrackback($my_trackback);
        debug("A trackback from '" . $my_trackback['name'] . "' added.");
        //update the 'last trackbacks' file
        if (isset($my_trackback)) {
            generateLastTrackbacks($my_trackback);
        }
        // Clean the simple cache..
        $PIVOTX['cache']->clear();
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        // After messing about with the trackbacks, clear the cache.
        $PIVOTX['cache']->cache['entries'] = array();
        respondExit();
    } else {
        respondExit($message, 1);
    }
}
Пример #2
0
// the GPL version 2. see: http://www.pivotlog.net/help/help_about_gpl.php
// for more information.
//
// ---------------------------------------------------------------------------
// First line defense.
if (file_exists(dirname(__FILE__) . "/first_defense.php")) {
    include_once dirname(__FILE__) . "/first_defense.php";
    block_refererspam();
    block_postedspam();
}
include_once "pv_core.php";
include_once "modules/module_userreg.php";
// convert encoding to UTF-8
i18n_array_to_utf8($Pivot_Vars, $dummy_variable);
// Using our integrated Trackback Spam Killer
killtrackbackspam();
// functions
function generate_last_trackbacks($temptrack)
{
    global $entry, $Cfg;
    // if it exists, load it
    $lasttrack = load_serialize("db/ser_lasttrack.php", true, true);
    $lasttrack[] = array('title' => $temptrack['title'], 'excerpt' => trimtext($temptrack['excerpt'], 250), 'name' => $temptrack['name'], 'url' => $temptrack['url'], 'date' => $temptrack['date'], 'code' => $entry['code'], 'category' => $entry['category'], 'ip' => $temptrack['ip']);
    if (count($lasttrack) > $Cfg['lastcomm_amount_max']) {
        array_shift($lasttrack);
    }
    save_serialize("db/ser_lasttrack.php", $lasttrack);
}
function send_mail_tb()
{
    global $Cfg, $entry, $PIV_PARA, $my_trackback, $Weblogs, $Current_weblog, $Paths, $Users, $i18n_use;