Example #1
0
function myProcess($values)
{
    global $form;
    $destination = './uploads/';
    // Account FTP on remote server, directory destination, and allows Y/N file overwriting
    $ftp = array('user' => $values['ftpaccount']['U'], 'pass' => $values['ftpaccount']['P'], 'host' => $values['ftpaccount']['H'], 'dest' => $values['ftpdir'], 'overwrite' => (bool) $values['overwrite']);
    $result = 'done';
    $file =& $form->getElement('tstUpload');
    if ($file->isUploadedFile()) {
        $_ftp = new Net_FTP($ftp['host']);
        $ret = $_ftp->connect();
        if (PEAR::isError($ret)) {
            $result = $ret->getMessage();
            // NET_FTP_ERR_CONNECT_FAILED
        } else {
            $ret = $_ftp->login($ftp['user'], $ftp['pass']);
            if (PEAR::isError($ret)) {
                $result = $ret->getMessage();
                // NET_FTP_ERR_LOGIN_FAILED
            } else {
                $_ftp->setPassive();
                $ret = $_ftp->cd($ftp['dest']);
                if (PEAR::isError($ret)) {
                    $result = $ret->getMessage();
                    // NET_FTP_ERR_DIRCHANGE_FAILED
                } else {
                    $fval = $file->getValue();
                    $ret = $_ftp->put($fval['tmp_name'], $fval['name'], $ftp['overwrite']);
                    if (PEAR::isError($ret)) {
                        $result = $ret->getMessage();
                        // NET_FTP_ERR_UPLOADFILE_FAILED
                    }
                }
            }
            $ret = $_ftp->disconnect();
            if (PEAR::isError($ret)) {
                $result = $ret->getMessage();
                // NET_FTP_ERR_DISCONNECT_FAILED
            }
        }
    }
    // write the semaphore to tell progress meter to stop
    // in script 'progressbar.php'
    $semaphore = $destination . $_GET['ID'];
    $fp = fopen($semaphore, 'w', false);
    fwrite($fp, $result);
    fclose($fp);
}
Example #2
0
 function cd($dir)
 {
     if (!PEAR::isError(parent::cd($dir))) {
         $this->_currentwd = $dir;
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * @param Net_FTP $ftp
  * @param $remoteFileInformations
  * @param $directory
  * @return bool
  */
 private function _directoryInformations(Net_FTP $ftp, &$remoteFileInformations, $directory)
 {
     $content = $ftp->ls($directory);
     if (@PEAR::isError($content)) {
         if ($this->rawDataFallback) {
             $content = $ftp->ls($directory, NET_FTP_RAWLIST);
         }
         if (@PEAR::isError($content)) {
             return false;
         }
         $content = $this->parseRawFtpContent($content, $directory);
     }
     if (sizeof($content) == 0) {
         return false;
     } else {
         if (!empty($directory)) {
             $directory .= '/';
         }
         while (list(, $val) = each($content)) {
             if ($val['name'] != '.' && $val['name'] != '..') {
                 $remoteFileInformations[$directory . $val['name']] = $val;
             }
         }
         return true;
     }
 }
 public static function chmodRecursiveSoft(Net_FTP $ftp, $target, $permissions)
 {
     $stats = array('success' => 0, 'failure' => 0);
     // chmod target
     $ret = $ftp->chmod($target, $permissions);
     if (PEAR::isError($ret)) {
         $stats['failure']++;
         //throw new Engine_Package_Exception($ret->getMessage());
     } else {
         $stats['success']++;
     }
     $files = self::ftpLsRecursive($ftp, $target);
     foreach ($files as $file) {
         $ret = $ftp->chmod($file['name'], $permissions);
         if (PEAR::isError($ret)) {
             $stats['failure']++;
             //throw new Engine_Package_Exception($ret->getMessage());
         } else {
             $stats['success']++;
         }
     }
     return $stats;
 }
/**
 * @author soeren
 * @copyright soeren (C) 2006
 * 
 * This file handles ftp authentication
 */
function ftp_authentication($ftp_login = '', $ftp_pass = '')
{
    global $dir, $mosConfig_live_site;
    if ($ftp_login != '' || $ftp_pass != '') {
        while (@ob_end_clean()) {
        }
        @header("Status: 200 OK");
        $ftp_host = mosGetParam($_POST, 'ftp_host', 'localhost:21');
        $url = @parse_url('ftp://' . $ftp_host);
        if (empty($url)) {
            echo jx_alertBox('Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21');
            echo jx_scriptTag('', '$(\'loadingindicator\').innerHTML = \'\';');
            echo 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21';
            exit;
        }
        $port = empty($url['port']) ? 21 : $url['port'];
        $ftp = new Net_FTP($url['host'], $port, 20);
        $res = $ftp->connect();
        if (PEAR::isError($res)) {
            echo jx_alertBox($GLOBALS['messages']['ftp_connection_failed']);
            echo jx_scriptTag('', '$(\'loadingindicator\').innerHTML = \'\';');
            echo $GLOBALS['messages']['ftp_connection_failed'] . '<br />[' . $res->getMessage() . ']';
            exit;
        } else {
            $res = $ftp->login($ftp_login, $ftp_pass);
            $ftp->disconnect();
            if (PEAR::isError($res)) {
                echo jx_alertBox($GLOBALS['messages']['ftp_login_failed']);
                echo jx_scriptTag('', '$(\'loadingindicator\').innerHTML = \'\';');
                echo $GLOBALS['messages']['ftp_login_failed'] . '<br />[' . $res->getMessage() . ']';
                exit;
            }
            echo jx_alertBox('Login OK!');
            $_SESSION['ftp_login'] = $ftp_login;
            $_SESSION['ftp_pass'] = $ftp_pass;
            $_SESSION['ftp_host'] = $_POST['ftp_host'];
            session_write_close();
            echo jx_docLocation(str_replace('index3.php', 'index2.php', make_link('list', '') . '&file_mode=ftp'));
            exit;
        }
    } else {
        ?>
		<script type="text/javascript" src="components/com_joomlaxplorer/scripts/mootools.ajax.js"></script>
		<script type="text/javascript" src="components/com_joomlaxplorer/scripts/functions.js"></script>
		<script type="text/javascript">
		function checkFTPAuth( url ) {
			showLoadingIndicator( $('loadingindicator'), true );
			$('loadingindicator').innerHTML += ' <strong><?php 
        echo $GLOBALS['messages']['ftp_login_check'];
        ?>
</strong>';
			
			var controller = new ajax( url, { 	postBody: $('adminform'),
												evalScripts: true,
												update: 'statustext' 
												} 
									);
			controller.request();
			return false;
		}
		</script>
		
		<?php 
        show_header($GLOBALS["messages"]["ftp_header"]);
        ?>
<br/>
	
	<form name="ftp_auth_form" method="post" action="<?php 
        echo $mosConfig_live_site;
        ?>
/administrator/index3.php" onsubmit="return checkFTPAuth('<?php 
        echo $mosConfig_live_site;
        ?>
/administrator/index3.php');" id="adminform">
	
	<input type="hidden" name="no_html" value="1" />
	<table class="adminform" style="width:400px;">
		<tr><th colspan="3"><?php 
        echo $GLOBALS["messages"]["ftp_login_lbl"];
        ?>
</th></tr>
		
		<tr><td colspan="3" style="text-align:center;" id="loadingindicator"></td></tr>
		<tr><td colspan="3" style="font-weight:bold;text-align:center" id="statustext">&nbsp;</td></tr>
		
		<tr>
			<td width="50" style="text-align:center;" rowspan="3"><img align="absmiddle" src="images/security_f2.png" alt="Login!" /></td>
			<td><?php 
        echo $GLOBALS["messages"]["ftp_login_name"];
        ?>
:</td>
			<td align="left">
				<input type="text" name="ftp_login_name" size="25" title="<?php 
        echo $GLOBALS["messages"]["ftp_login_name"];
        ?>
" />
			</td>
		</tr>		
		<tr>
			<td><?php 
        echo $GLOBALS["messages"]["ftp_login_pass"];
        ?>
:</td>
			<td align="left">
				<input type="password" name="ftp_login_pass" size="25" title="<?php 
        echo $GLOBALS["messages"]["ftp_login_pass"];
        ?>
" />
			</td>
		</tr>		
		<tr>
			<td><?php 
        echo $GLOBALS["messages"]["ftp_hostname_port"];
        ?>
:</td>
			<td align="left">
				<input type="text" name="ftp_host" size="25" title="<?php 
        echo $GLOBALS["messages"]["ftp_hostname"];
        ?>
" value="<?php 
        echo mosGetParam($_SESSION, 'ftp_host', 'localhost:21');
        ?>
" />
			</td>
		</tr>
		<tr><td colspan="2">&nbsp;</td></tr>
		<tr>
			<td style="text-align:center;" colspan="3">
			<input type="hidden" name="action" value="ftp_authentication" />
			<input type="hidden" name="option" value="com_joomlaxplorer" />
			<input type="submit" name="submit" value="<?php 
        echo $GLOBALS['messages']['btnlogin'];
        ?>
" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" name="cancel" value="<?php 
        echo $GLOBALS['messages']['btncancel'];
        ?>
" onclick="javascript:document.location='<?php 
        echo make_link('list', $dir);
        ?>
';" />
			</td>
		</tr>
		<tr><td colspan="3">&nbsp;</td></tr>
	</table>
	</form>
	<?php 
    }
}
Example #6
0
    // Setup for displaying console output.
    Var_Dump::displayInit(array('display_mode' => 'Text'));
    /**
     * Headline function for XHTML output
     *
     * @param string $text Text to put in header
     *
     * @return void
     */
    function head($text)
    {
        echo "\n--- " . $text . " ---\n";
    }
}
head("\$ftp = new Net_FTP();");
$ftp = new Net_FTP();
head("\$ftp->setHostname({$host})");
Var_Dump::display($ftp->setHostname($host));
head("\$ftp->setPort({$port})");
Var_Dump::display($ftp->setPort($port));
head("\$ftp->connect({$host}, {$port})");
Var_Dump::display($ftp->connect());
head("\$ftp->setUsername({$user})");
Var_Dump::display($ftp->setUsername($user));
head("\$ftp->setPassword(xxx)");
Var_Dump::display($ftp->setPassword($pass));
head("\$ftp->login({$user}, xxx)");
Var_Dump::display($ftp->login($user, $pass));
head("\$ftp->pwd()");
Var_Dump::display($ftp->pwd());
head("\$ftp->ls(null, NET_FTP_DIRS_FILES)");
Example #7
0
    function execAction()
    {
        $ftp_login = extGetParam($_POST, 'ftp_login_name', '');
        $ftp_pass = extGetParam($_POST, 'ftp_login_pass', '');
        global $dir, $mosConfig_live_site;
        if ($ftp_login != '' || $ftp_pass != '') {
            $ftp_host = extGetParam($_POST, 'ftp_hostname_port', 'localhost:21');
            $url = @parse_url('ftp://' . $ftp_host);
            if (empty($url)) {
                ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21');
            }
            $port = empty($url['port']) ? 21 : $url['port'];
            $ftp = new Net_FTP($url['host'], $port, 20);
            $res = $ftp->connect();
            if (PEAR::isError($res)) {
                ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'] . ' (' . $url['host'] . ')');
            } else {
                $res = $ftp->login($ftp_login, $ftp_pass);
                $ftp->disconnect();
                if (PEAR::isError($res)) {
                    ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed']);
                }
                $_SESSION['ftp_login'] = $ftp_login;
                $_SESSION['ftp_pass'] = $ftp_pass;
                $_SESSION['ftp_host'] = $ftp_host;
                $_SESSION['file_mode'] = 'ftp';
                session_write_close();
                ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success'));
            }
        } else {
            ?>
	<div style="width:auto;">
	    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
	    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
	
	        <h3 style="margin-bottom:5px;"><?php 
            echo $GLOBALS["messages"]["ftp_header"];
            ?>
</h3>
	        <strong><?php 
            echo $GLOBALS["messages"]["ftp_login_lbl"];
            ?>
</strong><br />
	<br />
	        <div id="adminForm">
	
	        </div>
	    </div></div></div>
	    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
	</div>
			<script type="text/javascript">
	var simple = new Ext.form.Form({
	    labelWidth: 175, // label settings here cascade unless overridden
	    url:'<?php 
            echo make_link("rename", $dir, $item);
            ?>
'
	});
	simple.add(
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_login_name', true);
            ?>
',
	        name: 'ftp_login_name',
	        width:175,
	        allowBlank:false
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_login_pass', true);
            ?>
',
	        name: 'ftp_login_pass',
	        inputType: 'password',
	        width:175,
	        allowBlank:false
	    }),
	    new Ext.form.TextField({
	        fieldLabel: '<?php 
            echo ext_Lang::msg('ftp_hostname_port', true);
            ?>
',
	        name: 'ftp_hostname_port',
	        value: '<?php 
            echo extGetParam($_SESSION, 'ftp_host', 'localhost:21');
            ?>
',
	        width:175,
	        allowBlank:false
	    })
	    );
	
	simple.addButton({text: '<?php 
            echo ext_Lang::msg('btnlogin', true);
            ?>
', type: 'submit' }, function() {
		statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
	    simple.submit({
	        //reset: true,
	        reset: false,
	        success: function(form, action) { location.reload() },
	        failure: function(form, action) {
	        	if( !action.result ) return;
	        	Ext.MessageBox.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
	        	statusBarMessage( action.result.error, false, false );
	        },
	        scope: simple,
	        // add some vars to the request, similar to hidden fields
	        params: {option: 'com_extplorer', 
	        		action: 'ftp_authentication'
	        }
	    });
	});
	simple.addButton('<?php 
            echo ext_Lang::msg('btncancel', true);
            ?>
', function() { dialog.destroy(); } );
	simple.render('adminForm');
			</script>
			
			<br/>
		<?php 
        }
    }
Example #8
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $project = $this->getProject();
     require_once 'Net/FTP.php';
     $ftp = new Net_FTP($this->host, $this->port);
     $ret = $ftp->connect();
     if (@PEAR::isError($ret)) {
         throw new BuildException('Could not connect to FTP server ' . $this->host . ' on port ' . $this->port . ': ' . $ret->getMessage());
     } else {
         $this->log('Connected to FTP server ' . $this->host . ' on port ' . $this->port, $this->logLevel);
     }
     $ret = $ftp->login($this->username, $this->password);
     if (@PEAR::isError($ret)) {
         throw new BuildException('Could not login to FTP server ' . $this->host . ' on port ' . $this->port . ' with username ' . $this->username . ': ' . $ret->getMessage());
     } else {
         $this->log('Logged in to FTP server with username ' . $this->username, $this->logLevel);
     }
     if ($this->passive) {
         $this->log('Setting passive mode', $this->logLevel);
         $ret = $ftp->setPassive();
         if (@PEAR::isError($ret)) {
             $ftp->disconnect();
             throw new BuildException('Could not set PASSIVE mode: ' . $ret->getMessage());
         }
     }
     // append '/' to the end if necessary
     $dir = substr($this->dir, -1) == '/' ? $this->dir : $this->dir . '/';
     if ($this->clearFirst) {
         // TODO change to a loop through all files and directories within current directory
         $this->log('Clearing directory ' . $dir, $this->logLevel);
         $ftp->rm($dir, true);
     }
     // Create directory just in case
     $ret = $ftp->mkdir($dir, true);
     if (@PEAR::isError($ret)) {
         $ftp->disconnect();
         throw new BuildException('Could not create directory ' . $dir . ': ' . $ret->getMessage());
     }
     $ret = $ftp->cd($dir);
     if (@PEAR::isError($ret)) {
         $ftp->disconnect();
         throw new BuildException('Could not change to directory ' . $dir . ': ' . $ret->getMessage());
     } else {
         $this->log('Changed directory ' . $dir, $this->logLevel);
     }
     $fs = FileSystem::getFileSystem();
     $convert = $fs->getSeparator() == '\\';
     foreach ($this->filesets as $fs) {
         $ds = $fs->getDirectoryScanner($project);
         $fromDir = $fs->getDir($project);
         $srcFiles = $ds->getIncludedFiles();
         $srcDirs = $ds->getIncludedDirectories();
         foreach ($srcDirs as $dirname) {
             if ($convert) {
                 $dirname = str_replace('\\', '/', $dirname);
             }
             $this->log('Will create directory ' . $dirname, $this->logLevel);
             $ret = $ftp->mkdir($dirname, true);
             if (@PEAR::isError($ret)) {
                 $ftp->disconnect();
                 throw new BuildException('Could not create directory ' . $dirname . ': ' . $ret->getMessage());
             }
         }
         foreach ($srcFiles as $filename) {
             $file = new PhingFile($fromDir->getAbsolutePath(), $filename);
             if ($convert) {
                 $filename = str_replace('\\', '/', $filename);
             }
             $this->log('Will copy ' . $file->getCanonicalPath() . ' to ' . $filename, $this->logLevel);
             $ret = $ftp->put($file->getCanonicalPath(), $filename, true, $this->mode);
             if (@PEAR::isError($ret)) {
                 $ftp->disconnect();
                 throw new BuildException('Could not deploy file ' . $filename . ': ' . $ret->getMessage());
             }
         }
     }
     $ftp->disconnect();
     $this->log('Disconnected from FTP server', $this->logLevel);
 }
