HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/nyloncams.com/public_html/admin/template_settings.php
<?php

require "db.php";





if (isset($_POST['formSubmit'])) {

    $_POST = array_map_array('trim', $_POST);

    foreach ($_POST as $k => $v) {

        if (in_array($k, array('formSubmit'))) {

            continue;

        }

		dbQuery("UPDATE template_configuration SET value = '".mysqli_real_escape_string($dblink,$v)."' WHERE field = '$k' AND template = '" . mysqli_real_escape_string($dblink, $template_name) . "'");

    }	

	

	if (!getMessages(false, 'error')) {	

		$output = array();

		$results = dbQuery("SELECT * FROM `template_configuration` WHERE template = '".$template_name."'", false);

		foreach ($results as $row) {

			$output[$row['field']] = $row['value'];

		}

		file_put_contents("$basepath/admin/scripts/template_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>Template Settings</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">Settings for "<?php echo $template_name; ?>" template</th>

                            </tr>

                        </thead>

                        <tbody>

                            <?php $result = dbQuery("SELECT * FROM `template_configuration` WHERE `template` = '" . mysqli_real_escape_string($dblink, $template_name) . "' ORDER BY `record_num`", false); ?>

							<?php if(is_array($result)) { ?>

								<?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 } ?>

							<?php } else { ?>

							<tr class="item">

								<td colspan="2">

                                    Sorry, there are no configuration options available for the selected template. If you believe this is in error, please make sure you have the correct template name defined in the script settings.

                                </td>

							</tr>

							<?php } ?>

							<?php if(is_array($result)) { ?>

                            <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>

							<?php } ?>

                        </tbody>

                    </table>

               

            </form>

        </div>

    </div>

</div>



<?php require "footer.php"; ?>