Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4733
Modified Files:
NEWS serendipity_functions.inc.php
serendipity_functions_installer.inc.php
Log Message:
No trackback for large files. Is 150kb a reasonable HTML-limit?
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- serendipity_functions.inc.php 22 Jun 2004 10:07:32 -0000 1.301
+++ serendipity_functions.inc.php 23 Jun 2004 11:13:09 -0000 1.302
@@ -2046,11 +2046,50 @@
}
function serendipity_reference_autodiscover($loc, $url, $author, $title, $text) {
+
+ $filelimit = 150 * 1024; // We do not check files larger than 150kb
+ $timeout = 30;
+
+ $u = parse_url($loc);
+
+ if ($u['scheme'] != 'http') {
+ return;
+ }
+
echo '<br />';
printf(TRACKBACK_CHECKING, $loc);
echo '<br />';
flush();
- $res = @file_get_contents($loc);
+
+ if (empty($u['port'])) {
+ $u['port'] = 80;
+ }
+
+ if (!empty($u['query'])) {
+ $u['path'] .= '?' . $u['query'];
+ }
+
+ $res = '';
+ $fp = fsockopen($u['host'], $u['port'], $err, $timeout);
+ if ($fp) {
+ fputs($fp, "GET {$u['path']} HTTP/1.0\r\n");
+ fputs($fp, "Host: {$u['host']}\r\n");
+ fputs($fp, "User-Agent: Serendipity/{$GLOBALS['serendipity']['version']}\r\n");
+ fputs($fp, "Referer: {$GLOBALS['serendipity']['baseURL']}\r\n");
+ fputs($fp, "Connection: close\r\n\r\n");
+
+ while ($fp && !feof($fp) && strlen($res) < $filelimit) {
+ $res .= fgets($fp, 4096);
+ }
+ fclose($fp);
+
+ if (strlen($res) >= $filelimit) {
+ printf(TRACKBACK_SIZE, $filelimit);
+ echo '<br />';
+ return;
+ }
+ }
+
if (strlen($res) != 0) {
serendipity_trackback_autodiscover($res, $loc, $url, $author, $title, $text);
serendipity_pingback_autodiscover($loc, $res);
Index: serendipity_functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_installer.inc.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- serendipity_functions_installer.inc.php 21 Jun 2004 14:55:32 -0000 1.15
+++ serendipity_functions_installer.inc.php 23 Jun 2004 11:13:09 -0000 1.16
@@ -278,9 +278,9 @@
$response = '';
if ($sock) {
- fputs($sock, "GET {$_SERVER['PHP_SELF']}nonexistant HTTP/1.0\n");
- fputs($sock, "Host: $serendipity_host\n");
- fputs($sock, "Connection: close\n\n");
+ fputs($sock, "GET {$_SERVER['PHP_SELF']}nonexistant HTTP/1.0\r\n");
+ fputs($sock, "Host: $serendipity_host\r\n");
+ fputs($sock, "Connection: close\r\n\r\n");
while (!feof($sock) && strlen($response) < 4096) {
$response .= fgets($sock, 400);
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- NEWS 22 Jun 2004 13:45:42 -0000 1.158
+++ NEWS 23 Jun 2004 11:13:08 -0000 1.159
@@ -3,6 +3,14 @@
Version 0.7 ()
------------------------------------------------------------------------
+ * Auto-Trackback from serendipity will now only fetch links smaller
+ than 150kb. Use socket connections instead of URL wrappers for
+ better control. (garvinhicking)
+
+ * Fixed HTTP requests from installer and htmlvalidator plugin to
+ send "\r\n" headers instead of only "\n". IIS-Servers didn't
+ respond to the latter (garvinhicking)
+
* Updated plugins to show default values in plugin configuration
immediately. New bag property 'default' introduced to Plugin API,
backwards compatible. (garvinhicking)
|