OSDN Git Service

Renamed sanitize() => input_filter(), to avoid misunderstanding
[pukiwiki/pukiwiki.git] / mail.php
index cef79ce..590c3bb 100644 (file)
--- a/mail.php
+++ b/mail.php
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: mail.php,v 1.5 2004/07/17 13:24:27 henoheno Exp $
+// $Id: mail.php,v 1.7 2004/07/17 15:17:48 henoheno Exp $
 //
 
 // APOP/POP Before SMTP
@@ -35,7 +35,7 @@ function pop_before_smtp($pop_userid = '', $pop_passwd = '',
 
        // Greeting message from server, may include <challenge-string> of APOP
        $message = fgets($fp, 1024); // 512byte max
-       if (! preg_match('/^\+OK /', $message)) {
+       if (! preg_match('/^\+OK/', $message)) {
                fclose($fp);
                return ("pop_before_smtp(): Greeting message seems invalid");
        }
@@ -54,20 +54,26 @@ function pop_before_smtp($pop_userid = '', $pop_passwd = '',
                $method = 'POP'; // POP auth
                fputs($fp, 'USER ' . $pop_userid . "\r\n");
                $message = fgets($fp, 1024); // 512byte max
-               if (! preg_match('/^\+OK /', $message)) {
+               if (! preg_match('/^\+OK/', $message)) {
                        fclose($fp);
                        return ("pop_before_smtp(): USER seems invalid");
                }
                fputs($fp, 'PASS ' . $pop_passwd . "\r\n");
        }
+
        $result = fgets($fp, 1024); // 512byte max, auth result
+       $auth   = preg_match('/^\+OK/', $result);
+       if ($auth) {
+               fputs($fp, "STAT\r\n"); // STAT, trigger SMTP relay!
+               $message = fgets($fp, 1024); // 512byte max
+       }
 
        // Disconnect
        fputs($fp, "QUIT\r\n");
        $message = fgets($fp, 1024); // 512byte max, last "+OK"
        fclose($fp);
 
-       if (! preg_match('/^\+OK /', $result)) {
+       if (! $auth) {
                return ("pop_before_smtp(): $method authentication failed");
        } else {
                return TRUE;    // Success