126 lines
3.1 KiB
PHP
Executable File
126 lines
3.1 KiB
PHP
Executable File
<?php
|
|
include_once 'path.php';
|
|
session_write_close();
|
|
|
|
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true)
|
|
exit(header("Location:../index.php"));
|
|
|
|
if(empty($userName)){
|
|
$userName = $_SESSION['userName'];
|
|
}
|
|
if($_SESSION['validUser'] === true)
|
|
{
|
|
$fullPath = isset($_GET['fullPath'])?$_GET['fullPath']:'/';
|
|
$fullPath = phpRealEscapeString($fullPath);
|
|
$pageid = (isset( $_GET['pageid'] )) ? $_GET['pageid'] : '0';
|
|
/* Backup Location - Start */
|
|
$rListPath = constructRestoreFileName($fullPath);
|
|
|
|
$rListPath = constructRestoreFileName($fullPath, $pageid);
|
|
$pidFile = createFullRestoreDir($fullPath);
|
|
$pidFile .= '/'.PID_FILE;
|
|
|
|
$retryCount = 0;
|
|
$dirFiles = NULL;
|
|
while(1){
|
|
if ( file_exists( $rListPath ) && customFileSize( $rListPath ) )
|
|
{
|
|
$dirFiles = file_get_contents($rListPath);
|
|
break;
|
|
}
|
|
else if ( file_exists( $pidFile ) )
|
|
{
|
|
if ( $retryCount <= 20 )
|
|
{
|
|
++$retryCount;
|
|
sleep(1);
|
|
}
|
|
else
|
|
{
|
|
$response = array();
|
|
$response[] = false;
|
|
$response['retry'] = true;
|
|
echo json_encode($response);
|
|
exit;
|
|
}
|
|
}
|
|
else if( $pageid != '0' )
|
|
{
|
|
$response = array();
|
|
$response[] = false;
|
|
$response['retry'] = false;
|
|
echo json_encode($response);
|
|
exit;
|
|
}
|
|
else
|
|
{
|
|
remoteList("$fullPath");
|
|
if (file_exists($pidFile)) unlink($pidFile);
|
|
// If there's a race condition, we might need to send
|
|
// retry flag in response variable.
|
|
exit;
|
|
}
|
|
}
|
|
$dirArrayDefault = json_decode($dirFiles,true);
|
|
ksort($dirArrayDefault);
|
|
/* Backup Location - End */
|
|
|
|
$countDir = count($dirArrayDefault);
|
|
$resStatus = true;
|
|
$resHtml = '';
|
|
|
|
if($countDir>0){
|
|
$fullPath = $fullPath!="/"?"$fullPath/":"$fullPath";
|
|
$count = 0;
|
|
|
|
foreach($dirArrayDefault as $dir=>$property) {
|
|
$dirName = $dir;
|
|
$fullPathHTML = htmlentities($fullPath.$dirName, ENT_QUOTES);
|
|
$dirNameHTML = str_replace(" "," ",htmlentities($dirName, ENT_QUOTES));
|
|
if($property['type'] == "D") {
|
|
$resHtml .= "<tr>";
|
|
$resHtml .= "<td width=\"100%\" class=\"cont_heading\"";
|
|
$resHtml .= "title='".$dirNameHTML."'>";
|
|
$resHtml .= "<a class=\"getBackupDirList\" href=\"javascript:void(0);\" alt='".$fullPathHTML."' ><img src=\"include/images/idq_ico_folder.png\"><span>".$dirNameHTML."</span></a>";
|
|
$resHtml .= "<input type=\"hidden\" value='".htmlentities($fullPath.$dirName."/", ENT_QUOTES)."' />";
|
|
$resHtml .= "</td>";
|
|
$resHtml .= "</tr>";
|
|
$count++;
|
|
$type[] = 'folder';
|
|
/*} else {
|
|
$type[] = 'file';
|
|
}*/
|
|
$dirArray[] = $fullPath.$dirName;
|
|
}
|
|
}
|
|
if($count === 0){
|
|
$response = array();
|
|
$response[] = false;
|
|
$response['retry'] = true;
|
|
echo json_encode($response);
|
|
exit;
|
|
}
|
|
} else {
|
|
$resStatus = false;
|
|
$resHtml = "<div class=\"nfiles\" style=\"display:block;\">".NO_FILES."</div>";
|
|
}
|
|
|
|
if(isset($_GET['fullPath'])){
|
|
$resArr[]=$resStatus;
|
|
$resArr[]=$resHtml;
|
|
if(!isset($dirArray)) {
|
|
$dirArray = array();
|
|
}
|
|
if(!isset($type)) {
|
|
$type = "";
|
|
}
|
|
$resArr[]= array('url'=>$fullPath,'dir'=>$dirArray,'type'=>$type,'size'=>$size,'date'=>$date);
|
|
echo json_encode($resArr);
|
|
exit;
|
|
} else {
|
|
echo $resHtml;
|
|
}
|
|
|
|
}
|
|
?>
|