#42982 [Opn->Bgs]: FGETS Crash using FSOCKOPEN
| From: | johannes@php.net | Date: | Tue, 16 Oct 2007 20:37:40 +0000 |
| Subject: | #42982 [Opn->Bgs]: FGETS Crash using FSOCKOPEN | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118602@lists.php.net to get a copy of this message | ||
ID: 42982
Updated by: johannes@php.net
Reported By: mkz at terra dot com dot br
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Windows XP Professional
PHP Version: 5.2.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2007-10-15 20:49:04] mkz at terra dot com dot br
Description:
------------
Fgets function cause a fatal error in script.
Reproduce code:
---------------
<?
class Smtp{
//Creditos: Red neck adaptada por Micael Vianna (http://aiatola.net)
var $conn;
var $user;
var $pass;
var $html;
var $debug = true;
var $logado = false;
var $erro;
function Smtp($host,$porta){
$this->conn = fsockopen($host, $porta, $errno, $errstr, 30);
$this->Put("EHLO $host");
}
function Auth(){
$this->Put("AUTH LOGIN");
$this->Put(base64_encode($this->user));
$this->Put(base64_encode($this->pass));
}
function Send($toName, $to, $fromName, $from, $replyTo, $subject,
$msg)
{
if(isset($this->conn))
{
// se nao estiver logado, loga
if (!$this->logado)
{
$this->Auth();
$this->logado = true;
}
$this->Put("MAIL FROM: <" . $from.">");
$this->Put("RCPT TO: <" . $to.">");
$this->Put("DATA");
$this->Put($this->toHeader($toName."<".$to.">",
$fromName."<".$from.">",
$fromName."<".$replyTo.">", $subject));
$this->Put("\r\n");
$this->Put($msg);
$this->Put(".");
$i = 0;
$dados = $this->conn;
}
else
return false;
while (!feof ($dados) || $this->conn)
{
flush();
$buffer = fgets($this->conn, 4096);
}
}
function Put($value){
return fputs($this->conn, $value . "\r\n");
echo $this->conn;
}
function getRetorno($valor)
{
return $valor{0}.$valor{1}.$valor{2};
}
function toHeader($to, $from, $replyTo, $subject){
$header = "Message-Id: <". date('YmdHis').".".
md5(microtime()).".". strtoupper($from) ."> \r\n";
$header .= "From: ". $from . " \r\n";
$header .= "To: ".$to." \r\n";
$header .= "Reply-To: ".$replyTo."\r\n";
$header .= "Subject: ".$subject." \r\n";
$header .= "Date: ". date('D, d M Y H:i:s O') ." \r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1 \r\n";
$header .= "X-MSMail-Priority: High \r\n";
return $header;
}
function Close(){
$this->Put("QUIT");
return fclose($this->conn);
}
function getErro()
{
return $this->erro;
}
}
set_time_limit(10);
require_once('../modulos/addons/smtp/class.smtp.php');
$smtp = new Smtp("YOUR SMTP SERVER",25);
$smtp->debug = false;
$smtp->user = "YOUR SMTP USERNAME";
$smtp->pass = "YOUR SMTP PASSWORD";
if ($smtp->Send('micael','YOUR EMAIL','fulano','YOUR
EMAIL','REPLY','Super
promo��o',"<html><body><table><tr><td>oi</td><td>tudo</td></tr></table></body></html>"))
{ echo "ok"; }
else
{
echo "ERRO".$smtp->getErro();
}
$smtp->Close();
?>
Expected result:
----------------
List all status from SMTP connect :)
Actual result:
--------------
Fatal error: Maximum execution time of 10 seconds exceeded line 46
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42982&edit=1