119 lines
4.3 KiB
PHP
119 lines
4.3 KiB
PHP
<?php
|
|
|
|
define("MAIN_DIR", __dir__."/..");
|
|
|
|
function get_info($url)
|
|
{
|
|
$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+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");
|
|
|
|
$xml = new DOMDocument('1.0', 'UTF-8');
|
|
$xml->formatOutput = true;
|
|
|
|
$xml_feed = $xml->createElement("feed");
|
|
$xml_feed->setAttribute("xmlns", "http://www.w3.org/2005/Atom");
|
|
|
|
$xml_feed_link = $xml->createElement("link");
|
|
$xml_feed_link->setAttribute("rel", "self");
|
|
$xml_feed_link->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])."atom.php?".$user);
|
|
|
|
$xml_feed_rights = $xml->createElement("rights", "Pommultimédia Online Converter");
|
|
$xml_feed_rights->setAttribute("type", "text");
|
|
|
|
$xml_feed_author = $xml->createElement("author");
|
|
$xml_feed_author->appendChild($xml->createElement("name", "nemunaire"));
|
|
|
|
$xml_feed->appendChild($xml->createElement("title", "Musiques téléchargées de ".$user));
|
|
$xml_feed->appendChild($xml->createElement("updated", date('c')));
|
|
$xml_feed->appendChild($xml->createElement("id", "http://musik.p0m.fr/atom.php?".$user));
|
|
$xml_feed->appendChild($xml_feed_link);
|
|
$xml_feed->appendChild($xml->createElement("generator", "Onyx Atom generator"));
|
|
$xml_feed->appendChild($xml_feed_rights);
|
|
$xml_feed->appendChild($xml_feed_author);
|
|
|
|
$files = array();
|
|
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);
|
|
$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])))
|
|
{
|
|
$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]))));
|
|
else
|
|
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik[4]))));
|
|
|
|
$xml_entry_summary = $xml->createElement("summary", htmlentities(utf8_decode($musik[2])));
|
|
$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("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("rel", "via");
|
|
$xml_entry->appendChild($xml_entry_enclosure);
|
|
|
|
$xml_entry_link = $xml->createElement("link");
|
|
$xml_entry_link->setAttribute("rel", "alternate");
|
|
$xml_entry_link->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])."?".$user);
|
|
|
|
$xml_entry->appendChild($xml_entry_summary);
|
|
$xml_entry->appendChild($xml_entry_link);
|
|
$xml_feed->appendChild($xml_entry);
|
|
}
|
|
}
|
|
}
|
|
|
|
$xml->appendChild($xml_feed);
|
|
|
|
//Cache::set('flux', array("date" => time(), "flux" => $xml->saveXML()));
|
|
|
|
print $xml->saveXML();
|
|
?>
|