Browse Source

grosse modifs

master
Cabillot Julien 5 years ago
parent
commit
b815baaf6f
12 changed files with 234 additions and 169 deletions
  1. 27
      controller/status.php
  2. 8
      include/config.php
  3. 14
      lib/Download.php
  4. 13
      lib/Stream.php
  5. 5
      root/admin/index.php
  6. 25
      root/css/admin.css
  7. 125
      root/css/scripts.css
  8. BIN
      root/img/ip.png
  9. BIN
      root/img/link.png
  10. 11
      root/index.php
  11. 2
      root/scripts/index.html
  12. 173
      templates/status.php

27
controller/status.php

@ -2,24 +2,25 @@
function getStatus() function getStatus()
{ {
$listAdded = Download::listByState('added');
$listAdded = Download::listByState('added');
$listDownloading = Download::listByState('downloading'); $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()); $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() function cleanList()

8
include/config.php

@ -19,7 +19,7 @@ define('DOWNLOADEDDIR', __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'ro
*/ */
define('DOWNLOADLOCK', DOWNLOADINGDIR.DIRECTORY_SEPARATOR.'lock'); 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';

14
lib/Download.php

@ -176,22 +176,22 @@ class Download {
static function listByState($state) static function listByState($state)
{ {
$db = DbMongo::get();
$coll = $db->download;
$db = DbMongo::get();
$coll = $db->download;
$retour = []; $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']); $element['time'] = DateTime::createFromFormat('U', $element['timestamp']);
if (file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$element['filename'])) { if (file_exists(DOWNLOADEDDIR.DIRECTORY_SEPARATOR.$element['filename'])) {
$element['href'] = true; $element['href'] = true;
} else { } else {
$element['href'] = false; $element['href'] = false;
} }
$retour[] = $element; $retour[] = $element;
} }
return $retour; return $retour;
} }

13
lib/Stream.php

@ -8,6 +8,7 @@ class Stream {
public $cstate; public $cstate;
public $url; public $url;
public $ip; public $ip;
public $hide;
static public $validStates = ['begin', 'finished']; static public $validStates = ['begin', 'finished'];
function __construct($url, $premURL, $filename, $ip) function __construct($url, $premURL, $filename, $ip)
@ -16,9 +17,10 @@ class Stream {
$this->timestamp = time(); $this->timestamp = time();
$this->premURL = $premURL; $this->premURL = $premURL;
$this->filename = $filename; $this->filename = $filename;
$this->cstate = 'begin';
$this->cstate = 'getlink';
$this->url = $url; $this->url = $url;
$this->ip = $ip; $this->ip = $ip;
$this->hide = false;
$db = DbMongo::get(); $db = DbMongo::get();
$coll = $db->stream; $coll = $db->stream;
@ -28,7 +30,8 @@ class Stream {
'ip' => $this->ip, 'ip' => $this->ip,
'url' => $this->url, 'url' => $this->url,
'cstate' => $this->cstate, 'cstate' => $this->cstate,
'filename' => $this->filename
'filename' => $this->filename,
'hide' => $this->hide
]); ]);
} }
@ -121,6 +124,10 @@ class Stream {
$db = DbMongo::get(); $db = DbMongo::get();
$coll = $db->stream; $coll = $db->stream;
$coll->remove(['cstate' => $state]);
$coll->update(
[],
[ '$set' => [ 'hide' => true ]],
[ 'multiple' => true ]
);
} }
} }

5
root/admin/index.php

@ -1,6 +1,7 @@
<?php <?php
include dirname(__FILE__).'/../../include/config.php';
include __DIR__.'/../../include/config.php';
include __DIR__.'/../../controller/status.php';
include dirname(__FILE__).'/../../controller/status.php';
getStatus(); getStatus();

root/css/my.css → root/css/admin.css

@ -83,14 +83,17 @@ a.btn {
/* Page d'admin */ /* Page d'admin */
div.account { div.account {
background-color: #F2A965;
background-color: #ffa726;
text-align: center; text-align: center;
margin-bottom: 1em; margin-bottom: 1em;
color: #FEFCFC;
} }
div.addMulti { div.addMulti {
margin-bottom: 1em; margin-bottom: 1em;
text-align: center; text-align: center;
margin-top: 5em;
margin-left: 1em;
} }
div.list { div.list {
@ -100,3 +103,23 @@ div.list {
div.list div { div.list div {
margin-bottom: 1em; margin-bottom: 1em;
} }
table.listdl {
width: 100%
}
.added {
background-color: #ccff90;
}
.downloading {
background-color: #78909c;
}
.downloaded {
background-color: #29b6f6;
}
.dupp {
background-color: #ef5350;
}

125
root/css/scripts.css

@ -0,0 +1,125 @@
html {
font-family : "Roboto", "Helvetica Neue", Helvetica, sans-serif;
font-size: 14px;
background: rgb(242, 242, 242);
}
a {
text-decoration: none;
color: #F2AA65;
}
h1 {
color: #DA4336;
font-size: 22px;
}
div.warning {
background: #DA4336;
color: #FEFCFC;
padding: 0.5em;
text-align: center;
box-shadow: 1px 1px 12px rgba(85, 85, 85, 0.25);
position: fixed;
top: 0;
width: 100%;
left: 0;
height: 3em;
}
div.contenu {
margin-left: 1em;
margin-top: 5em;
}
div.cont1 {
display: inline-block;
width: 100%;
height: 80px;
}
div.extension {
background: white;
float: left;
text-align: center;
padding-top: 0.8em;
padding-bottom: 0.8em;
padding-left: 2em;
padding-right: 2em;
margin-left: 3%;
border: 1px solid rgb(230, 230, 230);
height: inherit;
}
div.extension img {
margin-left: 1em;
margin-right: 1em;
margin-top: 0.5em;
}
div.script {
background: white;
float: left;
text-align: center;
padding-top: 0.8em;
padding-bottom: 0.8em;
padding-left: 2em;
padding-right: 2em;
margin-left: 5%;
border: 1px solid rgb(230, 230, 230);
height: inherit;
}
div.mybtn {
margin-top: 1.2em;
}
a.btn {
box-shadow: 1px 1px 1px rgba(102, 102, 102, 0.25);
color: rgb(254, 254, 254);
background: #fa963f;
padding: 10px 20px 10px 20px;
}
/* Page d'admin */
div.account {
background-color: #ffa726;
text-align: center;
margin-bottom: 1em;
color: #FEFCFC;
}
div.addMulti {
margin-bottom: 1em;
text-align: center;
margin-top: 5em;
margin-left: 1em;
}
div.list {
background-color: #B9C1CC;
}
div.list div {
margin-bottom: 1em;
}
table.listdl {
width: 100%
}
.added {
background-color: #ccff90;
}
.downloading {
background-color: #78909c;
}
.downloaded {
background-color: #29b6f6;
}
.dupp {
background-color: #ef5350;
}

BIN
root/img/ip.png

Before After
Width: 16  |  Height: 16  |  Size: 385 B

BIN
root/img/link.png

Before After
Width: 16  |  Height: 16  |  Size: 343 B

11
root/index.php

@ -1,6 +1,6 @@
<?php <?php
include dirname(__FILE__).'/../include/config.php';
include __DIR__.'/../include/config.php';
if (!isset($_GET['action'])) { if (!isset($_GET['action'])) {
exit(); exit();
@ -9,12 +9,12 @@ if (!isset($_GET['action'])) {
switch($_GET['action']) { switch($_GET['action']) {
case 'stream': case 'stream':
// http://mydl.cabillot.eu/stream/?myurl=https://1fichier.com/?fgrh5c7roq // http://mydl.cabillot.eu/stream/?myurl=https://1fichier.com/?fgrh5c7roq
include dirname(__FILE__).'/../controller/stream.php';
include __DIR__.'/../controller/stream.php';
getStream(); getStream();
break; break;
case 'download': case 'download':
// http://mydl.cabillot.eu/download/?myurls[]=https://1fichier.com/?fgrh5c7roq // http://mydl.cabillot.eu/download/?myurls[]=https://1fichier.com/?fgrh5c7roq
include dirname(__FILE__).'/../controller/download.php';
include __DIR__.'/../controller/download.php';
addDownload(); addDownload();
break; break;
case 'launchdownload': case 'launchdownload':
@ -23,6 +23,9 @@ switch($_GET['action']) {
break; break;
case 'cleanList': case 'cleanList':
// https://mydl.cabillot.eu/?action=cleanList&state=dupp // https://mydl.cabillot.eu/?action=cleanList&state=dupp
include dirname(__FILE__).'/../controller/status.php';
include __DIR__.'/../controller/status.php';
cleanList(); cleanList();
break;
case 'getHostersList':
echo json_encode(PremiumizeMe::getHosters()['hostershort']);
} }

2
root/scripts/index.html

@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Comment T&eacute;l&eacute;charger</title> <title>Comment T&eacute;l&eacute;charger</title>
<link rel="icon" type="image/png" href="/img/favicon.png"> <link rel="icon" type="image/png" href="/img/favicon.png">
<link rel="stylesheet" href="/css/my.css">
<link rel="stylesheet" href="/css/scripts.css">
<link href='//fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> <link href='//fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
</head> </head>
<body> <body>

173
templates/status.php

@ -4,158 +4,63 @@
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Admin</title> <title>Admin</title>
<link rel="icon" type="image/png" href="/img/favicon.png"> <link rel="icon" type="image/png" href="/img/favicon.png">
<link rel="stylesheet" href="/css/my.css">
<link rel="stylesheet" href="/css/admin.css">
<link href='//fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> <link href='//fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="/js/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/js/my.js"></script> <script type="text/javascript" src="/js/my.js"></script>
</head> </head>
<body> <body>
<div class="account">
Expiration : <?= $infos['expires']->format('d/m/Y') ?> (<?= $restant ?>)<br>
Traffic Restant : <?= intval($infos['trafficleft_gigabytes']) ?>Go (<?= intval($infos['fairuse_left'] * 100) ?>%)<br>
</div>
<div class="warning">
<b>Expiration :</b> <?= $infos['expires']->format('d/m/Y') ?> (<?= $restant ?>)<br>
<b>Traffic Restant :</b> <?= intval($infos['trafficleft_gigabytes']) ?>Go (<?= intval($infos['fairuse_left'] * 100) ?>%)<br>
</div>
<div class="addMulti"> <div class="addMulti">
<textarea id="urls" name="urls" style="margin: 0px; width: 985px; height: 401px;"></textarea><br> <textarea id="urls" name="urls" style="margin: 0px; width: 985px; height: 401px;"></textarea><br>
<input type="button" id="sub" name="sub" value="submit" onclick="javascript:subURL();"><br> <input type="button" id="sub" name="sub" value="submit" onclick="javascript:subURL();"><br>
</div> </div>
<div class="list">
<?php
if (!empty($listAdded)) {
?>
<div class="listAdded">
Liste des fichiers a traiter :<br>
<table>
<thead>
<tr>
<th>Date</th>
<th>Filename</th>
</tr>
</thead>
<tbody>
<?php
foreach ($listAdded as $result) {
?>
<tr>
<td><?= $result['time']->format('d/m/Y'); ?></td>
<td>
<img src="/img/ip.png" height=16 width=16 title="<?= $result['event'][0]['ip']; ?>" alt="<?= $result['event'][0]['ip']; ?>">
<a href="<?= $result['url']; ?>"><img src="/img/link.png" height=16 width=16></a>
<?= $result['filename']; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<input type="button" value="Wipe" onClick="javascript:wipe('download', 'added'); ">
</div>
<?php
}
if (!empty($listDownloading)) {
?>
<div class="listDownloading">
Liste des fichiers en cours :<br>
<table>
<thead>
<tr>
<th>Date</th>
<th>Filename</th>
<th>IP</th>
</tr>
</thead>
<tbody>
<?php
foreach ($listDownloading as $result) {
?>
<tr>
<td><?= $result['time']->format('d/m/Y'); ?></td>
<td>
<img src="/img/ip.png" height=16 width=16 title="<?= $result['event'][0]['ip']; ?>" alt="<?= $result['event'][0]['ip']; ?>">
<a href="<?= $result['url']; ?>"><img src="/img/link.png" height=16 width=16></a>
<?= $result['filename']; ?>
</td>
<td><?= $result['event'][0]['ip']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
}
if (!empty($listDownloaded)) {
?>
<div class="listDownloaded">
Liste des fichiers termin&eacute;s :<br>
<table>
<thead>
<tr>
<th>Date</th>
<th>Filename</th>
</tr>
</thead>
<tbody>
<div class="list">
<div class="">
<table>
<tr>
<td class="added">Ajouté</td>
<td class="downloading">En cours</td>
<td class="downloaded">Fini</td>
<td class="dupp">Duppliqu&eacute;</td>
</tr>
</table>
</div>
<table class="listdl">
<thead>
<tr>
<th>Date</th>
<th>Filename</th>
</tr>
</thead>
<tbody>
<?php <?php
foreach ($listDownloaded as $result) {
if ($result['href']) {
$nameLink = '<a href="/downloaded/'.$result['filename'].'">'.$result['filename'].'</a>';
foreach([ 'added' => $listAdded, 'downlading' => $listDownloading, 'downloaded' => $listDownloaded, 'dupp' => $listDupp ] as $catName => $cat) {
foreach($cat as $element) {
if ($element['href']) {
$nameLink = '<a href="/downloaded/'.$element['filename'].'">'.$element['filename'].'</a>';
} else { } else {
$nameLink = $result['filename'];
$nameLink = $element['filename'];
} }
?> ?>
<tr>
<td><?= $result['time']->format('d/m/Y'); ?></td>
<td>
<img src="/img/ip.png" height=16 width=16 title="<?= $result['event'][0]['ip']; ?>" alt="<?= $result['event'][0]['ip']; ?>">
<a href="<?= $result['url']; ?>"><img src="/img/link.png" height=16 width=16></a>
<?= $nameLink; ?>
</td>
</tr>
<tr class="<?= $element['cstate']; ?>">
<td><?= $element['time']->format('d/m/Y'); ?></td>
<td><?= $nameLink; ?></td>
<td>
<img src="/img/ip.png" height=16 width=16 title="<?= $element['event'][0]['ip']; ?>" alt="<?= $element['event'][0]['ip']; ?>">
<a href="<?= $element['url']; ?>"><img src="/img/link.png" height=16 width=16></a>
</td>
</tr>
<?php <?php
} }
?>
</tbody>
</table>
<input type="button" value="Wipe" onClick="javascript:wipe('download', 'downloaded');">
</div>
<?php
} }
if (!empty($listDupp)) {
?>
<div class="listDupp">
Liste des fichiers duppliqu&eacute;s :<br>
<table>
<thead>
<tr>
<th>Date</th>
<th>Filename</th>
<th>IP</th>
</tr>
</thead>
<tbody>
<?php
foreach ($listDupp as $result) {
?> ?>
<tr>
<td><?= $result['time']->format('d/m/Y'); ?></td>
<td><?= $result['filename']; ?></td>
<td><?= $result['event'][0]['ip']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<input type="button" value="Wipe" onClick="javascript:wipe('download', 'dupp');">
</div>
</tbody>
</table>
<?php <?php
}
if (!empty($streamBegin)) { if (!empty($streamBegin)) {
?> ?>
<div class="$streamBegin"> <div class="$streamBegin">

Loading…
Cancel
Save