Location: PHPKode > projects > Moers - Event Registration System > moers-1.046/admin_users.php
<?php
/************************************************************************************
    Copyright © 2008 xhub.com

    Bill Bennert
    5 Hooksett Tpke
    Bow, NH 03304-4414
    hide@address.com

    This file is part of the SCCNH Online Registration System.

    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 3 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, see <http://www.gnu.org/licenses/>.

    Any system sensitive data such as IP addresses, usernames, and passwords 
    must be removed from this file before distribution.

************************************************************************************/

include 'include/config.php';
include 'include/functions.php';

// Connects to your Database
mysql_connect($database_IP, $database_Username, $database_Password) or die(mysql_error());
mysql_select_db($database_Name) or die(mysql_error());

//checks cookies to make sure they are logged in
if(isset($_COOKIE['SCCNH_ID']))
{
  $hashUsername = $_COOKIE['SCCNH_ID'];
  $sessionId = $_COOKIE['SCCNH_Session_ID'];

  $check = mysql_query("SELECT * FROM users WHERE user_hash = '$hashUsername'")or die(mysql_error());
  while($info = mysql_fetch_array( $check ))
  {
    $username = $info['username'];
    //if the cookie has the wrong sessionid, they are taken to the login page
    if ($sessionId != $info['session_id'])
    { header("Location: logout.php");
    }

    //otherwise they are shown the admin area
    elseif ($info['admin'])
    {
      changeCookie(); // keep the session id changing

      if (isset($_POST['emailUsers']))
      {
        $emailList = "";
        $userCheck = mysql_query("SELECT * FROM users")or die(mysql_error());
        while($userInfo = mysql_fetch_array( $userCheck ))
        {
          $emailList .= $userInfo['email'];
        }
     
      }

      echo file_get_contents("header.html");
      echo "<font size=\"3\">Welcome <b>'".$info['username']."'</b> ";
      echo file_get_contents("header2.html");
      echo "</font><hr />\n";

      echo file_get_contents("admin_header.html");
      echo "<br />\n";


      echo "<table class=\"default\"><tr>\n";
      echo "<td>Username</td>\n";
      echo "<td>Full Name</td>\n";
      echo "<td>Email</td>\n";
      echo "<td>Member Type</td>\n";
      echo "<td>Member of</td>\n";
      echo "<td>Creation</td>\n";
      echo "<td>Last Login</td>\n";
      echo "</tr>\n";

      $userCount = 0;

//      $userCheck = mysql_query("SELECT * FROM users WHERE username != '$username'")or die(mysql_error());
      $userCheck = mysql_query("SELECT * FROM users")or die(mysql_error());
      while($userInfo = mysql_fetch_array( $userCheck ))
      {
        $userCount += 1;
        echo "<tr>\n";
        echo "<td>".$userInfo['username']."</td>\n";
        echo "<td>".$userInfo['fname']." ".$userInfo['lname']."</td>\n";
        echo "<td>".$userInfo['email']."</td>\n";

        if ($userInfo['member'] == 0)
        {
          echo "<td>Non-Member</td>\n";
        }
        else if ($userInfo['member'] == 1)
        {
          echo "<td>Member-Online</td>\n";
        }
        else if ($userInfo['member'] == 2)
        {
          echo "<td>Member-Offline</td>\n";
        }
        else if ($userInfo['member'] == 3)
        {
          echo "<td>Partner-Member</td>\n";
        }
        else
        {
          echo "<td>ERROR</td>\n";
        }

        echo "<td>".$userInfo['club']."</td>\n";
        echo "<td>".$userInfo['creation']."</td>\n";
        echo "<td>".$userInfo['lastLogon']."</td>\n";

        echo "</tr>\n";
      }
      echo "</table>\n";
      echo "<br /><br />Total Number of Users: ".$userCount."<br />\n";
      echo file_get_contents("footer.html");
    }
  }
}
else
//if the cookie does not exist, they are taken to the login screen
{
  header("Location: logout.php");
}
?>
Return current item: Moers - Event Registration System