<?php
require_once('includes/config.php');

//Titre de la page
$pagetitle = 'Info du site et statistiques';

//Stats : bbclone
define("_BBC_PAGE_NAME", $pagetitle);
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);

include_once('includes/header.php');
?>

<body>

<div id="container">

   	<?php
	   include_once('includes/header-logo.php');
	   include_once('includes/nav.php');
	?>

    	<div id="body">
	<div id="content">

	<?php include_once('includes/ariane.php'); ?>

	<br />

	<div style="text-align: center;"><span style="font-size: 14pt; font-weight: bold;">Les 5 derniers torrents :</span></div>
	<br />	

        <table>

                <th>Nom du torrent</th>
		<th>Seeders</th>
		<th>Leechers</th>

	<?php
	$stmt = $db->query('SELECT blog_posts_seo.postID,blog_posts_seo.postHash,blog_posts_seo.postTitle,blog_posts_seo.postSlug,xbt_files.seeders,xbt_files.leechers FROM blog_posts_seo,xbt_files WHERE blog_posts_seo.postID = xbt_files.fid ORDER BY postID DESC LIMIT 5');
	while($row = $stmt->fetch()){
		echo '<tr>';
        		echo '
			<td style="width:85%;"><img src="'.SITEURL.'/images/torrentfileblue.png" style="width:20px; height:20px; vertical-align:text-bottom;" alt="" /> <a style="text-decoration: none; color:black; font-size:14px;" href="'.SITEURL.'/'.html($row['postSlug']).'"><span>'.html($row['postTitle']).'</span></a></td>
			<td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: green;">'.html($row['seeders']).'</span></a></td> 
			<td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: red;">'.html($row['leechers']).'</span></a></td>
		';
		echo '</tr>';
        }
	?>

        </table>

	<br /><br />

	<div style="text-align: center;"><span style="font-size: 14pt; font-weight: bold;">Les 5 torrents les plus populaires :</span></div>
        <br />

        <table>

	<th>Nom du torrent</th>
	<th>Nb de vues</th>

	<?php
	$stmt = $db->query('SELECT postSlug,postTitle,postAuthor,postDate,postViews FROM blog_posts_seo ORDER BY postViews DESC LIMIT 5');
	while($row = $stmt->fetch()) {
        	echo '<tr>';
			echo '
			<td style="width:88%;"><img src="'.SITEURL.'/images/torrentfileblue.png" style="width:20px; height:20px; vertical-align:text-bottom;" alt="" /><a style="text-decoration: none; color:black; font-size:14px;" href="'.SITEURL.'/'.html($row['postSlug']).'">'.html($row['postTitle']).'</a></td>
			<td style="text-align:center;"><span style="color: green; font-size:14px; font-weight:bold;">'.html($row['postViews']).'</span></td>
			';
		echo '</tr>';
	}
	?>

	</table>

	<?php
        $stmt = $db->query('SELECT blog_posts_seo.postID,blog_posts_seo.postHash,blog_posts_seo.postTitle,blog_posts_seo.postSlug,xbt_files.fid,xbt_files.seeders,xbt_files.leechers FROM blog_posts_seo,xbt_files WHERE blog_posts_seo.postID = xbt_files.fid AND xbt_files.seeders = 0 AND xbt_files.leechers > 0 ORDER BY postID DESC LIMIT 5');
	$count = $stmt->rowCount();

	if (!empty($count)) {
	?>

		<br /><br />

		<div style="text-align: center;"><span style="font-size: 14pt; font-weight: bold;">Torrents qui ont besoin de seeds :</span></div>
        	<br />

        	<table>

        	<th>Nom du torrent</th>
        	<th>Seeders</th>
		<th>Leechers</th>

		<?php
		while($row = $stmt->fetch()) {
			echo '<tr>';
                	echo '
				<td style="width: 85%;"><img src="'.SITEURL.'/images/torrentfileblue.png" style="width:20px; height:20px; vertical-align:text-bottom;" alt="" /> <a style="text-decoration: none; color:black; font-size:14px;" href="'.SITEURL.'/'.html($row['postSlug']).'">'.html($row['postTitle']).'</td>
				<td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: green;">'.html($row['seeders']).'</span></a></td>
                        	<td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: red;">'.html($row['leechers']).'</span></a></td>
				';
			echo '</tr>';
		}
        	?>

		</table>
	<?php } ?>


	<br /><br />

	        <div style="text-align: center;"><span style="font-size: 14pt; font-weight: bold;">Les 5 torrents les plus actifs :</span></div>
        <br />

        <table>

                <th>Nom du torrent</th>
                <th>Seeders</th>
                <th>Leechers</th>

        <?php
        $stmt = $db->query('SELECT blog_posts_seo.postID,blog_posts_seo.postHash,blog_posts_seo.postTitle,blog_posts_seo.postSlug,xbt_files.seeders,xbt_files.leechers FROM blog_posts_seo,xbt_files WHERE blog_posts_seo.postID = xbt_files.fid ORDER BY xbt_files.seeders DESC LIMIT 5');
        while($row = $stmt->fetch()){
                echo '<tr>';
                        echo '
                        <td style="width:85%;"><img src="'.SITEURL.'/images/torrentfileblue.png" style="width:20px; height:20px; vertical-align:text-bottom;" alt="" /> <a style="text-decoration: none; color:black; font-size:14px;" href="'.SITEURL.'/'.html($row['postSlug']).'"><span>'.html($row['postTitle']).'</span></a></td>
                        <td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: green;">'.html($row['seeders']).'</span></a></td>
                        <td style="text-align:center;"><a style="text-decoration: none; font-size:14px; font-weight:bold;" href="../peers.php?hash='.html($row['postHash']).'"><span style="color: red;">'.html($row['leechers']).'</span></a></td>
                ';
                echo '</tr>';
        }
        ?>

        </table>

        <br />



</div>

	<?php include_once('sidebar.php'); ?>
        
    	<div class="clear"></div>
    </div>
</div>

<div id="footer">
	<?php include_once('includes/footer.php'); ?>
</div>

</body>
</html>