Check size before download
Add common.php with common functions
This commit is contained in:
parent
30cd0ba548
commit
f8d59cca32
8 changed files with 455 additions and 308 deletions
|
|
@ -2,48 +2,9 @@
|
|||
|
||||
define("MAIN_DIR", __dir__."/..");
|
||||
|
||||
function get_info($url)
|
||||
{
|
||||
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$nbLign = count($ec);
|
||||
require(MAIN_DIR."/common.php");
|
||||
|
||||
for ($i = 0; $i < $nbLign; $i++)
|
||||
{
|
||||
if ($ec[$i] == $url)
|
||||
break;
|
||||
else
|
||||
{
|
||||
while ($i < $nbLign && trim($ec[$i]) != "--")
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($i+2 < $nbLign)
|
||||
{
|
||||
if ($ec[$i+3] == "-- ")
|
||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+2]);
|
||||
else
|
||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+3]);
|
||||
@$filenameogg = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.ogg', $filename);
|
||||
return @array($ec[$i], $ec[$i+1], $ec[$i+2], $ec[$i+3], trim($filename), trim($filenameogg));
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$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.");
|
||||
|
||||
header("Content-type: application/atom+xml;charset=utf-8");
|
||||
//header("Content-type: application/atom+xml;charset=utf-8");
|
||||
|
||||
$xml = new DOMDocument('1.0', 'UTF-8');
|
||||
$xml->formatOutput = true;
|
||||
|
|
@ -70,33 +31,32 @@ $xml_feed->appendChild($xml_feed_rights);
|
|||
$xml_feed->appendChild($xml_feed_author);
|
||||
|
||||
$files = array();
|
||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
||||
|
||||
$ec = get_dlmusiks($user);
|
||||
$cnt = 0;
|
||||
for ($i = count ($ec) - 1; $i >= 0 && $cnt < 10; $i--, $cnt++)
|
||||
{
|
||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$cnt = 0;
|
||||
for ($i = count ($ec) - 1; $i >= 0 && $cnt < 10; $i--, $cnt++)
|
||||
{
|
||||
$musik = get_info($ec[$i]);
|
||||
if (isset($musik) && (is_file (MAIN_DIR."/content/".$musik[4]) || is_file (MAIN_DIR."/content/".$musik[5])))
|
||||
$musik = $ec[$i];
|
||||
if (isset($musik) && (is_file (MAIN_DIR."/content/".$musik["mp3"]) || is_file (MAIN_DIR."/content/".$musik["ogg"])))
|
||||
{
|
||||
$xml_entry = $xml->createElement("entry");
|
||||
$xml_entry->appendChild($xml->createElement("id", "http://musik.p0m.fr/".$musik[0]));
|
||||
@$xml_entry->appendChild($xml->createElement("title", strip_tags($musik[1])));
|
||||
if (is_file (MAIN_DIR."/content/".$musik[5]))
|
||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik[5]))));
|
||||
$xml_entry->appendChild($xml->createElement("id", "http://musik.p0m.fr/".$musik["filename"]));
|
||||
@$xml_entry->appendChild($xml->createElement("title", strip_tags($musik["title"])));
|
||||
if (is_file (MAIN_DIR."/content/".$musik["ogg"]))
|
||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik["ogg"]))));
|
||||
else
|
||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik[4]))));
|
||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik["mp3"]))));
|
||||
|
||||
$xml_entry_summary = $xml->createElement("summary", htmlentities(utf8_decode($musik[2])));
|
||||
$xml_entry_summary = $xml->createElement("summary", htmlentities(utf8_decode($musik["title"])));
|
||||
$xml_entry_summary->setAttribute("type", "html");
|
||||
|
||||
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
||||
$xml_entry_enclosure->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"]).urlencode("dl.php?".$user."&f=".$i));
|
||||
$xml_entry_enclosure->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"]).urlencode("dl.php?".$user."&s&f=".$i));
|
||||
$xml_entry_enclosure->setAttribute("rel", "enclosure");
|
||||
$xml_entry->appendChild($xml_entry_enclosure);
|
||||
|
||||
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
||||
$xml_entry_enclosure->setAttribute("href", $musik[0]);
|
||||
$xml_entry_enclosure->setAttribute("href", $musik["url"]);
|
||||
$xml_entry_enclosure->setAttribute("rel", "via");
|
||||
$xml_entry->appendChild($xml_entry_enclosure);
|
||||
|
||||
|
|
@ -109,7 +69,7 @@ if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
|||
$xml_feed->appendChild($xml_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$xml->appendChild($xml_feed);
|
||||
|
||||
|
|
|
|||
Reference in a new issue