Skip to content

Commit

Permalink
Finished the settings section for footer social media icons in the ad…
Browse files Browse the repository at this point in the history
…min panel
  • Loading branch information
MariusTBjercke committed Oct 12, 2018
1 parent ef8f287 commit eb3534b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 76 deletions.
86 changes: 17 additions & 69 deletions admin/edit_socialicons.php
Original file line number Diff line number Diff line change
@@ -1,92 +1,40 @@
<?php
if (isset($_POST['save_submit'])) {
$servername = addslashes(trim($_POST['servername']));
$serveraddress = addslashes(trim($_POST['serveraddress']));
$worldport = addslashes(trim($_POST['worldport']));
$contact = addslashes(trim($_POST['contact']));
if (isset($_POST['submit'])) {
$facebook = addslashes(trim($_POST['facebook']));
$instagram = addslashes(trim($_POST['instagram']));
$twitter = addslashes(trim($_POST['twitter']));
$youtube = addslashes(trim($_POST['youtube']));
$download = addslashes(trim($_POST['download']));
if (isset($_POST['show_post_frontpage'])) {
$check = 1;
} else {
$check = 0;
}

$result = $mysqli_cms->query("UPDATE config SET servername='$servername', serveraddress='$serveraddress', worldport='$worldport', show_post_frontpage='$check', contact='$contact', youtube='$youtube', download='$download' WHERE id='1'");
echo '<script>window.location="admin.php?page=edit_settings&action=success";</script>';
$result = $mysqli_cms->query("UPDATE config SET facebook='$facebook', instagram='$instagram', twitter='$twitter', youtube='$youtube' WHERE id='1'");
echo '<script>window.location="admin.php?page=edit_socialicons&action=success";</script>';
exit;
}

$result = $mysqli_cms->query("SELECT * FROM config");
$fetch = $result->fetch_assoc();
?>

<div class="edit_settings">

<h1>Edit social icons in the footer</h1>
<button onclick="window.location='admin.php';">Go back</button>

<h3>Fill in URLs here<br><div class="small">If you want to hide an icon, example Facebook - simply remove all text inside the Facebook input field.</div></h3>

<form action="" method="post">
<ul>
<?php
if ($_GET['action'] == 'edit') {
$edit_settings = true;
while ($row = $result->fetch_assoc()) {
?>
<?php
echo '<form action="" method="post">';
?>
<p>Use the first post as the front page header?</p>
<input type="checkbox" name="show_post_frontpage" <?php if (($row['show_post_frontpage']) > 0) { echo 'checked'; } ?>>
<?php
echo '<p><li><label>Server name:</label> <input type="text" name="servername" value="' . $row['servername'] . '"></li></p>';
echo '<p><li><label>Server address:</label> <input type="text" name="serveraddress" value="' . $row['serveraddress'] . '"></li></p>';
echo '<p><li><label>World port:</label> <input type="text" name="worldport" value="' . $row['worldport'] . '"></li></p>';
echo '<p><li><label>Contact mail:</label> <input type="text" name="contact" value="' . $row['contact'] . '"></li></p>';
echo '<p><li><label>YouTube embed URL:</label> <input type="text" name="youtube" value="' . $row['youtube'] . '"></li></p>';
echo '<p><li><label>Client download link:</label> <input type="text" name="download" value="' . $row['download'] . '"></li></p>';
echo '<p><input type="submit" name="save_submit" value="Save">';
echo '</form>';
}
} else {
while ($row = $result->fetch_assoc()) {
?>
<p>Use the first post as the front page header?</p>
<?php
if (($row['show_post_frontpage']) > 0) {
echo 'Yes';
} else {
echo 'No';
}
?>
<?php
echo '<p><li><label>Server name:</label> ' . $row['servername'] . '</li></p>';
echo '<p><li><label>Server address:</label> ' . $row['serveraddress'] . '</li></p>';
echo '<p><li><label>World port:</label> ' . $row['worldport'] . '</li></p>';
echo '<p><li><label>Contact mail:</label> ' . $row['contact'] . '</li></p>';
echo '<p><li><label>YouTube embed URL:</label> ' . $row['youtube'] . '</li></p>';
echo '<p><li><label>Client download link:</label> ' . $row['download'] . '</li></p>';
}
}
?>
<li><p>Facebook: <input type="text" name="facebook" class="form-control" value="<?= $fetch['facebook']; ?>"></p></li>
<li><p>Instagram: <input type="text" name="instagram" class="form-control" value="<?= $fetch['instagram']; ?>"></p></li>
<li><p>Twitter: <input type="text" name="twitter" class="form-control" value="<?= $fetch['twitter']; ?>"></p></li>
<li><p>YouTube: <input type="text" name="youtube" class="form-control" value="<?= $fetch['youtube']; ?>"></p></li>
</ul>

<?php
<input type="submit" name="submit" value="Edit settings" class="btn">
</form>

<?php
if ($_GET['action'] == 'success') {
echo '<div class="success">The details have been saved.</div>';
}

?>

<?php
if ($_GET['action'] == 'edit') {
?>
<p><button onclick="javascript:window.location='admin.php?page=edit_settings';">Cancel editing</button></p>
<?php
} else {
?>
<p><button onclick="javascript:window.location='admin.php?page=edit_settings&action=edit';">Edit settings</button></p>
<?php
}
?>

</div>
Loading

0 comments on commit eb3534b

Please sign in to comment.