rendered paste body<?php
require_once("config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>
Sickbeard Viewer
</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(function() {
$("table").tablesorter({debug: true});
});
</script>
</head>
<body>
<div class="content">
<div id="top">
<h1>Sickbeard</h1>
<h2>Viewer</h2>
</div>
<!-- end of the Top part -->
</div>
<div class="content">
<table>
<thead>
<tr>
<th>Show Name</th>
<th>Network</th>
<th>Quality</th>
<th>Downloads</th>
<th>Complete</th>
<th>Status</th>
</tr>
</thead>
<?php
$db = new PDO('sqlite:' . $sickbeardDb);
$result = $db->query('SELECT * FROM tv_shows order by show_name');
foreach($result as $row)
{
$showsNotDownloaded = 0;
$totalShows = 0;
$showsDownloaded = 0;
$result2 = $db->query("SELECT COUNT(*) FROM tv_episodes WHERE showid = '" . $row['tvdb_id'] . "' and location = '' and season > 0 and status <> 1");
foreach ($result2 as $row2)
{
$showsNotDownloaded = $row2[0];
}
$result2 = $db->query("SELECT COUNT(*) FROM tv_episodes WHERE showid = '" . $row['tvdb_id'] . "' and season > 0 and status <> 1");
foreach ($result2 as $row2)
{
$totalShows = $row2[0];
}
$showsDownloaded = $totalShows - $showsNotDownloaded;
$wth = round(($showsDownloaded / $totalShows) * 100, 0);
if ($showsDownloaded == $totalShows)
{
$class = "Downloaded";
}
else
{
$class = "";
}
?>
<tr>
<td class="<?php echo $class; ?>"><a href="eps.php?tvdb_id=<?php echo $row['tvdb_id']; ?>&show=<?php echo $row['show_name']; ?>"><?php echo $row['show_name']; ?></a></td>
<td class="<?php echo $class; ?>"><?php echo $row['network']; ?></td>
<td class="<?php echo $class; ?>"><?php echo seasonQuality($row['quality']); ?></td>
<td class="<?php echo $class; ?>"><span style="display: none;"><?php echo $wth;?></span><?php echo $showsDownloaded . " / " . $totalShows; ?></td>
<td style="background-color: #efefef; width: 150px;"><div style="width: <?php echo $wth; ?>%; background-color: #555;"> </div><span style="display: none;"><?php echo $wth;?></span></td>
<td class="<?php echo $class; ?>"><?php echo $row['status']; ?></td>
</tr>
<?php
}
/*
$result = $db->query("SELECT name FROM sqlite_master
WHERE type='table'
ORDER BY name;");
foreach($result as $row)
{
print_r($row);
}
*/
?>
</table>
</div>
<p style="text-align: center; color: #dddddd; margin: 20px 20px 20px 20px; ">pretenda</p>
</body>
</html>