Annotation of embedaddon/php/ext/curl/tests/curl_ftp_pasv.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test curl_exec() function with basic functionality
! 3: --CREDITS--
! 4: --SKIPIF--
! 5: <?php
! 6: if (!extension_loaded("curl")) exit("skip curl extension not loaded");
! 7: if (false === getenv('PHP_CURL_FTP_REMOTE_SERVER')) exit("skip PHP_CURL_FTP_REMOTE_SERVER env variable is not defined");
! 8: if (false === getenv('PHP_CURL_FTP_REMOTE_USER')) exit("skip PHP_CURL_FTP_REMOTE_USER env variable is not defined");
! 9: if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REMOTE_PASSWD env variable is not defined");
! 10: ?>
! 11: --FILE--
! 12: <?php
! 13: $host = getenv('PHP_CURL_FTP_REMOTE_SERVER');
! 14: $username = getenv('PHP_CURL_FTP_REMOTE_USER');
! 15: $password = getenv('PHP_CURL_FTP_REMOTE_PASSWD');
! 16:
! 17: // FTP this script to a server
! 18: $fp = fopen ( __FILE__ , "r" );
! 19: $url = "ftp://$username:$password@$host/test.phpt" ;
! 20:
! 21: $ch = curl_init ();
! 22:
! 23: // enable below to get the output in verbose mode.
! 24: // curl_setopt ( $ch , CURLOPT_VERBOSE, 1 );
! 25:
! 26: /* Without enabling SKIP_PASV_IP flag, the following output will be seen..
! 27: < 227 Entering Passive Mode (10,5,80,146,100,199)
! 28: * Trying 10.5.80.146... * connected
! 29: * Connecting to 10.5.80.146 (10.5.80.146) port 25799
! 30: */
! 31:
! 32: /* After enabling SKIP_PASV_IP flag, the following output will be seen..
! 33: < 227 Entering Passive Mode (10,5,80,146,50,229)
! 34: * Skips 10.5.80.146 for data connection, uses 10.5.80.146 instead
! 35: * Trying 10.5.80.146... * connected
! 36: */
! 37:
! 38: curl_setopt ( $ch , CURLOPT_URL, $url );
! 39: curl_setopt ( $ch , CURLOPT_TRANSFERTEXT, 1 );
! 40:
! 41: //force passive connection
! 42: curl_setopt ( $ch , CURLOPT_FTP_USE_EPSV, 0 );
! 43: curl_setopt ( $ch , CURLOPT_FTP_SKIP_PASV_IP, 1 );
! 44:
! 45: // mark the file for upload..
! 46: curl_setopt ( $ch , CURLOPT_INFILE, $fp );
! 47: curl_setopt ( $ch , CURLOPT_INFILESIZE, filesize(__FILE__) );
! 48: curl_setopt ( $ch , CURLOPT_PUT, 1 );
! 49: curl_setopt ( $ch , CURLOPT_UPLOAD, 1 );
! 50:
! 51: $result = curl_exec ( $ch );
! 52: var_dump ( $result );
! 53: curl_close ( $ch );
! 54:
! 55: ?>
! 56: ===DONE===
! 57: --EXPECTF--
! 58: bool(true)
! 59: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>