diff options
author | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
---|---|---|
committer | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
commit | 5fd9fa480f302902328b81f912dd67ce378284f8 (patch) | |
tree | 66234843ae2857fda12442e4f7577c527d48977c /Html/admin/index.php | |
parent | ebe731862c7c741171138b1083906f391fc35aff (diff) | |
download | freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.tar.xz freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.zip |
V.1.4.6
Diffstat (limited to 'Html/admin/index.php')
-rw-r--r-- | Html/admin/index.php | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/Html/admin/index.php b/Html/admin/index.php new file mode 100644 index 0000000..d47b017 --- /dev/null +++ b/Html/admin/index.php @@ -0,0 +1,185 @@ +<?php +require_once('../includes/config.php'); + +//Si pas connecté OU si le membre n'est pas admin, pas de connexion à l'espace d'admin --> retour sur la page login +if(!$user->is_logged_in()) { + header('Location: login.php?action=connecte'); + exit(); +} + +if(isset($_SESSION['userid'])) { + if($_SESSION['userid'] != 1) { + header('Location: login.php?action=pasledroit'); + exit(); + } +} + +//Si le torrent est à supprimer ... +if(isset($_GET['delpost'])) { + + // 1 - on supprime le fichier .torrent dans le répertoire /torrents ... + $stmt4 = $db->prepare('SELECT postID, postTorrent, postImage FROM blog_posts_seo WHERE postID = :postID') ; + $stmt4->execute(array( + ':postID' => $_GET['delpost'] + )); + $efface = $stmt4->fetch(); + + $file = $REP_TORRENTS.$efface['postTorrent']; + if (file_exists($file)) { + unlink($file); + } + + // 2 - ... on supprime aussi l'image de présentation du torrent + $postimage = $REP_IMAGES_TORRENTS.$efface['postImage']; + if (file_exists($postimage)) { + unlink($postimage); + } + + + // 3 - on supprime le torrent dans la base + $stmt = $db->prepare('DELETE FROM blog_posts_seo WHERE postID = :postID') ; + $stmt->execute(array( + ':postID' => $_GET['delpost'] + )); + + // 4 - on supprime sa référence de catégorie + $stmt1 = $db->prepare('DELETE FROM blog_post_cats WHERE postID = :postID'); + $stmt1->execute(array( + ':postID' => $_GET['delpost'] + )); + + // 5 - on supprime sa référence de licence + $stmt2 = $db->prepare('DELETE FROM blog_post_licences WHERE postID_BPL = :postID_BPL'); + $stmt2->execute(array( + ':postID_BPL' => $_GET['delpost'] + )); + + // 6 - on supprime ses commentaires s'ils existent + /* + $stmt22 = $db->prepare('SELECT cid_torrent FROM blog_posts_comments WHERE cid_torrent = :cid_torrent'); + $stmt22->execute(array( + ':cid_torrent' => $_GET['delpost'] + )); + $commentaire = $stmt22->fetch(); + + if(!empty($commentaire)) { + $stmtsupcomm = $db->prepare('DELETE FROM blog_posts_comments WHERE cid_torrent = :cid_torrent'); + $stmtsupcomm->execute(array( + ':cid_torrent' => $_GET['delpost'] + )); + } + */ + + // 7 - enfin, on met le flag à "1" pour supprimer le fichier dans la tables xbt_files + $stmt3 = $db->prepare('UPDATE xbt_files SET flags = :flags WHERE fid = :fid') ; + $stmt3->execute(array( + ':flags' => '1', + ':fid' => $_GET['delpost'] + )); + + + header('Location: index.php?action=supprime'); + exit; + +}//fin de if isset $_GET['delpost'] + + +// titre de la page +$pagetitle = 'Admin : gestion des torrents'; + +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('menu.php'); + ?> + + <?php + //show message from add / edit page + if(isset($_GET['action']) && $_GET['action'] == 'supprime'){ + echo '<div class="alert-msg rnd8 success">Le torrent a été supprimé avec succès.</div><br />'; + } + + if(isset($_GET['action']) && $_GET['action'] == 'ajoute'){ + echo '<div class="alert-msg rnd8 success">Le torrent a été ajouté avec succès.</div><br />'; + } + + if(isset($_GET['message']) && $_GET['message'] == 'envoye') { + echo '<div class="alert-msg rnd8 success">Message envoyé à tous les membres.</div><br />'; + } + ?> + + <table> + <tr> + <th>Titre</th> + <th style="text-align: center;">Date</th> + <th style="text-align: center;">Uploader</th> + <th style="text-align: center;">Action</th> + </tr> + <?php + try { + + $pages = new Paginator('10','p'); + + $stmt = $db->query('SELECT postID FROM blog_posts_seo'); + + //pass number of records to + $pages->set_total($stmt->rowCount()); + + $stmt = $db->query('SELECT postID, postTitle, postAuthor, postDate FROM blog_posts_seo ORDER BY postID DESC '.$pages->get_limit()); + while($row = $stmt->fetch()){ + + echo '<tr>'; + echo '<td style="width:55%;">'.$row['postTitle'].'</td>'; + sscanf($row['postDate'], "%4s-%2s-%2s %2s:%2s:%2s", $annee, $mois, $jour, $heure, $minute, $seconde); + echo '<td style="text-align: center;">'.$jour.'-'.$mois.'-'.$annee.'</td>'; + echo '<td style="text-align: center;"><a href="profil.php?membre='.$row['postAuthor'].'">'.$row['postAuthor'].'</a></td>'; + ?> + + <td style="text-align: center;"> + <a style="text-decoration: none;" href="edit-post.php?id=<?php echo $row['postID'];?>"><input type="button" class="button" value="Edit." /></a> + <a style="text-decoration: none;" href="javascript:delpost('<?php echo $row['postID'];?>','<?php echo $row['postTitle'];?>')"><input type="button" class="button" value="Supp." /></a> + </td> + + <?php + echo '</tr>'; + + } + + + } catch(PDOException $e) { + echo $e->getMessage(); + } + ?> + </table> + + <p> + <?php echo $pages->page_links(); ?> + </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> |