177 lines
4.7 KiB
PHP
177 lines
4.7 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)
|
|
{
|
|
@$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;
|
|
}
|
|
|
|
header("Content-type: text/html;charset=utf-8");
|
|
|
|
$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.");
|
|
?>
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>.: Pommultimédia - Online Converter :.</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
|
|
<meta http-equiv="refresh" content="42">
|
|
</head>
|
|
<body>
|
|
<div class="blk">
|
|
<h2>Chansons prêtes à être téléchargées</h2>
|
|
<ul><?php
|
|
$dir = MAIN_DIR."/content/";
|
|
|
|
$someone = false;
|
|
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)
|
|
{
|
|
$musik = get_info($lign);
|
|
if(isset($musik) && is_file($dir.'/'.$musik[4]))
|
|
{
|
|
$someone = true;
|
|
echo '<li><a href="dl.php?'.$user.'&f='.$k.'">'.$musik[1].'</a></li>';
|
|
}
|
|
}
|
|
}
|
|
|
|
if (empty($someone))
|
|
echo "<h3>Aucun élément dans cette liste</h3>";
|
|
?> </ul>
|
|
</div>
|
|
<div class="blk">
|
|
<h2>Ajouter une chanson</h2>
|
|
<?php
|
|
if ((!empty($_GET["a"]) && $_GET["a"] == "add" && (!empty($_POST["url"]) || !empty($_SERVER["HTTP_REFERER"]))) || !empty($_GET["url"]))
|
|
{
|
|
if (!empty($_GET["url"]))
|
|
$url = $_GET["url"];
|
|
elseif (!empty($_POST["url"]))
|
|
$url = $_POST["url"];
|
|
else
|
|
$url = $_SERVER["HTTP_REFERER"];
|
|
|
|
if ($url == "clear")
|
|
{
|
|
if ($fp = fopen(MAIN_DIR."/users/".$user.".dlist", "a+"))
|
|
{
|
|
fputs($fp, "clear\n");
|
|
print "<h3 style=\"color: #00FF00;\">La demande de vidage de la liste a été ajouté à la file d'attente</h3>";
|
|
}
|
|
}
|
|
elseif (preg_match("#^http://(www.)?youtube.com/watch\?v=([a-zA-Z0-9_-]+)#", $url, $matched))
|
|
{
|
|
//Check if the URL isn't already in the file
|
|
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
|
$content = file(MAIN_DIR."/users/".$user.".dlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
else
|
|
$content = array();
|
|
if (!in_array($matched[0], $content) && $fp = fopen(MAIN_DIR."/users/".$user.".dlist", "a+"))
|
|
{
|
|
fputs($fp, $matched[0]."\n");
|
|
print "<h3 style=\"color: #00FF00;\">L'adresse a bien été ajoutée avec succès.</h3>";
|
|
}
|
|
}
|
|
else
|
|
print "<h3>L'adresse fournie n'est pas valide !</h3>";
|
|
}
|
|
?>
|
|
<form method="post" action="?a=add&<?php echo $user; ?>">
|
|
<label for="url">Adresse :</label> <input type="text" name="url" size="50">
|
|
<input type="submit" value="Ajouter">
|
|
</form>
|
|
</div>
|
|
<div class="blk">
|
|
<h2>Chansons en file d'attente</h2>
|
|
<form method="post" action="?a=del">
|
|
<ul><?php
|
|
$someone = false;
|
|
if (is_file(MAIN_DIR."/users/".$user.".dlist.ec"))
|
|
{
|
|
$ec = file(MAIN_DIR."/users/".$user.".dlist.ec",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
|
|
if (!empty($ec[0]))
|
|
{
|
|
$musik = get_info($ec[0]);
|
|
if(isset($musik))
|
|
{
|
|
echo '<div style="text-align: center;"><img src="'.$musik[2].'" alt="Miniature"></div>';
|
|
|
|
if (count ($ec) == 1)
|
|
echo "<label>En cours de téléchargement :</label>";
|
|
else if (count ($ec) == 2)
|
|
echo "<label>En cours de conversion :</label>";
|
|
|
|
echo $musik[1];
|
|
$encours = $ec[0];
|
|
$someone = true;
|
|
}
|
|
}
|
|
}
|
|
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
|
{
|
|
$ec = file(MAIN_DIR."/users/".$user.".dlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
|
|
foreach ($ec as $k => $lign)
|
|
{
|
|
if (isset($encours) && $lign == $encours)
|
|
continue;
|
|
|
|
$someone = true;
|
|
$musik = get_info($lign);
|
|
if(isset($musik) && is_file($dir.'/'.$musik[4]))
|
|
echo '<li>'.$musik[1].'</li>';
|
|
else
|
|
echo '<li>'.$lign.' <input type="submit" name="del'.sha1($lign).'" value="Retirer de la liste"></li>';
|
|
}
|
|
}
|
|
|
|
if (empty($someone))
|
|
echo "<h3>Aucun élément dans cette liste</h3>";
|
|
?></ul>
|
|
</form>
|
|
</div>
|
|
<div class="blk">
|
|
<h2>Chansons déjà téléchargées</h2>
|
|
<h3>Prochainement ...</h3>
|
|
</div>
|
|
</body>
|
|
</html>
|