Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28128
Modified Files:
NEWS exit.php serendipity_db_mysqli.inc.php
serendipity_db_mysql.inc.php serendipity_db_postgres.inc.php
serendipity_db_sqlite.inc.php serendipity_functions.inc.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_db_mysqli.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_mysqli.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_db_mysqli.inc.php 16 Jun 2004 18:28:58 -0000 1.1
+++ serendipity_db_mysqli.inc.php 5 Jul 2004 08:25:49 -0000 1.2
@@ -7,7 +7,7 @@
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s)
*/
-function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false) {
+function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false, $assocKey=false, $assocVal=false) {
global $serendipity;
$type_map = array('assoc' => MYSQLI_ASSOC, 'num' => MYSQLI_NUM, 'both' => MYSQLI_BOTH);
@@ -49,8 +49,13 @@
}
$rows = array();
- while ( $row = mysqli_fetch_array($c, $result_type) ) {
- $rows[] = $row;
+ while ($row = mysqli_fetch_array($c, $result_type)) {
+ if (!empty($assocKey) && !empty($assocVal)) {
+ // You can fetch a key-associated array via the two function parameters assocKey and assocVal
+ $rows[$row[$assocKey]] = $row[$assocVal];
+ } else {
+ $rows[] = $row;
+ }
}
return $rows;
}
Index: serendipity_db_postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_postgres.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- serendipity_db_postgres.inc.php 6 Jun 2004 20:30:00 -0000 1.13
+++ serendipity_db_postgres.inc.php 5 Jul 2004 08:25:49 -0000 1.14
@@ -45,7 +45,7 @@
return pg_last_oid($serendipity['dbLastResult']);
}
-function serendipity_db_query($sql, $single = false, $result_type = "both") {
+function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false, $assocKey=false, $assocVal=false) {
global $serendipity;
static $type_map = array(
'assoc' => PGSQL_ASSOC,
@@ -88,7 +88,13 @@
default:
$rows = array();
for ($i = 0; $i < $n; $i++) {
- $rows[] = pg_fetch_array($serendipity['dbLastResult'], $i, $result_type);
+ if (!empty($assocKey) && !empty($assocVal)) {
+ // You can fetch a key-associated array via the two function parameters assocKey and assocVal
+ $row = pg_fetch_array($serendipity['dbLastResult'], $i, $result_type);
+ $rows[$row[$assocKey]] = $row[$assocVal];
+ } else {
+ $rows[] = pg_fetch_array($serendipity['dbLastResult'], $i, $result_type);
+ }
}
return $rows;
}
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- NEWS 3 Jul 2004 16:33:10 -0000 1.165
+++ NEWS 5 Jul 2004 08:25:49 -0000 1.166
@@ -3,7 +3,17 @@
Version 0.7 ()
------------------------------------------------------------------------
- * Actually log the IP of users whom submit comments and blogs which
+ * Track Exits plugin: Now only uses the link id for link referal.
+ Reduces URI length and makes random exit.php calling useless for
+ spammers, as no URL is tracked, which the author didn't refer to
+ (garvinhicking, isotopp)
+
+ * Use '+' as separator for words in our "nice" URLs, so Google and
+ others can recognize 'a+nifty+word' as 'a nifty word'. Previously
+ this was indexed as one single word. Thanks to Absynth for
+ pointing this out. (garvinhicking)
+
+ * Actually log the IP of users who submit comments and blogs which
trackback (tomsommer)
* Plugin hook 'backend_publish' now executed on entries saved as
@@ -22,7 +32,7 @@
* Added dutch and portugues language. Thanks to Paul de Bruyne and
Ranulfo Netto!
- * Multi User: Fixed bug #977695 where simple editors couldn't re-edit
+ * Multi User: Fixed bug #977695 where simple editors couldn't re-edit
their entries (garvinhicking)
* Auto-Trackback from serendipity will now only fetch links smaller
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.311
retrieving revision 1.312
diff -u -d -r1.311 -r1.312
--- serendipity_functions.inc.php 5 Jul 2004 06:28:14 -0000 1.311
+++ serendipity_functions.inc.php 5 Jul 2004 08:25:49 -0000 1.312
@@ -640,7 +640,7 @@
elseif (is_array($range) && count($range)==2) {
$startts = $range[0];
$endts = $range[1];
- $and = " WHERE timestamp >= $startts AND timestamp <= $endts";
+ $and = " WHERE timestamp >= $startts AND timestamp <= $endts";
}
else {
if ($modified_since) {
@@ -993,7 +993,7 @@
'y',
- '_');
+ '+');
$str = str_replace($from, $to, $str);
return preg_replace('#[^' . PAT_FILENAME . ']#i', '', $str);
Index: exit.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/exit.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- exit.php 8 Jul 2003 09:13:27 -0000 1.5
+++ exit.php 5 Jul 2004 08:25:49 -0000 1.6
@@ -2,21 +2,28 @@
include_once 'serendipity_config.inc.php';
-$entry_id = 0;
$url = $serendipity['baseURL'];
-if ( isset($_GET['url']) &&
- !empty($_GET['url'])) {
- if ( isset($_GET['entry_id']) &&
- !empty($_GET['entry_id'])) {
- $entry_id = $_GET['entry_id'];
+if (isset($_GET['url_id']) && !empty($_GET['url_id']) && isset($_GET['entry_id']) && !empty($_GET['entry_id'])) {
+
+ // See if the submitted link is in our database and should be tracked
+ $links = serendipity_db_query("SELECT link FROM {$serendipity['dbPrefix']}references WHERE id = {$_GET['url_id']} AND entry_id = {$_GET['entry_id']}", true);
+
+ if (is_array($links) && isset($links['link'])) {
+ // URL is valid. Track it.
+ $url = $links['link'];
+ serendipity_track_url('exits', $url, $_GET['entry_id']);
+ } elseif (isset($_GET['url']) && !empty($_GET['url'])) {
+ // URL is invalid. But a URL-location was sent, so we want to redirect the user kindly.
+ $url = str_replace('&', '&', base64_decode($_GET['url']));
}
+} elseif (isset($_GET['url']) && !empty($_GET['url'])) {
+ // No entry-link ID was submitted. Possibly a spammer tried to mis-use the script to get into the top-list.
$url = str_replace('&', '&', base64_decode($_GET['url']));
-
- serendipity_track_url('exits', $url, $entry_id);
}
header('Location: ' . $url);
+exit;
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_db_sqlite.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_sqlite.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- serendipity_db_sqlite.inc.php 21 Jun 2004 14:55:32 -0000 1.7
+++ serendipity_db_sqlite.inc.php 5 Jul 2004 08:25:49 -0000 1.8
@@ -64,7 +64,7 @@
return $row;
}
-function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false)
+function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false, $assocKey=false, $assocVal=false)
{
global $serendipity;
static $type_map = array(
@@ -104,7 +104,12 @@
$rows = array();
while (($row = serendipity_db_sqlite_fetch_array($res, $type_map[$result_type]))) {
- $rows[] = $row;
+ if (!empty($assocKey) && !empty($assocVal)) {
+ // You can fetch a key-associated array via the two function parameters assocKey and assocVal
+ $rows[$row[$assocKey]] = $row[$assocVal];
+ } else {
+ $rows[] = $row;
+ }
}
if ($debug) fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE RESULT: ' . print_r($rows, true). "\n\n");
Index: serendipity_db_mysql.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_mysql.inc.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- serendipity_db_mysql.inc.php 6 Jun 2004 20:30:00 -0000 1.19
+++ serendipity_db_mysql.inc.php 5 Jul 2004 08:25:49 -0000 1.20
@@ -7,7 +7,7 @@
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s)
*/
-function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false) {
+function serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr=false, $assocKey=false, $assocVal=false) {
global $serendipity;
static $type_map = array(
'assoc' => MYSQL_ASSOC,
@@ -55,7 +55,12 @@
$rows = array();
while (($row = mysql_fetch_array($c, $result_type))) {
- $rows[] = $row;
+ if (!empty($assocKey) && !empty($assocVal)) {
+ // You can fetch a key-associated array via the two function parameters assocKey and assocVal
+ $rows[$row[$assocKey]] = $row[$assocVal];
+ } else {
+ $rows[] = $row;
+ }
}
return $rows;
}
|