<?php include 'sets.php';?>
<?php
$superuser="1";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Webadmin <?php echo $domain ?></title>
<?php include 'codes.php';?>
</head>
<body>

<?php include 'navbar.php';?>
    
<div class="container">
<div class="frame">
<div class="frametitles fadd"><?php echo $adminadd ?>
<div class="floatright"><a href="list-langvars.php"><img src="img/list.png" alt="<?php echo $adminlist ?>" title="<?php echo $adminlist ?>"></a></div>
</div>
<div class="framein">

<?php
$id = $mysqli->real_escape_string(stripslashes($_REQUEST['id']));

$result = $mysqli->query("SELECT insert_id FROM langvars WHERE lang_id=$lang ORDER BY insert_id desc LIMIT 1");
$row = $result->fetch_array(); 
$isid=$row['insert_id'];
$insertid=$isid + 1;
?>

<form name="forma" method="post" enctype="multipart/form-data">

<table>
    <tr>
      <td class="tabletd1">&nbsp;</td> 
      <td class="tabletd2"><?php echo $adminnamed ?> *</td>
      <td> 
        <input type="text" name="name" size="100" required>
        </td>
    </tr>
    </table>
    
  <?php
$result30 = $mysqli->query("SELECT * FROM lang WHERE active=1 ORDER BY priority");
while($row = $result30->fetch_array()) {
$langid=$row['id'];
$language=$row['language'];
$dir=$row['dir'];
?>

<?php 
if  (isset($_POST['submit'])) {
$name = $mysqli->real_escape_string(stripslashes($_REQUEST['name']));
$name = strip_tags($name);
$name = preg_replace('/\s+/', ' ',$name);
$text = $mysqli->real_escape_string(stripslashes($_REQUEST["text$langid"]));
$text = str_replace('\r\n', ' ',$text);
$text = preg_replace('/\s+/', ' ',$text);
$priority = $mysqli->real_escape_string(stripslashes($_REQUEST['priority'])); 

$mysqli->query("INSERT INTO langvars (insert_id, lang_id, name, text, priority) VALUES ('$insertid', '$langid', '$name', '$text', '$priority')");
} ?>

  <table>
    <tr>
      <td class="tabletd1"><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"></td>
      <td class="tabletd2"><?php echo $admintext ?> </td>
      <td><textarea name="text<?php echo $langid ?>" cols="75" rows="6"></textarea></td>
    </tr>
    </table>

<?php } ?>

<table>
    <tr>
      <td class="tabletd1">&nbsp;</td>
      <td class="tabletd2"><span class="icon fa-sort-numeric-asc" title="<?php echo $adminpriority ?>"></span></td>
      <td><input name="priority" type="text" class="inputauto" value="2" size="15" maxlength="11"></td>
    </tr>
</table>
   <hr>
  <div class="divallbuttons">
<div class="divlist"><a href="list-langvars.php" title="<?php echo $adminlist ?>" class="icstyle1 color1"><span class="icon fa-tasks"></span></a></div>
<div class="divbuttons">
  <button type="submit" name="submit" class="button"><span class="icon fa-check"></span> <?php echo $adminsubmit ?></button>
  <button type="reset" name="reset" class="button buttondelete"><span class="icon fa-refresh"></span> <?php echo $adminreset ?></button> 
</div>
   </div>
   
</form>  

</div>
</div>
</div>

<?php include 'menudown.php';?>

</body>
</html>