Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv20680
Modified Files:
db.sql exit.php serendipity_functions.inc.php
Log Message:
Add 'entry' column to 'exits' and 'referrers' tables to keep track of which blog entry was linked from or referred to. Currently this only works for exits, have to think of a way for the referrers, but the framework is there.
Index: db.sql
===================================================================
RCS file: /cvsroot/php-blog/serendipity/db.sql,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- db.sql 3 Apr 2003 20:07:39 -0000 1.12
+++ db.sql 5 Apr 2003 14:08:41 -0000 1.13
@@ -72,6 +72,7 @@
port varchar(5),
path varchar(255),
query varchar(255),
+ entry int(11) not null,
PRIMARY KEY (host,day)
);
@@ -87,6 +88,7 @@
port varchar(5),
path varchar(255),
query varchar(255),
+ entry int(11) not null,
PRIMARY KEY (host,day)
);
Index: exit.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/exit.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exit.php 2 Apr 2003 07:06:07 -0000 1.1
+++ exit.php 5 Apr 2003 14:08:42 -0000 1.2
@@ -1,12 +1,19 @@
<?php
include_once 'serendipity_config.inc.php';
-$url = $serendipity['baseURL'];
+$entry = 0;
+$url = $serendipity['baseURL'];
if ( isset($_GET['url']) &&
!empty($_GET['url'])) {
+ if ( isset($_GET['entry']) &&
+ !empty($_GET['entry'])) {
+ $entry = $_GET['entry'];
+ }
+
$url = str_replace('&', '&', base64_decode($_GET['url']));
- serendipity_track_exit($url);
+
+ serendipity_track_url('exits', $url, $entry);
}
header('Location: ' . $url);
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- serendipity_functions.inc.php 4 Apr 2003 16:32:36 -0000 1.26
+++ serendipity_functions.inc.php 5 Apr 2003 14:08:42 -0000 1.27
@@ -279,10 +279,10 @@
echo "</div>";
echo "<div class='serendipity_entry'>";
- echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['body'])));
+ echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['body'], $entry['id'])));
if ($extended && strlen($entry['extended'])) {
echo '<a name="#extended"></a>';
- echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['extended'])));
+ echo nl2br(serendipity_emoticate(serendipity_markup_text($entry['extended'], $entry['id'])));
}
if ($entry['exflag'] && !$extended) {
echo "<br><div class='serendipity_time'><a href=\""
@@ -487,7 +487,7 @@
return("<tt>".str_replace(' ', ' ', $arg[1])."</tt>");
}
-function serendipity_markup_text($str) {
+function serendipity_markup_text($str, $entry = 0) {
global $serendipity;
$ret = $str;
@@ -521,6 +521,8 @@
$ret = preg_replace('/([\\\])([*#_|^@%])/', '\2', $ret);
if ($serendipity['track_exits']) {
+ $serendipity['encodeExitsCallback_entry'] = $entry;
+
$ret = preg_replace_callback(
"#<a href=(\"|')http://([^\"']+)(\"|')#im",
'serendipity_encodeExitsCallback',
@@ -538,13 +540,15 @@
function serendipity_encodeExitsCallback($buffer) {
global $serendipity;
- $url = 'http://' . $buffer[2];
+ $entry = $serendipity['encodeExitsCallback_entry'];
+ $url = 'http://' . $buffer[2];
return sprintf(
- '<a href="%sexit.php?url=%s" title="%s" onMouseOver="window.status=\'%s\';return true;" onMouseOut="window.status=\'\';return true;"',
+ '<a href="%sexit.php?url=%s%s" title="%s" onMouseOver="window.status=\'%s\';return true;" onMouseOut="window.status=\'\';return true;"',
$serendipity['baseURL'],
base64_encode($url),
+ ($entry != 0) ? '&entry=' . $entry : '',
$url,
$url
);
@@ -1448,43 +1452,47 @@
serendipity_db_query($gc);
}
-function serendipity_track_exit($url) {
- serendipity_track_url('exits', $url);
-}
-
-function serendipity_track_url($list, $url) {
+function serendipity_track_url($list, $url, $entry = 0) {
global $serendipity;
- $url_parts = parse_url($url);
+ $url_parts = parse_url($url);
serendipity_db_query(
@sprintf(
"UPDATE %s
SET count = count + 1
- WHERE scheme = '$url_parts[scheme]'
- AND host = '$url_parts[host]'
- AND port = '$url_parts[port]'
- AND path = '$url_parts[path]'
- AND query = '$url_parts[query]'
- AND day = NOW()",
+ WHERE scheme = '%s'
+ AND host = '%s'
+ AND port = '%s'
+ AND path = '%s'
+ AND query = '%s'
+ AND day = NOW()
+ %s",
- $serendipity['dbPrefix'].$list
+ $serendipity['dbPrefix'] . $list,
+ $url_parts['scheme'],
+ $url_parts['host'],
+ $url_parts['port'],
+ $url_parts['path'],
+ $url_parts['query'],
+ ($entry != 0) ? "AND entry = '$entry'" : ''
)
);
if (serendipity_db_affected_rows() == 0) {
serendipity_db_query(
sprintf(
- "INSERT INTO %s%s
- (day, count, scheme, host, port, path, query)
- VALUES ( NOW(), 1, '%s', '%s', '%s', '%s', '%s')",
- $serendipity['dbPrefix'],
- $list,
- $url_parts[scheme],
- $url_parts[host],
- $url_parts[port],
- $url_parts[path],
- $url_parts[query]
+ "INSERT INTO %s
+ (day, count, scheme, host, port, path, query%s)
+ VALUES ( NOW(), 1, '%s', '%s', '%s', '%s', '%s'%s)",
+ $serendipity['dbPrefix'] . $list,
+ ($entry != 0) ? ', entry' : '',
+ $url_parts['scheme'],
+ $url_parts['host'],
+ $url_parts['port'],
+ $url_parts['path'],
+ $url_parts['query'],
+ ($entry != 0) ? ", '$entry'" : ''
)
);
}
|