Exemplo n.º 1
0
 /**
  *
  * @param string $area
  * @param string $key 
  */
 public static function clear($area = "", $key = "")
 {
     $path = self::getCacheDir($area);
     if ($key == "") {
         FileSystem::deleteDir($path);
     } else {
         FileSystem::deleteFile($path . "/" . md5($key) . ".txt");
     }
 }
Exemplo n.º 2
0
 public function uploadFileToRemoteHost($path, $url, $deleteFile = true)
 {
     global $SynchSessionController;
     $sessionId = $SynchSessionController->getCurrentSessionId();
     $fileUploader = new CurlFileUploader($path, $url, 'file1', array('sessionId' => $sessionId));
     $fileUploader->UploadFile();
     if ($deleteFile) {
         FileSystem::deleteFile($path);
     }
     return true;
 }
Exemplo n.º 3
0
require '../_inc/functions.inc';
require '../_inc/FileInterface.inc';
require '../_inc/FileSystemInterface.inc';
$return = array();
$return['result'] = 'fail';
$return['errors'] = array();
if (!isset($_REQUEST['filename']) || empty($_REQUEST['filename'])) {
    $return['missing'] = array('filename' => 'File Name');
} elseif (mb_strpos($_REQUEST['filename'], '/') !== false) {
    $return['errors'][] = 'Invalid file name';
} else {
    // should validate/sanitise the filename
    $file_to_delete = '../' . FMS_USER_FOLDER . '/' . trim($_REQUEST['filename']);
    if (!is_file($file_to_delete)) {
        $return['result'] = 'success';
    } else {
        $file = new \File($file_to_delete);
        $fileSystem = new \FileSystem('../' . FMS_USER_FOLDER);
        if ($fileSystem->deleteFile($file)) {
            $return['result'] = 'success';
        } else {
            $return['errors'][] = $fileSystem->error;
        }
    }
}
if (defined('FMS_AJAX') && FMS_AJAX === true) {
    header("HTTP/1.1 200 OK");
    header('Content-type: text/plain; charset=utf-8');
    echo json_encode($return);
    exit;
}