aboutsummaryrefslogtreecommitdiff
path: root/Html/torrents.php
blob: 77b73c7510f3a94d288bdd99500009c61d30d327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
require_once('includes/config.php');

//Titre de la page
$pagetitle = 'Liste des torrents';

//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;">Liste des torrents :</span></div>
	<br />	
	
        <?php
        // On affiche : torrent ajouté ! 
        if(isset($_GET['action']) && $_GET['action'] == 'ajoute') {
                echo '<div class="alert-msg rnd8 success">Le torrent a été ajouté avec succès !</div>';
        }

	// Pas d'accès direct à la page download sans file ID
        if(isset($_GET['action']) && $_GET['action'] == 'nodirect') {
                echo '<div class="alert-msg rnd8 error">ERREUR :<br />Vous ne pouvez pas accéder directement à cette page sans préciser le torrent à télécharger...</div>';
        }

	// Pas d'accès à la page download si le file ID n'existe pas
        if(isset($_GET['action']) && $_GET['action'] == 'noexist') {
                echo '<div class="alert-msg rnd8 error">ERREUR :<br />Ce torrent n\'existe pas !</div>';
        }

	//On affiche le message de suppression
	if(isset($_GET['delpost'])){
		echo '<div class="alert-msg rnd8 success">Le torrent a été supprimé avec succès.</div>';
	}
	?>

        <table>
        <tr>
                <th style="width:50%;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postTitle&ordre=desc">&#x2191;</a>Nom<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postTitle&ordre=asc">&#x2193;</a></th>
		<th style="text-align: center; width: 8%;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postTaille&ordre=desc">&#x2191;</a>Taille<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postTaille&ordre=asc">&#x2193;</a></th>
		<th style="text-align: center; width: 8%;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postDate&ordre=desc">&#x2191;</a>Ajouté<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postDate&ordre=asc">&#x2193;</a></th>
		<!-- <th style="text-align: center;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postAuthor&ordre=desc">&#x2191;</a>Par<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=postAuthor&ordre=asc">&#x2193;</a></th> -->
		<th style="text-align: center; width: 20%;">Catégorie(s)</th>
		<th style="text-align: center;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=seeders&ordre=desc">&#x2191;</a>S<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=seeders&ordre=asc">&#x2193;</a></th>
		<th style="text-align: center;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=leechers&ordre=desc">&#x2191;</a>L<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=leechers&ordre=asc">&#x2193;</a></th>
		<th style="text-align: center;"><a style="color: #fff; text-decoration: none;" href="torrents.php?tri=completed&ordre=desc">&#x2191;</a>T<a style="color: #fff; text-decoration: none;" href="torrents.php?tri=completed&ordre=asc">&#x2193;</a></th>
        </tr>
        <?php
                try {
			// On affiche 15 torrents par page
			$pages = new Paginator(NBTORRENTS,'page');

			$stmt = $db->query('SELECT postHash FROM blog_posts_seo');
			$pages->set_total($stmt->rowCount());


			// On met en place le tri--------------------------------------------
			if(isset($_GET['tri'])) {
				$tri = html($_GET['tri']);
			}
			else {
				$post_tri = 'postDate';
				$tri = html($post_tri);
			}

			if(isset($_GET['ordre'])) {
				$ordre = html($_GET['ordre']);
			}
			else {
				$ordre_tri = 'desc';
				$ordre = html($ordre_tri);
			}

			// Protection du tri -----------------------------------------------
			if (!empty($_GET['tri']) && !in_array($_GET['tri'], array('postID','postHash', 'postTitle', 'postViews', 'postTaille', 'postDate', 'postAuthor', 'seeders', 'leechers', 'completed'))) {
				header('Location: index.php');
				exit();
			}
			if (!empty($_GET['ordre']) && !in_array($_GET['ordre'], array('asc','desc','ASC','DESC'))) {
				header('Location: index.php');
				exit();
			}


                        $stmt = $db->query('SELECT * FROM blog_posts_seo b LEFT JOIN xbt_files x ON x.fid = b.postID ORDER BY '.$tri.' '.$ordre.' '.$pages->get_limit());

	                while($row = $stmt->fetch()){

				$stmt2 = $db->prepare('SELECT catTitle, catSlug FROM blog_cats, blog_post_cats WHERE blog_cats.catID = blog_post_cats.catID AND blog_post_cats.postID = :postID ORDER BY catTitle ASC');
				$stmt2->execute(array(':postID' => $row['postID']));
			
			$catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC);

			echo '<tr>';
                        echo '<td style="font-size: 14px; font-weight: bold;"><img src="'.SITEURL.'/images/imgtorrents/'.$row['postImage'].'" style="width:25px; height:25px; vertical-align:middle;" alt="" /> <a style="text-decoration:none; color:black;" href="'.html($row['postSlug']).'">'.html($row['postTitle']).'</a>';
			echo '</td>';
			echo '<td style="text-align: center; font-size: 9px;">';
				echo html(makesize($row['postTaille']));
			echo '</td>';

			sscanf($row['postDate'], "%4s-%2s-%2s %2s:%2s:%2s", $annee, $mois, $jour, $heure, $minute, $seconde);
			echo '<td style="text-align: center; font-size: 7pt;">'.$jour.'-'.$mois.'-'.$annee.'</td>';
			
			//echo '<td style="font-size: 8pt; text-align: center;"><a style="text-decoration: none;" href="admin/profil.php?membre='.html($row['postAuthor']).'">'.html($row['postAuthor']).'</a></td>';

			$links = array();
			foreach ($catRow as $cat) {
                               	$links[] = '<a style="text-decoration: none;" href="c-'.$cat['catSlug'].'">'.$cat['catTitle'].'</a>';
                        }

			$max = 120;
			$chaine = implode(", ", $links);
			if (strlen($chaine) >= $max) {
				$chaine = substr($chaine, 0, $max);
				$espace = strrpos($chaine, ", ");
				$chaine = substr($chaine, 0, $espace).' ...';
			}

			echo '<td style="text-align: center; font-size: 10px; line-height: 120%;">'.$chaine.'</td>';

			$exa = '0x';
			$hash = $exa.$row['postHash'];
			
			$stmt3 = $db->prepare('SELECT * FROM blog_posts_seo,xbt_files WHERE blog_posts_seo.postHash = :postHash AND xbt_files.info_hash = '.$hash);
			$stmt3->execute(array(':postHash' => $row['postHash']));
			$xbt = $stmt3->fetch();

			echo '<td style="text-align:center;"><a style="text-decoration: none; color:green; font-size:14px; font-weight:bold;" href="peers.php?hash='.html($row['postHash']).'">'.$xbt['seeders'].'</a></td>';
			echo '<td style="text-align:center;"><a style="text-decoration: none; color:red; font-size:14px; font-weight:bold;" href="peers.php?hash='.html($row['postHash']).'">'.$xbt['leechers'].'</a></td>';
			echo '<td style="text-align:center; font-size: 8pt;">'.$xbt['completed'].'</td>';

			echo '</tr>';
                        }


                } catch(PDOException $e) {
                    echo $e->getMessage();
                }
        ?>
        </table>

	<br />

	<?php echo $pages->page_links('?tri='.$tri.'&ordre='.$ordre.'&'); ?>

	<br />
        <p class="edito" style="font-size: 10px; font-style: italic;"><span style="font-weight: bold;">Légende :</span> S = Nb de Seeders, L = Nb de Leechers, T = Nb de Téléchargements</p>

</div>

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

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

</body>
</html>