<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.framework
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: ftp.datasource.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefFTPDataSource")) {
//-------------------------------------------------------------------------
// Define
define("DefFTPDataSource", "1");
//-------------------------------------------------------------------------
// Include
@require_once (FRAMEWORK_DIR . "datasource.php");
//-------------------------------------------------------------------------
// Class
class FTPDataSource extends DataSource {
//---------------------------------------------------------------------
// Constructor
/**
* Data source constructor
* @param string host
* @param string port
* @param string user
* @param string pass
* @param string base
*/
function FTPDataSource($hostName = "", $hostPort = 0, $userName = "", $passWord = "", $directory = "") {
$this->m_protocol = "ftp";
$this->m_hostName = $hostName;
$this->m_hostPort = $hostPort;
$this->m_userName = $userName;
$this->m_passWord = $passWord;
$this->m_dataBase = @rtrim(@addslashes($directory) , "/\\");
}
//---------------------------------------------------------------------
// Properties
/**
*
* overrided DataSource property
*
* @return object
*
* @see
*/
function getDataHandler() {
//
return ($this);
}
/**
* ~= Database property
*
* @return string
*/
function Directory() {
//
return ($this->m_dataBase);
}
/**
*
* overrided DataSource property
*
* @return string
*/
function errorString() {
//
if ($this->isConnectionOpen() == false) return ("FTP server not available");
//
return ("");
}
/**
* overrided DataSource property
*
* @return integer
*/
function errorNumber() {
//
return (0);
}
//---------------------------------------------------------------------
// Methods
//
// DataSource interface
//
/**
* overrided DataSource method
*
* @return boolean
*/
function openConnection() {
//
$this->m_resource = @ftp_connect($this->m_hostName, $this->m_hostPort);
if (false !== $this->m_resource) {
//
if (@ftp_login($this->m_resource, $this->m_userName, $this->m_passWord) == true) return (true);
//
$this->closeConnection();
}
//
return (false);
}
/**
* overrided DataSource method
*
* @return boolean
*/
function closeConnection() {
//
if ($this->isConnectionOpen() == false) return (false);
//
@ftp_quit($this->m_resource);
$this->m_resource = false;
//
return (true);
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>