<?

  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'];
  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 WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR="#EFEFF8">
<TR><TD VALIGN=top BGCOLOR="#BFBFDF" STYLE="border-bottom: 1px solid #505090;"><FONT COLOR="navy"><B>';
  echo $admin_Top_Menu_Items;
  echo '</B></FONT></TD></TR><TR><TD VALIGN=top>


';
  if ($_POST['save'])
  {
    if (!($result = mysql_query ('SELECT * FROM topmenu')))
    {
      exit ('Query failed4');
      ;
    }

    $row = mysql_fetch_array ($result);
    $_POST['items'] = trim ($_POST['items']);
    if ($row)
    {
      if (!(mysql_query ('' . 'UPDATE topmenu SET items=\'' . $_POST['items'] . '\'')))
      {
        exit ('Query failed');
        ;
      }

      echo '<B><FONT COLOR="white" STYLE="background-color:red;">&nbsp;';
      echo $admin_Last_Changes_Saved;
      echo '&nbsp;</FONT></B>';
    }
    else
    {
      if (!(mysql_query ('' . 'INSERT INTO topmenu VALUES(\'' . $_POST['items'] . '\')')))
      {
        exit ('Query failed');
        ;
      }

      echo '<B><FONT COLOR="white" STYLE="background-color:red;">&nbsp;';
      echo $admin_Last_Changes_Saved;
      echo '&nbsp;</FONT></B>';
    }

    $items = split ('
', $_POST['items']);
    for ($i = 0; $i < sizeof ($items); ++$i)
    {
      if (!file_exists ($documentroot . '/upload/topmenu/' . $items[$i] . '.html'))
      {
        $handle = fopen ($documentroot . '/upload/topmenu/' . $items[$i] . '.html', 'w+');
        $buffer = fputs ($handle, $items[$i] . '.html');
        fclose ($handle);
        continue;
      }
    }
  }

  echo '



';
  if (!($result = mysql_query ('SELECT * FROM topmenu')))
  {
    exit ('Query failed4');
    ;
  }

  $row = mysql_fetch_array ($result);
  echo '
<form action="';
  echo $php_self;
  echo '" method="post">
';
  echo $admin_Item_Listing;
  echo '<BR>
<textarea cols="50" rows="10" name="items">';
  echo $row['items'];
  echo '</textarea><br><br>
<INPUT TYPE=submit NAME="save" VALUE="';
  echo $admin_Save_changes;
  echo '">
</FORM>

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