]> granicus.if.org Git - php/commitdiff
FTP test from Nathaniel McHugh
authorZoe Slattery <zoe@php.net>
Fri, 5 Dec 2008 16:27:41 +0000 (16:27 +0000)
committerZoe Slattery <zoe@php.net>
Fri, 5 Dec 2008 16:27:41 +0000 (16:27 +0000)
ext/ftp/tests/ftp_mdtm_basic.phpt [new file with mode: 0644]
ext/ftp/tests/server.inc

diff --git a/ext/ftp/tests/ftp_mdtm_basic.phpt b/ext/ftp/tests/ftp_mdtm_basic.phpt
new file mode 100644 (file)
index 0000000..c8ff2d8
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+Test the File Modification Time as described in http://tools.ietf.org/html/rfc3659#section-3.1
+--XFAIL--
+Fails because of missing Unicode implemetation in PHP6
+--CREDITS--
+Nathaniel McHugh 
+--SKIPIF--
+<?php
+require 'skipif.inc';
+?>
+--FILE--
+<?php
+
+require 'server.inc';
+
+$ftp = ftp_connect('127.0.0.1', $port);
+if (!$ftp) die("Couldn't connect to the server");
+
+var_dump(ftp_login($ftp, 'user', 'pass'));
+
+
+date_default_timezone_set('UTC');
+
+$time = ftp_mdtm($ftp, "A");
+echo date("F d Y H:i:s u",$time), PHP_EOL;
+
+$time = ftp_mdtm($ftp, "B");
+echo date("F d Y H:i:s u",$time), PHP_EOL;
+
+$time = ftp_mdtm($ftp, "C");
+echo date("F d Y H:i:s u",$time), PHP_EOL;
+
+$time = ftp_mdtm($ftp, "D");
+var_dump($time);
+
+$time = ftp_mdtm($ftp, "19990929043300 File6");
+echo date("F d Y H:i:s u",$time), PHP_EOL;
+
+$time = ftp_mdtm($ftp, "MdTm 19990929043300 file6");
+var_dump($time);
+
+?>
+--EXPECTF--
+bool(true)
+June 15 1998 10:00:45 000000
+June 15 1998 10:00:45 000000
+July 05 1998 13:23:16 000000
+int(-1)
+October 05 1999 21:31:02 000000
+int(-1)
index c101c7c70f680de8a971e9827942bbdcccebbd17..bf11257af0cef77d0eb06de39b4d67f75c7b3503 100644 (file)
@@ -244,7 +244,26 @@ while($buf = fread($s, 4098)) {
        } elseif (preg_match('/^USER /', $buf)) {
                user_auth($buf);
 
-       } else {
+       } elseif (preg_match('/^MDTM ([\w\h]+)/', $buf, $matches)) {
+               switch ($matches [1]){
+                       case "A":
+                               fputs($s, "213 19980615100045.014\r\n");
+                               break;
+                       case "B":
+                               fputs($s, "213 19980615100045.014\r\n");
+                               break;
+                       case "C":
+                               fputs($s, "213 19980705132316\r\n");
+                               break;
+                       case "19990929043300 File6":
+                               fputs($s, "213 19991005213102\r\n");
+                               break;
+                       default :
+                               fputs($s, "550 No file named \"{$matches [1]}\"\r\n");
+                               break;
+               }
+       }       
+       else {
                fputs($s, "500 Syntax error, command unrecognized.\r\n");
                dump_and_exit($buf);
        }