Location: PHPKode > projects > Club video list website > animelists/user_management.php
<?php
/*
Animelists website
Copyright (C) 2002 Jeff Wartes

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

-------------------------------------------------

This page displays a table with every regestered site user. Not every user
will have full access to the functionality of this page, but it allows
user accounts to be modified, deleted, or have their access level changed.

$Id: user_management.php,v 1.3 2002/10/20 19:20:59 pyreforge Exp $
*/

if (!isset($COMMONINCLUDED)){
    include("common.php");
}
setcookie("lastview", "user_management.php", time()+COOKIELIFE);

if (!isset($USERINCLUDED)){
    include("userclass.php");
}
?>

<html>
<head>
<style> <!-- @import url(animelists.css); --> </style>
<title>User Management</title>
</head>

<?php
//This is an executable include, it may kill the process if it encounters an error.
//otherwise, it processes the necessary data without interrupting or changing execution.
//Process_user.php allows the page to demote/promote/delete user accounts when passed
//the proper form-style data.
//(see file for details)
include("process_user.php");

dieIfNoLogin();
$userData = new UserList(USERDATAFILE);
$thisUser = $userData->getByName($username);

//validate user login info before making changes
if (!$thisUser || !$thisUser->validateUser($username, $userpass)){
    dieWithInvalidUser();
}

?>

<body>

<table class="listtable" id="userTable" rules="groups" cols=3 hlcolor="#BEC5DE" slcolor="#33CC99">
  <caption><b>
    <h2>User Information</h2> <small><small><a href="help" onclick="window.open('./table_help.htm#manage_users', '', 'menubar=no,directories=no,location=no,status=no,toolbar=no,scrollbars=yes,height=400,width=400'); return false;">explanation</a></small></small>
  </b></caption>
  <thead>
    <tr class="listheaderrow">
      <td class="listheader">User Name</td>
      <td class="listheader">Contact info</td>
      <td class="listheader">Access level</td>
    </tr>
  </thead>
  <tbody>

<?php
//first load the list data into a PHP variable

$listData = new UserList(USERDATAFILE);

//now write a table row for every Show in listData
if ($listData){
    foreach($listData->users as $aUser){
        if ($thisUser->rank > USER || $thisUser->compareName($aUser->name)){
            $name = $aUser->name;
            //add edit/delete buttons. TODO: edit button
            if (allowDelete($thisUser, $aUser)){
                $name = $name . printManageUserLink("<img src='" . IMAGESDIR . "ban.gif' alt='Delete this user and all their list entries' border=0 height=12 width=11 hspace=5>",
                                                    "?changeuser=" . $aUser->name . "&operation=delete",
                                                    "onclick='return confirm(\"This will permanently remove the user as well as anything they have added to the list! Are you sure?\");'");
            }

            $contact = $aUser->email;
            //wrap contact info in a mailto link if it's an email address
            if (isEmail($contact)){
                $contact = wrapEmail($contact, "Anime Lists");
                //$contact = '<a href="mailto:' . $contact . '?subject=Anime Lists">' . $contact . "</a>";
            }

            $rank = getUserLevel($aUser->rank);
            //add promote/demote links
            if (allowPromotion($thisUser, $aUser)){
                $rank = $rank . printManageUserLink("<img src='" . IMAGESDIR . "plus.gif' alt='Promote this person to " . getUserLevel($aUser->rank + 1) . "' border=0 height=10 width=9 hspace=5>",
                                                    "?changeuser=" . $aUser->name . "&operation=promote");
            }
            if (allowDemotion($thisUser, $aUser)){
                $rank = $rank . printManageUserLink("<img src='" . IMAGESDIR . "minus.gif' alt='Demote this person to " . getUserLevel($aUser->rank - 1) . "' border=0 height=10 width=9 hspace=5>",
                                                    "?changeuser=" . $aUser->name . "&operation=demote");
            }

            //print table row for this user
            echo "    <tr class='listrow'>\n";
            echo "      <td class='listitem'>" . stripslashes($name) . "</td>\n";
            echo "      <td class='listitem'>" . stripslashes($contact) . "</td>\n";
            echo "      <td class='listitem'>" . stripslashes($rank) . "</td>\n";
            echo "    </tr>\n";
        }
    }
}





?>

  </tbody>
</table>
&nbsp;
<hr>
&nbsp;
<table border="on">
  <caption>Current Settings:</caption>
  <tr>
    <td>Default access level for new users:</td>
    <td><b><?php echo getUserLevel(DEFAULTRANK);?></b></td>
  </tr>
  <tr>
    <td>Minimum access level to view other users' contact info:</td>
    <td><b><?php echo getUserLevel(USER + 1);?><b></td>
  </tr>
  <tr>
    <td>Promotion can only be performed by <?php echo getUserLevel(ADMIN);?>-level users:</td>

    <td><b><?php echo RESTRICTPROMOTION ? "True" : "False";?></b></td>

  </tr>

</table>

<?php echo printLinkFooter(); ?>


</body>
</html>
Return current item: Club video list website