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/categories.php | |
parent | ebe731862c7c741171138b1083906f391fc35aff (diff) | |
download | freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.tar.xz freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.zip |
V.1.4.6
Diffstat (limited to 'Html/admin/categories.php')
-rw-r--r-- | Html/admin/categories.php | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Html/admin/categories.php b/Html/admin/categories.php new file mode 100644 index 0000000..66c911a --- /dev/null +++ b/Html/admin/categories.php @@ -0,0 +1,112 @@ +<?php +//include config +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'); +} + +if(isset($_SESSION['userid'])) { + if($_SESSION['userid'] != 1) { + header('Location: '.SITEURL); + } +} + +//show message from add / edit page +if(isset($_GET['delcat'])){ + + $stmt = $db->prepare('DELETE FROM blog_cats WHERE catID = :catID') ; + $stmt->execute(array(':catID' => html($_GET['delcat']))); + + header('Location: categories.php?action=supprime'); + exit; +} + +// titre de la page +$pagetitle= 'Admin : gestion des catégories'; +require('../includes/header.php'); +?> + +<body> + +<div id="container"> + + <?php + require('../includes/header-logo.php'); + require('../includes/nav.php'); + ?> + + + <div id="body"> + <div id="content"> + + + <?php include('menu.php');?> + + <?php + //show message from add / edit page + if(isset($_GET['action']) && $_GET['action'] == 'supprime'){ + echo '<h3>La catégorie a été supprimée avec succès.</h3>'; + } + if(isset($_GET['action']) && $_GET['action'] == 'ajoute'){ + echo '<h3>La catégorie a été ajoutée avec succès.</h3>'; + } + + ?> + + <table> + <tr> + <th>Titre</th> + <th>Action</th> + </tr> + <?php + try { + $pages = new Paginator('10','p'); + $stmt = $db->query('SELECT catID FROM blog_cats'); + //pass number of records to + $pages->set_total($stmt->rowCount()); + + $stmt = $db->query('SELECT catID, catTitle, catSlug FROM blog_cats ORDER BY catTitle ASC '.$pages->get_limit()); + + while($row = $stmt->fetch()){ + + echo '<tr>'; + echo '<td style="width: 80%;">'.html($row['catTitle']).'</td>'; + ?> + + <td> + <a style="text-decoration: none;" href="edit-category.php?id=<?php echo html($row['catID']);?>"><input type="button" class="button" value="Edit."></a> | + <a style="text-decoration: none;" href="javascript:delcat('<?php echo html($row['catID']);?>','<?php echo html($row['catSlug']);?>')"><input type="button" class="button" value="Suppr."</a> + </td> + + <?php + echo '</tr>'; + } + + } catch(PDOException $e) { + echo $e->getMessage(); + } + ?> + </table> + + <br /> + <p style="text-align: right;"><a href="add-category.php" style="text-decoration: none;"><input type="button" class="button" value="Ajouter une catégorie" /></a></p> + + <?php + echo $pages->page_links(); + ?> + </div> + + <?php require('../sidebar.php'); ?> + + <div class="clear"></div> + </div> +</div> + +<div id="footer"> + <?php require('../includes/footer.php'); ?> +</div> + +</body> +</html> |