File: //home/httpd/mech_ftp/baretube.com/admin/edit_rss.php
<?php
require "db.php";
if (!is_numeric($_REQUEST['id'])) {
exit();
}
$id = (int) $_REQUEST['id'];
$row = dbRow("SELECT * FROM `rss_feed` WHERE `record_num` = '$id'");
if (!is_array($row)) {
setMessage("RSS Feed ID $id does not exist!", 'error');
pageNotFound(true);
}
if (isset($_POST['formSubmit'])) {
if(is_array($_POST['niche'])) {
foreach($_POST['niche'] as $i) {
$niches[] = (int)$i;
}
}
@$niches = mysqli_real_escape_string($dblink,json_encode($niches));
$_POST = array_map_array('trim', $_POST);
if ($_POST['name'] == "") {
setMessage('Feed "Name" is required!', 'error');
}
if (!getMessages(false, 'error')) {
dbUpdate('rss_feed', array(
'name' => $_POST['name'],
'top' => $_POST['top'],
'bottom' => $_POST['bottom'],
'feed' => $_POST['feed'],
'record_num' => $id,
'channels' => $niches
));
setMessage('RSS updated');
header("Location: $_SERVER[REQUEST_URI]");
exit();
}
}
$_POST += (array) $row;
entities_walk($_POST);
$thisniche = json_decode($_POST['channels']);
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="rss.php">RSS Feeds</a></span>
</div>
</div>
<div class="content-outer">
<h2>Edit<strong>RSS</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">Edit Feed - <?php echo $_POST['name']; ?></th>
</tr>
</thead>
<tr>
<td>Name</td>
<td><input name="name" type="text" value="<? echo $_POST['name']; ?>" required /></td>
</tr>
<tr>
<td>Top</td>
<td><textarea name="top" cols="35" rows="4" ><? echo $_POST['top']; ?></textarea></td>
</tr>
<tr>
<td>Loop</td>
<td>
<textarea name="feed" cols="35" rows="15"><? echo $_POST['feed']; ?></textarea>
<p class="hint">Valid Tags:<br />{title} {keywords} {description} {url} {thumb_main} {thumb1-9} {embed} {pornstars} {categories} {lengthsec} {length}</p>
</td>
</tr>
<tr>
<td>Bottom</td>
<td><textarea name="bottom" cols="35" rows="4"><? echo $_POST['bottom']; ?></textarea></td>
</tr>
<tr>
<td>Categories</td>
<td>
<select name="niche[]" multiple="multiple" class="full-width">
<?php
$presult = dbQuery("SELECT * FROM niches ORDER BY name ASC", false);
foreach ($presult as $srow) {
?>
<option<?php echo in_array($srow['record_num'], $thisniche) ? ' selected' : ''; ?> value="<?php echo $srow['record_num']; ?>"><?php echo $srow['name']; ?></option>
<?php } ?>
</select><br>
(Hold ctrl to select multiple. Leave blank for all categories)
</td>
</tr>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="formSubmit" value="1" />
<button type="submit" class="btn action-save">Save</button>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<? require "footer.php"; ?>