FTP Component

I wrote the FTP component to allow for an easy way of uploading files via FTP. This component is easily extensible.

1. Install Pear package Net_ftp or copy the files to your libs directory.

2. Create a config file ftp.php in your config directory for any possible defines.

3. Make a directory FTP in your Zoop installation. Please include the following files:
/*************************
***** ftp_component.php **
*************************/
<?php
/**
* FTP component - Component allows for transferring files using the PEAR package Net_FTP
*
* Copyright (c) 2009 Jayesh Wadhwani, Dominion Enterprises
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* If you have any questions or comments, please email:
* Jayesh Wadhwani
* jayesh.wadhwani@dominionenterprises.com
* http://www.dominionenterprises.com/
*
*
* PHP versions 5
*
* * component_ftp
*
* Please make sure that you have the Pear package Net_FTP installed on your system.
* Alternately you could also download the files and put them in your libs folder.
* @uses component
* @package
* @version $id$
* @copyright 2009 Dominion Enterprises
* @author Jayesh Wadhwani
*/
class component_ftp extends component
{
function component_ftp()
{

}

function getIncludes()
{
return array(
"ftp" => $this->getBasePath() . "/ftp.php"
);
}
}
?>
/*************************
******** ftp.php *********
*************************/
<?php
require_once 'FTP.php';
/**
* A wrapper for the Net_ftp Pear package
*
* The most common application for FTP is to connect and send a file. This is what I
* have implemented. You can extend this class for more functionality.
*
* @author Jayesh Wadhwani
* @copyright 2009 Dominion Enterprises
* @license http://www.gnu.org/copyleft/gpl.html GPL License 2 or later
*/
class ftp
{

//The FTP handle
private $ftp;

//login credentials
private $username;
private $password;

/**
* Instantiation of class and setup
*
* @param string $host e.g. somehost.mysite.com
* @param int $port e.g. 21 default is 21
* @param string $username e.g. somehost.mysite.com
* @access public
*/
function __construct($host, $port = 21, $username, $password){
$this->username = $username;
$this->password = $password;
$this->ftp = new Net_FTP($host, $port);
}

/**
* Use this to upload a file to the host server
*
* @param string $sourceFile
* @param string $destinationFile
* @param bool $overwrite - a value of true will overwrite the destination file.
* @param int $transferMode - FTP_ASCII or FTP_BINARY. Default is FTP_ASCII
* @param int $transferMode - FTP_ASCII or FTP_BINARY. Default is FTP_ASCII
* @access public
*/
function ftpUpload($sourceFile, $destinationFile, $overwrite = true, $transferMode = FTP_ASCII, $passive = true){

//make the connection
$result = $this->ftp->connect();

if (PEAR::isError($result)){
print $result;
}

//login
$result = $this->ftp->login($this->username, $this->password);

if (PEAR::isError($result)){
print $result;
}

//set connection type
if($passive === true){
$this->ftp->setPassive();
}

//upload
$result = $this->ftp->put($sourceFile, $destinationFile, $overwrite, $transferMode);

if (PEAR::isError($result)){
print $result;
}
}

/**
* Close connection on exit
* @access public
*/
function __destruct(){
$this->ftp->disconnect();
}

}

/***************************
*** defaultConstants.php ***
***************************/

<?php

?>
/***************************
*** Example: ***************
***************************/
<?php
$sourceFileName = '/www/files/source.xml';
$destination = '/public_html/destination.xml';

$b = new ftp('somehost.somesite.com', 21, 'username', 'password');
$b->ftpUpload($sourceFileName, $destination, true, FTP_BINARY);

?>

web design cardiff -

web design cardiff - limegreentangerine is a full service creative design, branding and digital communications agency based in Cardiff.

Allenwood 06 Aug 2011

This is a very informative

This is a very informative article.I was looking for these things and here I found it. I am doing a project and this information is very useful me. If you are interested, but this is my duty to inform you that virtual administrative assistant a very dedicated service and can be applied anywhere you want and get better results. tom ford sunglasses

eavedrop44 26 Aug 2011

Great work you have done by

Great work you have done by sharing them to all. simply superb. Thanks for a nice share you have given to us with such an large collection of information regards.Automatic Backlink Creator WordPress Plugin
Crawler Master X - Get 10,000 visitors a day within just 2-3 months

hongchen 31 Oct 2011

Tassels and fringe - Many

Tassels and fringe - Many decorative 117-101 throw pillows, blankets and 1z0-050 curtains are bordered with tassels or fringe. Kittens love to chew and swallow these objects. Ideally, these should be put HP0-S30 away until the kitten is older and less curious.

roter 07 Sep 2011

For sure this one will work

For sure this one will work for me now, I found similar guide few months ago, but there were several errors.
web design company

darrensy 14 Sep 2011

This is a smart blog. I mean

This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.... Heel Pain

simsim 11 Oct 2011

Admirable

That is quite admirable placement from your side. I am so grateful to you that you have shared such an outstanding content over here. Hope that you will keep placing more in the future. hawaii marine newspaper

iamasterss 14 Oct 2011

What will be the extension

What will be the extension of the file which will be created inside directory FTP. Also before installation do we need to clean registry of our system? I will be really thankful if you can illustrate the installation process more precisely.

imwilliam 27 Oct 2011

Technological advancement has helped us

Technological advancement has helped us do things flawlessly and in a faster way. There are so many things that used to be done manually could be done through different software. I really liked your post the instructions given would help blog readers. I was searching for information on ppc bid management software when I saw your post.

its_me 03 Nov 2011

I really enjoyed reading

I really enjoyed reading every pieces of text shared here and got a lot of useful information.
custom essay writing services

adam7962 02 Dec 2011

Excellent post and wonderful

Excellent post and wonderful blog, I really like this type of interesting articles keep it u. I am really loving the theme/design of your web site.
best ghost writers

adam7962 24 Dec 2011