67 lines
No EOL
2.3 KiB
PHP
67 lines
No EOL
2.3 KiB
PHP
<?php
|
|
// Tool to list all files in a container
|
|
include 'config.php';
|
|
|
|
// Set up the container query URL
|
|
$accountName = 'opticaltranslations';
|
|
$container = isset($_GET['container']) ? $_GET['container'] : 'translated-documents';
|
|
$sasToken = AZURE_STORAGE_SAS_TOKEN;
|
|
|
|
// Build URL with SAS token
|
|
$url = "https://$accountName.blob.core.windows.net/$container?restype=container&comp=list&$sasToken";
|
|
|
|
echo "<h1>Container Contents: $container</h1>";
|
|
echo "<p>URL: $url</p>";
|
|
|
|
// Make the request
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
if ($httpCode === 200) {
|
|
// Parse XML response
|
|
$xml = simplexml_load_string($response);
|
|
if ($xml) {
|
|
echo "<h2>Files:</h2>";
|
|
echo "<table border='1'>";
|
|
echo "<tr><th>Name</th><th>Size</th><th>Last Modified</th><th>URL</th></tr>";
|
|
|
|
if (isset($xml->Blobs->Blob)) {
|
|
foreach ($xml->Blobs->Blob as $blob) {
|
|
$name = (string)$blob->Name;
|
|
$size = (string)$blob->Properties->{'Content-Length'};
|
|
$lastModified = (string)$blob->Properties->{'Last-Modified'};
|
|
$url = "https://$accountName.blob.core.windows.net/$container/$name?$sasToken";
|
|
$downloadLink = htmlspecialchars($url);
|
|
|
|
echo "<tr>";
|
|
echo "<td>$name</td>";
|
|
echo "<td>$size bytes</td>";
|
|
echo "<td>$lastModified</td>";
|
|
echo "<td><a href='$downloadLink' target='_blank'>Download</a></td>";
|
|
echo "</tr>";
|
|
}
|
|
} else {
|
|
echo "<tr><td colspan='4'>No files found in container</td></tr>";
|
|
}
|
|
|
|
echo "</table>";
|
|
} else {
|
|
echo "<p>Error parsing XML response</p>";
|
|
echo "<pre>" . htmlspecialchars($response) . "</pre>";
|
|
}
|
|
} else {
|
|
echo "<p>Error: HTTP code $httpCode</p>";
|
|
echo "<pre>" . htmlspecialchars($response) . "</pre>";
|
|
}
|
|
|
|
// Add links to switch containers
|
|
echo "<p>";
|
|
echo "<a href='?container=source-documents'>View Source Documents</a> | ";
|
|
echo "<a href='?container=translated-documents'>View Translated Documents</a>";
|
|
echo "</p>";
|
|
?>
|