[ Index ] |
|
Code source de PunBB 1.2.16 |
1 <?php 2 /*********************************************************************** 3 4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) 5 6 This file is part of PunBB. 7 8 PunBB is free software; you can redistribute it and/or modify it 9 under the terms of the GNU General Public License as published 10 by the Free Software Foundation; either version 2 of the License, 11 or (at your option) any later version. 12 13 PunBB is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 MA 02111-1307 USA 22 23 ************************************************************************/ 24 25 26 // Tell header.php to use the admin template 27 define('PUN_ADMIN_CONSOLE', 1); 28 29 define('PUN_ROOT', './'); 30 require PUN_ROOT.'include/common.php'; 31 require PUN_ROOT.'include/common_admin.php'; 32 33 34 if ($pun_user['g_id'] > PUN_ADMIN) 35 message($lang_common['No permission']); 36 37 38 // Add a rank 39 if (isset($_POST['add_rank'])) 40 { 41 confirm_referrer('admin_ranks.php'); 42 43 $rank = trim($_POST['new_rank']); 44 $min_posts = $_POST['new_min_posts']; 45 46 if ($rank == '') 47 message('Vous devez saisir un titre au rang.'); 48 49 if (!@preg_match('#^\d+$#', $min_posts)) 50 message('Le nombre minimum de messages doit être un entier positif.'); 51 52 // Make sure there isn't already a rank with the same min_posts value 53 $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()); 54 if ($db->num_rows($result)) 55 message('Il y a déjà un rang avec un nombre minimum de '.$min_posts.'messages.'); 56 57 $db->query('INSERT INTO '.$db->prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($rank).'\', '.$min_posts.')') or error('Unable to add rank', __FILE__, __LINE__, $db->error()); 58 59 // Regenerate the ranks cache 60 require_once PUN_ROOT.'include/cache.php'; 61 generate_ranks_cache(); 62 63 redirect('admin_ranks.php', 'Rang ajouté. Redirection ...'); 64 } 65 66 67 // Update a rank 68 else if (isset($_POST['update'])) 69 { 70 confirm_referrer('admin_ranks.php'); 71 72 $id = intval(key($_POST['update'])); 73 74 $rank = trim($_POST['rank'][$id]); 75 $min_posts = trim($_POST['min_posts'][$id]); 76 77 if ($rank == '') 78 message('You must enter a rank title.'); 79 80 if (!@preg_match('#^\d+$#', $min_posts)) 81 message('Le nombre minimum de messages doit être un entier positif.'); 82 83 // Make sure there isn't already a rank with the same min_posts value 84 $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE id!='.$id.' AND min_posts='.$min_posts) or error('Unable to fetch rank info', __FILE__, __LINE__, $db->error()); 85 if ($db->num_rows($result)) 86 message('Il y a déjà un rang avec un nombre minimum de '.$min_posts.' messages.'); 87 88 $db->query('UPDATE '.$db->prefix.'ranks SET rank=\''.$db->escape($rank).'\', min_posts='.$min_posts.' WHERE id='.$id) or error('Unable to update rank', __FILE__, __LINE__, $db->error()); 89 90 // Regenerate the ranks cache 91 require_once PUN_ROOT.'include/cache.php'; 92 generate_ranks_cache(); 93 94 redirect('admin_ranks.php', 'Rangs modifiés. Redirection ...'); 95 } 96 97 98 // Remove a rank 99 else if (isset($_POST['remove'])) 100 { 101 confirm_referrer('admin_ranks.php'); 102 103 $id = intval(key($_POST['remove'])); 104 105 $db->query('DELETE FROM '.$db->prefix.'ranks WHERE id='.$id) or error('Unable to delete rank', __FILE__, __LINE__, $db->error()); 106 107 // Regenerate the ranks cache 108 require_once PUN_ROOT.'include/cache.php'; 109 generate_ranks_cache(); 110 111 redirect('admin_ranks.php', 'Rang supprimé. Redirection ...'); 112 } 113 114 115 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Rangs'; 116 $focus_element = array('ranks', 'new_rank'); 117 require PUN_ROOT.'header.php'; 118 119 generate_admin_menu('ranks'); 120 121 ?> 122 <div class="blockform"> 123 <h2><span>Rangs</span></h2> 124 <div class="box"> 125 <form id="ranks" method="post" action="admin_ranks.php?action=foo"> 126 <div class="inform"> 127 <fieldset> 128 <legend>Ajouter un rang</legend> 129 <div class="infldset"> 130 <p>Saisissez un titre de rang et un nombre minimum de messages que l'utilisateur devra atteindre afin d'obtenir ce rang. Plusieurs rangs ne peuvent avoir le même nombre minimum de messages. Si un titre est donné à un utilisateur, le titre sera affiché à la place du rang. <strong>Les rangs utilisateurs doivent êtres activés à la page <a href="admin_options.php#ranks">Options</a> pour qu'ils aient un quelconque effet.</strong></p> 131 <table cellspacing="0"> 132 <thead> 133 <tr> 134 <th class="tcl" scope="col">Titre du rang</th> 135 <th class="tc2" scope="col">Nombre minimum de messages</th> 136 <th class="hidehead" scope="col">Action</th> 137 </tr> 138 </thead> 139 <tbody> 140 <tr> 141 <td><input type="text" name="new_rank" size="24" maxlength="50" tabindex="1" /></td> 142 <td><input type="text" name="new_min_posts" size="7" maxlength="7" tabindex="2" /></td> 143 <td><input type="submit" name="add_rank" value=" Ajouter " tabindex="3" /></td> 144 </tr> 145 </tbody> 146 </table> 147 </div> 148 </fieldset> 149 </div> 150 <div class="inform"> 151 <fieldset> 152 <legend>Modifier/supprimer les rangs</legend> 153 <div class="infldset"> 154 <?php 155 156 $result = $db->query('SELECT id, rank, min_posts FROM '.$db->prefix.'ranks ORDER BY min_posts') or error('Unable to fetch rank list', __FILE__, __LINE__, $db->error()); 157 if ($db->num_rows($result)) 158 { 159 160 ?> 161 <table cellspacing="0"> 162 <thead> 163 <tr> 164 <th class="tcl" scope="col"><strong>Titre du rang</strong></th> 165 <th class="tc2" scope="col"><strong>Nombre minimum de messages</strong></th> 166 <th class="hidehead" scope="col">Actions</th> 167 </tr> 168 </thead> 169 <tbody> 170 <?php 171 172 while ($cur_rank = $db->fetch_assoc($result)) 173 echo "\t\t\t\t\t\t\t\t".'<tr><td><input type="text" name="rank['.$cur_rank['id'].']" value="'.pun_htmlspecialchars($cur_rank['rank']).'" size="24" maxlength="50" /></td><td><input type="text" name="min_posts['.$cur_rank['id'].']" value="'.$cur_rank['min_posts'].'" size="7" maxlength="7" /></td><td><input type="submit" name="update['.$cur_rank['id'].']" value="Modifier" /> <input type="submit" name="remove['.$cur_rank['id'].']" value="Supprimer" /></td></tr>'."\n"; 174 175 ?> 176 </tbody> 177 </table> 178 <?php 179 180 } 181 else 182 echo "\t\t\t\t\t\t\t".'<p>Aucun rang dans la liste.</p>'."\n"; 183 184 ?> 185 </div> 186 </fieldset> 187 </div> 188 </form> 189 </div> 190 </div> 191 <div class="clearer"></div> 192 </div> 193 <?php 194 195 require PUN_ROOT.'footer.php';
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 22:44:38 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |