Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_GET['q'] == 'ftp_connect')
- {
- $connection = new connect_to_ftp;
- echo $connection->ftp_connection();
- }
- elseif($_GET['q'] == 'get_connection_id')
- {
- $connection = new connect_to_ftp;
- echo $connection->get_connection();
- }
- class connect_to_ftp
- {
- public $ftp_server = "";
- public $username = "";
- public $password = "";
- public $connectionID, $login_result, $response;
- public function ftp_connection()
- {
- $this->connectionID = ftp_connect($this->ftp_server);
- if($this->connectionID==true)
- {
- $this->response = array("connection_error" => "Connected to ".$this->ftp_server);
- $this->login_result = ftp_login($this->connectionID, $this->username, $this->password);
- if($this->login_result==true)
- {
- $this->response = array("connection_error" => "Login successful to ".$this->ftp_server);
- }else
- {
- $this->response = array("connection_error" => "Failed to login to ".$this->ftp_server." Check username and password");
- }
- }else
- {
- $this->response = array("connection_error" => "Could not connect to ".$this->ftp_server);
- }
- return json_encode($this->response);
- }
- public function get_connection()
- {
- return $this->connectionID;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement