<?


  echo '<HTML><BODY STYLE="color: Navy;"><LINK HREF="../style.css" REL="stylesheet" TYPE="text/css"><TABLE WIDTH="600" BORDER=0 CELLSPACING=0 CELLPADDING=1><TR><TD style="background-color:#505090;"><TABLE HEIGHT=320 WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR="#EFEFF8"><TR><TD VALIGN=top>

';
  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  if (!($result_proper = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $proper = mysql_fetch_array ($result_proper);
  include '../lang/' . $proper['admin_language'];
  include '../../lang/' . $proper['language'];
  echo '





';
  if ($_POST['modify'])
  {
    if ($_POST['post_allow'])
    {
      $separated = join ('
', $_POST['post_allow']) . '
';
    }

    if ($_POST['pass'] != '********')
    {
      $_POST['pass'] = md5 ($_POST['pass']);
    }
    else
    {
      $_POST['pass'] = $_POST['old_password'];
    }

    $valid = mktime (23, 59, 59, $_POST['post_month'], $_POST['post_day'], $_POST['post_year']);
    $SQL = '' . 'UPDATE visitors SET username=\'' . $_POST['user'] . '\', password=\'' . $_POST['pass'] . '\', allowed=\'' . $separated . '\', status=\'' . $_POST['status'] . '\', valid=\'' . $valid . '\' WHERE id=\'' . $_POST['id'] . '\'';
    if (mysql_query ($SQL))
    {
      echo '<B><FONT COLOR="white" STYLE="background-color:red;">&nbsp;';
      echo $admin_Last_Changes_Saved;
      echo '&nbsp;</FONT></B>';
    }
  }

  echo '




';
  if ($_GET['id'])
  {
    $ID = $_GET['id'];
  }
  else
  {
    $ID = $_POST['id'];
  }

  if (!($result = mysql_query ('' . 'SELECT * FROM visitors WHERE id=\'' . $ID . '\'')))
  {
    exit ('Query failed4');
    ;
  }

  $row = mysql_fetch_array ($result);
  echo '
<FORM ACTION="visitor_edit.php" METHOD="post">

<TABLE>
<TR>
	<TD ALIGN=right>';
  echo $admin_Username;
  echo '</TD>
	<TD><INPUT TYPE=text NAME="user" value="';
  echo $row['username'];
  echo '"></TD>
</TR>
<TR>
	<TD ALIGN=right>';
  echo $admin_Password;
  echo '</TD>
	<TD><INPUT TYPE=text NAME="pass" value="********"></TD>
</TR>
<TR>
	<TD ALIGN=right>';
  echo $admin_Allowed_Categories;
  echo '</TD>
	<TD>
		';
  echo '<S';
  echo 'ELECT NAME="post_allow[]" SIZE="10" MULTIPLE>
		';
  if (!($result1 = mysql_query ('SELECT * FROM categories')))
  {
    exit ('Query failed4');
    ;
  }

  while ($row1 = mysql_fetch_array ($result1))
  {
    unset ($match);
    $SPLIT = split ('
', $row['allowed']);
    for ($i = 0; $i < sizeof ($SPLIT); ++$i)
    {
      if ($SPLIT[$i] == $row1['id'])
      {
        $match = 1;
        break;
      }
    }

    echo '<option value="';
    echo $row1['id'];
    echo '" ';
    if ($match == 1)
    {
      echo 'selected';
    }

    echo '>';
    echo $row1['name'];
    echo '</option>';
  }

  echo '		</select>		
	</TD>
</TR>
<TR>
	<TD ALIGN=right>';
  echo $admin_Validto;
  echo '</TD>
	<TD>
		';
  echo '<S';
  echo 'ELECT NAME="post_day">';
  for ($i = 1; $i < 32; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('j', $row['valid']))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>
		';
  echo '<S';
  echo 'ELECT NAME="post_month">';
  for ($i = 0; $i < 12; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i + 1;
    echo '" ';
    if ($i == date ('n', $row['valid']) - 1)
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $month[$i];
    echo '</OPTION>';
  }

  echo '</SELECT>
		';
  echo '<S';
  echo 'ELECT NAME="post_year">';
  for ($i = date ('Y', $curtime[0]); $i <= 2020; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('Y', $row['valid']))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>
</TD>
</TR>
<TR>
	<TD ALIGN=right>';
  echo $admin_Status;
  echo '</TD>
	<TD>
		<INPUT TYPE="radio" NAME="status" value="enabled" checked>Enabled
		<INPUT TYPE="radio" NAME="status" value="disabled" ';
  if ($row['status'] == 'disabled')
  {
    echo 'checked';
  }

  echo '>Disabled
	</TD>
</TR>
</TABLE>

<INPUT TYPE=hidden NAME="id" VALUE="';
  echo $row['id'];
  echo '">

<DIV ALIGN="center"><INPUT TYPE=submit NAME="modify" VALUE="';
  echo $admin_Modify;
  echo '"> <INPUT TYPE=button VALUE="';
  echo $admin_Go_back;
  echo '" onClick="window.location=\'visitor.php\'"></DIV>

</FORM>


</TD></TR></TABLE></TD></TR></TABLE></BODY></HTML>';
?>
