|
|
|
@ -2,61 +2,56 @@ |
|
|
|
|
|
|
|
function getStatus() |
|
|
|
{ |
|
|
|
$listAdded = []; |
|
|
|
$listDownloading = []; |
|
|
|
$listDownloaded = []; |
|
|
|
$listDupp = []; |
|
|
|
$db = DbMongo::get(); |
|
|
|
$coll = $db->download; |
|
|
|
$listAdded = Download::listByState('added'); |
|
|
|
$listDownloading = Download::listByState('downloading'); |
|
|
|
$listDownloaded = Download::listByState('downloaded'); |
|
|
|
$listDupp = Download::listByState('dupp'); |
|
|
|
$streamFinished = Stream::listByState('finished'); |
|
|
|
$streamBegin = Stream::listByState('begin'); |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'added']) as $element) { |
|
|
|
$listAdded[] = $element; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'downloading']) as $element) { |
|
|
|
$listDownloading[] = $element; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'downloaded']) as $element) { |
|
|
|
$listDownloaded[] = $element; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'dupp']) as $element) { |
|
|
|
$listDupp[] = $element; |
|
|
|
} |
|
|
|
|
|
|
|
$coll = $db->stream; |
|
|
|
$infos = PremiumizeMe::getStatus(); |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'finished']) as $element) { |
|
|
|
$streamFinished[] = $element; |
|
|
|
$tmpRestant = $infos['expires']->diff(new DateTime()); |
|
|
|
$restant = ''; |
|
|
|
if ($tmpRestant->m !== 0) { |
|
|
|
$restant .= $tmpRestant->m.'mois '; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($coll->find(['cstate' => 'begin']) as $element) { |
|
|
|
$streamBegin[] = $element; |
|
|
|
if ($tmpRestant->d !== 0) { |
|
|
|
$restant .= $tmpRestant->d.'jours '; |
|
|
|
} |
|
|
|
|
|
|
|
$infos = PremiumizeMe::getStatus(); |
|
|
|
include dirname(__FILE__).'/../templates/status.php'; |
|
|
|
} |
|
|
|
|
|
|
|
function cleanList() |
|
|
|
{ |
|
|
|
// TODO : plus de verif
|
|
|
|
if (!isset($_GET['type']) || empty($_GET['type'])) { |
|
|
|
echo json_encode('pas de type, exit'); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO : plus de verif
|
|
|
|
if (!isset($_GET['state']) || empty($_GET['state'])) { |
|
|
|
echo json_encode('pas de state, exit'); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
$db = DbMongo::get(); |
|
|
|
$coll = $db->$_GET['type']; |
|
|
|
|
|
|
|
$coll->remove(['cstate' => $_GET['state']]); |
|
|
|
|
|
|
|
echo json_encode('ok'); |
|
|
|
if ($_GET['type'] === 'download') { |
|
|
|
if (!in_array($_GET['state'], Download::$validStates)) { |
|
|
|
echo json_encode('mauvais state, exit'); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
Download::clear($_GET['state']); |
|
|
|
echo json_encode('ok'); |
|
|
|
} elseif ($_GET['type'] === 'stream') { |
|
|
|
if (!in_array($_GET['state'], Stream::$validStates)) { |
|
|
|
echo json_encode('mauvais state, exit'); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
Stream::clear($_GET['state']); |
|
|
|
echo json_encode('ok'); |
|
|
|
} else { |
|
|
|
echo json_encode('mauvais type, exit'); |
|
|
|
exit(); |
|
|
|
} |
|
|
|
} |