note 60038 added to ref.ftp

From: Date: Fri, 23 Dec 2005 16:19:26 +0000
Subject: note 60038 added to ref.ftp
Groups: php.notes 
Request: Send a blank email to php-notes+get-100624@lists.php.net to get a copy of this message
This is a simple script writen by me which allows the user run it in console and get tree from FTP Server. <?php $argv = $_SERVER["argv"]; $argv = array_slice($argv,1); if (getenv("HTTP_HOST")) {exit("For bash execution only!");} if ((empty($argv[0])) || (empty($argv[1]))) {exit("Usage: thisscript.php 10.0.0.10 /games/Arcade/ where 10.0.0.10 is the FTP Server and /games/Arcade is the start path on FTP\n");} // connect to the ftp server $connect_id = ftp_connect($argv[0]); // login on the server if ($connect_id) { $login_result = ftp_login($connect_id, 'anonymous', 'JustForFun'); } // check connection if ((!$connect_id) || (!$login_result)) { echo "Unable to connect the remote FTP Server!\n"; exit; } function ftp_get_dir ($ftp_dir) { global $connect_id; $ftp_contents = ftp_nlist ($connect_id, $ftp_dir); for ($myCounter_for_server_elements = 0; !empty ($ftp_contents[$myCounter_for_server_elements]); $myCounter_for_server_elements++) { // get elements list in current dir echo $argv[0] . $ftp_dir . $ftp_contents[$myCounter_for_server_elements] . "\n"; ftp_get_dir ($ftp_dir . $ftp_contents[$myCounter_for_server_elements] . '/'); } } ftp_get_dir ($argv[1]); // close connection ftp_close($connect_id); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.ftp.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60038 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60038&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60038&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100624) next »