forked from halo-battle/game
Ajout d'une étape de linting dans DroneCi (#3)
Corrige un doublons laissé par le rebase semi-manuel Ajout d'une étape de linting dans DroneCi Fix linting Co-authored-by: Nigel Sheldon <nigelsheldon@live.fr> Reviewed-on: https://gitea.nemunai.re/halo-battle/game/pulls/3
This commit is contained in:
parent
5b17a7dbd7
commit
dd61d3b66b
263 changed files with 45327 additions and 42695 deletions
|
|
@ -27,26 +27,26 @@ class SMTP
|
|||
* SMTP server port
|
||||
* @var int
|
||||
*/
|
||||
var $SMTP_PORT = 25;
|
||||
public $SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* SMTP reply line ending
|
||||
* @var string
|
||||
*/
|
||||
var $CRLF = "\r\n";
|
||||
public $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Sets whether debugging is turned on
|
||||
* @var bool
|
||||
*/
|
||||
var $do_debug; # the level of debug to perform
|
||||
public $do_debug; # the level of debug to perform
|
||||
|
||||
/**#@+
|
||||
* @access private
|
||||
*/
|
||||
var $smtp_conn; # the socket to the server
|
||||
var $error; # error if any on the last call
|
||||
var $helo_rply; # the reply the server sent to us for HELO
|
||||
public $smtp_conn; # the socket to the server
|
||||
public $error; # error if any on the last call
|
||||
public $helo_rply; # the reply the server sent to us for HELO
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,8 @@ class SMTP
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function SMTP() {
|
||||
public function SMTP()
|
||||
{
|
||||
$this->smtp_conn = 0;
|
||||
$this->error = null;
|
||||
$this->helo_rply = null;
|
||||
|
|
@ -79,12 +80,13 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Connect($host,$port=0,$tval=30) {
|
||||
public function Connect($host, $port=0, $tval=30)
|
||||
{
|
||||
# set the error val to null so there is no confusion
|
||||
$this->error = null;
|
||||
|
||||
# make sure we are __not__ connected
|
||||
if($this->connected()) {
|
||||
if ($this->connected()) {
|
||||
# ok we are connected! what should we do?
|
||||
# for now we will just give an error saying we
|
||||
# are already connected
|
||||
|
|
@ -93,7 +95,7 @@ class SMTP
|
|||
return false;
|
||||
}
|
||||
|
||||
if(empty($port)) {
|
||||
if (empty($port)) {
|
||||
$port = $this->SMTP_PORT;
|
||||
}
|
||||
|
||||
|
|
@ -104,11 +106,11 @@ class SMTP
|
|||
$errstr, # error message if any
|
||||
$tval); # give up after ? secs
|
||||
# verify we connected properly
|
||||
if(empty($this->smtp_conn)) {
|
||||
if (empty($this->smtp_conn)) {
|
||||
$this->error = array("error" => "Failed to connect to server",
|
||||
"errno" => $errno,
|
||||
"errstr" => $errstr);
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": $errstr ($errno)" . $this->CRLF;
|
||||
}
|
||||
|
|
@ -118,8 +120,9 @@ class SMTP
|
|||
# sometimes the SMTP server takes a little longer to respond
|
||||
# so we will give it a longer timeout for the first read
|
||||
// Windows still does not have support for this timeout function
|
||||
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
if (substr(PHP_OS, 0, 3) != "WIN") {
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
}
|
||||
|
||||
# get any announcement stuff
|
||||
$announce = $this->get_lines();
|
||||
|
|
@ -128,7 +131,7 @@ class SMTP
|
|||
//if(function_exists("socket_set_timeout"))
|
||||
// socket_set_timeout($this->smtp_conn, 0, 100000);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
|
||||
}
|
||||
|
||||
|
|
@ -141,19 +144,20 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Authenticate($username, $password) {
|
||||
public function Authenticate($username, $password)
|
||||
{
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "AUTH LOGIN" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 334) {
|
||||
if ($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -164,14 +168,14 @@ class SMTP
|
|||
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 334) {
|
||||
if ($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "Username not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -182,14 +186,14 @@ class SMTP
|
|||
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 235) {
|
||||
if ($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Password not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -204,13 +208,14 @@ class SMTP
|
|||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function Connected() {
|
||||
if(!empty($this->smtp_conn)) {
|
||||
public function Connected()
|
||||
{
|
||||
if (!empty($this->smtp_conn)) {
|
||||
$sock_status = socket_get_status($this->smtp_conn);
|
||||
if($sock_status["eof"]) {
|
||||
if ($sock_status["eof"]) {
|
||||
# hmm this is an odd situation... the socket is
|
||||
# valid but we aren't connected anymore
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE:" . $this->CRLF .
|
||||
"EOF caught while checking if connected";
|
||||
}
|
||||
|
|
@ -229,10 +234,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function Close() {
|
||||
public function Close()
|
||||
{
|
||||
$this->error = null; # so there is no confusion
|
||||
$this->helo_rply = null;
|
||||
if(!empty($this->smtp_conn)) {
|
||||
if (!empty($this->smtp_conn)) {
|
||||
# close the connection and cleanup
|
||||
fclose($this->smtp_conn);
|
||||
$this->smtp_conn = 0;
|
||||
|
|
@ -263,30 +269,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Data($msg_data) {
|
||||
public function Data($msg_data)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Data() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"DATA" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "DATA" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 354) {
|
||||
if ($code != 354) {
|
||||
$this->error =
|
||||
array("error" => "DATA command not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -304,9 +311,9 @@ class SMTP
|
|||
# line. NOTE: this does not count towards are limit.
|
||||
|
||||
# normalize the line breaks so we know the explode works
|
||||
$msg_data = str_replace("\r\n","\n",$msg_data);
|
||||
$msg_data = str_replace("\r","\n",$msg_data);
|
||||
$lines = explode("\n",$msg_data);
|
||||
$msg_data = str_replace("\r\n", "\n", $msg_data);
|
||||
$msg_data = str_replace("\r", "\n", $msg_data);
|
||||
$lines = explode("\n", $msg_data);
|
||||
|
||||
# we need to find a good way to determine is headers are
|
||||
# in the msg_data or if it is a straight msg body
|
||||
|
|
@ -315,43 +322,42 @@ class SMTP
|
|||
# does not contain a space then it _should_ be a header
|
||||
# and we can process all lines before a blank "" line as
|
||||
# headers.
|
||||
$field = substr($lines[0],0,strpos($lines[0],":"));
|
||||
$field = substr($lines[0], 0, strpos($lines[0], ":"));
|
||||
$in_headers = false;
|
||||
if(!empty($field) && !strstr($field," ")) {
|
||||
if (!empty($field) && !strstr($field, " ")) {
|
||||
$in_headers = true;
|
||||
}
|
||||
|
||||
$max_line_length = 998; # used below; set here for ease in change
|
||||
|
||||
while(list(,$line) = @each($lines)) {
|
||||
while (list(, $line) = @each($lines)) {
|
||||
$lines_out = null;
|
||||
if($line == "" && $in_headers) {
|
||||
if ($line == "" && $in_headers) {
|
||||
$in_headers = false;
|
||||
}
|
||||
# ok we need to break this line up into several
|
||||
# smaller lines
|
||||
while(strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line,0,$max_line_length)," ");
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos + 1);
|
||||
while (strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line, 0, $max_line_length), " ");
|
||||
$lines_out[] = substr($line, 0, $pos);
|
||||
$line = substr($line, $pos + 1);
|
||||
# if we are processing headers we need to
|
||||
# add a LWSP-char to the front of the new line
|
||||
# rfc 822 on long msg headers
|
||||
if($in_headers) {
|
||||
if ($in_headers) {
|
||||
$line = "\t" . $line;
|
||||
}
|
||||
}
|
||||
$lines_out[] = $line;
|
||||
|
||||
# now send the lines to the server
|
||||
while(list(,$line_out) = @each($lines_out)) {
|
||||
if(strlen($line_out) > 0)
|
||||
{
|
||||
if(substr($line_out, 0, 1) == ".") {
|
||||
while (list(, $line_out) = @each($lines_out)) {
|
||||
if (strlen($line_out) > 0) {
|
||||
if (substr($line_out, 0, 1) == ".") {
|
||||
$line_out = "." . $line_out;
|
||||
}
|
||||
}
|
||||
fputs($this->smtp_conn,$line_out . $this->CRLF);
|
||||
fputs($this->smtp_conn, $line_out . $this->CRLF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -360,18 +366,18 @@ class SMTP
|
|||
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "DATA not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -396,30 +402,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return string array
|
||||
*/
|
||||
function Expand($name) {
|
||||
public function Expand($name)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Expand() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
|
||||
fputs($this->smtp_conn, "EXPN " . $name . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "EXPN not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -427,9 +434,9 @@ class SMTP
|
|||
}
|
||||
|
||||
# parse the reply and place in our array to return to user
|
||||
$entries = explode($this->CRLF,$rply);
|
||||
while(list(,$l) = @each($entries)) {
|
||||
$list[] = substr($l,4);
|
||||
$entries = explode($this->CRLF, $rply);
|
||||
while (list(, $l) = @each($entries)) {
|
||||
$list[] = substr($l, 4);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
@ -447,10 +454,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Hello($host="") {
|
||||
public function Hello($host="")
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Hello() without being connected");
|
||||
return false;
|
||||
|
|
@ -458,17 +466,17 @@ class SMTP
|
|||
|
||||
# if a hostname for the HELO wasn't specified determine
|
||||
# a suitable one to send
|
||||
if(empty($host)) {
|
||||
if (empty($host)) {
|
||||
# we need to determine some sort of appopiate default
|
||||
# to send to the server
|
||||
$host = "localhost";
|
||||
}
|
||||
|
||||
// Send extended hello first (RFC 2821)
|
||||
if(!$this->SendHello("EHLO", $host))
|
||||
{
|
||||
if(!$this->SendHello("HELO", $host))
|
||||
if (!$this->SendHello("EHLO", $host)) {
|
||||
if (!$this->SendHello("HELO", $host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -479,22 +487,23 @@ class SMTP
|
|||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function SendHello($hello, $host) {
|
||||
public function SendHello($hello, $host)
|
||||
{
|
||||
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => $hello . " not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -521,35 +530,36 @@ class SMTP
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function Help($keyword="") {
|
||||
public function Help($keyword="")
|
||||
{
|
||||
$this->error = null; # to avoid confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Help() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
$extra = "";
|
||||
if(!empty($keyword)) {
|
||||
if (!empty($keyword)) {
|
||||
$extra = " " . $keyword;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
|
||||
fputs($this->smtp_conn, "HELP" . $extra . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 211 && $code != 214) {
|
||||
if ($code != 211 && $code != 214) {
|
||||
$this->error =
|
||||
array("error" => "HELP not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -573,30 +583,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Mail($from) {
|
||||
public function Mail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Mail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "MAIL FROM:<" . $from . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "MAIL not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -615,30 +626,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Noop() {
|
||||
public function Noop()
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Noop() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"NOOP" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "NOOP" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "NOOP not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -658,42 +670,43 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Quit($close_on_error=true) {
|
||||
public function Quit($close_on_error=true)
|
||||
{
|
||||
$this->error = null; # so there is no confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Quit() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
# send the quit command to the server
|
||||
fputs($this->smtp_conn,"quit" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "quit" . $this->CRLF);
|
||||
|
||||
# get any good-bye messages
|
||||
$byemsg = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
|
||||
}
|
||||
|
||||
$rval = true;
|
||||
$e = null;
|
||||
|
||||
$code = substr($byemsg,0,3);
|
||||
if($code != 221) {
|
||||
$code = substr($byemsg, 0, 3);
|
||||
if ($code != 221) {
|
||||
# use e as a tmp var cause Close will overwrite $this->error
|
||||
$e = array("error" => "SMTP server rejected quit command",
|
||||
"smtp_code" => $code,
|
||||
"smtp_rply" => substr($byemsg,4));
|
||||
"smtp_rply" => substr($byemsg, 4));
|
||||
$rval = false;
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $e["error"] . ": " .
|
||||
$byemsg . $this->CRLF;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($e) || $close_on_error) {
|
||||
if (empty($e) || $close_on_error) {
|
||||
$this->Close();
|
||||
}
|
||||
|
||||
|
|
@ -712,30 +725,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Recipient($to) {
|
||||
public function Recipient($to)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Recipient() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
if ($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "RCPT not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -756,30 +770,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Reset() {
|
||||
public function Reset()
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Reset() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RSET" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "RSET" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "RSET failed",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -805,30 +820,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Send($from) {
|
||||
public function Send($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Send() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SEND FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SEND not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -853,30 +869,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function SendAndMail($from) {
|
||||
public function SendAndMail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendAndMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SAML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SAML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -901,30 +918,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function SendOrMail($from) {
|
||||
public function SendOrMail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendOrMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SOML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SOML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -946,10 +964,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Turn() {
|
||||
public function Turn()
|
||||
{
|
||||
$this->error = array("error" => "This method, TURN, of the SMTP ".
|
||||
"is not implemented");
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -968,30 +987,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
function Verify($name) {
|
||||
public function Verify($name)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Verify() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
|
||||
fputs($this->smtp_conn, "VRFY " . $name . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
if ($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "VRFY failed on name '$name'",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -1013,27 +1033,26 @@ class SMTP
|
|||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function get_lines() {
|
||||
public function get_lines()
|
||||
{
|
||||
$data = "";
|
||||
while($str = fgets($this->smtp_conn,515)) {
|
||||
if($this->do_debug >= 4) {
|
||||
while ($str = fgets($this->smtp_conn, 515)) {
|
||||
if ($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data was \"$data\"" .
|
||||
$this->CRLF;
|
||||
echo "SMTP -> get_lines(): \$str is \"$str\"" .
|
||||
$this->CRLF;
|
||||
}
|
||||
$data .= $str;
|
||||
if($this->do_debug >= 4) {
|
||||
if ($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
|
||||
}
|
||||
# if the 4th character is a space then we are done reading
|
||||
# so just break the loop
|
||||
if(substr($str,3,1) == " ") { break; }
|
||||
if (substr($str, 3, 1) == " ") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue