示例#1
0
文件: MAIL5.php 项目: voitto/dbscript
 public function name($host = null, $debug = null)
 {
     if (!FUNC5::is_debug($debug)) {
         $debug = debug_backtrace();
     }
     if (!is_string($host)) {
         FUNC5::trace($debug, 'invalid hostname type');
     } else {
         $host = strtolower(trim($host));
         if (!($host != '' && ($host == 'localhost' || FUNC5::is_ipv4($host) || FUNC5::is_hostname($host, true, $debug)))) {
             FUNC5::trace($debug, 'invalid hostname value');
         }
         $this->Name = $host;
         return $this->_result(array(0 => 'set HELO/EHLO hostname'), true);
     }
 }
示例#2
0
 function test_connection($pop3fetcher_username, $pop3fetcher_password, $pop3fetcher_serveraddress, $pop3fetcher_serverport, $pop3fetcher_ssl)
 {
     define('DISPLAY_XPM4_ERRORS', false);
     // display XPM4 errors
     require_once './plugins/pop3fetcher/XPM4/POP35.php';
     require_once './plugins/pop3fetcher/XPM4/FUNC5.php';
     $pop3fetcher_serverport = intval($pop3fetcher_serverport);
     if ($this->config["debug"]) {
         write_log("pop3fetcher.txt", "TESTING CONNECTION: {$pop3fetcher_username}, {$pop3fetcher_password}, {$pop3fetcher_serveraddress}, {$pop3fetcher_serverport}, {$pop3fetcher_ssl}");
     }
     if ($pop3fetcher_serverport > 0 && FUNC5::is_hostname($pop3fetcher_serveraddress, true)) {
         $c = POP35::connect($pop3fetcher_serveraddress, $pop3fetcher_username, $pop3fetcher_password, $pop3fetcher_serverport, $pop3fetcher_ssl, 100, NULL, false);
         if ($c) {
             if ($this->config["debug"]) {
                 write_log("pop3fetcher.txt", "TESTING CONNECTION: SUCCESS {$pop3fetcher_serveraddress}:{$pop3fetcher_serverport}");
             }
             POP35::disconnect($c, false);
             return true;
         } else {
             if ($this->config["debug"]) {
                 write_log("pop3fetcher.txt", "TESTING CONNECTION: FAIL {$pop3fetcher_serveraddress}:{$pop3fetcher_serverport}");
             }
             return false;
         }
     } else {
         if ($this->config["debug"]) {
             write_log("pop3fetcher.txt", "TESTING CONNECTION: FAIL {$pop3fetcher_serveraddress}:{$pop3fetcher_serverport}");
         }
         return false;
     }
 }
示例#3
0
 public static function connect($host = null, $user = null, $pass = null, $port = null, $vssl = null, $tout = null, $context = null, $debug = null)
 {
     if (!FUNC5::is_debug($debug)) {
         $debug = debug_backtrace();
     }
     global $_RESULT;
     $_RESULT = array();
     if ($port == null) {
         $port = self::PORT;
     }
     if ($tout == null) {
         $tout = self::TOUT;
     }
     $err = array();
     if (!is_string($host)) {
         $err[] = 'invalid host type';
     } else {
         if (!(trim($host) != '' && (FUNC5::is_ipv4($host) || FUNC5::is_hostname($host, true, $debug)))) {
             $err[] = 'invalid host value';
         }
     }
     if (!is_string($user)) {
         $err[] = 'invalid username type';
     } else {
         if (($user = FUNC5::str_clear($user)) == '') {
             $err[] = 'invalid username value';
         }
     }
     if (!is_string($pass)) {
         $err[] = 'invalid password type';
     } else {
         if (($pass = FUNC5::str_clear($pass)) == '') {
             $err[] = 'invalid password value';
         }
     }
     if (!(is_int($port) && $port > 0)) {
         $err[] = 'invalid port value';
     }
     if ($vssl != null) {
         if (!is_string($vssl)) {
             $err[] = 'invalid ssl version type';
         } else {
             $vssl = strtolower($vssl);
             if (!($vssl == 'tls' || $vssl == 'ssl' || $vssl == 'sslv2' || $vssl == 'sslv3')) {
                 $err[] = 'invalid ssl version value';
             }
         }
     }
     if (!(is_int($tout) && $tout > 0)) {
         $err[] = 'invalid timeout value';
     }
     if ($context != null && !is_resource($context)) {
         $err[] = 'invalid context type';
     }
     if (count($err) > 0) {
         FUNC5::trace($debug, implode(', ', $err));
     } else {
         $ret = false;
         $prt = $vssl == null ? 'tcp' : $vssl;
         $conn = $context == null ? stream_socket_client($prt . '://' . $host . ':' . $port, $errno, $errstr, $tout) : stream_socket_client($prt . '://' . $host . ':' . $port, $errno, $errstr, $tout, STREAM_CLIENT_CONNECT, $context);
         if (!$conn) {
             $_RESULT[401] = $errstr;
         } else {
             if (!stream_set_timeout($conn, self::COUT)) {
                 $_RESULT[402] = 'could not set stream timeout';
             } else {
                 if (!self::_ok($conn, $resp, $debug)) {
                     $_RESULT[403] = $resp;
                 } else {
                     $ret = self::auth($conn, $user, $pass, $debug);
                 }
             }
         }
         if (!$ret) {
             if (is_resource($conn)) {
                 @fclose($conn);
             }
             $conn = false;
         }
         return $conn;
     }
 }
示例#4
0
文件: SMTP5.php 项目: voitto/dbscript
 public static function ehlo($conn = null, $host = null, $debug = null)
 {
     if (!FUNC5::is_debug($debug)) {
         $debug = debug_backtrace();
     }
     global $_RESULT;
     $_RESULT = $err = array();
     if (!is_resource($conn)) {
         $err[] = 'invalid resource connection';
     }
     if (!is_string($host)) {
         $err[] = 'invalid host type';
     } else {
         $host = strtolower(trim($host));
         if (!($host != '' && ($host == 'localhost' || FUNC5::is_ipv4($host) || FUNC5::is_hostname($host, true, $debug)))) {
             $err[] = 'invalid host value';
         }
     }
     if (count($err) > 0) {
         FUNC5::trace($debug, implode(', ', $err));
     } else {
         $ret = false;
         if (!fwrite($conn, 'EHLO ' . $host . self::CRLF)) {
             $_RESULT[307] = 'can not write';
         } else {
             if (!self::_cres($conn, $resp, 250, null, $debug)) {
                 $_RESULT[308] = $resp;
             } else {
                 $_RESULT[309] = $resp;
                 $ret = true;
             }
         }
         return $ret;
     }
 }