<?php require_once('Connections/conn_newland.php'); ?><?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "administrator";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rs_registeredUsers = 20;
$pageNum_rs_registeredUsers = 0;
if (isset($_GET['pageNum_rs_registeredUsers'])) {
  $pageNum_rs_registeredUsers = $_GET['pageNum_rs_registeredUsers'];
}
$startRow_rs_registeredUsers = $pageNum_rs_registeredUsers * $maxRows_rs_registeredUsers;

mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_registeredUsers = "SELECT userID, firstName, lastName, username, userGroup FROM tbl_users ORDER BY lastName ASC";
$query_limit_rs_registeredUsers = sprintf("%s LIMIT %d, %d", $query_rs_registeredUsers, $startRow_rs_registeredUsers, $maxRows_rs_registeredUsers);
$rs_registeredUsers = mysql_query($query_limit_rs_registeredUsers, $conn_newland) or die(mysql_error());
$row_rs_registeredUsers = mysql_fetch_assoc($rs_registeredUsers);

if (isset($_GET['totalRows_rs_registeredUsers'])) {
  $totalRows_rs_registeredUsers = $_GET['totalRows_rs_registeredUsers'];
} else {
  $all_rs_registeredUsers = mysql_query($query_rs_registeredUsers);
  $totalRows_rs_registeredUsers = mysql_num_rows($all_rs_registeredUsers);
}
$totalPages_rs_registeredUsers = ceil($totalRows_rs_registeredUsers/$maxRows_rs_registeredUsers)-1;

$queryString_rs_registeredUsers = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rs_registeredUsers") == false && 
        stristr($param, "totalRows_rs_registeredUsers") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rs_registeredUsers = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rs_registeredUsers = sprintf("&totalRows_rs_registeredUsers=%d%s", $totalRows_rs_registeredUsers, $queryString_rs_registeredUsers);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Newland Tours: Dodaj użytkownika do grupy administratorów</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body class="oneColFixCtrHdr">
<a href="#top"><img src="images/spacer.gif" alt="Przejdź do głównej treści strony" border="0" /></a>
<div id="container">
  <div id="header">
    <img src="images/banner_left.gif" width="451" height="68" alt="Banner Newland Tours, strona lewa." /><img src="images/banner_right.jpg" width="276" height="68" id="bannerRight" alt="Banner Newland Tours, strona prawa" />
  <!-- end #header --></div>
  <div id="navigation">
  	<ul>
        <li><a href="index.php">Główna</a></li>
        <li><span class=""><span class=""><a href="about.cfm">O firmie</a></span></span></li>
<li><a href="tours.php">Znajdź wyjazd</a></li>
        <li><a href="profiles.php">Opisy krajów</a></li>
        <li><a href="contact.php">Kontakt z nami</a></li>
    </ul>
    </div>
  <div id="mainContent">
    <h1><a name="top" id="top"></a>Dodaj  użytkownika do grupy administratorów </h1>
    <p>Aby dodać  użytkownika do grupy administratorów, wybierz z listy jego nazwę i&nbsp;na następnej  stronie zmień jego grupę praw dostępu na &quot;administrator&quot;.</p>
    <p>&nbsp;
    <table border="1" align="center">
      <tr>
        <td>firstName</td>
        <td>lastName</td>
        <td>username</td>
        <td>userGroup</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_rs_registeredUsers['firstName']; ?>&nbsp; </td>
          <td><?php echo $row_rs_registeredUsers['lastName']; ?>&nbsp; </td>
          <td><a href="admin_addUser_detail.php?recordID=<?php echo $row_rs_registeredUsers['userID']; ?>"> <?php echo $row_rs_registeredUsers['username']; ?>&nbsp; </a> </td>
          <td><?php echo $row_rs_registeredUsers['userGroup']; ?>&nbsp; </td>
        </tr>
        <?php } while ($row_rs_registeredUsers = mysql_fetch_assoc($rs_registeredUsers)); ?>
    </table>
    <br />
    <table border="0">
      <tr>
        <td><?php if ($pageNum_rs_registeredUsers > 0) { // Show if not first page ?>
              <a href="<?php printf("%s?pageNum_rs_registeredUsers=%d%s", $currentPage, 0, $queryString_rs_registeredUsers); ?>">First</a>
              <?php } // Show if not first page ?>
        </td>
        <td><?php if ($pageNum_rs_registeredUsers > 0) { // Show if not first page ?>
              <a href="<?php printf("%s?pageNum_rs_registeredUsers=%d%s", $currentPage, max(0, $pageNum_rs_registeredUsers - 1), $queryString_rs_registeredUsers); ?>">Previous</a>
              <?php } // Show if not first page ?>
        </td>
        <td><?php if ($pageNum_rs_registeredUsers < $totalPages_rs_registeredUsers) { // Show if not last page ?>
              <a href="<?php printf("%s?pageNum_rs_registeredUsers=%d%s", $currentPage, min($totalPages_rs_registeredUsers, $pageNum_rs_registeredUsers + 1), $queryString_rs_registeredUsers); ?>">Next</a>
              <?php } // Show if not last page ?>
        </td>
        <td><?php if ($pageNum_rs_registeredUsers < $totalPages_rs_registeredUsers) { // Show if not last page ?>
              <a href="<?php printf("%s?pageNum_rs_registeredUsers=%d%s", $currentPage, $totalPages_rs_registeredUsers, $queryString_rs_registeredUsers); ?>">Last</a>
              <?php } // Show if not last page ?>
        </td>
      </tr>
    </table>
    Rekordy od <?php echo ($startRow_rs_registeredUsers + 1) ?> do <?php echo min($startRow_rs_registeredUsers + $maxRows_rs_registeredUsers, $totalRows_rs_registeredUsers) ?> z <?php echo $totalRows_rs_registeredUsers ?>
    </p>
<br clear="all" />
  <!-- end #mainContent --></div>
  <div id="footer">
    <p>&copy; 2007 Newland Tours</p>
  <!-- end #footer --></div>
<!-- end #container --></div>

</body>
</html>
<?php
mysql_free_result($rs_registeredUsers);
?>
