diff options
Diffstat (limited to 'phpBB/admin/admin_ranks.php')
| -rw-r--r-- | phpBB/admin/admin_ranks.php | 94 |
1 files changed, 41 insertions, 53 deletions
diff --git a/phpBB/admin/admin_ranks.php b/phpBB/admin/admin_ranks.php index ff3424f9f2..52c5d4e98b 100644 --- a/phpBB/admin/admin_ranks.php +++ b/phpBB/admin/admin_ranks.php @@ -19,52 +19,42 @@ * ***************************************************************************/ -define('IN_PHPBB', 1); - -if( !empty($setmodules) ) +if (!empty($setmodules)) { - if ( !$auth->acl_get('a_user') ) + if (!$auth->acl_get('a_ranks')) { return; } - $file = basename(__FILE__); - $module['Users']['Ranks'] = "$file$SID"; + $module['Users']['Ranks'] = basename(__FILE__) . $SID; return; } -// +define('IN_PHPBB', 1); // Let's set the root dir for phpBB -// $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -// -// -// -if ( !$auth->acl_get('a_user') ) +// Do we have permission? +if (!$auth->acl_get('a_ranks')) { - return; + trigger_error($user->lang['NO_ADMIN']); } -// -// -// -if ( isset($_GET['mode']) || isset($_POST['mode']) ) +// Check mode +if (isset($_REQUEST['mode'])) { - $mode = ( isset($_POST['mode']) ) ? $_POST['mode'] : $_GET['mode']; + $mode = $_REQUEST['mode']; } else { - // // These could be entered via a form button - // - if ( isset($_POST['add']) ) + if (isset($_POST['add'])) { $mode = 'add'; } - else if ( isset($_POST['save']) ) + else if (isset($_POST['save'])) { $mode = 'save'; } @@ -74,23 +64,21 @@ else } } -// -// -// -if ( $mode != '' ) +// Process mode +if ($mode != '') { - if ( $mode == 'edit' || $mode == 'add' ) + if ($mode == 'edit' || $mode == 'add') { // // They want to add a new rank, show the form. // - $rank_id = ( isset($_GET['id']) ) ? intval($_GET['id']) : 0; + $rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; $s_hidden_fields = '<input type="hidden" name="mode" value="save" />'; - if ( $mode == 'edit' ) + if ($mode == 'edit') { - if ( empty($rank_id) ) + if (empty($rank_id)) { message_die(MESSAGE, $user->lang['Must_select_rank']); } @@ -126,15 +114,15 @@ if ( $mode != '' ) </tr> <tr> <td class="row1" width="40%"><?php echo $user->lang['Rank_special']; ?>: </td> - <td class="row2"><input type="radio" name="special_rank" value="1"<?php echo ( $rank_info['rank_special'] ) ? ' checked="checked"' : ''; ?> /><?php echo $user->lang['Yes']; ?> <input type="radio" name="special_rank" value="0"<?php echo ( !$rank_info['rank_special'] ) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['No']; ?></td> + <td class="row2"><input type="radio" name="special_rank" value="1"<?php echo ($rank_info['rank_special']) ? ' checked="checked"' : ''; ?> /><?php echo $user->lang['Yes']; ?> <input type="radio" name="special_rank" value="0"<?php echo (!$rank_info['rank_special']) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['No']; ?></td> </tr> <tr> <td class="row1" width="40%"><?php echo $user->lang['Rank_minimum']; ?>: </td> - <td class="row2"><input type="text" name="min_posts" size="5" maxlength="10" value="<?php echo ( $rank_info['rank_special'] ) ? '' : $rank_info['rank_min']; ?>" /></td> + <td class="row2"><input type="text" name="min_posts" size="5" maxlength="10" value="<?php echo ($rank_info['rank_special']) ? '' : $rank_info['rank_min']; ?>" /></td> </tr> <tr> <td class="row1" width="40%"><?php echo $user->lang['Rank_image']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Rank_image_explain']; ?></span></td> - <td class="row2"><input type="text" name="rank_image" size="40" maxlength="255" value="<?php echo ( $rank_info['rank_image'] != '' ) ? $rank_info['rank_image'] : ''; ?>" /><br /><?php echo ( $rank_info['rank_image'] != '' ) ? '<img src="../' . $rank_info['rank_image'] . '" />' : ''; ?></td> + <td class="row2"><input type="text" name="rank_image" size="40" maxlength="255" value="<?php echo ($rank_info['rank_image'] != '') ? $rank_info['rank_image'] : ''; ?>" /><br /><?php echo ($rank_info['rank_image'] != '') ? '<img src="../' . $rank_info['rank_image'] . '" />' : ''; ?></td> </tr> <tr> <td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="submit" value="<?php echo $user->lang['Submit']; ?>" class="mainoption" /> <input type="reset" value="<?php echo $user->lang['Reset']; ?>" class="liteoption" /></td> @@ -146,24 +134,24 @@ if ( $mode != '' ) page_footer(); } - else if ( $mode == 'save' ) + else if ($mode == 'save') { // // Ok, they sent us our info, let's update it. // - $rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : 0; - $rank_title = ( isset($_POST['title']) ) ? trim($_POST['title']) : ''; - $special_rank = ( $_POST['special_rank'] == 1 ) ? TRUE : 0; - $min_posts = ( isset($_POST['min_posts']) ) ? intval($_POST['min_posts']) : -1; - $rank_image = ( (isset($_POST['rank_image'])) ) ? trim($_POST['rank_image']) : ''; + $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0; + $rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : ''; + $special_rank = ($_POST['special_rank'] == 1) ? TRUE : 0; + $min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1; + $rank_image = ((isset($_POST['rank_image']))) ? trim($_POST['rank_image']) : ''; - if ( $rank_title == '' ) + if ($rank_title == '') { message_die(MESSAGE, $user->lang['Must_select_rank']); } - if ( $special_rank == 1 ) + if ($special_rank == 1) { $min_posts = -1; } @@ -171,15 +159,15 @@ if ( $mode != '' ) // // The rank image has to be a jpg, gif or png // - if ( $rank_image != '' ) + if ($rank_image != '') { - if ( !preg_match('/(\.gif|\.png|\.jpg|\.jpeg)$/is', $rank_image)) + if (!preg_match('/(\.gif|\.png|\.jpg|\.jpeg)$/is', $rank_image)) { $rank_image = ''; } } - if ( $rank_id ) + if ($rank_id) { $sql = "UPDATE " . RANKS_TABLE . " SET rank_title = '" . str_replace("\'", "''", $rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . str_replace("\'", "''", $rank_image) . "' @@ -202,22 +190,22 @@ if ( $mode != '' ) message_die(MESSAGE, $message); } - else if ( $mode == 'delete' ) + else if ($mode == 'delete') { // // Ok, they want to delete their rank // - if ( isset($_POST['id']) || isset($_GET['id']) ) + if (isset($_POST['id']) || isset($_GET['id'])) { - $rank_id = ( isset($_POST['id']) ) ? intval($_POST['id']) : intval($_GET['id']); + $rank_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']); } else { $rank_id = 0; } - if ( $rank_id ) + if ($rank_id) { $sql = "DELETE FROM " . RANKS_TABLE . " WHERE rank_id = $rank_id"; @@ -265,23 +253,23 @@ $sql = "SELECT * FROM " . RANKS_TABLE . " ORDER BY rank_min ASC, rank_special ASC"; $result = $db->sql_query($sql); -if ( $row = $db->sql_fetchrow($result) ) +if ($row = $db->sql_fetchrow($result)) { do { - $row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2'; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; ?> <tr> <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['rank_title']; ?></td> - <td class="<?php echo $row_class; ?>" align="center"><?php echo ( $row['rank_special'] ) ? '-' : $row['rank_min']; ?></td> - <td class="<?php echo $row_class; ?>" align="center"><?php echo ( $row['rank_special'] ) ? $user->lang['Yes'] : $user->lang['No']; ?></td> + <td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['rank_special']) ? '-' : $row['rank_min']; ?></td> + <td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['rank_special']) ? $user->lang['Yes'] : $user->lang['No']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&mode=edit&id=" . $row['rank_id']; ?>"><?php echo $user->lang['Edit']; ?></a></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_ranks.$phpEx$SID&mode=delete&id=" . $row['rank_id']; ?>"><?php echo $user->lang['Delete']; ?></a></td> </tr> <?php } - while ( $row = $db->sql_fetchrow($result) ); + while ($row = $db->sql_fetchrow($result)); } ?> |
