File "ftp_index.php"

Full Path: /home/analogde/www/filechange/ftp_index.php
File size: 6.61 KB
MIME-type: text/x-php
Charset: utf-8

<?php session_start(); ?>
<!--PHTP 2.0 Beta 1 version, by Antoine_935, for PHP
This file may be distributed under the terms of the Genreal Public License
This software comes with absolutely no warranty
Join the community at www.phtp.be
-->
<?php
require("config.php");
require("language/$lang/lang-inter.php");
if(!is_dir($rootdir)||!is_writeable($rootdir)) die("Error : \"$rootdir\" directory does not exist or isn't writeable.<br>Please read INSTALL.txt<br>\n<a href=\"configurator.php\" target=\"_blank\">Access configurator</a>");
ob_start();
$curhost = "";
$curusr = "";
$curpwd = "";
if (isset($host)) $curhost = $host;
if (isset($user)) $curusr = $user;
if (isset($pwd)) $curpwd = $pwd;
if(!isset($curdir)) $curdir= getcwd();
if(!isset($ftp_curdir)) $ftp_curdir = "";
if(!isset ($passive)) $passive = "pasv";
if (!isset($port)) $port = "21";

function local_is_dir($dir) {
	if(@opendir("./$dir")) {
		opendir("../");
		return TRUE;
	}
	else 
	return FALSE;
}

function ftp_is_dir($ftp, $dir) {
	if(@ftp_chdir($ftp, "$dir/")) {
		ftp_cdup($ftp);
		return TRUE;
	}
	else
	return FALSE;
}
?>
<html>
<head>
<link rel="SHORCUT ICON" href="favicon.ico">
<link rel="stylesheet" type="text/css" media="all" href="styles.css" />
<script language="javascript">
function rename() {
var newname = prompt('Enter the new name for the first selected file.', '');
document.action.param.value = newname;
document.action.mod.value="rename";
document.action.submit();
}
function mode(mod) {
	document.action.mod.value = mod ;
	document.action.submit();
}
function renew() {
	 document.renewal.hosted.value = document.action.hosted.value;
	 document.renewal.usr.value = document.action.usr.value;
	 document.renewal.pwd.value = document.action.pwd.value;
	 document.renewal.port.value= document.action.port.value;
	 document.renewal.passive.value = document.action.passive.value;
	 document.renewal.ftp_curdir.value = "";
	 document.renewal.submit();
}
function ftp_chgtdir() {
	document.renewal.ftp_curdir.value = '<?php echo $ftp_curdir; ?>'+document.action.ftp_chgdir.value+'/';
	document.renewal.submit();
}
function del() {
	if(confirm) {
	document.action.mod.value="del";
	document.action.submit();
	}
}
function mkdir() {
	var newname = prompt('Enter the name for the directory.', '');
	if(newname != "") {
	document.action.param.value = newname;
	document.action.mod.value="newdir";
	document.action.submit();
	}
}
</script>
<title>PHTP : <?php print("$user@$host"); ?></title>
</head>
<body onload="window.status='<?php print("$user@$host"); ?>'; return true;">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="980" class="menu">
<tr height="100"><td colspan="3"><a href="http://www.phtp.be/" target="_blank"><img src="phtp.jpg" style="border: 0px none; width: 980px; height: 100px;"></a></tr>
<tr>
<td style="text-align: right; background-color: #66BB66">
<a href="logout.php" class="menu"><?php echo $logout; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="javascript:void();" onclick="window.open('configurator.php', '', 'width=640, height=480');" class="menu"><?php echo $configure; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="http://www.phtp.be" target="_blank" class="menu">PHTP's Website</td><td width="30" bgcolor="#66BB66">&nbsp;</td>
</tr></table>
<form name="action" method="post" class="button" action="queue.php?submit=1" target="queue">
<table border="0" cellpadding="0" cellspacing="0" width="980" height="300">
<tr><td colspan="3"><hr></td></tr>
<tr valign="top" align="left">
<td width="40%">
<select size="13" name="local[]" multiple>
	<?php
	$pointeur = opendir($rootdir);
	$filelist = array();
	while ( $file = readdir($pointeur)) {
		if ($file!=".") {
		if (!is_dir($file)) 
		array_push($filelist, $file);
	}
	array_multisort($filelist, SORT_STRING);
}
foreach ($filelist as $file) {
	$size = filesize("$rootdir/$file");
	$term = 0;
	while ($size >1024) {
		$size = ($size/1024);
		$term++;
	}
	switch ($term) {
		case 0 : $term = "b";
		break;
		case 1 : $term = "Kb";
		break;
		case 2 : $term = "Mb";
		break;
		case 3 : $term = "Gb";
		break;
	}
	$size = number_format($size, 2);
	print("<option style=\"color: #00CC00;\" value=\"$file\">[$size $term] $file</option>\n");
}
?>
<option>____________________________________________________</option>
</select><br>
</td>
<td width="20%" align="center" class="tranfert">
<input type="button" onclick="mode('toftp');" value="=====>"><br>
<input type="button" onclick="mode('topc');" value="<====="><br>
<input type="button" onclick="rename('ftp');" value="Rename"><br>
<input type="button" onclick="del();" value="&nbsp;&nbsp;Delete&nbsp;&nbsp;"><br>
<input type="button" onclick="mkdir();" value="&nbsp;New Dir."><br>
<input type="checkbox" name="incpath">Include path in name<br><br>
<input type="hidden" name="param"><br>
<input type="hidden" name="mod">
<td width="40%">
<input type="text" name="ftp_curdir" value="<?php
	$ftp = ftp_connect($host);
	@ftp_login($ftp, $user, $pwd);
	@ftp_pasv($ftp, TRUE);
	@ftp_chdir($ftp, $ftp_curdir);
	if($dirlist = @ftp_nlist($ftp, ".")) {
	$ftp_dossier = array("..");
	$ftp_filelist = array();
		foreach ($dirlist as $file) {
			if(ftp_is_dir($ftp, $file))
			array_push($ftp_dossier, $file);
			else
			array_push($ftp_filelist, $file);
		}
	}
	echo ftp_pwd($ftp);
?>" readonly size="46"><br>
<select name="ftp_chgdir" onchange="ftp_chgtdir()">
<option selected value=""><u>----------Change directory----------</u></option>
<?php
	foreach ($ftp_dossier as $doc) {
		print("<option value=\"$doc\">$doc</option>\n");
	}
?>
</select><br>
<select size="10" name="distant[]" multiple>
	<?php
		foreach ($ftp_dossier as $doc) {
		print("<option style=\"color: #CC0000;\" value=\"$doc\">$doc</option>\n");
		}
		foreach ($ftp_filelist as $file) {
			print("<option style=\"color: #00CC00;\" value=\"$file\">$file</option>\n");
		}
	?>
<option>____________________________________________________</option>
</select>
</form>
</td>
</tr>
<tr><td colspan="3"><hr>
<form class="button">
<input type="button" value="Empty Queuelist" onclick="parent.queue.location.href='queue.php?submit=1&mod=empty';">&nbsp;&nbsp;&nbsp;
<input type="button" value="Begin Transfer" onclick="window.open('action.php', '', 'width=640, height=480, scrollbars=yes');">
</form>
<form name="renewal" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="curdir" value="<?php echo getcwd(); ?>">
<input type="hidden" name="ftp_curdir" value="<?php @print($ftp_dir = ftp_pwd($ftp)); ftp_quit($ftp);  ?>">
<input type="hidden" name="passive" value="<?php echo $passive; ?>">
</form></td></tr>
<tr><td colspan="3"><iframe src="queue.php" name="queue" style="border:0px none; width:100%; height: 120;"></iframe></td></tr>
</table>
</center>
</body>
</html>
<?php flush ?>