$output .= "<td class='" . ($item->{'fail_message'} != "" ? "sabhistoryfail" : "sabhistorysuccess") . "'></td>";
                 $output .= "<td>" . htmlspecialchars($item->{'name'}, ENT_QUOTES) . "</td>";
                 $output .= "<td style='text-align:center;'>" . htmlspecialchars($item->{'category'}, ENT_QUOTES) . "</td>";
                 $output .= "<td title='" . htmlspecialchars($item->{'fail_message'}, ENT_QUOTES) . "' style='text-align:center;'>" . $item->{'status'} . "</td>";
                 $output .= "<td style='text-align:right;'>" . $item->{'size'} . "</td>";
                 $output .= "<td style='text-align:right;'>" . gmdate("H:i:s", $item->{'download_time'}) . "</td>";
                 $output .= "<td style='text-align:right;'>" . gmdate("Y-m-d H:i", $item->{'completed'}) . "</td>";
                 $output .= "</tr>\n";
                 $count++;
             }
             $output .= "</table>";
         }
     }
     break;
 case "nzbget":
     $queue = $nzbget->getQueue();
     if (is_array($queue) && count($queue) > 0) {
         $count = 1;
         $output .= "<table class=\"data highlight\">";
         $output .= "<tr>\r\n                            <th></th>\r\n                            <th>Name</th>\r\n                            <th style='width:80px;'>size</th>\r\n                            <th style='width:80px;'>left</th>\r\n                            <th style='width:50px;'>%</th>\r\n                            <th>left</th>\r\n                            <th></th>\r\n                            </tr>";
         foreach ($queue as $item) {
             $output .= "<tr>";
             $output .= "<td style='text-align:right;'>" . $count . "</td>";
             $output .= "<td>" . htmlspecialchars($item['NZBNicename'], ENT_QUOTES) . "</td>";
             $output .= "<td style='text-align:right;'>" . round($item['FileSizeMB'], 2) . " MB</td>";
             $output .= "<td class='right'>" . round($item['RemainingSizeMB'], 2) . " MB</td>";
             $output .= "<td class='right'>" . ($item['FileSizeMB'] == 0 ? 0 : round($item['RemainingSizeMB'] / $item['FileSizeMB'] * 100)) . "%</td>";
             $output .= "<td style='text-align:right;'>" . $item['RemainingFileCount'] . "</td>";
             $output .= "<td style='text-align:right;'><a  onclick=\"return confirm('Are you sure?');\" href='?nzbgetdel=" . $item['NZBID'] . "'>delete</a></td>";
             $output .= "</tr>";
             $count++;
Esempio n. 2
0
<?php

use newznab\utility\Utility;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$nzbget = new NZBGet($page);
$output = "";
$data = $nzbget->getQueue();
if ($data !== false) {
    if (count($data > 0)) {
        $status = $nzbget->status();
        if ($status !== false) {
            $output .= "<div class='container text-center' style='display:block;'>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Avg Speed:</b><br /> " . Utility::bytesToSizeString($status['AverageDownloadRate'], 2) . "/s </div>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Speed:</b><br /> " . Utility::bytesToSizeString($status['DownloadRate'], 2) . "/s </div>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Limit:</b><br /> " . Utility::bytesToSizeString($status['DownloadLimit'], 2) . "/s </div>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Queue Left(no pars):</b><br /> " . Utility::bytesToSizeString($status['RemainingSizeLo'], 2) . " </div>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Free Space:</b><br /> " . Utility::bytesToSizeString($status['FreeDiskSpaceMB'] * 1024000, 2) . " </div>\n\t\t\t\t<div style='width:16.666666667%;float:left;'><b>Status:</b><br /> " . ($status['Download2Paused'] == 1 ? 'Paused' : 'Downloading') . " </div>\n\t\t\t</div>";
        }
        $count = 1;
        $output .= "<table class='table table-striped table-condensed table-highlight data'>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr >\n\t\t\t\t\t\t<th style='width=10px;text-align:center;'>#</th>\n\t\t\t\t\t\t<th style='text-align:left;'>Name</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Size</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Left(+pars)</th>\n\t\t\t\t\t\t<th style='width:50px;text-align:center;'>Done</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Status</th>\n\t\t\t\t\t\t<th style='width:50px;text-align:center;'>Delete</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'><a href='?pall'>Pause all</a></th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'><a href='?rall'>Resume all</a></th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>";
        foreach ($data as $item) {
            $output .= "<tr>" . "<td style='text-align:center;width:10px'>" . $count . "</td>" . "<td style='text-align:left;'>" . $item['NZBName'] . "</td>" . "<td style='text-align:center;'>" . $item['FileSizeMB'] . " MB</td>" . "<td style='text-align:center;'>" . $item['RemainingSizeMB'] . " MB</td>" . "<td style='text-align:center;'>" . ($item['FileSizeMB'] == 0 ? 0 : round(100 - $item['RemainingSizeMB'] / $item['FileSizeMB'] * 100)) . "%</td>" . "<td style='text-align:center;'>" . ($item['ActiveDownloads'] > 0 ? 'Downloading' : 'Paused') . "</td>" . "<td style='text-align:center;'><a  onclick=\"return confirm('Are you sure?');\" href='?del=" . $item['LastID'] . "'>Delete</a></td>" . "<td style='text-align:center;'><a href='?pause=" . $item['LastID'] . "'>Pause</a></td>" . "<td style='text-align:center;'><a href='?resume=" . $item['LastID'] . "'>Resume</a></td>" . "</tr>";
            $count++;
        }
        $output .= "</tbody>\n\t\t</table>";
    } else {
        $output .= "<br /><br /><p style='text-align:center;'>The queue is currently empty.</p>";
    }
} else {
    $output .= "<p style='text-align:center;'>Error retreiving queue.</p>";
}
print $output;