You are not logged in.
- Topics: Active | Unanswered
Pages: 1
#1 2010-01-11 11:17 am
- Hotaru
- Member
- Registered: 2009-11-08
- Posts: 2
My Spammers not showing my submissions
Hi all,
Really great service this. I've made a plugin for HotaruCMS.org, but I'm struggling at the last hurdle.
Using the API, I submit the spammers details, but he doesn't show up in My Spammers. I've used two different HTTP classes and both return "success". Here's the function I'm using:
/**
* Add spammer to the StopForumSpam.com database
*/
public function addSpammer($ip = '', $username = '', $email = '', $apikey = '')
{
if (!$ip || !$username || !$email || !$apikey || $ip == '127.0.0.1') { return false; }
$url = "http://www.stopforumspam.com/post.php?";
$url .= "username=" . urlencode($username);
$url .= "&ip_addr=" . $ip;
$url .= "&email=" . urlencode($email);
$url .= "&api_key=" . $apikey;
echo $url . "<br />";
/*
// Old method:
require_once(EXTENSIONS . 'SWCMS/class.httprequest.php');
$r = new HTTPRequest($url);
$error = $r->DownloadToString();
if (!$error) { echo "Success"; } else { echo $error; }
*/
// New method:
// http://www.phpfour.com/blog/2008/01/php-http-class/
require_once(EXTENSIONS . 'http/class.http.php');
$http = new Http();
$http->execute($url);
if (!$http->error) { echo "Success"; } else { echo $http->error; }
exit;
}And here's the (edited) output:
Maybe there's just a delay? Can you spot anything odd, or do we need to delve into the classes I'm using?
Thanks guys!
Nick.
Offline
#2 2010-01-11 11:53 am
- pedigree
- uıɐbɐ ʎɐqǝ ɯoɹɟ pɹɐoqʎǝʞ ɐ buıʎnq ɹǝʌǝu ɯ,ı
- From: Londonderry
- Registered: 2008-04-16
- Posts: 4,445
Re: My Spammers not showing my submissions
Change post.php to add.php
Youre passing GET url params to a php file that only accepts POST data
if you wish to POST data to post.php, here is a function that will allow you do it without too much trouble
As your class appears (from what I can see) to return a true/false as to the result of the class being able to connect to our site, then your function works, however the post page just exits(); when no post data is found.
<?php
function file_post_contents($url,$headers=false) {
$url = parse_url($url);
if (!isset($url['port'])) {
if ($url['scheme'] == 'http') { $url['port']=80; }
elseif ($url['scheme'] == 'https') { $url['port']=443; }
}
$url['query']=isset($url['query'])?$url['query']:'';
$url['protocol']=$url['scheme'].'://';
$eol="\r\n";
$headers = "POST ".$url['protocol'].$url['host'].$url['path']." HTTP/1.0".$eol.
"Host: ".$url['host'].$eol.
"Referer: ".$url['protocol'].$url['host'].$url['path'].$eol.
"Content-Type: application/x-www-form-urlencoded".$eol.
"Content-Length: ".strlen($url['query']).$eol.
$eol.$url['query'];
$fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
if($fp) {
fputs($fp, $headers);
$result = '';
while(!feof($fp)) { $result .= fgets($fp, 128); }
fclose($fp);
if (!$headers) {
//removes headers
$pattern="/^.*\r\n\r\n/s";
$result=preg_replace($pattern,'',$result);
}
return $result;
}
}
?>Offline
#3 2010-01-12 12:40 am
- Hotaru
- Member
- Registered: 2009-11-08
- Posts: 2
Re: My Spammers not showing my submissions
I changed post.php to add.php and it worked fine. Thank you very much for your help!
Last edited by Hotaru (2010-01-12 12:40 am)
Offline
#4 2010-02-15 4:50 pm
- stevemagruder
- Member
- From: Louisville, Kentucky USA
- Registered: 2010-01-31
- Posts: 10
- Website
Re: My Spammers not showing my submissions
FYI... the example on the page http://www.stopforumspam.com/apis shows post.php instead of add.php.
Steve Magruder - Administrator of Louisville History & Issues and New Media Developer, WebCommons :: Media
Offline
#5 2010-02-15 6:56 pm
- pedigree
- uıɐbɐ ʎɐqǝ ɯoɹɟ pɹɐoqʎǝʞ ɐ buıʎnq ɹǝʌǝu ɯ,ı
- From: Londonderry
- Registered: 2008-04-16
- Posts: 4,445
Re: My Spammers not showing my submissions
Yes, and was I mentioned in another thread, Im fixing the code and the pages
but for a quick fix, ive changed the apis page
Offline
#6 2010-02-16 4:39 pm
- stevemagruder
- Member
- From: Louisville, Kentucky USA
- Registered: 2010-01-31
- Posts: 10
- Website
Re: My Spammers not showing my submissions
Thank you kindly. I didn't see the other thread.
Steve Magruder - Administrator of Louisville History & Issues and New Media Developer, WebCommons :: Media
Offline
Pages: 1




