From b815baaf6fa68947e2c5de8d26a58ce57976a22a Mon Sep 17 00:00:00 2001 From: Cabillot Julien Date: Mon, 14 Dec 2015 14:03:01 +0100 Subject: [PATCH] grosse modifs --- controller/status.php | 27 ++--- include/config.php | 8 +- lib/Download.php | 14 +-- lib/Stream.php | 13 ++- root/admin/index.php | 5 +- root/css/{my.css => admin.css} | 25 ++++- root/css/scripts.css | 125 ++++++++++++++++++++++++ root/img/ip.png | Bin 0 -> 385 bytes root/img/link.png | Bin 0 -> 343 bytes root/index.php | 11 ++- root/scripts/index.html | 2 +- templates/status.php | 173 ++++++++------------------------- 12 files changed, 234 insertions(+), 169 deletions(-) rename root/css/{my.css => admin.css} (84%) create mode 100644 root/css/scripts.css create mode 100644 root/img/ip.png create mode 100644 root/img/link.png diff --git a/controller/status.php b/controller/status.php index 96a37b4..5a95e73 100644 --- a/controller/status.php +++ b/controller/status.php @@ -2,24 +2,25 @@ function getStatus() { - $listAdded = Download::listByState('added'); + $listAdded = Download::listByState('added'); $listDownloading = Download::listByState('downloading'); - $listDownloaded = Download::listByState('downloaded'); - $listDupp = Download::listByState('dupp'); - $streamFinished = Stream::listByState('finished'); - $streamBegin = Stream::listByState('begin'); + $listDownloaded = Download::listByState('downloaded'); + $listDupp = Download::listByState('dupp'); + $streamFinished = Stream::listByState('finished'); + $streamBegin = Stream::listByState('begin'); - $infos = PremiumizeMe::getStatus(); - + $infos = PremiumizeMe::getStatus(); $tmpRestant = $infos['expires']->diff(new DateTime()); - $restant = ''; - if ($tmpRestant->m !== 0) { - $restant .= $tmpRestant->m.'mois '; + $restant = ''; + + if (0 !== $tmpRestant->m) { + $restant .= $tmpRestant->m.' mois '; } - if ($tmpRestant->d !== 0) { - $restant .= $tmpRestant->d.'jours '; + if (0 !== $tmpRestant->d) { + $restant .= $tmpRestant->d.' jours'; } - include dirname(__FILE__).'/../templates/status.php'; + + include __DIR__.'/../templates/status.php'; } function cleanList() diff --git a/include/config.php b/include/config.php index cf68a04..6ee18aa 100644 --- a/include/config.php +++ b/include/config.php @@ -19,7 +19,7 @@ define('DOWNLOADEDDIR', __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'ro */ define('DOWNLOADLOCK', DOWNLOADINGDIR.DIRECTORY_SEPARATOR.'lock'); -include dirname(__FILE__).'/../lib/DbMongo.php'; -include dirname(__FILE__).'/../lib/Download.php'; -include dirname(__FILE__).'/../lib/PremiumizeMe.php'; -include dirname(__FILE__).'/../lib/Stream.php'; +include __DIR__.'/../lib/DbMongo.php'; +include __DIR__.'/../lib/Download.php'; +include __DIR__.'/../lib/PremiumizeMe.php'; +include __DIR__.'/../lib/Stream.php'; diff --git a/lib/Download.php b/lib/Download.php index a5edf39..37abd1c 100644 --- a/lib/Download.php +++ b/lib/Download.php @@ -176,22 +176,22 @@ class Download { static function listByState($state) { - $db = DbMongo::get(); - $coll = $db->download; + $db = DbMongo::get(); + $coll = $db->download; $retour = []; - - foreach ($coll->find(['cstate' => $state]) as $element) { + + foreach ($coll->find(['cstate' => $state])->sort(['timestamp' => -1]) as $element) { $element['time'] = DateTime::createFromFormat('U', $element['timestamp']); - + if (file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$element['filename'])) { $element['href'] = true; } else { $element['href'] = false; } - + $retour[] = $element; } - + return $retour; } diff --git a/lib/Stream.php b/lib/Stream.php index 0c92e34..d6b0845 100644 --- a/lib/Stream.php +++ b/lib/Stream.php @@ -8,6 +8,7 @@ class Stream { public $cstate; public $url; public $ip; + public $hide; static public $validStates = ['begin', 'finished']; function __construct($url, $premURL, $filename, $ip) @@ -16,9 +17,10 @@ class Stream { $this->timestamp = time(); $this->premURL = $premURL; $this->filename = $filename; - $this->cstate = 'begin'; + $this->cstate = 'getlink'; $this->url = $url; $this->ip = $ip; + $this->hide = false; $db = DbMongo::get(); $coll = $db->stream; @@ -28,7 +30,8 @@ class Stream { 'ip' => $this->ip, 'url' => $this->url, 'cstate' => $this->cstate, - 'filename' => $this->filename + 'filename' => $this->filename, + 'hide' => $this->hide ]); } @@ -121,6 +124,10 @@ class Stream { $db = DbMongo::get(); $coll = $db->stream; - $coll->remove(['cstate' => $state]); + $coll->update( + [], + [ '$set' => [ 'hide' => true ]], + [ 'multiple' => true ] + ); } } diff --git a/root/admin/index.php b/root/admin/index.php index 1771ea3..7bea6b4 100644 --- a/root/admin/index.php +++ b/root/admin/index.php @@ -1,6 +1,7 @@ PVT!zEki%z`$7qnjYLLKekiBe_#B!Cva+bq$mcetG#des(cA3L=o5pyW#DIW< zfq{gBj-7~#g^7xay1ll$y|=u-xW2)=zrnl1#lOhO#Lm#m&d|)++Sl9N+5P?f{{H^| z|Nrr`Cv^Y-00?waPE!DLuCDj}{{Has6w3er0ES6KK~xyiRgUQrf-npQ1E`=PiuYNp z0dGs+|LN@4iCXtxc6O2wIb!uC#!S7|3a#=&*-Wr1%#Uk`FdsmKd0)hQxjSr;=OSjS z{br0j6ER&(MnmM*niL{0%CbQ2NdA`cs}oUbK4(pJ;hU!9_t;50DC+W)@BHvN(Djwi f+_2BR2*CUXU{V>TkaNUk00000NkvXXu0mjfqb|N% literal 0 HcmV?d00001 diff --git a/root/img/link.png b/root/img/link.png new file mode 100644 index 0000000000000000000000000000000000000000..25eacb7c2524142262d68bf729c5e2b61adfd6d4 GIT binary patch literal 343 zcmV-d0jU0oP)$`dXYaZs9=SbAto%g@>T~?_bH&lTUn@`uo|1bXE{eSR(AO)ESb=V4`uk}mK|39Px&03WLbv~pzk+s7D@lK^ zn+aB+sp)&Y_x-B3>;6ywU--WQNUr<8>TU0P-|L#1U&;A)67w(+> pDf@fM7q9#F25QXo3rUI;002ro52U44e~JJA002ovPDHLkV1l;_q@Mr) literal 0 HcmV?d00001 diff --git a/root/index.php b/root/index.php index 99858db..f4ccb2b 100644 --- a/root/index.php +++ b/root/index.php @@ -1,6 +1,6 @@ Comment Télécharger - + diff --git a/templates/status.php b/templates/status.php index 7227b86..fb950fb 100644 --- a/templates/status.php +++ b/templates/status.php @@ -4,158 +4,63 @@ Admin - + - +
+ Expiration : format('d/m/Y') ?> ()
+ Traffic Restant : Go (%)
+


-
- -
- Liste des fichiers a traiter :
- - - - - - - - - - - - - - - -
DateFilename
format('d/m/Y'); ?> - <?= $result['event'][0]['ip']; ?> - - -
- -
- -
- Liste des fichiers en cours :
- - - - - - - - - - - - - - - - - -
DateFilenameIP
format('d/m/Y'); ?> - <?= $result['event'][0]['ip']; ?> - - -
-
- -
- Liste des fichiers terminés :
- - - - - - - - +
+
+
DateFilename
+ + + + + + +
AjoutéEn coursFiniDuppliqué
+
+ + + + + + + + '.$result['filename'].''; +foreach([ 'added' => $listAdded, 'downlading' => $listDownloading, 'downloaded' => $listDownloaded, 'dupp' => $listDupp ] as $catName => $cat) { + foreach($cat as $element) { + if ($element['href']) { + $nameLink = ''.$element['filename'].''; } else { - $nameLink = $result['filename']; + $nameLink = $element['filename']; } ?> - - - - + + + + + - -
DateFilename
format('d/m/Y'); ?> - <?= $result['event'][0]['ip']; ?> - - -
format('d/m/Y'); ?> + <?= $element['event'][0]['ip']; ?> + +
- -
- -
- Liste des fichiers duppliqués :
- - - - - - - - - - - - - - - - - -
DateFilenameIP
format('d/m/Y'); ?>
- -
+ +