--- NP_TrackBack.php.orig Wed Feb 18 13:46:58 2004 +++ NP_TrackBack.php Sat May 28 00:00:00 2005 @@ -402,6 +402,30 @@ if (!$blog_name) $blog_name = $this->noblogname; if (!$title) $title = $this->notitle; if (!$excerpt) $excerpt = $this->noexcerpt; + + // check for NG patterns + global $TRACKBACK_NG_PATTERNS; + if (isset($TRACKBACK_NG_PATTERNS)) { + $remote_addr = serverVar('REMOTE_ADDR'); + $subject = $url . $title . $excerpt . $blog_name . $remote_addr; + foreach ($TRACKBACK_NG_PATTERNS as $pattern) { + if (preg_match($pattern, $subject)) { + ACTIONLOG::add(INFO, "TrackBack ping was denied from ip:$remote_addr for pattern:$pattern"); + return 'Sorry, no trackback pings are accepted'; + } + } + } + + // check for interval + global $TRACKBACK_INTERVAL; + if (isset($TRACKBACK_INTERVAL)) { + $query = 'SELECT timestamp FROM ' . sql_table('plugin_tb') . " WHERE url = '" . addslashes($url) . "' AND timestamp > '" . mysqldate($b->getCorrectTime() - $TRACKBACK_INTERVAL) . "'"; + $res = @mysql_query($query); + if ($res && mysql_num_rows($res)) { + ACTIONLOG::add(INFO, "TrackBack ping was denied from url:$url for interval:$TRACKBACK_INTERVAL seconds"); + return 'Sorry, no trackback pings are accepted'; + } + } // 3. save data in the DB $query = 'INSERT INTO ' . sql_table('plugin_tb') . " (tb_id, url, title, excerpt, blog_name, timestamp) VALUES ('".$tb_id."','".addslashes($url)."','".addslashes($title)."','".addslashes($excerpt)."','".addslashes($blog_name)."',".mysqldate($b->getCorrectTime()).")"; @@ -433,6 +457,9 @@ } + // clear cache + $this->clearCache($tb_id); + return ''; } @@ -441,7 +468,7 @@ * Show a 'ping site' form, where a ping URL can be entered for an item */ function showPingForm() { - global $manager, $CONF, $HTTP_REFERER; + global $manager, $CONF; // get values to put in the fields $ping_url = requestVar('ping_url'); @@ -475,7 +502,7 @@ - + @@ -512,7 +539,7 @@ * Blogger does not support trackback) */ function showManualPingForm() { - global $manager, $CONF, $HTTP_REFERER; + global $manager, $CONF; // check if we are allowed to accept pings if ($this->getOption('AcceptPing') == 'no') @@ -542,7 +569,7 @@ - +
URL
@@ -712,8 +739,11 @@ $query = 'DELETE FROM ' . sql_table('plugin_tb') . " WHERE tb_id='$tb_id' and url='".addslashes($url)."'"; mysql_query($query); - global $HTTP_REFERER; - header('Location: ' . $HTTP_REFERER); + + // clear cache + $this->clearCache($tb_id); + + header('Location: ' . serverVar('HTTP_REFERER')); } /** @@ -923,6 +953,9 @@ $res = @mysql_query($query); if (!$res) return 'Could not save trackback data, possibly because of a double entry: ' . mysql_error(); + + // clear cache + $this->clearCache($tb_id); } /** @@ -979,8 +1012,11 @@ $query = 'DELETE FROM ' . sql_table('plugin_tb_lc') . " WHERE tb_id='$tb_id' and from_id='$from_id'"; mysql_query($query); - global $HTTP_REFERER; - header('Location: ' . $HTTP_REFERER); + + // clear cache + $this->clearCache($tb_id); + + header('Location: ' . serverVar('HTTP_REFERER')); } function jencording($text,$charset=_CHARSET){ @@ -1053,5 +1089,16 @@ return $res; } + function clearCache($itemid) { + global $manager; + + // call event_PreUpdateItem of NP_Cache if exists + if ($manager->pluginInstalled('NP_Cache')) { + $plugin = $manager->getPlugin('NP_Cache'); + if ($plugin && method_exists($plugin, 'event_PreUpdateItem')) { + call_user_func(array(&$plugin, 'event_PreUpdateItem'), array('itemid' => $itemid)); + } + } + } } ?> \ No newline at end of file
Article URL