Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elseif($args["action"] == "list-ftp") {
- // get ftp details
- $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_suhnersn_downloads_ftps');
- $ftp = $queryBuilder
- ->select('*')
- ->from('tx_suhnersn_downloads_ftps')
- ->where(
- $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($args["ftp_id"]))
- )
- ->execute()
- ->fetch();
- try {
- set_time_limit(5);
- ini_set('max_execution_time', 5);
- // set up basic SSL connection
- $ftp_conn = ftp_ssl_connect($ftp["host"], 990) or die("Could not connect to ".$ftp["host"]);
- // login
- $login = ftp_login($ftp_conn, $ftp["username"], $ftp["password"]);
- // if login successful
- if($login) {
- // echo "[".date("H:i:s")."] "."Login successful."."<br />";
- $path = $ftp["remote_path"];
- if($args["ftp_dir"]) { $path = $args["ftp_dir"]; }
- $contents = ftp_rawlist($ftp_conn, $path);
- if(is_array($contents)) {
- echo "<ul>";
- $items = array();
- $i = 0;
- foreach ($contents as $content) {
- $i++;
- $chunks = preg_split("/\s+/", $content);
- // skip parent directories
- if(!($chunks[8] == "." || $chunks[8] == ".." || $chunks[8] == ".htaccess")) {
- // put everything in associative array
- $items[$i]["permissions"] = $chunks[0];
- $items[$i]["owner"] = $chunks[2];
- $items[$i]["file_name"] = $chunks[8];
- echo "<li>";
- echo '<a class="goto-ftp-dir" href="#ftp:">';
- echo "<span class=\"t3js-icon icon icon-size-small icon-state-default apps-filetree-folder-default\" data-identifier=\"apps-filetree-folder-default\">
- <span class=\"icon-markup\">
- <img src=\"/typo3/sysext/core/Resources/Public/Icons/T3Icons/apps/apps-filetree-folder-default.svg\" width=\"16\" height=\"16\">
- </span>
- </span> ";
- echo $chunks[8];
- echo "</a>";
- echo "</li>";
- }
- }
- echo "</ul>";
- }
- else {
- echo "[".date("H:i:s")."] "."File listing failed.";
- }
- }
- else {
- echo "[".date("H:i:s")."] "."Login failed.";
- }
- // close SSL connection
- ftp_close($ftp_conn);
- } catch (Exception $e) {
- echo 'Exception abgefangen: ', $e->getMessage(), "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement