<?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
// Tworzy połączenie z bazą danych
$host = "localhost";
$user = "root";
$pwd = "";
$dbConn = mysql_connect($host,$user,$pwd);
mysql_query("set names utf8");
// Połączenie z bazą danych newland_tours
$database = "newland_tours";
mysql_select_db($database);
$query_rs_regions = "SELECT regionID, regionName FROM tbl_region ORDER BY regionName";
$rs_regions = mysql_query($query_rs_regions);
$row_rs_regions = mysql_fetch_assoc($rs_regions);
$query_rs_countryDetail = "SELECT countryID, region, countryName, population, country_currency, description, imageURL, imageALT FROM tbl_country WHERE tbl_country.countryID=".mysql_real_escape_string($_GET['countryID']);
$rs_countryDetail = mysql_query($query_rs_countryDetail);
$row_rs_countryDetail = mysql_fetch_assoc($rs_countryDetail);
?>
<!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: Administracja: Zmień opis kraju</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>Uaktualnij  opis kraju</h1>
    <form action="admin_cp_update_processor.php" method="post" name="frm_updatetProfile" id="frm_updatetProfile">
      <table width="95%" border="1" cellpadding="3" cellspacing="0">
        <tr>
          <td width="44%">Rejon</td>
          <td width="56%">
            <select name="region" id="region">
           <?php
				do {
			?>
				<option value="<?php echo $row_rs_regions['regionID']; ?>"
					<?php
					if ($row_rs_regions['regionID'] == $row_rs_countryDetail['region']) {
						echo " selected=\"selected\"";
					}
					?>
				><?php echo $row_rs_regions['regionName']; ?></option>		  
			<?php
				}
				while ($row_rs_regions = mysql_fetch_assoc($rs_regions));
			?>
            </select>
          </td>
        </tr>
        <tr>
          <td>Nazwa kraju</td>
          <td><input type="text" name="countryName" value="<?php echo $row_rs_countryDetail['countryName']; ?>" /></td>
        </tr>
        <tr>
          <td>Liczba ludności (nie rozdzielaj cyfr)</td>
          <td><input type="text" name="population" id="population" value="<?php echo $row_rs_countryDetail['population']; ?>" /></td>
        </tr>
        <tr>
          <td>Waluta</td>
          <td><input type="text" name="country_currency" value="<?php echo $row_rs_countryDetail['country_currency']; ?>" /></td>
        </tr>
        <tr>
          <td>Opis kraju</td>
          <td><textarea name="description"  cols="55" rows="9"><?php echo $row_rs_countryDetail['description'];?></textarea></td>
        </tr>
        <tr>
          <td>Adres URL obrazu (Nie zapomnij przesłać pliku do folderu images na serwerze)</td>
          <td><input type="text" name="imageURL" id="imageURL" value="<?php echo $row_rs_countryDetail['imageURL']; ?>" /></td>
        </tr>
        <tr>
          <td>Alternatywny opis obrazu</td>
          <td><textarea name="imageALT"  cols="55" ><?php echo $row_rs_countryDetail['imageALT'];?></textarea></td>
        </tr>
        <tr>
          <td><input type="hidden" name="countryID" value="<?php echo $row_rs_countryDetail['countryID'];?>"></td>
          <td><input type="submit" name="button" value="Wyślij" /></td>
        </tr>
      </table>
    </form>

    <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_regions);
mysql_free_result($rs_countryDetail);
?>