o: ActiveSupport::Cache::Entry :@compressedF:@value"N"N
| dl.php | ||
|---|---|---|
| 50 | 50 |
// Create a temporary directory. Here we have an unavoidable but highly |
| 51 | 51 |
// unlikely to occure race condition |
| 52 | 52 |
|
| 53 |
$tmpname1 = tempnam("temp", "wsvn-");
|
|
| 54 |
$tmpname = $tmpname1; |
|
| 55 |
$tmpname .= "dir"; |
|
| 56 |
if (mkdir($tmpname)) |
|
| 53 |
if (count(glob("wsvn*"))<2) // Omezeni na pocet soucasne stahovanych souboru
|
|
| 57 | 54 |
{
|
| 58 |
// Get the name of the directory being archived |
|
| 59 |
$arcname = substr($path, 0, -1); |
|
| 60 |
$arcname = basename($arcname); |
|
| 61 |
if (empty($arcname)) |
|
| 62 |
$arcname = $rep->name; |
|
| 63 |
|
|
| 64 |
$svnrep->exportDirectory($path, $tmpname.DIRECTORY_SEPARATOR.$arcname, $rev); |
|
| 65 |
|
|
| 66 |
// ZIP it up |
|
| 67 |
chdir($tmpname); |
|
| 68 |
exec("zip -r ".quote("$arcname")." .");
|
|
| 69 |
|
|
| 70 |
$size = filesize("$arcname.zip");
|
|
| 71 |
|
|
| 72 |
// Give the file to the browser |
|
| 73 |
|
|
| 74 |
if ($fp = @fopen("$arcname.zip","rb"))
|
|
| 75 |
{
|
|
| 76 |
header("Content-Type: application/zip");
|
|
| 77 |
header("Content-Length: $size");
|
|
| 78 |
header("Content-Disposition: attachment; filename=\"".$rep->name."-$arcname.zip\"");
|
|
| 79 |
// Use a loop to transfer the data 4KB at a time. |
|
| 80 |
while(!feof($fp)) |
|
| 81 |
{
|
|
| 82 |
echo fread($fp, 4096); |
|
| 83 |
ob_flush(); |
|
| 84 |
} |
|
| 85 |
} |
|
| 86 |
else |
|
| 87 |
{
|
|
| 88 |
print "Unable to open file $arcname.zip"; |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
fclose($fp); |
|
| 92 |
|
|
| 93 |
chdir("..");
|
|
| 94 |
|
|
| 95 |
// Delete the directory. Why doesn't PHP have a generic recursive directory |
|
| 96 |
// deletion command? It's stupid. |
|
| 97 |
|
|
| 98 |
// if ($config->serverIsWindows) |
|
| 99 |
// {
|
|
| 100 |
// $cmd = quoteCommand("rmdir /S /Q ".quote($tmpname), false);
|
|
| 101 |
// } |
|
| 102 |
// else |
|
| 103 |
// {
|
|
| 104 |
$cmd = quoteCommand("rm -fr ".quote($tmpname), false);
|
|
| 105 |
// } |
|
| 106 |
|
|
| 107 |
@exec($cmd); |
|
| 55 |
$tmpname1 = tempnam("temp", "wsvn-");
|
|
| 56 |
$tmpname = $tmpname1; |
|
| 57 |
$tmpname .= "dir"; |
|
| 58 |
if (mkdir($tmpname)) |
|
| 59 |
{
|
|
| 60 |
// Get the name of the directory being archived |
|
| 61 |
$arcname = substr($path, 0, -1); |
|
| 62 |
$arcname = basename($arcname); |
|
| 63 |
if (empty($arcname)) |
|
| 64 |
$arcname = $rep->name; |
|
| 65 |
|
|
| 66 |
$svnrep->exportDirectory($path, $tmpname.DIRECTORY_SEPARATOR.$arcname, $rev); |
|
| 67 |
|
|
| 68 |
// ZIP it up |
|
| 69 |
chdir($tmpname); |
|
| 70 |
exec("zip -r ".quote("$arcname")." .");
|
|
| 71 |
|
|
| 72 |
$size = filesize("$arcname.zip");
|
|
| 73 |
|
|
| 74 |
// Give the file to the browser |
|
| 75 |
|
|
| 76 |
if ($fp = @fopen("$arcname.zip","rb"))
|
|
| 77 |
{
|
|
| 78 |
header("Content-Type: application/zip");
|
|
| 79 |
header("Content-Length: $size");
|
|
| 80 |
header("Content-Disposition: attachment; filename=\"".$rep->name."-$arcname.zip\"");
|
|
| 81 |
// Use a loop to transfer the data 4KB at a time. |
|
| 82 |
while(!feof($fp)) |
|
| 83 |
{
|
|
| 84 |
echo fread($fp, 4096); |
|
| 85 |
ob_flush(); |
|
| 86 |
} |
|
| 87 |
} |
|
| 88 |
else |
|
| 89 |
{
|
|
| 90 |
print "Unable to open file $arcname.zip"; |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
fclose($fp); |
|
| 94 |
|
|
| 95 |
chdir("..");
|
|
| 96 |
|
|
| 97 |
// Delete the directory. Why doesn't PHP have a generic recursive directory |
|
| 98 |
// deletion command? It's stupid. |
|
| 99 |
|
|
| 100 |
// if ($config->serverIsWindows) |
|
| 101 |
// {
|
|
| 102 |
// $cmd = quoteCommand("rmdir /S /Q ".quote($tmpname), false);
|
|
| 103 |
// } |
|
| 104 |
// else |
|
| 105 |
// {
|
|
| 106 |
$cmd = quoteCommand("rm -fr ".quote($tmpname), false);
|
|
| 107 |
// } |
|
| 108 |
|
|
| 109 |
@exec($cmd); |
|
| 110 |
} |
|
| 111 |
unlink($tmpname1); // Pomocny soubor smazeme az po smazani adresare |
|
| 108 | 112 |
} |
| 109 |
unlink($tmpname1); // Pomocny soubor smazeme az po smazani adresare |
|
| 110 |
|
|
| 113 |
else |
|
| 114 |
{
|
|
| 115 |
print "Sorry."; |
|
| 116 |
print "Server is overloaded..."; |
|
| 117 |
} |
|
| 111 | 118 |
?> |