protected function execute() { $uri = $this->request->getPath(); $storage = new binarypool_storage($this->bucket); // Access control if (!$storage->fileExists($uri)) { throw new binarypool_exception(115, 404, "File not found: " . $uri); } if (!$storage->isDir($uri)) { throw new binarypool_exception(115, 404, "File not found: " . $uri); } // List all assets matching the view $xml = '<status method="view">'; $xml .= '<bucket>' . htmlspecialchars($this->bucket) . '</bucket>'; // Remove leading slash and bucket name $dir = substr($uri, 2 + strlen($this->bucket)); $files = $storage->listDir($dir); foreach ($files as $file) { $asset = $storage->getAssetObject($file); $xml .= '<file id="' . htmlspecialchars($asset->getHash()) . '">'; $xml .= htmlspecialchars($asset->getBasePath()); $xml .= '</file>'; } $xml .= '</status>'; array_push($this->data, new api_model_xml($xml)); }
/** * Returns all items which expired in the last seven days * including today. * * All the returned file names are relative paths. */ public static function getExpired($bucket) { $files = array(); $storage = new binarypool_storage($bucket); for ($day = 0; $day < 100; $day++) { // Date directory for given day $dateDir = date('Y/m/d', time() - $day * 24 * 60 * 60); // Get all asset files which expired in those days $retval = $storage->listDir('expiry/' . $dateDir); $files = array_merge($files, $retval); } return $files; }