Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. elseif($args["action"] == "list-ftp") {
  2.  
  3. // get ftp details
  4. $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_suhnersn_downloads_ftps');
  5. $ftp = $queryBuilder
  6. ->select('*')
  7. ->from('tx_suhnersn_downloads_ftps')
  8. ->where(
  9. $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($args["ftp_id"]))
  10. )
  11. ->execute()
  12. ->fetch();
  13.  
  14. try {
  15. set_time_limit(5);
  16. ini_set('max_execution_time', 5);
  17.  
  18.  
  19. // set up basic SSL connection
  20. $ftp_conn = ftp_ssl_connect($ftp["host"], 990) or die("Could not connect to ".$ftp["host"]);
  21.  
  22. // login
  23. $login = ftp_login($ftp_conn, $ftp["username"], $ftp["password"]);
  24.  
  25. // if login successful
  26. if($login) {
  27. // echo "[".date("H:i:s")."] "."Login successful."."<br />";
  28.  
  29. $path = $ftp["remote_path"];
  30. if($args["ftp_dir"]) { $path = $args["ftp_dir"]; }
  31.  
  32. $contents = ftp_rawlist($ftp_conn, $path);
  33. if(is_array($contents)) {
  34.  
  35. echo "<ul>";
  36. $items = array();
  37. $i = 0;
  38. foreach ($contents as $content) {
  39. $i++;
  40.  
  41. $chunks = preg_split("/\s+/", $content);
  42.  
  43. // skip parent directories
  44. if(!($chunks[8] == "." || $chunks[8] == ".." || $chunks[8] == ".htaccess")) {
  45.  
  46. // put everything in associative array
  47. $items[$i]["permissions"] = $chunks[0];
  48. $items[$i]["owner"] = $chunks[2];
  49. $items[$i]["file_name"] = $chunks[8];
  50.  
  51. echo "<li>";
  52. echo '<a class="goto-ftp-dir" href="#ftp:">';
  53. echo "<span class=\"t3js-icon icon icon-size-small icon-state-default apps-filetree-folder-default\" data-identifier=\"apps-filetree-folder-default\">
  54. <span class=\"icon-markup\">
  55. <img src=\"/typo3/sysext/core/Resources/Public/Icons/T3Icons/apps/apps-filetree-folder-default.svg\" width=\"16\" height=\"16\">
  56. </span>
  57. </span> ";
  58. echo $chunks[8];
  59. echo "</a>";
  60. echo "</li>";
  61. }
  62.  
  63. }
  64. echo "</ul>";
  65. }
  66. else {
  67. echo "[".date("H:i:s")."] "."File listing failed.";
  68. }
  69. }
  70. else {
  71. echo "[".date("H:i:s")."] "."Login failed.";
  72. }
  73.  
  74. // close SSL connection
  75. ftp_close($ftp_conn);
  76.  
  77. } catch (Exception $e) {
  78. echo 'Exception abgefangen: ', $e->getMessage(), "\n";
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement