| [ PHPXref.com ] | [ Generated: Thu Aug 19 03:35:06 2010 ] | [ FluxBB 1.4.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Copyright (C) 2008-2010 FluxBB 5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB 6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher 7 */ 8 9 // Tell header.php to use the admin template 10 define('PUN_ADMIN_CONSOLE', 1); 11 12 define('PUN_ROOT', './'); 13 require PUN_ROOT.'include/common.php'; 14 require PUN_ROOT.'include/common_admin.php'; 15 16 17 if ($pun_user['g_id'] != PUN_ADMIN) 18 message($lang_common['No permission']); 19 20 // Load the admin_ranks.php language file 21 require PUN_ROOT.'lang/'.$admin_language.'/admin_ranks.php'; 22 23 // Add a rank 24 if (isset($_POST['add_rank'])) 25 { 26 confirm_referrer('admin_ranks.php'); 27 28 $rank = pun_trim($_POST['new_rank']); 29 $min_posts = trim($_POST['new_min_posts']); 30 31 if ($rank == '') 32 message($lang_admin_ranks['Must enter title message']); 33 34 if ($min_posts == '' || preg_match('/[^0-9]/', $min_posts)) 35 message($lang_admin_ranks['Must be integer message']); 36 37 // Make sure there isn't already a rank with the same min_posts value 38 $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()); 39 if ($db->num_rows($result)) 40 message(sprintf($lang_admin_ranks['Dupe min posts message'], $min_posts)); 41 42 $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()); 43 44 // Regenerate the ranks cache 45 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 46 require PUN_ROOT.'include/cache.php'; 47 48 generate_ranks_cache(); 49 50 redirect('admin_ranks.php', $lang_admin_ranks['Rank added redirect']); 51 } 52 53 54 // Update a rank 55 else if (isset($_POST['update'])) 56 { 57 confirm_referrer('admin_ranks.php'); 58 59 $id = intval(key($_POST['update'])); 60 61 $rank = pun_trim($_POST['rank'][$id]); 62 $min_posts = trim($_POST['min_posts'][$id]); 63 64 if ($rank == '') 65 message($lang_admin_ranks['Must enter title message']); 66 67 if ($min_posts == '' || preg_match('/[^0-9]/', $min_posts)) 68 message($lang_admin_ranks['Must be integer message']); 69 70 // Make sure there isn't already a rank with the same min_posts value 71 $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()); 72 if ($db->num_rows($result)) 73 message(sprintf($lang_admin_ranks['Dupe min posts message'], $min_posts)); 74 75 $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()); 76 77 // Regenerate the ranks cache 78 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 79 require PUN_ROOT.'include/cache.php'; 80 81 generate_ranks_cache(); 82 83 redirect('admin_ranks.php', $lang_admin_ranks['Rank updated redirect']); 84 } 85 86 87 // Remove a rank 88 else if (isset($_POST['remove'])) 89 { 90 confirm_referrer('admin_ranks.php'); 91 92 $id = intval(key($_POST['remove'])); 93 94 $db->query('DELETE FROM '.$db->prefix.'ranks WHERE id='.$id) or error('Unable to delete rank', __FILE__, __LINE__, $db->error()); 95 96 // Regenerate the ranks cache 97 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 98 require PUN_ROOT.'include/cache.php'; 99 100 generate_ranks_cache(); 101 102 redirect('admin_ranks.php', $lang_admin_ranks['Rank removed redirect']); 103 } 104 105 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Ranks']); 106 $focus_element = array('ranks', 'new_rank'); 107 define('PUN_ACTIVE_PAGE', 'admin'); 108 require PUN_ROOT.'header.php'; 109 110 generate_admin_menu('ranks'); 111 112 ?> 113 <div class="blockform"> 114 <h2><span><?php echo $lang_admin_ranks['Ranks head'] ?></span></h2> 115 <div class="box"> 116 <form id="ranks" method="post" action="admin_ranks.php?action=foo"> 117 <div class="inform"> 118 <fieldset> 119 <legend><?php echo $lang_admin_ranks['Add rank subhead'] ?></legend> 120 <div class="infldset"> 121 <p><?php echo $lang_admin_ranks['Add rank info'].' '.($pun_config['o_ranks'] == '1' ? sprintf($lang_admin_ranks['Ranks enabled'], '<a href="admin_options.php#ranks">'.$lang_admin_common['Options'].'</a>') : sprintf($lang_admin_ranks['Ranks disabled'], '<a href="admin_options.php#ranks">'.$lang_admin_common['Options'].'</a>')) ?></p> 122 <table cellspacing="0"> 123 <thead> 124 <tr> 125 <th class="tcl" scope="col"><?php echo $lang_admin_ranks['Rank title label'] ?></th> 126 <th class="tc2" scope="col"><?php echo $lang_admin_ranks['Minimum posts label'] ?></th> 127 <th class="hidehead" scope="col"><?php echo $lang_admin_ranks['Actions label'] ?></th> 128 </tr> 129 </thead> 130 <tbody> 131 <tr> 132 <td class="tcl"><input type="text" name="new_rank" size="24" maxlength="50" tabindex="1" /></td> 133 <td class="tc2"><input type="text" name="new_min_posts" size="7" maxlength="7" tabindex="2" /></td> 134 <td><input type="submit" name="add_rank" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="3" /></td> 135 </tr> 136 </tbody> 137 </table> 138 </div> 139 </fieldset> 140 </div> 141 <div class="inform"> 142 <fieldset> 143 <legend><?php echo $lang_admin_ranks['Edit remove subhead'] ?></legend> 144 <div class="infldset"> 145 <?php 146 147 $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()); 148 if ($db->num_rows($result)) 149 { 150 151 ?> 152 <table cellspacing="0"> 153 <thead> 154 <tr> 155 <th class="tcl" scope="col"><?php echo $lang_admin_ranks['Rank title label'] ?></th> 156 <th class="tc2" scope="col"><?php echo $lang_admin_ranks['Minimum posts label'] ?></th> 157 <th class="hidehead" scope="col"><?php echo $lang_admin_ranks['Actions label'] ?></th> 158 </tr> 159 </thead> 160 <tbody> 161 <?php 162 163 while ($cur_rank = $db->fetch_assoc($result)) 164 echo "\t\t\t\t\t\t\t\t".'<tr><td class="tcl"><input type="text" name="rank['.$cur_rank['id'].']" value="'.pun_htmlspecialchars($cur_rank['rank']).'" size="24" maxlength="50" /></td><td class="tc2"><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="'.$lang_admin_common['Update'].'" /> <input type="submit" name="remove['.$cur_rank['id'].']" value="'.$lang_admin_common['Remove'].'" /></td></tr>'."\n"; 165 166 ?> 167 </tbody> 168 </table> 169 <?php 170 171 } 172 else 173 echo "\t\t\t\t\t\t\t".'<p>'.$lang_admin_ranks['No ranks in list'].'</p>'."\n"; 174 175 ?> 176 </div> 177 </fieldset> 178 </div> 179 </form> 180 </div> 181 </div> 182 <div class="clearer"></div> 183 </div> 184 <?php 185 186 require PUN_ROOT.'footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |