File: /home/httpd/html/nyloncams.com/public_html/admin/settings.php
<?php
require "db.php";
$settingGroups = array(
'site' => 'Site Configuration',
'general' => 'General Settings',
'paths' => 'Binary Paths',
'email' => 'E-mail Settings',
'social' => 'Social Networking Settings',
);
/* Add additional settings from installed modules */
foreach (modulesLoadSettings() as $module => $settings) {
$settingGroups[$settings['settings_group']] = $settings['settings_label'];
}
if (isset($_POST['formSubmit'])) {
$_POST = array_map_array('trim', $_POST);
foreach ($_POST as $k => $v) {
if (in_array($k, array('formSubmit'))) {
continue;
}
dbUpdate('configuration', array(
'field' => $k,
'value' => $v,
), 'field');
}
if (!is_writable("$basepath/admin/scripts/config.json")) {
setMessage("File <em>$basepath/admin/scripts/config.json</em> is not writable! Please, chmod to 0777 and submit this form again.", 'error');
}
if (!getMessages(false, 'error')) {
$output = array();
$results = dbQuery("SELECT * FROM `configuration`", false);
foreach ($results as $row) {
$output[$row['field']] = $row['value'];
}
file_put_contents("$basepath/admin/scripts/config.json", json_encode($output));
setMessage('Configuration saved!');
header("Location: ".$_SERVER['REQUEST_URI']);
exit();
}
}
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="settings.php">Manage Settings</a></span>
</div>
</div>
<div class="content-outer">
<h2>Edit<strong>Settings</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<?php foreach ($settingGroups as $group => $label) { ?>
<table class="pagetable">
<thead>
<tr>
<th colspan="2"><?php echo $label; ?></th>
</tr>
</thead>
<tbody>
<?php $result = dbQuery("SELECT * FROM `configuration` WHERE `group` = '" . mysqli_real_escape_string($dblink, $group) . "' ORDER BY `record_num`", false); ?>
<?php foreach ($result as $row) { ?>
<?php $row['settings'] = json_decode($row['settings'], true); ?>
<?php if (is_array(json_decode($row['data'], true))) { ?>
<tr>
<td><?php echo $row['field_name']; ?> <?php if ($row['field_description']) { ?><a href="#" title="<?php echo htmlentities($row['field_description'], ENT_QUOTES, 'UTF-8'); ?>"><i class="ion ion-help-circled"></i></a><?php } ?></td>
<td>
<select name="<?php echo $row['field']; ?>">
<?php unset($jsonData); ?>
<?php $jsonData = json_decode($row['data'], true); ?>
<?php foreach ($jsonData as $k => $v) { ?>
<option<?php echo ((string) $v == $row['value']) ? ' selected' : ''; ?> value="<?php echo (string) $v; ?>"><?php echo $k; ?></option>
<?php } ?>
</select>
</td>
</tr>
<?php } else if ($row['settings']['type'] === 'number') { ?>
<tr>
<td><?php echo $row['field_name']; ?> <?php if ($row['field_description']) { ?><a href="#" title="<?php echo htmlentities($row['field_description'], ENT_QUOTES, 'UTF-8'); ?>"><i class="ion ion-help-circled"></i></a><?php } ?></td>
<td>
<input type="number" name="<?php echo $row['field']; ?>" id="<?php echo $row['field']; ?>" value="<?php echo $row['value']; ?>" class="short" <? echo isset($row['settings']['min']) ? ' min="' . $row['settings']['min'] . '"' : ''; ?><? echo isset($row['settings']['max']) ? ' max="' . $row['settings']['max'] . '"' : ''; ?><? echo isset($row['settings']['step']) ? ' step="' . $row['settings']['step'] . '"' : ''; ?>>
<? if (isset($row['settings']['suffix']) && ($row['settings']['suffix'] != "")) { ?>
<span class="suffix"><? echo $row['settings']['suffix']; ?></span>
<? } ?>
</td>
</tr>
<?php } else if ($row['settings']['type'] === 'textarea') { ?>
<tr>
<td><?php echo $row['field_name']; ?> <?php if ($row['field_description']) { ?><a href="#" title="<?php echo htmlentities($row['field_description'], ENT_QUOTES, 'UTF-8'); ?>"><i class="ion ion-help-circled"></i></a><?php } ?></td>
<td>
<textarea name="<?php echo $row['field']; ?>" type="text" id="<?php echo $row['field']; ?>"><?php echo htmlentities($row['value'], ENT_QUOTES, 'UTF-8'); ?></textarea>
<?php if ($row['group'] == 'paths') { ?>
<span class="description"><i class="ion ion-information-circled"></i> Paths for <?php echo shell_exec("whereis " . substr($row['field'], 0, strpos($row['field'], '_'))); ?></span>
<?php } ?>
</td>
</tr>
<?php } else { ?>
<tr>
<td><?php echo $row['field_name']; ?> <?php if ($row['field_description']) { ?><a href="#" title="<?php echo htmlentities($row['field_description'], ENT_QUOTES, 'UTF-8'); ?>"><i class="ion ion-help-circled"></i></a><?php } ?></td>
<td>
<input name="<?php echo $row['field']; ?>" type="text" id="<?php echo $row['field']; ?>" value="<?php echo htmlentities($row['value'], ENT_QUOTES, 'UTF-8'); ?>" />
<?php if ($row['group'] == 'paths') { ?>
<span class="description"><i class="ion ion-information-circled"></i> Paths for <?php echo shell_exec("whereis " . substr($row['field'], 0, strpos($row['field'], '_'))); ?></span>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php } ?>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="formSubmit" value="1">
<button type="submit" class="btn action-save">Save</button>
</td>
</tr>
</tbody>
</table>
<?php } ?>
</form>
</div>
</div>
</div>
<?php require "footer.php"; ?>