/WebSVN/dl.php
50,62 → 50,69
// Create a temporary directory. Here we have an unavoidable but highly
// unlikely to occure race condition
 
$tmpname1 = tempnam("temp", "wsvn-");
$tmpname = $tmpname1;
$tmpname .= "dir";
if (mkdir($tmpname))
if (count(glob("wsvn*"))<2) // Omezeni na pocet soucasne stahovanych souboru
{
// Get the name of the directory being archived
$arcname = substr($path, 0, -1);
$arcname = basename($arcname);
if (empty($arcname))
$arcname = $rep->name;
 
$svnrep->exportDirectory($path, $tmpname.DIRECTORY_SEPARATOR.$arcname, $rev);
// ZIP it up
chdir($tmpname);
exec("zip -r ".quote("$arcname")." .");
$size = filesize("$arcname.zip");
 
// Give the file to the browser
 
if ($fp = @fopen("$arcname.zip","rb"))
{
header("Content-Type: application/zip");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"".$rep->name."-$arcname.zip\"");
// Use a loop to transfer the data 4KB at a time.
while(!feof($fp))
{
echo fread($fp, 4096);
ob_flush();
}
}
else
{
print "Unable to open file $arcname.zip";
}
fclose($fp);
chdir("..");
 
// Delete the directory. Why doesn't PHP have a generic recursive directory
// deletion command? It's stupid.
 
// if ($config->serverIsWindows)
// {
// $cmd = quoteCommand("rmdir /S /Q ".quote($tmpname), false);
// }
// else
// {
$cmd = quoteCommand("rm -fr ".quote($tmpname), false);
// }
@exec($cmd);
$tmpname1 = tempnam("temp", "wsvn-");
$tmpname = $tmpname1;
$tmpname .= "dir";
if (mkdir($tmpname))
{
// Get the name of the directory being archived
$arcname = substr($path, 0, -1);
$arcname = basename($arcname);
if (empty($arcname))
$arcname = $rep->name;
$svnrep->exportDirectory($path, $tmpname.DIRECTORY_SEPARATOR.$arcname, $rev);
// ZIP it up
chdir($tmpname);
exec("zip -r ".quote("$arcname")." .");
$size = filesize("$arcname.zip");
// Give the file to the browser
if ($fp = @fopen("$arcname.zip","rb"))
{
header("Content-Type: application/zip");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"".$rep->name."-$arcname.zip\"");
// Use a loop to transfer the data 4KB at a time.
while(!feof($fp))
{
echo fread($fp, 4096);
ob_flush();
}
}
else
{
print "Unable to open file $arcname.zip";
}
fclose($fp);
chdir("..");
// Delete the directory. Why doesn't PHP have a generic recursive directory
// deletion command? It's stupid.
// if ($config->serverIsWindows)
// {
// $cmd = quoteCommand("rmdir /S /Q ".quote($tmpname), false);
// }
// else
// {
$cmd = quoteCommand("rm -fr ".quote($tmpname), false);
// }
@exec($cmd);
}
unlink($tmpname1); // Pomocny soubor smazeme az po smazani adresare
}
unlink($tmpname1); // Pomocny soubor smazeme az po smazani adresare
 
else
{
print "Sorry.";
print "Server is overloaded...";
}
?>