function trimtext($str, $length, $nbsp = FALSE) { $str = strip_tags($str); if (strlen($str) > $length) { $str = unentify($str); $str = substr($str, 0, $length + 1); $str = entify($str) . "…"; } if ($nbsp == TRUE) { $str = str_replace(" ", " ", $str); } $str = str_replace("http://", "", $str); return $str; }
$registered = 1; } } // If magic_quotes_gpc is set, we need to strip slashes.. if (get_magic_quotes_gpc()) { $Pivot_Vars['piv_name'] = stripslashes($Pivot_Vars['piv_name']); $Pivot_Vars['piv_email'] = stripslashes($Pivot_Vars['piv_email']); $Pivot_Vars['piv_url'] = stripslashes($Pivot_Vars['piv_url']); $Pivot_Vars['piv_comment'] = stripslashes($Pivot_Vars['piv_comment']); } $comment_text = strip_trailing_space($Pivot_Vars['piv_comment']); $comment_text = str_replace("\r\n", "\n", $comment_text); // CRLF(Win) to LF $comment_text = str_replace("\r", "\n", $comment_text); // CR(Mac) to LF $my_comment = array('name' => entify($Pivot_Vars['piv_name']), 'email' => entify($Pivot_Vars['piv_email']), 'url' => entify($Pivot_Vars['piv_url']), 'ip' => $Pivot_Vars['REMOTE_ADDR'], 'date' => format_date("", "%year%-%month%-%day%-%hour24%-%minute%"), 'comment' => $comment_text, 'registered' => $registered, 'notify' => $Pivot_Vars['piv_notify'], 'discreet' => $Pivot_Vars['piv_discreet'], 'moderate' => $Cfg['moderate_comments'] == 1); //here we do a check to prevent double entries... $duplicate = FALSE; if (isset($entry['comments']) && count($entry['comments']) > 0) { foreach ($entry['comments'] as $loop_comment) { $diff = 1 / (min(strlen($loop_comment['comment']), 200) / (levenshtein(substr($loop_comment['comment'], 0, 200), substr($my_comment['comment'], 0, 200)) + 1)); if ($diff < 0.25 && $loop_comment['ip'] == $my_comment['ip']) { $duplicate = TRUE; break; } } } // set the message and take proper action: if (isset($Pivot_Vars['preview'])) { // Add a 'show in preview' flag to $my_comment, otherwise it would be suppressed on display $my_comment['showpreview'] = 1;
/** * Store an edited trackback, and then show the edit_trackbacks screen * * @see edit_trackbacks() * */ function submit_trackback() { global $Cfg, $Pivot_Vars; // If magic_quotes_gpc is set, we need to strip slashes.. if (get_magic_quotes_gpc()) { $Pivot_Vars['title'] = stripslashes($Pivot_Vars['title']); $Pivot_Vars['excerpt'] = stripslashes($Pivot_Vars['excerpt']); $Pivot_Vars['name'] = stripslashes($Pivot_Vars['name']); } $mytrack = array('title' => entify($Pivot_Vars['title']), 'excerpt' => entify($Pivot_Vars['excerpt']), 'name' => entify($Pivot_Vars['name']), 'url' => $Pivot_Vars['url'], 'ip' => $Pivot_Vars['ip'], 'date' => $Pivot_Vars['date']); $db = new db(); $entry = $db->read_entry($Pivot_Vars['id']); $entry['trackbacks'][$Pivot_Vars['count']] = $mytrack; $db->set_entry($entry); $db->save_entry(); // remove it from cache, to make sure the laters one is used. $db->unread_entry($entry['code']); $msg = lang('notice', 'trackback_saved'); edit_trackbacks($msg); }
// checking if IP address of trackbacking site is blocked if (ip_check_block($Pivot_Vars['REMOTE_ADDR'])) { debug("Blocked user from " . $Pivot_Vars['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); } // Exit if no trackback (entry) ID is given if (!($Pivot_Vars['tb_id'] = mungeTbId($Pivot_Vars['tb_id']))) { respondExit(lang('trackback', 'noid'), 1); } // Open database $db = new db(); // Exit if non-existing ID supplied if (!$db->entry_exists($Pivot_Vars['tb_id'])) { respondExit('Non-existing ID', 1); } $my_trackback = array('name' => entify(urldecode(stripslashes($Pivot_Vars['blog_name']))), 'title' => entify(urldecode(stripslashes($Pivot_Vars['title']))), 'url' => urldecode($Pivot_Vars['url']), 'ip' => $Pivot_Vars['REMOTE_ADDR'], 'date' => format_date("", "%year%-%month%-%day%-%hour24%-%minute%"), 'excerpt' => strip_trailing_space(urldecode(stripslashes($Pivot_Vars['excerpt'])))); // Exit if no URL is given - need to know URL to foreign entry that // trackbacked us. if (empty($my_trackback['url'])) { respondExit(lang('trackback', 'nourl'), 1); } // load an entry $entry = $db->read_entry($Pivot_Vars['tb_id']); //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'], -200), substr($my_trackback['excerpt'], -200)) + 1)); if ($diff < 0.25 && $loop_trackback['ip'] == $my_trackback['ip']) { $duplicate = TRUE; }