示例#1
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 24/11/15
 * Time: 4:37 AM
 */
function HandleFileRequest($Request)
{
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    include '../common/controller/user_get.php';
    include '../common/controller/add_file.php';
    include '../common/controller/file_get.php';
    include '../common/controller/add_fav.php';
    include '../common/controller/Rename.php';
    if (validate_file_request($Request) == "True") {
        $UserDetail = GetUser($Request["payloads"]);
        if (isset($UserDetail[0]['Username'])) {
            $RequestData['Username'] = $UserDetail[0]['Username'];
            $RequestData['Time'] = time();
            switch ($Request["type"]) {
                case "PUT":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Filename'] = $Request['payloads']['File'];
                    $RequestData['Type'] = $Request['payloads']['Type'];
                    $Res = AddFile($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                case "GET":
                    $Response = GetFile($RequestData['Username']);
                    break;
                case "FAV":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Fav'] = $Request['payloads']['Fav'];
                    $Res = AddFav($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                case "RENAME":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Filename'] = $Request['payloads']['Filename'];
                    $Res = RenameFile($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                default:
                    $Response = ReturnResponse(TYPE_NOT_SPECIFIED);
            }
            return $Response;
        } else {
            $Response = ReturnResponse(PAYLOAD_MISSING);
            $Response['info'] = "Could Not Get User";
            return $Response;
        }
    } else {
        $Response = ReturnResponse(PAYLOAD_MISSING);
        $Response['info'] = "Data verification failed";
        return $Request;
    }
}
示例#2
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 24/11/15
 * Time: 4:37 AM
 */
function HandleFileRequest($Request)
{
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    include '../common/controller/user_get.php';
    include '../common/controller/add_file.php';
    include '../common/controller/file_get.php';
    include '../common/controller/add_fav.php';
    include '../common/controller/Rename.php';
    if (validate_file_request($Request) == "True") {
        $Type = $Request["type"];
        $Data = $Request["payloads"];
        $Username = GetUser($Data);
        if (isset($Username[0]['Username'])) {
            $username = $Username[0]['Username'];
            $RequestData['Username'] = $username;
            $RequestData['File'] = $Data['File'];
            $RequestData['Filename'] = $Data['File'];
            $RequestData['Type'] = $Data['Type'];
            $RequestData['Time'] = time();
            switch ($Type) {
                case "PUT":
                    $Response["STATUS CODE"] = AddFile($RequestData);
                    if ($Response["STATUS CODE"] == ERROR_DUP_NAME) {
                        $Response["SUCCESS"] = "False";
                        $Response["Message"] = "Something Went Wrong";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["Message"] = "File Added Successfully";
                    }
                    return $Response;
                case "GET":
                    $Response["Payloads"] = GetFile($RequestData['Username']);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "No Files To Display";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                case "FAV":
                    $RequestData['Fav'] = $Data['Fav'];
                    $Response["Payloads"] = AddFav($RequestData);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "Authentication Error";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                case "RENAME":
                    $Response["Payloads"] = RenameFile($RequestData);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "Authentication Error";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                default:
                    return TYPE_NOT_SPECIFIED;
            }
        } else {
            $Response["SUCCESS"] = "False";
            $Response["STATUS CODE"] = PAYLOAD_MISSING;
            $Response["Payloads"] = "Payload Does Not Exists";
        }
    } else {
        $Response["SUCCESS"] = "False";
        $Response["STATUS CODE"] = PAYLOAD_MISSING;
        $Response["Payloads"] = "Invalid Json";
        return $Response;
    }
}
示例#3
0
    $file = base64_decode($_GET['file']);
    DownloadFile($file);
}
if ($action == 'delete') {
    $file = base64_decode($_GET['file']);
    echo DeleteFile($file);
}
if ($action == 'newdir') {
    $curdir = base64_decode($_GET['curdir']);
    $name = base64_decode($_GET['name']);
    echo NewDir($curdir, $name);
}
if ($action == 'rename') {
    $oldname = base64_decode($_GET['old']);
    $newname = base64_decode($_GET['new']);
    echo RenameFile($oldname, $newname);
}
if ($action == 'upload') {
    $curdir = base64_decode($_GET['curdir']);
    echo UploadFile($curdir);
}
return;
/* *********************** Actions-End *********************** */
function UploadFile($curdir)
{
    if (!file_exists($curdir)) {
        return 'basedir not found';
    }
    if (!isset($_FILES['files'])) {
        return 'file not found';
    }
示例#4
0
	/* ----- setup variables ----- */
	$action = GetVariable("action");
	$seriesid = GetVariable("seriesid");
	$modality = GetVariable("modality");
	$datatype = GetVariable("datatype");
	$filename = GetVariable("filename");
	
	//$datadir = GetDataDir($seriesid, $modality, $datatype);
	
	/* determine action */
	if ($action == "delete") {
		DeleteFile($seriesid, $modality, $datatype, $filename);
		DisplayFileList($seriesid, $modality, $datatype);
	}
	elseif ($action == "rename") {
		RenameFile($seriesid, $modality, $datatype, $filename, $newfilename);
		DisplayFileList($seriesid, $modality, $datatype);
	}
//	elseif ($action == "download") {
//		Download($seriesid, $modality, $datatype, $filename);
//	}
	else {
		DisplayFileList($seriesid, $modality, $datatype);
	}
	
	
	/* ------------------------------------ functions ------------------------------------ */

	
	/* -------------------------------------------- */
	/* ------- GetDataDir ------------------------- */