File: /home/httpd/html/freecams1.com/public_html/admin/servers_list.php
<?php
require "db.php";
if ($_POST['list'] && is_array($_POST['list'])) {
foreach ($_POST['list'] as $i) {
if (is_numeric($i)) {
dbQuery("DELETE FROM `servers` WHERE `record_num` = $i");
}
}
}
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']}'", false))) {
dbInsert('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'],
));
setMessage('Success! New server has been added!');
} 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');
}
}
if (!$config['multiple_servers']) {
setMessage('Please enable multi-server mode under Settings & Server Status -> Settings', 'alert');
}
?>
<? 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</a></span>
</div>
</div>
<div class="content-outer">
<h2>Manage<strong>Servers</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<? if ($config['multiple_servers']) { ?>
<form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th colspan="2">Add Server</th>
</tr>
</thead>
<tr>
<td>Name</td>
<td><input name="name" type="text" 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" required /></td>
</tr>
<tr>
<td>URL Path</td>
<td><input name="url_path" type="text" placeholder="http://media.domain.com" 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" /></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" /></td>
</tr>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="formSubmit" value="1">
<button type="submit" class="btn action-save">Submit</button>
</td>
</tr>
</table>
</form>
<form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th>Name</th>
<th>NFS Mount</th>
<th>URL Path</th>
<th class="options"></th>
<th style="width:50px">
<label for="check-select-all-1" class="checkbox">
<input type="checkbox" name="select_all" value="1" data-items="list[]" id="check-select-all-1">
<i></i>
</label>
</th>
</tr>
</thead>
<tbody>
<?php $result = dbQuery("SELECT * FROM `servers` ORDER BY `name`", false); ?>
<?php if (count($result) == 0) { ?>
<tr><td colspan="5"><div class="notification alert">No servers found</div></td></tr>
<?php } else { ?>
<?php foreach ($result as $row) { ?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['nfs_path']; ?></td>
<td><?php echo $row['url_path']; ?></td>
<td class="options">
<a href="servers_edit.php?id=<?php echo $row['record_num']; ?>" class="btn btn-xs btn-orange" title="Edit Server"><i class="ion ion-edit icon-edit"></i></a>
</td>
<td>
<label class="checkbox">
<input type="checkbox" name="list[]" value="<?php echo $row['record_num']; ?>" id="ids-<?php echo $row['record_num']; ?>"><i></i>
</label>
</td>
</tr>
<?php } ?>
<tr class="item submit">
<td colspan="5">
<button type="submit" class="btn action-delete">Delete Selected</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
<? } ?>
</div>
</div>
</div>
<?php require "footer.php"; ?>