コード例 #1
0
	/**
	 * Returns an object that is a child of the FTPClient class or null on failure.
	 */
	public static function initializeFTP() {
		if (self::$ftp === null && Config::get('base.ftp.enabled') == true) {
			self::$ftp = FTPClient::getObject();
			$data = Config::get('base.ftp');
			if (self::$ftp !== null && self::$ftp->setServer($data['host'], $data['port']) !== true) {
				self::$debug->addText('Could not set ftp server to ...');
				self::$ftp = null;
			}
			if (self::$ftp !== null && self::$ftp->connect() !== true) {
				self::$debug->addText('Could not connect to ftp server');
				self::$ftp->quit();
				self::$ftp = null;
			}
			if (self::$ftp !== null && self::$ftp->login($data['username'], $data['password']) !== true) {
				self::$debug->addText('Could not login on ftp server with user data ...');
				self::$ftp->quit();
				self::$ftp = null;
			}
			if (self::$ftp !== null && self::$ftp->chdir($data['directory']) !== true) {
				self::$debug->addText('Could not change directory on ftp server to ...');
				self::$ftp->quit();
				self::$ftp = null;
			}
		}
		return self::$ftp;
	}