File: //home/httpd/mech_ftp/baretube.com/admin/edit_photo_content.php
<?php
include_once('db.php');
$mbAuthToken = md5(uniqid());
$_SESSION['mbAuthToken']= $mbAuthToken;
$languages = dbQuery("SELECT * FROM languages", false);
if (!is_numeric($_REQUEST['id'])) {
exit();
}
$modulePaysite = false;
if (modulesCheck('paysite')) {
$modulePaysite = true;
}
if ($_POST) {
$_POST = mysql_real_escape_array($_POST);
$_POST['title'] = strip_tags($_POST['title']);
$_POST['description'] = strip_tags($_POST['description']);
$_POST['keywords'] = strip_tags($_POST['keywords']);
$filter = "S";
if (in_array($_POST['filter'], array("S", "G", "T"))) {
$filter = $_POST['filter'];
}
dbQuery("UPDATE content SET filter = '$filter', title = '$_POST[title]', description = '$_POST[description]', thumbnail = '$_POST[thumbnail]', main_thumb = '$_POST[mainthumb]', length = '$_POST[length]', keywords = '$_POST[keywords]', scheduled_date = '$_POST[scheduled_date]', paysite = '$_POST[paysite]', pornstars = '$_POST[pornstars]', embed = '$_POST[embed]', enabled = '$_POST[enabled]', pornstartmp = '', force_related = '$_POST[force_related]', access_level = '$_POST[access_level]', encoded_date = '$_POST[encoded_date]', scheduled_date = '$_POST[scheduled_date]' WHERE record_num = '$_REQUEST[id]'");
dbQuery("UPDATE content_views SET views = '$_POST[views]' WHERE content = '$_REQUEST[id]'");
if($_POST['enabled_old'] == 0 && $_POST['enabled'] == 1) {
dbQuery("UPDATE content SET encoded_date = NOW(), scheduled_date = NOW() WHERE record_num = '$_REQUEST[id]'");
}
if ($modulePaysite && function_exists('paysiteSaveContent')) {
paysiteSaveContent($_REQUEST['id'], $_POST);
}
$success = true;
$insertid = (int) $_REQUEST['id'];
dbQuery("DELETE FROM content_niches WHERE content = '$_REQUEST[id]'");
dbQuery("DELETE FROM content_pornstars WHERE content = '$_REQUEST[id]'");
if ($_FILES['postroll']['tmp_name']) {
$name = $_REQUEST[id] . '.jpg';
move_uploaded_file($_FILES['postroll']['tmp_name'], $thumb_path . '/embedded/' . $name);
}
if ($_POST['niche']) {
foreach ($_POST['niche'] as $i) {
if (is_numeric($i)) {
dbQuery("INSERT INTO content_niches (content,niche) VALUES ('$_REQUEST[id]','$i')");
}
}
}
if ($_POST['pornstar']) {
foreach ($_POST['pornstar'] as $i) {
if (is_numeric($i)) {
dbQuery("INSERT INTO content_pornstars (content,pornstar) VALUES ('$_REQUEST[id]','$i')");
}
}
}
if (is_numeric($insertid)) {
foreach ($_POST['lang'] as $k => $v) {
dbQuery("INSERT INTO content_languages SET content = '$insertid', language = '$k', title = '" . $_POST['lang'][$k]['title'] . "', description = '" . $_POST['lang'][$k]['description'] . "', keywords = '" . $_POST['lang'][$k]['keywords'] . "' ON DUPLICATE KEY UPDATE title = '" . $_POST['lang'][$k]['title'] . "', description = '" . $_POST['lang'][$k]['description'] . "', keywords = '" . $_POST['lang'][$k]['keywords'] . "' ");
}
}
//clear empty languages...
dbQuery("DELETE FROM content_languages WHERE content = '$insertid' AND title = '' AND keywords = '' AND description = ''");
updateContentSearch($_REQUEST['id']);
}
if (count(dbQuery("SELECT content FROM content_views WHERE content = '$_REQUEST[id]'",false)) < 1) {
dbQuery("INSERT INTO content_views SET content = '$_REQUEST[id]', views = 0");
}
$row = dbQuery("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) AS views FROM content WHERE content.record_num = '$_REQUEST[id]' AND photos = 1",false);
$row = $row[0];
$langRow = dbQuery("SELECT * FROM content_languages WHERE content = '$_REQUEST[id]'", false);
if (is_array($langRow)) {
foreach ($langRow as $k => $v) {
$langRow[$langRow[$k]['language']]['title'] = $langRow[$k]['title'];
$langRow[$langRow[$k]['language']]['description'] = $langRow[$k]['description'];
$langRow[$langRow[$k]['language']]['keywords'] = $langRow[$k]['keywords'];
}
}
if (!$row['record_num']) {
include_once 'header.popup.php';
echo '<div class="notification error">Gallery not found</div>';
include_once 'footer.popup.php';
exit();
}
include_once 'header.popup.php';
?>
<?php if ($success) { ?>
<script>
if (parent.$.fn.colorbox) {
parent.$.fn.colorbox.close();
}
</script>
<?php } ?>
<script>
$().ready(function () {
$('<input>').attr({
type: 'hidden',
id: 'mbAuthToken',
name: 'mbAuthToken',
value: '<? echo $mbAuthToken; ?>'
}).appendTo('form');
$( function() {
$( ".datepicker" ).datepicker({
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: 'yy-mm-dd'
});
} );
});
</script>
<form method="POST" enctype="multipart/form-data" action="" class="form form-embed has-sticky-foot">
<input type="hidden" name="referrer" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['id']; ?>" />
<input type="hidden" name="enabled_old" value="<?php echo $row['enabled']; ?>" />
<header class="window-head">
<h1>Editing: <?php echo $row['title']; ?></h1>
<a href="#" class="close"><i class="ion ion-close"></i></a>
</header>
<table class="pagetable">
<tr>
<td style="width:65%" class="main-cell">
<table id="languages">
<tr>
<td colspan="2" class="lang-selection">
<ul class="tabs custom">
<li><a href="#baseLang" class="tab active">Default</a></li>
<?php foreach ($languages as $l) { ?>
<li><a href="#<?php echo $l['iso']; ?>" class="tab"><i class="flag-icon flag-icon-<?php echo strtolower($l['iso']); ?>"></i><?php echo $l['iso']; ?></a></li>
<?php } ?>
</ul>
</td>
</tr>
<tr class="baseLang langInput">
<td width="63">Title</td>
<td colspan="3">
<input name="title" type="text" value="<?php echo $row[title]; ?>" />
</td>
</tr>
<?php foreach ($languages as $l) { ?>
<tr class="<?php echo $l['iso']; ?> langInput" style="display: none;">
<td><i class="flag-icon flag-icon-<?php echo strtolower($l['iso']); ?>"></i>Title (<?php echo $l['name']; ?>/<?php echo $l['iso']; ?>)</td>
<td colspan="3">
<input name="lang[<?php echo $l['iso']; ?>][title]" type="text" value="<?php echo $langRow[$l['iso']]['title']; ?>" />
</td>
</tr>
<?php } ?>
<tr class="baseLang langInput">
<td>Description</td>
<td colspan="3">
<textarea name="description" cols="80" rows="3"><?php echo $row['description']; ?></textarea>
</td>
</tr>
<?php foreach ($languages as $l) { ?>
<tr class="<?php echo $l['iso']; ?> langInput" style="display: none;">
<td><i class="flag-icon flag-icon-<?php echo strtolower($l['iso']); ?>"></i>Description (<?php echo $l['name']; ?>/<?php echo $l['iso']; ?>)</td>
<td colspan="3">
<textarea name="lang[<?php echo $l['iso']; ?>][description]" cols="35" rows="4"><?php echo $langRow[$l['iso']]['description']; ?></textarea>
</td>
</tr>
<?php } ?>
<tr class="baseLang langInput">
<td>Keywords</td>
<td colspan="3">
<input name="keywords" type="text" value="<?php echo $row[keywords]; ?>" />
</td>
</tr>
<?php foreach ($languages as $l) { ?>
<tr class="<?php echo $l['iso']; ?> langInput" style="display: none;">
<td><i class="flag-icon flag-icon-<?php echo strtolower($l['iso']); ?>"></i>Keywords (<?php echo $l['name']; ?>/<?php echo $l['iso']; ?>)</td>
<td colspan="3">
<input name="lang[<?php echo $l['iso']; ?>][keywords]" type="text" value="<?php echo $langRow[$l['iso']]['keywords']; ?>" />
</td>
</tr>
<?php } ?>
<tr>
<td>Access Control</td>
<td>
<select name="access_level">
<option value="0" <?php echo ($row['access_level'] == '0') ? 'selected' : ''; ?>>Public</option>
<option value="1" <?php echo ($row['access_level'] == '1') ? 'selected' : ''; ?>>Private</option>
<option value="2" <?php echo ($row['access_level'] == '2') ? 'selected' : ''; ?>>Premium</option>
</select>
</td>
</tr>
<tr>
<td>Paysite:</td>
<td>
<select name="paysite">
<option value="0">None</option>
<?php $rresult = dbQuery("SELECT * FROM paysites ORDER BY name ASC",false); ?>
<?php foreach($rresult as $rrow) { ?>
<option<?php echo $row['paysite'] == $rrow['record_num'] ? ' selected' : ''; ?> value="<?php echo $rrow['record_num']; ?>"><?php echo $rrow['name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Force Related <a href="#" title="Comma separate IDs of other content, which will be forced as related videos/photos on gallery page. Please enter with no trailing comma."><i class="ion ion-help-circled"></i></a></td>
<td><input name="force_related" value="<?php echo $row['force_related']; ?>" type="text" /></td>
</tr>
</table>
</td>
<td width="35%" class="main-cell" style='vertical-align: top !important;'>
<table>
<tr>
<td>Filter</td>
<td>
<select name="filter">
<option value="S" <?php echo ($row['filter'] == 'S') ? 'selected' : ''; ?>>Straight</option>
<option value="G" <?php echo ($row['filter'] == 'G') ? 'selected' : ''; ?>>Gay</option>
<option value="T" <?php echo ($row['filter'] == 'T') ? 'selected' : ''; ?>>Shemale</option>
</select>
</td>
</tr>
<tr>
<td>Views</td>
<td><input name="views" value="<?php echo $row['views']; ?>" type="number" min="0" class="short" /></td>
</tr>
<tr>
<td>Published</td>
<td>
<select name="enabled">
<option<?php echo ($row['enabled'] == '1') ? ' selected' : ''; ?> value="1">Yes</option>
<option<?php echo ($row['enabled'] == '0') ? ' selected' : ''; ?> value="0">No</option>
</select>
</td>
</tr>
<tr>
<td>Submitter</td>
<td>
<?php if ($row['submitter'] != 0) { ?>
<?php $rrow = dbQuery("SELECT * FROM users WHERE record_num = '$row[submitter]'"); $rrow = $rrow[0]; ?>
<a href="edit_user.php?id=<?php echo $rrow['record_num']; ?>"><?php echo $rrow['username']; ?></a>
<?php } else { ?>
Anonymous
<?php } ?>
</td>
</tr>
<tr>
<td>Date Published <a href="#" title="Date the video was published or republished. For unpublished videos, this is the timestamp when encoding finished."><i class="ion ion-help-circled"></i></a></td>
<td><input name="encoded_date" value="<?php echo $row['encoded_date']; ?>" type="text" /></td>
</tr>
<tr>
<td>Scheduled Date <a href="#" title="Date the video was scheduled for publishing."><i class="ion ion-help-circled"></i></a></td>
<td><input class='datepicker' name="scheduled_date" value="<?php echo $row['scheduled_date']; ?>" type="text" /></td>
</tr>
</table>
</td>
</tr>
<?php if ($modulePaysite) { ?>
<tr>
<td colspan="2">
<table>
<tr>
<td>Release Delay</td>
<td>
<input type="number" min="0" name="paysite_drop_feed" class="short" value="<?php echo $row['paysite_drop_feed']; ?>" />
<span class="suffix">days</span>
<div class="field inline">
<span class="label">Schedule Date</span>
<?php
$paysiteScheduled = "0000-00-00";
$current = (int) $row['paysite_scheduled'];
if ($current != 0) {
$paysiteScheduled = date("Y-m-d", strtotime($row['paysite_scheduled']));
}
?>
<input type="text" name="paysite_scheduled" class="short small paysite_scheduled" value="<?php echo $paysiteScheduled; ?>" />
<script>
$().ready(function () {
$('input.paysite_scheduled').datepicker({
dateFormat: "yy-mm-dd"
});
});
</script>
</div>
</td>
</tr>
</table>
</td>
</tr>
<?php } ?>
<tr>
<td colspan="2">
<table>
<tr>
<td width="20%" style="vertical-align: top;" class="main-cell">
Categories: <i class="ion ion-plus pull-right btn-small-plus" id="addCategoryOpener"></i><br />
<?php $thisniche = array(); ?>
<?php $sresult = dbQuery("SELECT * FROM content_niches WHERE content = '$_REQUEST[id]'",false); ?>
<?php foreach($sresult as $srow) { ?>
<?php $thisniche[] = $srow['niche']; ?>
<?php } ?>
<select name="niche[]" multiple="multiple" class="full-width">
<?php $presult = dbQuery("SELECT * FROM niches ORDER BY name ASC",false); ?>
<?php 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><br>
<div id="addCategoryBox" class="row inline-widget" style="display: none;">
<div class="col-xs-12">Add Category:<br></div>
<div class="col-xs-12">
<a href="#" class="btn btn-green action-save pull-right link-button btn-add"><i class="ion ion-plus"></i> Add</a>
<div class="inline-field"><input name="add_category" value="" type="text" /></div>
</div>
</div>
</td>
<td width="20%" style="vertical-align: top;" class="main-cell">
Models: <i class="ion ion-plus pull-right btn-small-plus" id="addModelOpener"></i><br />
<?php $thisniche = array(); ?>
<?php $sresult = dbQuery("SELECT * FROM content_pornstars WHERE content = '$_REQUEST[id]'",false); ?>
<?php foreach($sresult as $srow) { ?>
<?php $thisniche[] = $srow['pornstar']; ?>
<?php } ?>
<select name="pornstar[]" multiple="multiple" class="full-width">
<?php $presult = dbQuery("SELECT * FROM pornstars ORDER BY name ASC",false); ?>
<?php 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><br>
<div id="addModelBox" class="row inline-widget" style="display: none;">
<div class="col-xs-12">Add Model:<br></div>
<div class="col-xs-12">
<a href="#" class="btn btn-green action-save pull-right link-button btn-add"><i class="ion ion-plus"></i> Add</a>
<div class="inline-field"><input name="add_model" value="" type="text" /></div>
</div>
</div>
</td>
<td width="60%" style="vertical-align:top" class="main-cell">
Gallery images:<br />
<div class="thumbs">
<ul>
<?php $rresult = dbQuery("SELECT * FROM `images` WHERE `gallery` = '$row[record_num]' ORDER BY LENGTH(`filename`), `filename`",false); ?>
<?php foreach($rresult as $rrow) { ?>
<li id="image<?php echo $rrow['record_num']; ?>" class="thumb-item">
<img src="<?php echo $gallery_url; ?>/<?php echo $row['filename']; ?>/thumbs/<?php echo $rrow['filename']; ?>" class="thumb" />
<label for="form-thumb-<?php echo $rrow['record_num']; ?>" class="radio">
<input type="radio" name="thumbnail" value="<?php echo $rrow['record_num']; ?>" <?php echo ($row['thumbnail'] == $rrow['record_num']) ? ' checked="checked"' : ''; ?> id="form-thumb-<?php echo $rrow['record_num']; ?>" />
<i></i> <?php echo truncate($rrow['filename'], 10); ?>
</label>
<div class="options">
<?php if ($rrow['record_num'] != $row['thumbnail']) { ?>
<a href="#" onclick="deleteImage(<?php echo $rrow['record_num']; ?>);
return false;" class="option" title="Delete image"><i class="ion ion-trash-a"></i></a>
<?php } else { ?>
<span class="option" title="This is main image"><i class="ion ion-checkmark-circled"></i></span>
<?php } ?>
</div>
</li>
<?php } ?>
</ul>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="item submit sticky-foot">
<a href="#" class="btn btn-back action-cancel pull-left">Cancel</a>
<button type="submit" class="btn action-save pull-right">Save</button>
</div>
</form>
<?php include_once 'footer.popup.php'; ?>