<?php include 'sets.php';?>
<?php
$superuser="0";
?>
<!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';?>

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

$result = $mysqli->query("SELECT * FROM links WHERE id='$id'");
$row = $result->fetch_array(); 
$name=$row['name'];
$url=$row['url'];
$publish=$row['publish'];
$priority=$row['priority'];
?>
    
<div class="container">
<div class="frame">
<div class="frametitles fedit"><?php echo $adminedit ?>
<div class="floatright"><a href="add-link.php"><img src="img/add.png" alt="<?php echo $adminadditem ?>" title="<?php echo $adminadditem ?>"></a></div>
</div>
<div class="framein">

<?php 
if  (isset($_POST['submit'])) {
$name = $mysqli->real_escape_string(stripslashes($_REQUEST['name']));
$name = strip_tags($name);
$name = preg_replace('/\s+/', ' ',$name);
$url = $mysqli->real_escape_string(stripslashes($_REQUEST['url']));
$url=preg_replace('/\s+/', '', $url);  
$publish = $mysqli->real_escape_string(stripslashes($_REQUEST['publish']));	  
$priority = $mysqli->real_escape_string(stripslashes($_REQUEST['priority']));	  

$mysqli->query("UPDATE links SET name='$name', url='$url', publish='$publish', priority='$priority' WHERE id='$id'");
} ?>

<?php if ($id) { ?>
<form name="forma" method="post" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="5000000">
  <input type="hidden" name="id" value="<?php echo $id ?>">
  <table>
    <tr>
      <td class="tabletd1">&nbsp;</td> 
      <td class="tabletd2"><?php echo $adminnamed ?> *
        </td>
      <td> 
        <input type="text" name="name" size="100" value="<?php echo $name ?>" required>
        </td>
    </tr>
    <tr>
      <td class="tabletd1">&nbsp;</td>
      <td class="tabletd2"><span class="icon fa-link" title="Link url"></span></td>
      <td><input type="text" name="url" value="<?php echo $url ?>" size="100"></td> 
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><span class="icon fa-image" title="<?php echo $adminimg ?>"></span></td>
      <td><input name="upload" type="file" size="50" title="upload .png"></td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td><span class="icon fa-eye<?php if ($publish=='no') { echo "-slash"; }?>" title="<?php echo $adminpublish ?>"></span></td>
      <td>
	<input type="hidden" name="publish" value="no"> <input type="checkbox" name="publish" value="yes"<?php if ($publish=='yes') { echo " checked"; }?>>
     </td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td><span class="icon fa-sort-numeric-asc" title="<?php echo $adminpriority ?>"></span></td>
      <td> 
        <input type="text" name="priority" value="<?php echo $priority ?>" size="15" maxlength="11" class="inputauto">
        </td>
    </tr>
    </table>

<!--UPLOAD --> 
<?php
if  ( isset($_POST['submit']) AND ($_FILES['upload']['tmp_name'] != "" ) ) {

	    $file_tmp =$_FILES['upload']['tmp_name'];
	   
		$uploadid=$id;
		$uploaddir = $filepath.'links/';
		$uploadname = $uploadid.'.png'; 
	
		copy($file_tmp,$uploaddir.$uploadname);
	
resizephoto($uploaddir.$uploadname,$uploaddir.$uploadname,$thumb_w,$thumb_h);

}
?> 

   <hr>
  <div class="divallbuttons">
<div class="divlist"><a href="list-links.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>
<?php } ?>

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

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

</body>
</html>