Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isuseradmin($userID) OR mb_substr(basename($_SERVER['REQUEST_URI']),0,16) != "admincenter2.php") die($_language->module['access_denied']);
- ?>
- <script>
- jQuery(function(){
- jQuery('.button').click(function(){
- jQuery('.Rights').hide();
- jQuery('#div'+$(this).attr('target')).show();
- });
- });
- </script>
- <h2>Medlemmar</h2>
- <?php
- $sql = mysql_query("
- SELECT ".PREFIX."user.username, ".PREFIX."user.registerdate, ".PREFIX."user.userID, ".PREFIX."user_groups.userID, ".PREFIX."user_groups.news, ".PREFIX."user_groups.user, ".PREFIX."user_groups.forum, ".PREFIX."user_groups.moderator, ".PREFIX."user_groups.super
- FROM ".PREFIX."user
- LEFT JOIN ".PREFIX."user_groups
- ON ".PREFIX."user.userID = ".PREFIX."user_groups.userID
- ");
- if (mysql_num_rows($sql) == 0) {
- echo '<div class="alert alert-box alert-error">Finns inga medlemmar.</div>';
- }
- else{
- echo '<form method="post">';
- echo '<table cellspacing="0" cellpadding="0" width="100%" class="table table-striped">';
- echo '<tr><td width="200"><strong>Användarnamn</strong></td><td><strong>Ålder</strong></td><td><strong>Blev medlem</strong></td><td align="right"></td></tr>';
- while ($rad = mysql_fetch_array($sql)) {
- if (isset($_POST['editadmin'])) {
- if (mysql_result(mysql_query("SELECT COUNT(*) AS ANTAL FROM ".PREFIX."user_groups WHERE userID='".$_POST['userID']."'"),0) > 0) {
- // Following example is part of a response at the following url.
- // http://www.hamsterpaj.net/diskussionsforum/gaa_till_post.php?post_id=4265149
- // Items to iterate through (sql-key => post-value)
- $postItems = array(
- 'newsadmin',
- 'forumpolis',
- 'moderator',
- 'memberadmin',
- 'superadmin'
- );
- // Check if each individual item is set and assign an integer for state
- // User altered information will be disregarded and changed to either a 0 or 1
- // depending on the key being assigned or not, so no filtering necessary
- foreach ($postItems as $postItem){
- $_POST[$postItem] = (!isset($_POST[$postItem])) ? 0 : 1;
- }
- // Cast userID to an integer only, non-numerical information will return 0
- $_POST['userID'] = (int)$_POST['userID'];
- // Construct query
- $sql2 = 'UPDATE user_groups SET news='.$_POST['newsadmin'].', forum='.$_POST['forumpolis'].', moderator='.$_POST['moderator'].', user='.$_POST['memberadmin'].', super='.$_POST['superadmin'].' WHERE userID='.$_POST['userID'];
- // Dump variable
- var_dump($sql);
- }
- }
- $res = mysql_query("SELECT birthday, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%Y') 'age' FROM ".PREFIX."user WHERE userID = '".$rad['userID']."'");
- $cur = mysql_fetch_array($res);
- $birthday = (int)$cur['age']." år ";
- $reg = date('Y/m/d, H:i', $rad['registerdate']);
- $news = ($rad['news'] == "1" && $rad['super'] == 0) ? 'checked="checked"' : '';
- $memberadmin = ($rad['user'] == "1" && $rad['super'] == 0) ? 'checked="checked"' : '';
- $moderator = ($rad['moderator'] == "1" && $rad['super'] == 0) ? 'checked="checked"' : '';
- $polis = ($rad['forum'] == "1" && $rad['super'] == 0) ? 'checked="checked"' : '';
- $superadmin = ($rad['super'] == "1") ? 'checked="checked"' : 'none';
- echo '<tr><td width="400"><a href="?p=user&id='.$rad['userID'].'" target="_BLANK">'.$rad['username'].'</a></td><td>'.$birthday.'</td><td>'.$reg.'</td><td align="right"><img src="../img/pencil.png"><img src="../img/user_suit.png" target="'.$rad['userID'].'" title="Rättigheter" class="button" style="cursor:pointer;margin-left: 5px; margin-right: 5px;"><img src="../img/delete.png"></td></tr>';
- echo '<tr class="Rights" id="div'.$rad['userID'].'"><td colspan="4">';
- echo '<h2>Ändra Rättigheter: '.getUsername($rad['userID']).' </h2>';
- echo '<table cellspacing="0" cellpadding="0" width="100%">';
- echo '<tr><td width="350"><strong>Nyhetsadmin</strong> (<small>Nyheter, Artiklar, Guider</small>)</td><td align="right"><input type="checkbox" name="newsadmin" value="1" '.$news.'></td></tr>';
- echo '<tr><td width="350"><strong>Medlemsadmin</strong> (<small>Medlemmar, Administratörer</small>)</td><td align="right"><input type="checkbox" name="memberadmin" value="1" '.$memberadmin.'></td></tr>';
- echo '<tr><td width="350"><strong>Moderator</strong> (<small>Trådar, Kategorier, Poliser</small>)</td><td align="right"><input type="checkbox" name="moderator" value="1" '.$moderator.'></td></tr>';
- echo '<tr><td width="350"><strong>Forumpolis</strong> (<small>Trådar, Kommentarer</small>)</td><td align="right"><input type="checkbox" name="forumpolis" value="1" '.$polis.'></td></tr>';
- echo '<tr><td width="350"><strong>Super</strong> (<small>Alla rättigheter</small>)</td><td align="right"><input type="checkbox" name="superadmin" value="1" '.$superadmin.'></td></tr>';
- echo '</table><input type="hidden" name="userID" value="'.$rad['userID'].'">';
- echo '<input type="submit" name="editadmin" value="Spara" class="btn btn-primary btn-small" style="font-weight:bold; width:100%;">';
- echo '</td></tr>';
- }
- echo '</table></form>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment