location.replace("..");'."\n";
// If language is not yet set, check the default language or try to get the language from your browser.
if($language==""){
if ($defaultLanguage !="") {
$language = $defaultLanguage ;
} else {
$browser_lang = getenv("http_accept_language");
$tmplang = $languages[$browser_lang];
if(file_exists("include/language/" . $tmplang . ".lang.php")) {
$language = $tmplang;
} else {
$language = "english";
}
}
}
//Include Language file
include("include/language/" . $language . ".lang.php"); // Selected language
if ($server!="")
{
$connection = @ftp_connect($server, $port);
$loggedOn = @ftp_login($connection, $altlogin, $password);
$loggedOn = $loggedOn? $loggedOn : @ftp_login($connection, $user, $password);
$systype = @ftp_systype($connection);
if($goPassive) {
$passiveMode = @ftp_pasv($connection, true);
}
if(!isset($mode))
{
$mode=1; //(FTP_ASCII = 0; FTP_BINARY=1)
}
if ($loggedOn)
{
if (isset($currentDir))
{
ftp_chdir($connection, $currentDir);
}
$currentDir = ftp_pwd($connection);
$msg = currentDirectory($currentDir);
// what to do now ???
if(isset($actionType)) {
switch ($actionType) {
case "chmod": // Change permissions
if(@ftp_site($connection, "chmod $permissions $file"))
{
$msg= $lblFilePermissionChanged;
} else
{
$msg= $lblCouldNotChangePermissions;
}
break;
case "cd": // Change directory
//First try : normal directory
if ($file=="..")
{
@ftp_cdup($connection);
$currentDir = @ftp_pwd($connection);
$msg = $lblIndexOf . " " . currentDirectory($currentDir);
}
else
{
if(@ftp_chdir($connection, $currentDir . $file))
{
$currentDir = @ftp_pwd($connection);
$msg = $lblIndexOf . " " . currentDirectory($currentDir);
}
elseif(@ftp_chdir($connection, $file)) // Symbolic link directory
{
$currentDir = @ftp_pwd($connection);
$msg = $lblIndexOf . " " . currentDirectory($currentDir);
}
else // link to a file so let's retrieve this...
{
header("Content-disposition: attachment; filename=\"$file\"");
header("Content-type: application/octetstream");
header("Pragma: ");
header("Cache-Control: cache");
header("Expires: 0");
//Determine original filename
$filearray = explode("/",$file);
$file = $filearray[sizeof($filearray)-1];
$msg = $file;
$fp = fopen($downloadDir . $file, "w");
if(!@ftp_fget($connection,$fp,"$file",$mode))
{
fclose($fp);
exit;
}
fclose($fp);
$data = readfile($downloadDir . $file);
$i=0;
while ($data[$i] != "")
{
echo $data[$i];
$i++;
}
unlink($downloadDir . $file);
exit;
}
}
break;
case "edit":
//First download the file to the server
$fp = fopen($downloadDir . $file, "w");
ftp_fget($connection,$fp,"$file",$mode) OR DIE($lblErrorDownloadingFile);
fclose($fp);
//Now open the content of the file in an edit window
?>
phpWebFTP
Edit
$MAX_FILE_SIZE)
{
$msg = "" . $lblFileSizeTooBig . " (max. " . $MAX_FILE_SIZE . "bytes)";
}
else
{
if(file_exists($HTTP_POST_FILES['file']['tmp_name']))
{
ftp_put($connection, $currentDir . "/" . filePart(StripSlashes($fname)), $HTTP_POST_FILES['file']['tmp_name'], $mode);
unlink($HTTP_POST_FILES['file']['tmp_name']);
}
else
{
$msg = $lblFileCouldNotBeUploaded;
}
}
break;
case "deldir"; // Delete directory
if(@ftp_rmdir($connection, "$file"))
{
$msg = "$file " . $lblDeleted;
}
else
{
//Verify if has files inside and if so, call recursive del
if ($lista = @ftp_nlist($connection, "$currentDir/$file")){
del_recursive($currentDir,$connection,$file);
$msg = "$file " . $lblDeleted;
}
else $msg = $lblCouldNotDelete . " " . $file;
}
break;
case "delfile"; // Delete file
if(@ftp_delete($connection, "$file"))
{
$msg = "$file " . $lblDeleted;
} else { // Delete the directory
if(@ftp_rmdir($connection, "$file"))
{
$msg = "$file " . $lblDeleted;
} else { // Recursivly delete the directory
//Verify if has files inside and if so, call recursive del
if ($lista = @ftp_nlist($connection, "$currentDir/$file")){
del_recursive($currentDir,$connection,$file);
$msg = "$file " . $lblDeleted;
}
else $msg = $lblCouldNotDelete . " " . $file;
}
}
break;
case "rename"; // Rename file
if(@ftp_rename($connection, "$file", "$file2"))
{
$msg = $file . " " . $lblRenamedTo . " " . $file2;
}
else
{
$msg = $lblCouldNotRename . " " . $file . " " . $lblTo . " " . $file2;
}
break;
case "createdir": // Create a new directory
if(@ftp_mkdir($connection, "$file"))
{
$msg = $file . " " . $lblCreated;
}
else
{
$msg = $lblCouldNotCreate . " " . $file;
}
break;
}
}
?>
phpWebFTP
|
";
}
else
{
if(!isset($msg))
{
$msg = "$lblCouldNotConnectToServer $server:$port $lblWithUser $user$lblTryAgain";
unset($_SESSION['server']);
unset($_SESSION['user']);
unset($_SESSION['password']);
unset($_SESSION['port']);
session_destroy();
}
?>
|
phpWebFTP
phpWebFTP
|