New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/lazzard/ftp-bridge

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/lazzard/ftp-bridge

  • v1.0.0-RC2
  • Source
  • Go
  • Socket score

Version published
Created
Source

Version Minimum PHP version tests codecov Scrutinizer Code Quality LICENSE

Lazzard/FtpBridge

Allows free communication with FTP servers according to RFC959 specification and others related RFC extensions.

Getting started

composer require lazzard/ftp-bridge:v1.0.0-RC2

Usage Example

<?php

require __DIR__ . "/vendor/autoload.php";

use Lazzard\FtpBridge\Logger\ArrayLogger;
use Lazzard\FtpBridge\Logger\LogLevel;
use Lazzard\FtpBridge\FtpBridge;

try {
   // Logger is optional
   $logger = new ArrayLogger;

   // set log levels prefixes
   LogLevel::setInfo('<--');
   LogLevel::setError('<--');
   LogLevel::setCommand('-->');

   // create bridge instance
   $ftp = new FtpBridge($logger);

   $hostname = 'foo@bar.com';
   $username = 'username';
   $password = 'password';

   if ($ftp->connect($hostname, 21)) {
       // connected
       if ($ftp->login($username, $password)) {
           // logged

           $ftp->send("PWD");
           $ftp->receive();

           // open a passive data connection
           if ($ftp->openPassive()) {
               $ftp->send("NLST .");
               $ftp->receive();

               $ftp->receiveData();
               $ftp->receive();
           }
       }

       $ftp->send("QUIT");
       $ftp->receive();
   }

   print_r($logger->getLogs());
   
} catch (Exception $ex) {
   print_r($ex->getMessage();
}

Result :

Array
(
    [0] => <-- 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 399 of 6900 allowed.
220-Local time is now 08:14. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 60 seconds of inactivity.

    [1] => --> USER username

    [2] => <-- 331 User username OK. Password required

    [3] => --> PASS password

    [4] => <-- 230-Your bandwidth usage is restricted
230 OK. Current restricted directory is /

    [5] => --> PWD

    [6] => <-- 257 "/" is your current location

    [7] => --> PASV

    [8] => <-- 227 Entering Passive Mode (185,27,134,11,205,216)

    [9] => --> NLST .

    [10] => <-- 150 Accepted data connection

    [11] => <-- .
..
.override
DO NOT UPLOAD FILES HERE
htdocs
lazzard.org

    [12] => <-- 226-Options: -a
226 6 matches total

    [13] => --> QUIT

    [14] => <-- 221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

)

FAQs

Package last updated on 01 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc