<?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
$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>
<title>Newland Tours: Dodaj użytkownika do grupy administratorów</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<link href="css/newland.css" rel="stylesheet" type="text/css" />
</head>

<body>
<a href="#top"><img src="images/spacer.gif" alt="Skip to main page content" width="1" height="1" border="0" align="left" /></a>
<table width="750" border="0" cellpadding="3" cellspacing="0">
 <tr>
  <td><img src="images/banner_left.gif" width="451" height="68" alt="Newland Tours Banner, Left." /></td>
  <td width="280"><img src="images/banner_right.jpg" width="276" height="68" alt="Newland Tour Banner, Right." /></td>
 </tr>
 <tr>
  <td><img src="images/navbar.gif" name="navbar" width="450" height="20" border="0" usemap="#navbarMap" alt="Navigation Bar." /></td>
  <td><img name="copyright_bar" src="images/copyright_bar.gif" width="272" height="20" border="0" alt="Copyright 2006 Newland Tours." /></td>
 </tr>
 <tr>
  <td colspan="2">	
	<h1><br />
	  <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 na  następnej stronie zmień jego grupę praw dostepu na &quot;administrator  &quot;.</p>
    <p> 
    <table border="1" align="center">
      <tr>
        <td><strong>Imię</strong></td>
        <td><strong>Nazwisko</strong></td>
        <td><strong>Adres e-mail </strong></td>
        <td><strong>Bieżąca grupa praw dostępu </strong></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" width="50%" align="center">
      <tr>
        <td width="23%" align="center"><?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); ?>">Pierwszy</a>
              <?php } // Show if not first page ?>
        </td>
        <td width="31%" align="center"><?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); ?>">Poprzedni</a>
              <?php } // Show if not first page ?>
        </td>
        <td width="23%" align="center"><?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); ?>">Następny</a>
              <?php } // Show if not last page ?>
        </td>
        <td width="23%" align="center"><?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); ?>">Ostatni</a>
              <?php } // Show if not last page ?>
        </td>
      </tr>
    </table>
    Recordy 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></td>
 </tr>
</table>

<br />


<map name="navbarMap" id="navbarMap">
 <area shape="rect" coords="1,0,62,20" href="index.php" alt="Home" />
 <area shape="rect" coords="71,0,117,20" href="about.php" alt="About" />
 <area shape="rect" coords="129,0,196,20" href="tours.php" alt="Find Tours" />
 <area shape="rect" coords="209,0,311,20" href="profiles.php" alt="Country Profiles" />
 <area shape="rect" coords="327,0,434,20" href="contact.php" alt="Contact An Agent" />
</map>
</body>
</html>
<?php
mysql_free_result($rs_registeredUsers);
?>