cvs: pear /Services_Trackback/Services Trackback.php /Services_Trackback/Services/Trackback SpamCheck.php /Services_Trackback/test
Services_Trackback_Test.php Services_Trackback_TestAll.php
| From: | Tobias Schlitt | Date: | Thu, 09 Feb 2006 19:09:37 +0000 |
| Subject: | cvs: pear /Services_Trackback/Services Trackback.php /Services_Trackback/Services/Trackback SpamCheck.php /Services_Trackback/test Services_Trackback_Test.php Services_Trackback_TestAll.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38082@lists.php.net to get a copy of this message | ||
toby Thu Feb 9 19:09:37 2006 UTC
Modified files:
/pear/Services_Trackback/Services Trackback.php
/pear/Services_Trackback/Services/Trackback SpamCheck.php
/pear/Services_Trackback/test Services_Trackback_Test.php
Services_Trackback_TestAll.php
Log:
- Bug #6341: Undefined variable on line 315 & 378.
- Fixed reference issues.
- Fixed small issue in continuos spam checks.
- Fix small issue in test cases.
- Added dev-env include_path setting.
http://cvs.php.net/viewcvs.cgi/pear/Services_Trackback/Services/Trackback.php?r1=1.14&r2=1.15&diff_format=u
Index: pear/Services_Trackback/Services/Trackback.php
diff -u pear/Services_Trackback/Services/Trackback.php:1.14
pear/Services_Trackback/Services/Trackback.php:1.15
--- pear/Services_Trackback/Services/Trackback.php:1.14 Tue Feb 7 22:42:19 2006
+++ pear/Services_Trackback/Services/Trackback.php Thu Feb 9 19:09:37 2006
@@ -21,7 +21,7 @@
* @author Tobias Schlitt <toby@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: Trackback.php,v 1.14 2006/02/07 22:42:19 toby Exp $
+ * @version CVS: $Id: Trackback.php,v 1.15 2006/02/09 19:09:37 toby Exp $
* @link http://pear.php.net/package/Services_Trackback
* @since File available since Release 0.1.0
*/
@@ -312,7 +312,7 @@
$trackbackUrl = trim($matches[1]);
// Check if the URL to trackback matches the identifier from the autodiscovery code
- $res = $this->_checkURLs($url, $identifier, $strictness);
+ $res = $this->_checkURLs($url, $identifier, $this->_options['strictness']);
if (PEAR::isError($res)) {
return $res;
}
@@ -346,6 +346,7 @@
function send($data = null)
{
// Load HTTP_Request
+ // @TODO: Make include_once
@require_once 'HTTP/Request.php';
if (!class_exists('HTTP_Request')) {
return PEAR::raiseError('Unable to load PEAR::HTTP_Request.');
@@ -375,7 +376,7 @@
$req->setMethod(HTTP_REQUEST_METHOD_POST);
// Add HTTP headers
- $req->addHeader("User-Agent", $this->options['useragent']);
+ $req->addHeader("User-Agent", $this->_options['useragent']);
// Adding data to send
$req->addPostData('url', $this->_data['url']);
@@ -726,11 +727,11 @@
*/
function _getContent($url)
{
- $handle = fopen($url, 'r');
- stream_set_timeout($handle, $this->_options['timeout']);
+ $handle = @fopen($url, 'r');
if (!is_resource($handle)) {
return PEAR::raiseError('Could not open URL "'.$url.'"');
}
+ stream_set_timeout($handle, $this->_options['timeout']);
$content = '';
for ($i = 0; ($i < $this->_options['fetchlines']) &&
!feof($handle);$i++) {
@@ -840,7 +841,7 @@
switch ($strictness) {
case SERVICES_TRACKBACK_STRICTNESS_HIGH:
if ($url1 !== $url2) {
- return PEAR::raiseError('URLs mismatch. "'.$url.'" !==
"'.$identifier.'".');
+ return PEAR::raiseError('URLs mismatch. "'.$url1.'"
!== "'.$url2.'".');
}
break;
http://cvs.php.net/viewcvs.cgi/pear/Services_Trackback/Services/Trackback/SpamCheck.php?r1=1.8&r2=1.9&diff_format=u
Index: pear/Services_Trackback/Services/Trackback/SpamCheck.php
diff -u pear/Services_Trackback/Services/Trackback/SpamCheck.php:1.8
pear/Services_Trackback/Services/Trackback/SpamCheck.php:1.9
--- pear/Services_Trackback/Services/Trackback/SpamCheck.php:1.8 Tue May 24 11:25:49 2005
+++ pear/Services_Trackback/Services/Trackback/SpamCheck.php Thu Feb 9 19:09:37 2006
@@ -24,7 +24,7 @@
* @author Tobias Schlitt <toby@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: SpamCheck.php,v 1.8 2005/05/24 11:25:49 toby Exp $
+ * @version CVS: $Id: SpamCheck.php,v 1.9 2006/02/09 19:09:37 toby Exp $
* @link http://pear.php.net/package/Services_Trackback
* @since File available since Release 0.5.0
*/
@@ -115,8 +115,8 @@
if (!class_exists($classname)) {
return PEAR::raiseError('SpamCheck ' . $type . ' not found.');
}
-
- return new $classname(@$options);
+ $res = new $classname(@$options);
+ return $res;
}
// }}}
@@ -141,6 +141,7 @@
if ($spam && !$this->_options['continuose']) {
// We already found spam and shall not continue
$this->_results[$id] = false;
+ break;
} else {
$this->_results[$id] =
$this->_checkSource($this->_options['sources'][$id], $trackback);
$spam = ($spam || $this->_results[$id]);
http://cvs.php.net/viewcvs.cgi/pear/Services_Trackback/test/Services_Trackback_Test.php?r1=1.5&r2=1.6&diff_format=u
Index: pear/Services_Trackback/test/Services_Trackback_Test.php
diff -u pear/Services_Trackback/test/Services_Trackback_Test.php:1.5
pear/Services_Trackback/test/Services_Trackback_Test.php:1.6
--- pear/Services_Trackback/test/Services_Trackback_Test.php:1.5 Tue May 24 07:29:04 2005
+++ pear/Services_Trackback/test/Services_Trackback_Test.php Thu Feb 9 19:09:37 2006
@@ -307,7 +307,7 @@
global $trackbackData;
$trackback = Services_Trackback::create($trackbackData['nospam']);
$url = 'http://www.example.com';
- $res = <<<EOD
+ $fakeRes = <<<EOD
<HTML>
<HEAD>
<TITLE>Example Web Page</TITLE>
@@ -322,8 +322,14 @@
</BODY>
</HTML>
EOD;
+
+ $res = $trackback->_getContent($url);
+ if (PEAR::isError($res)) {
+ $this->fail($res->getMessage());
+ return;
+ }
- $this->assertTrue(trim($trackback->_getContent($url)) == trim($res));
+ $this->assertTrue(trim($res) == trim($fakeRes));
}
// }}}
http://cvs.php.net/viewcvs.cgi/pear/Services_Trackback/test/Services_Trackback_TestAll.php?r1=1.2&r2=1.3&diff_format=u
Index: pear/Services_Trackback/test/Services_Trackback_TestAll.php
diff -u pear/Services_Trackback/test/Services_Trackback_TestAll.php:1.2
pear/Services_Trackback/test/Services_Trackback_TestAll.php:1.3
--- pear/Services_Trackback/test/Services_Trackback_TestAll.php:1.2 Mon May 23 14:26:25 2005
+++ pear/Services_Trackback/test/Services_Trackback_TestAll.php Thu Feb 9 19:09:37 2006
@@ -1,5 +1,9 @@
<?php
+if (isset($argc[2]) && $argc[2] == 'dev') {
+ ini_set('include_path',
dirname(__FILE__).PATH_SEPERATOR.ini_get('include_path'));
+}
+
echo "\n\nRunning test suite for Services_Trackback\n\n";
require_once 'Services_Trackback_Test.php';