Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_trackexits
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28128/plugins/serendipity_event_trackexits
Modified Files:
serendipity_event_trackexits.php
Log Message:
* Use '+' instead of '_' for URL generation - lets google recognize single
words instead of one huge
* Exit Tracking: Do not allow spammers to randomly submit URLs. We only
allow links to be tracked which we entered. Those are inserted in
serendipity_references, and we can fetch the ID. I talked this over with
Kristian Koehntopp, but please test this.
Index: serendipity_event_trackexits.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_trackexits/serendipity_event_trackexits.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_event_trackexits.php 29 Jun 2004 22:09:22 -0000 1.9
+++ serendipity_event_trackexits.php 5 Jul 2004 08:25:50 -0000 1.10
@@ -22,6 +22,7 @@
class serendipity_event_trackexits extends serendipity_event
{
+var $links;
function introspect(&$propbag)
{
@@ -69,7 +70,7 @@
switch($name) {
case 'commentredirection':
$propbag->add('type', 'select');
- $propbag->add('select_values', array('none' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_NONE,
+ $propbag->add('select_values', array('none' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_NONE,
's9y' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_S9Y,
'google' => PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION_GOOGLE));
$propbag->add('name', PLUGIN_EVENT_TRACKBACK_COMMENTREDIRECTION);
@@ -103,6 +104,10 @@
$element = $temp['element'];
$serendipity['encodeExitsCallback_entry_id'] = (isset($eventData['entry_id']) ? $eventData['entry_id'] : $eventData['id']);
+
+ // Fetch all existing links from the database. They have been inserted there by our trackback-discovery.
+ $this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']}", false, 'both', false, 'link', 'id');
+
$eventData[$element] = preg_replace_callback(
"#<a(.*)href=(\"|')http://([^\"']+)(\"|')#isUm",
array($this, '_encodeExitsCallback'),
@@ -166,15 +171,27 @@
);
}
- return sprintf(
- '<a%shref="%sexit.php?url=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
- $buffer[1],
- $serendipity['baseURL'],
- base64_encode($url),
- ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
- $url,
- $url
- );
+ if (isset($this->links[$url])) {
+ return sprintf(
+ '<a%shref="%sexit.php?url_id=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
+ $buffer[1],
+ $serendipity['baseURL'],
+ $this->links[$url],
+ ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
+ $url,
+ $url
+ );
+ } else {
+ return sprintf(
+ '<a%shref="%sexit.php?url=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
+ $buffer[1],
+ $serendipity['baseURL'],
+ base64_encode($url),
+ ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
+ $url,
+ $url
+ );
+ }
}
}
|