FTP Interface

Posted: August 26, 2011 in PHP
<? session_start();
	require 'ftp.php';		
	if($_POST['act']=='doNow' && isset($_POST['act']))
		$ftpHost = trim($_POST['ftpHost']);
		$ftpUsername = trim($_POST['ftpUsername']);
		$ftpPassword = trim($_POST['ftpPassword']);
		$mode = trim($_POST['mode']);
		$localPath = rtrim(trim($_POST['localPath']),'\\');		
		$livePath = rtrim(trim($_POST['livePath']),'/'); 
		if($ftpHost=="" || $ftpUsername=="" || $ftpPassword=="" || $mode=="" || $localPath=="" || $livePath=="")
			$_SESSION['msg'] = '<strong style="color:#CC0000;">Please enter all values.</strong>';
			$_SESSION['msg'] = '<strong style="color:#CC0000;">Local path doesn\'t exist.</strong>';
		$ftp = new ftp();
		$ftp->conn($ftpHost, $ftpUsername, $ftpPassword);
		if($mode == 'put')
		if($mode == 'get')
		$arr = $ftp->getLogData();		
		$str.= '<h4>Log:</h4>'.implode('<br />',$arr);		
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FTP Interface</title>
table td{ background-color:#F2F2F2;}

<body><br /><br /><br />
<? if($_POST['act']=='doNow' && isset($_POST['act'])) { ?>
<table align="center" bgcolor="#CCCCCC" width="900" border="0" cellspacing="1" cellpadding="5">
   <td  align="center"><h3>FTP Interface</h3></td>
   <td align="left"><?=$str;?></td>
<? } else { ?>
<form id="form1" name="form1" method="post" action="">
<input type="hidden" name="act" value="doNow" />
<table align="center" bgcolor="#CCCCCC" width="600" border="0" cellspacing="1" cellpadding="5">
   <td colspan="2" align="center"><h3>FTP Interface</h3></td>
    <td width="178" align="right">FTP Host :</td>
    <td width="399">
      <input type="text" style="width:300px;" name="ftpHost" />    </td>
    <td align="right">Username :</td>
    <td><input type="text" style="width:300px;" name="ftpUsername" /></td>
    <td align="right">Password :</td>
    <td><input type="password" style="width:300px;" name="ftpPassword" /></td>
    <td align="right">&nbsp;</td>
    <label><input type="radio" name="mode" value="get" /> Download </label>
    <label><input type="radio" name="mode" value="put" /> Upload </label>    </td>
    <td align="right">Local  Path :</td>
    <td><input type="text" style="width:300px;" name="localPath" /></td>
    <td align="right">Live Path : </td>
    <td><input type="text" style="width:300px;" name="livePath" /></td>
  <? if(isset($_SESSION['msg'])){ ?>
    <td align="right"></td>
  <? unset($_SESSION['msg']);} ?>
      <input type="submit" name="button" id="button" value="Submit" />
      <br /> <br />    
<? } ?>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s