I try to do so that I can download files but I have a problem and don't know how to fix it can you help me find the error?
Nothing happens. And help me to get this to work. I don't know how to fix this so need all the help I can get.
<?php
require("configuration.php");
require("include.php");
require_once('./libs/phpseclib/SFTP.php');
require_once("./libs/phpseclib/Crypt/AES.php");
if(!isset($_SESSION['clientid']))
{
//DON'T KNOW HOW THE REQEUSTOR IS!!
die();
}
$clientid = $_SESSION['clientid'];
$serverid = '';
$extendedPath = '';
$action = '';
if(!isset($_GET['serverid']) or !isset($_GET['path']) or !isset($_GET['action']))
{
die();
}
$serverid = $_GET['serverid'];
$extendedPath = $_GET['path'];
$action = $_GET['action'];
$boxDetailsSQL = sprintf("SELECT box.boxid, box.ip, box.login, box.password, box.sshport, srv.path
FROM %sbox box
JOIN %sserver srv ON box.boxid = srv.boxid
JOIN %sgroupMember grpm ON (grpm.groupids LIKE CONCAT(srv.groupid, ';%%')
OR grpm.groupids LIKE CONCAT('%%;', srv.groupid, ';%%'))
WHERE srv.serverid = %d
AND grpm.clientid = %d;", DBPREFIX, DBPREFIX, DBPREFIX, $serverid, $clientid);
$boxDetails = mysql_query($boxDetailsSQL);
$rowsBoxes = mysql_fetch_assoc($boxDetails);
$aes = new Crypt_AES();
$aes->setKeyLength(256);
$aes->setKey(CRYPT_KEY);
$sftp= new Net_SFTP($rowsBoxes['ip'], $rowsBoxes['sshport']);
if(!$sftp->login($rowsBoxes['login'], $aes->decrypt($rowsBoxes['password'])))
{
echo 'Failed to connect';
die();
}
//ACTION SELECTOR
if($action == 'list')
{
getlist($rowsBoxes, $extendedPath, $sftp);
}
if($action == 'fileUpload')
{
fileUpload($rowsBoxes, $extendedPath, $sftp);
}
if($action == 'download')
{
delete($rowsBoxes, $extendedPath, $sftp);
}
//ACTION FUNCTIONS
function download($rowsBoxes, $extendedPath, $sftp)
{
$remoteFile = dirname($rowsBoxes['path']).'/'.trim($extendedPath.'/');
$downloadfile $sftp->put($remoteFile);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($downloadfile));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($downloadfile));
readfile($downloadfile);
}
This code I need help to fix.
function download($rowsBoxes, $extendedPath, $sftp)
{
$remoteFile = dirname($rowsBoxes['path']).'/'.trim($extendedPath.'/');
$downloadfile $sftp->put($remoteFile);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($downloadfile));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($downloadfile));
readfile($downloadfile);
}