Home » Networking » Net_NNTP » Bug #817
post() doesnt work (v0.2.3)
Details
| Submitted | 2004-02-21 01:20 UTC |
|---|---|
| From | jake at braingle dot com |
| Assigned | heino |
| Status | Closed |
| Package | Net_NNTP |
| PHP Version | 4.3.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2004-02-21 01:20 UTC] jake at braingle dot com
Description:
------------
The post method does not work in the stable version (0.2.3). To fix it, you need to make the make the lines terminate with \r and \n like so:
fputs($this->fp, "Newsgroups: $newsgroup\r\n");
fputs($this->fp, "Subject: $subject\r\n");
...
Also, this function will not work with news servers that require authentication. To fix that, I added this line to the top of the post function:
$error = $this->authenticate($this->user, $this->pass, $this->authmode);
now it works. :)
Reproduce code:
---------------
$response = $nntp->post($subject, $group, $from, $body);
Expected result:
----------------
the message would be posted
Actual result:
--------------
the message is not posted
[2004-02-21 23:08 UTC] heino at php dot net
How about replacing line 261-276 with something like (not tested, since I'm rather busy):
---------------------------------------------------------
$r = $this->command('POST');
if (PEAR::isError($r) || $this->responseCode($r) != 340) {
return $this->raiseError($r);
}
$data = '';
$data .= "From: $from\r\n";
$data .= "Newsgroups: $newsgroup\r\n";
$data .= "Subject: $subject\r\n";
$data .= "X-poster: PEAR::Net_NNTP (0.2) by Martin Kaltoft\r\n";
if (!empty($aditional)) {
$data .= rtrim($aditional, "\r\n")."\r\n";
}
$data .= "\r\n";
$data .= "$body\r\n";
$data .= ".";
return $this->command($data, false);
---------------------------------------------------------
[2004-02-22 00:09 UTC] jake at braingle dot com
Yes, I believe that would fix it.