Guest User

Untitled

a guest
Apr 13th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. //just For showing up...
  4.  
  5. echo " #################\n";
  6. echo " FTP Client\n";
  7. echo " By:Giggs\n";
  8. echo " ################\n";
  9. //teh c0de begins...
  10. echo "Type The Host: ";
  11. $host=trim(fgets(STDIN));
  12. // got host
  13. echo "Type The User Name: ";
  14. $user=trim(fgets(STDIN));
  15. // got user
  16. echo "Now The Pass: ";
  17. // got pass
  18. $pass=trim(fgets(STDIN));
  19. echo "checking if the host is alive...\n";
  20. $connect=ftp_connect($host);
  21. if(!$connect){ // we are now inside a { bracket, so we indent
  22. echo "The Host is Down.\n";
  23. exit;
  24. } // end of it, note that the beggining of the block is in line with the end bracket }
  25. echo "connected,Logging in...\n";
  26. $ftp_log=ftp_login($connect,$user,$pass);
  27. if(!$ftp_log){
  28. echo "Wrong User Name/Password...";
  29. exit;
  30. } else {
  31. echo "Logged in,Listing Directories...\n";
  32. $contents=ftp_nlist($connect, "/");
  33. foreach ($contents as $entry) {
  34. echo $entry, "\n";
  35. }
  36. }
  37.  
  38. while(1) {
  39. echo "\n What would you Like To Do:\n 1-Upload Files \n 2-Download Files \n 3-Make Dir \n 4-Delete Dir\n ";
  40. $choise=trim(fgets(STDIN));
  41. switch($choise){
  42. case 1:{
  43. echo "Type The File Source: ";
  44. $file=trim(fgets(STDIN));
  45. $fup=fopen($file,'r');
  46. if((ftp_fput($connect, $file, $fup, FTP_ASCII))){
  47. echo "File Uploaded\n";
  48. $contents=ftp_nlist($connect, "/");
  49. foreach ($contents as $entry) {
  50. echo $entry, "\n";
  51. }
  52. } else {
  53. echo "failed\n";
  54. }
  55. break;
  56. }
  57.  
  58. case 2:{
  59. echo "Type The Drive You want To save To: \n";
  60. $local=trim(fgets(STDIN));
  61. echo "Type The File You want to Download: \n";
  62. $filed=trim(fgets(STDIN));
  63. if(ftp_get($connect,$local,$filed, FTP_BINARY)){
  64. echo "File Downloaded\n";
  65. $contents=ftp_nlist($connect, "/");
  66. foreach ($contents as $entry) {
  67. echo $entry, "\n";
  68. }
  69. } else {
  70. echo "Downloading Failed\n";
  71. }
  72. break;
  73. }
  74.  
  75. default:{
  76. echo "nay";
  77. }
  78. }
  79. }
  80.  
  81.  
  82. ?>
Add Comment
Please, Sign In to add comment