Example #9
0
</style>
<script type="text/javascript">
<!--
<?php 
echo $meter->getScript();
?>
//-->
</script>
</head>
<body>

<?php 
echo $meter->toHtml();
@set_time_limit(0);
// unlimited time operation (removed 30s default restriction)
$f = new Net_FTP();
//
// 3. connect to the FTP server
//
$ret = $f->connect($ftp['host'], $ftp['port']);
if (PEAR::isError($ret)) {
    die($ret->getMessage());
}
printf('connected at <b>%s</b><br />', $ftp['host']);
//
// 4. login to the FTP server as a well-known user
//
$ret = $f->login($ftp['user'], $ftp['pass']);
if (PEAR::isError($ret)) {
    $f->disconnect();
    die($ret->getMessage());
Example #10
0
    function execAction()
    {
        $ftp_login = extGetParam($_POST, 'ftp_login_name', '');
        $ftp_pass = extGetParam($_POST, 'ftp_login_pass', '');
        global $dir, $mosConfig_live_site;
        if ($ftp_login != '' || $ftp_pass != '') {
            $ftp_host = extGetParam($_POST, 'ftp_hostname_port', 'localhost:21');
            $url = @parse_url('ftp://' . $ftp_host);
            if (empty($url)) {
                ext_Result::sendResult('ftp_authentication', false, 'Unable to parse the specified Host Name. Please use a hostname in this format: hostname:21');
            }
            $port = empty($url['port']) ? 21 : $url['port'];
            $ftp = new Net_FTP($url['host'], $port, 20);
            $res = $ftp->connect();
            if (PEAR::isError($res)) {
                ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_connection_failed'] . ' (' . $url['host'] . ')');
            } else {
                $res = $ftp->login($ftp_login, $ftp_pass);
                $ftp->disconnect();
                if (PEAR::isError($res)) {
                    ext_Result::sendResult('ftp_authentication', false, $GLOBALS['messages']['ftp_login_failed']);
                }
                $_SESSION['ftp_login'] = $ftp_login;
                $_SESSION['ftp_pass'] = $ftp_pass;
                $_SESSION['ftp_host'] = $ftp_host;
                $_SESSION['file_mode'] = 'ftp';
                session_write_close();
                ext_Result::sendResult('ftp_authentication', true, ext_Lang::msg('actlogin_success'));
            }
        } else {
            ?>
	{
		"xtype": "form",
		"id": "simpleform",
		"labelWidth": 125,
		"url":"<?php 
            echo basename($GLOBALS['script_name']);
            ?>
",
		"dialogtitle": "<?php 
            echo $GLOBALS["messages"]["ftp_header"];
            ?>
",
		"title": "<?php 
            echo $GLOBALS["messages"]["ftp_login_lbl"];
            ?>
",
		"frame": true,
		"keys": {
		    "key": Ext.EventObject.ENTER,
		    "fn" : function(){
				if (Ext.getCmp("simpleform").getForm().isValid()) {
					statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
					Ext.getCmp("simpleform").getForm().submit({
						"reset": false,
						"success": function(form, action) { location.reload() },
						"failure": function(form, action) {
							if( !action.result ) return;
							Ext.Msg.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
							statusBarMessage( action.result.error, false, false );
						},
						"scope": Ext.getCmp("simpleform").getForm(),
						"params": {
							"option": "com_extplorer", 
							"action": "ftp_authentication"
						}
					});
    	        } else {
        	        return false;
            	}
            }
		},
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('ftp_login_name', true);
            ?>
",
			"name": "ftp_login_name",
			"width":175,
			"allowBlank":false
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('ftp_login_pass', true);
            ?>
",
			"name": "ftp_login_pass",
			"inputType": "password",
			"width":175,
			"allowBlank":false
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
            echo ext_Lang::msg('ftp_hostname_port', true);
            ?>
",
			"name": "ftp_hostname_port",
			"value": "<?php 
            echo extGetParam($_SESSION, 'ftp_host', 'localhost:21');
            ?>
",
			"width":175,
			"allowBlank":false
		}],
		"buttons": [{
			"text": "<?php 
            echo ext_Lang::msg('btnlogin', true);
            ?>
", 
			"type": "submit",
			"handler": function() {
				statusBarMessage( '<?php 
            echo ext_Lang::msg('ftp_login_check', true);
            ?>
', true );
				Ext.getCmp("simpleform").getForm().submit({
					"reset": false,
					"success": function(form, action) { location.reload() },
					"failure": function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert('<?php 
            echo ext_Lang::err('error', true);
            ?>
', action.result.error);
						statusBarMessage( action.result.error, false, false );
					},
					"scope": Ext.getCmp("simpleform").getForm(),
					"params": {
						"option": "com_extplorer", 
						"action": "ftp_authentication"
					}
				});
			}
		},{
			"text": "<?php 
            echo ext_Lang::msg('btncancel', true);
            ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}
		<?php 
        }
    }
 private function _directoryInformations(Net_FTP $ftp, &$remoteFileInformations, $directory)
 {
     $content = $ftp->ls($directory);
     if (@PEAR::isError($content) || sizeof($content) == 0) {
         return false;
     } else {
         if (!empty($directory)) {
             $directory .= '/';
         }
         while (list(, $val) = each($content)) {
             if ($val['name'] != '.' && $val['name'] != '..') {
                 $remoteFileInformations[$directory . $val['name']] = $val;
             }
         }
         return true;
     }
 }
Example #12
0
 function _retrieveServerData($id, $dataType)
 {
     switch ($this->{"_source" . ucfirst($dataType)}) {
         case "file":
             // File source is used, get file and read as-is into a string
             $source = realpath($this->{"_sourcePath" . ucfirst($dataType)} . "/" . $id . ".TXT");
             $data = @file_get_contents($source);
             if ($data === false) {
                 return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__);
             }
             break;
         case "http":
             // HTTP used, acquire request object and fetch data from webserver. Return body of reply
             include_once "HTTP/Request.php";
             $request = new HTTP_Request($this->{"_sourcePath" . ucfirst($dataType)} . "/" . $id . ".TXT", $this->_httpOptions);
             $status = $request->sendRequest();
             if (Services_Weather::isError($status) || (int) $request->getResponseCode() != 200) {
                 return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__);
             }
             $data = $request->getResponseBody();
             break;
         case "ftp":
             // FTP as source, acquire neccessary object first
             include_once "Net/FTP.php";
             // Parse source to get the server data
             $server = parse_url($this->{"_sourcePath" . ucfirst($dataType)} . "/" . $id . ".TXT");
             // If neccessary options are not set, use defaults
             if (!isset($server["port"]) || $server["port"] == "" || $server["port"] == 0) {
                 $server["port"] = 21;
             }
             if (!isset($server["user"]) || $server["user"] == "") {
                 $server["user"] = "******";
             }
             if (!isset($server["pass"]) || $server["pass"] == "") {
                 $server["pass"] = "******";
             }
             // Instantiate object and connect to server
             $ftp = new Net_FTP($server["host"], $server["port"], $this->_httpOptions["timeout"]);
             $status = $ftp->connect();
             if (Services_Weather::isError($status)) {
                 return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__);
             }
             // Login to server...
             $status = $ftp->login($server["user"], $server["pass"]);
             if (Services_Weather::isError($status)) {
                 return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__);
             }
             // ...and retrieve the data into a temporary file
             $tempfile = tempnam("./", "Services_Weather_Metar");
             $status = $ftp->get($server["path"], $tempfile, true, FTP_ASCII);
             if (Services_Weather::isError($status)) {
                 unlink($tempfile);
                 return Services_Weather::raiseError(SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA, __FILE__, __LINE__);
             }
             // Disconnect FTP server, and read data from temporary file
             $ftp->disconnect();
             $data = @file_get_contents($tempfile);
             unlink($tempfile);
             break;
     }
     // Split data into an array and return
     return preg_split("/\n|\r\n|\n\r/", $data);
 }