File: //home/httpd/mech_ftp/baretube.com/admin/servers_edit.php
<?php
require "db.php";
if (!is_numeric($_GET['id'])) {
header("Location: $basehttp/admin/servers_list.php");
exit();
}
$id = (int) $_GET['id'];
if (isset($_POST['formSubmit'])) {
if ($_POST['name'] && $_POST['nfs_path'] && $_POST['url_path']) {
if (filter_var($_POST['url_path'], FILTER_VALIDATE_URL) !== false) {
$post = mysqli_real_escape_array($_POST);
if (!is_array(dbQuery("SELECT * FROM `servers` WHERE `name` = '{$post['name']}' AND `nfs_path` = '{$post['nfs_path']}' AND `url_path` = '{$post['url_path']}' AND `record_num` != '$id'", false))) {
dbUpdate('servers', array(
'name' => $_POST['name'],
'nfs_path' => $_POST['nfs_path'],
'url_path' => $_POST['url_path'],
'hash_function' => $_POST['hash_function'],
'hash_key' => $_POST['hash_key'],
'record_num' => $id,
));
setMessage('Server successfully edited. <a href="servers_list.php">Click here to go back</a>.');
} else {
setMessage('Error! That server already exists!<br />Please provide unique name, NFS mount and URL path.', 'error');
}
} else {
setMessage('Error! Provide valid URL Path.', 'error');
}
} else {
setMessage('Error! Provide valid Name, NFS Path and URL Path.', 'error');
}
}
$_REQUEST += dbRow("SELECT * FROM `servers` WHERE `record_num` = '$id'");
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="servers_list.php">Servers List</a></span>
</div>
</div>
<div class="content-outer">
<h2>Edit<strong>Server</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th colspan="2">Server details</th>
</tr>
</thead>
<tr>
<td>Name</td>
<td><input name="name" type="text" value="<? echo $_REQUEST['name']; ?>" required /></td>
</tr>
<tr>
<td>NFS Path <a href="#" title="Should be full linux path"><i class="ion ion-help-circled"></i></a></td>
<td><input name="nfs_path" type="text" value="<? echo $_REQUEST['nfs_path']; ?>" required /></td>
</tr>
<tr>
<td>URL Path</td>
<td><input name="url_path" type="text" placeholder="http://media.domain.com" value="<? echo $_REQUEST['url_path']; ?>" required /></td>
</tr>
<tr>
<td>Hash Function <a href="#" title="Name of hashing function for secure download"><i class="ion ion-help-circled"></i></a></td>
<td><input name="hash_function" type="text" value="<? echo $_REQUEST['hash_function']; ?>" /></td>
</tr>
<tr>
<td>Hash Key <a href="#" title="Key for above hash function"><i class="ion ion-help-circled"></i></a></td>
<td><input name="hash_key" type="text" value="<? echo $_REQUEST['hash_key']; ?>" /></td>
</tr>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="id" value="<? echo $id; ?>">
<input type="hidden" name="formSubmit" value="1">
<button type="submit" class="btn action-save">Submit</button>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php require "footer.php" ?>