New version
This commit is contained in:
parent
d299e73fa4
commit
cf8262d3cb
8 changed files with 5058 additions and 133 deletions
|
|
@ -1,20 +1,73 @@
|
|||
<?php
|
||||
define("MAIN_DIR", __dir__."/..");
|
||||
|
||||
if (!empty($_GET["f"]) && is_file(MAIN_DIR."/content/".$_GET["f"]))
|
||||
function get_info($url)
|
||||
{
|
||||
$filename = MAIN_DIR."/content/".$_GET["f"];
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Disposition: attachment; filename=\"".$_GET["f"]."\"");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($filename));
|
||||
readfile($filename);
|
||||
exit;
|
||||
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$nbLign = count($ec);
|
||||
|
||||
for ($i = 0; $i < $nbLign; $i++)
|
||||
{
|
||||
if ($ec[$i] == $url)
|
||||
break;
|
||||
else
|
||||
{
|
||||
while ($i < $nbLign && trim($ec[$i]) != "--")
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($i < $nbLign)
|
||||
{
|
||||
$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+3]);
|
||||
return array($ec[$i], $ec[$i+1], $ec[$i+2], $ec[$i+3], trim($filename));
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
die ("Fichier introuvable");
|
||||
|
||||
$user = "generic";
|
||||
foreach ($_GET as $k => $t)
|
||||
{
|
||||
if (empty($t))
|
||||
{
|
||||
$user = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
||||
die ("Le nom d'utilisateur contient des caractères interdits.");
|
||||
|
||||
|
||||
if (isset($_GET["f"]))
|
||||
{
|
||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
||||
{
|
||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
foreach ($ec as $k => $lign)
|
||||
{
|
||||
if ($k == $_GET["f"])
|
||||
{
|
||||
$musik = get_info($lign);
|
||||
if (isset($musik) && is_file(MAIN_DIR."/content/".$musik[4]))
|
||||
{
|
||||
$filename = MAIN_DIR."/content/".$musik[4];
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Disposition: attachment; filename=\"".$musik[1].".mp3\"");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($filename));
|
||||
readfile($filename);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die ("Fichier introuvable");
|
||||
?>
|
||||
Reference in a new issue