function deleteFiles($dir = NULL, $files = NULL) { if ($dir == NULL || $files == NULL || count($files) <= 0) { return FALSE; } global $cfg; $root = $cfg['path']['root']; $thumbRoot = $cfg['path']['thumb']; $bucket = $cfg['as3']['bucket']; $as3 = new AmazonS3Manager($cfg['as3']['key'], $cfg['as3']['secret']); // Loop through files and delete them foreach ($files as $file) { $path = _clean($root . '/' . $dir . '/' . $file); $as3->DeleteFile($bucket, $path); $thumbPath = _clean($thumbRoot . '/' . $dir . '/' . $file . '.jpg'); $as3->DeleteFile($bucket, $thumbPath); } }
$cfg['deny'] = array('folder' => array($cfg['path']['root'] . '/' . 'file', $cfg['path']['root'] . '/' . 'flash', $cfg['path']['root'] . '/' . 'image', $cfg['path']['root'] . '/' . 'media')); $reply = array('dirs' => array(), 'files' => array()); // ------------------ require_once 's3lib.php'; $mode = isset($_GET['mode']) ? $_GET['mode'] : 'getDirs'; $dir = isset($_POST['dir']) ? urldecode($_POST['dir']) : ''; switch ($mode) { case 'cfg': $rootDir = listDirs(); $children = array(); for ($i = -1, $iCount = count($rootDir); ++$i < $iCount;) { $children[] = (object) $rootDir[$i]; } $exp_date = time() + 6000; $policy = AmazonS3Manager::construct_policy($cfg['as3']['bucket'], $exp_date, $cfg['as3']['acl'], $cfg['path']['root']); $reply['config'] = array('lang' => 'en', 'url' => $cfg['path']['rootUrl'] . '/', 'thumbUrl' => $cfg['path']['thumbUrl'] . '/', 'thumb' => $cfg['path']['thumb'], 'thumbWidth' => 100, 'thumbHeight' => 100, 'children' => $children, 'as3' => array('bucket' => $cfg['as3']['bucket'], 'accessKey' => $cfg['as3']['key'], 'acl' => $cfg['as3']['acl'], 'policy' => $policy, 'root' => $cfg['path']['root'], 'thumb' => $cfg['path']['thumb'], 'signature' => AmazonS3Manager::create_signature($policy, $cfg['as3']['secret']))); break; case 'createFolder': $path = urldecode($_POST['dir']); $name = urldecode($_POST['newname']); $reply['isSuccess'] = createDir($path, $name); break; case 'deleteFolder': $path = urldecode($_POST['dir']); $reply['isDelete'] = deleteDir($path); break; case 'deleteFiles': $dir = urldecode($_POST['dir']); $files = urldecode($_POST['files']); $files = explode('::', $files); deleteFiles($dir, $files);
function ListBucket($bucket, $path, $delimiter = '/', $accessKey = NULL, $secretKey = NULL) { if (empty($accessKey)) { $accessKey = $this->_accessKey; } if (empty($secretKey)) { $secretKey = $this->_secretKey; } $timestamp = time(); // Create policy $policy = "AmazonS3" . "ListBucket" . gmdate("Y-m-d\\TH:i:s.000\\Z", $timestamp); // Create signature $signature = AmazonS3Manager::create_signature($policy, $secretKey); // Call SOAP service and return result try { $result = self::$_service->ListBucket(array('Bucket' => $bucket, 'Prefix' => $path, 'Delimiter' => $delimiter, 'AWSAccessKeyId' => $accessKey, 'Timestamp' => $timestamp, 'Signature' => $signature)); return $result->ListBucketResponse; } catch (SoapFault $fault) { trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); } }