PUN_ADMIN) message($lang_common['No permission']); // Add a rank if (isset($_POST['add_rank'])) { confirm_referrer('admin_ranks.php'); $rank = trim($_POST['new_rank']); $min_posts = $_POST['new_min_posts']; if ($rank == '') message('Vous devez saisir un titre au rang.'); if (!preg_match('#^\d+$#', $min_posts)) message('Le nombre minimum de messages doit être un entier positif.'); // Make sure there isn't already a rank with the same min_posts value $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE min_posts='.$min_posts) or error('Unable to fetch rank info', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) message('Il y a déjà un rang avec un nombre minimum de '.$min_posts.'messages.'); $db->query('INSERT INTO '.$db->prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($rank).'\', '.$min_posts.')') or error('Impossible d\'ajouter le rang', __FILE__, __LINE__, $db->error()); // Regenerate the ranks cache require_once PUN_ROOT.'include/cache.php'; generate_ranks_cache(); redirect('admin_ranks.php', 'Rang ajouté. Redirection ...'); } // Update a rank else if (isset($_POST['update'])) { confirm_referrer('admin_ranks.php'); $id = intval(key($_POST['update'])); $rank = trim($_POST['rank'][$id]); $min_posts = trim($_POST['min_posts'][$id]); if ($rank == '') message('You must enter a rank title.'); if (!preg_match('#^\d+$#', $min_posts)) message('Le nombre minimum de messages doit être un entier positif.'); // Make sure there isn't already a rank with the same min_posts value $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE id!='.$id.' && min_posts='.$min_posts) or error('Impossible de retrouver les informations des rangs', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result)) message('Il y a déjà un rang avec un nombre minimum de '.$min_posts.' messages.'); $db->query('UPDATE '.$db->prefix.'ranks SET rank=\''.$db->escape($rank).'\', min_posts='.$min_posts.' WHERE id='.$id) or error('Impossible de modifier les rangs', __FILE__, __LINE__, $db->error()); // Regenerate the ranks cache require_once PUN_ROOT.'include/cache.php'; generate_ranks_cache(); redirect('admin_ranks.php', 'Rangs modifiés. Redirection ...'); } // Remove a rank else if (isset($_POST['remove'])) { confirm_referrer('admin_ranks.php'); $id = intval(key($_POST['remove'])); $db->query('DELETE FROM '.$db->prefix.'ranks WHERE id='.$id) or error('Impossible de supprimer le rang', __FILE__, __LINE__, $db->error()); // Regenerate the ranks cache require_once PUN_ROOT.'include/cache.php'; generate_ranks_cache(); redirect('admin_ranks.php', 'Rang supprimé. Redirection ...'); } $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Rangs'; $focus_element = array('ranks', 'new_rank'); require PUN_ROOT.'header.php'; generate_admin_menu('ranks'); ?>