File: /home/httpd/html/baretube.com/admin/ftp_content.php
<?php
require "db.php";
if (isset($_POST['formSubmit'])) {
if (!isset($_POST['paysite']) || !is_numeric($_POST['paysite'])) {
setMessage('Please select paysite', 'error');
}
if (!getMessages(false, 'error')) {
$counter = 0;
$files = scandir($ftp_path);
$getUser = dbRow("SELECT `record_num` FROM `users` WHERE `username` = '" . mysqli_real_escape_string($dbconn, $_POST['submitter']) . "'", false);
$_POST['submitter'] = is_array($getUser) ? $getUser['record_num'] : 0;
foreach ($files as $file) {
if ($file != '.' && $file != '..' && !is_dir("$ftp_path/$file")) {
$uniq = uniqid();
$parts = explode(".", $file);
$ext = array_pop($parts);
$f = $uniq . '-' . clearString(implode('.', $parts)) . '.';
$newfilename = $f . $ext;
$filename = $f . 'mp4';
if (rename("$ftp_path/$file", "$content_path/$newfilename")) {
$filesize = filesize("$content_path/$newfilename");
$title = implode(' ', array_map('trim', $parts));
$insert_id = dbInsert('content', array(
'title' => $title,
'description' => $title,
'keywords' => $title,
'orig_filename' => $newfilename,
'filename' => $filename,
'approved' => 0,
'date_added' => 'NOW()',
'submitter' => (int) $_POST['submitter'],
'vr' => (int) $_POST['vr'],
'paysite' => (int) $_POST['paysite'],
));
if (is_numeric($insert_id)) {
if (count($_POST['niche']) > 0) {
foreach ($_POST['niche'] as $niche_id) {
dbQuery("INSERT INTO `content_niches` (`content`, `niche`) VALUES ('$insert_id', '$niche_id')");
}
}
if (count($_POST['pornstar']) > 0) {
foreach ($_POST['pornstar'] as $pornstar_id) {
dbQuery("INSERT INTO `content_pornstars` (`content`, `pornstar`) VALUES ('$insert_id', '$pornstar_id')");
}
}
$counter++;
}
}
}
}
setMessage("<strong>$counter video(s) added to import queue. <a href=\"$basehttp/admin/queue.php\">Click here to proceed to the approval queue</a></strong>", 'info');
header("Location: $_SERVER[REQUEST_URI]");
exit();
}
}
$files_count = max(0, count(scandir($ftp_path)) - 2);
entities_walk($_POST);
?>
<? require "header.php"; ?>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<span><a href="ftp_content.php">FTP Import</a></span>
</div>
</div>
<div class="content-outer">
<h2>FTP<strong>Import</strong></h2>
<div class="notification info">This script will import all the content from "<i><b><?php echo $ftp_path; ?></b></i>" to the approval queue. Please select a video submitter and paysite from the dropdown before continueing. You will still need to add titles, descriptions, keywords, etc to each piece of content.</div>
<div class="notification info"><strong>***YOU NEED TO CHMOD ALL FILES IN THIS DIRECTORY TO 777! IF YOU DON'T, IMPORT WILL STILL FUNCTION BUT YOU WILL HAVE TO MANUALLY CLEAR THE DIRECTORY***</strong></div>
<? if ($files_count > 0) { ?>
<? echo setMessage("You have <b>$files_count videos</b> ready to import", 'info', true); ?>
<? } ?>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" class="form" novalidate autocomplete="off">
<table class="pagetable">
<tbody>
<tr>
<td>Uploader:</td>
<td>
<input type="text" name="submitter" id="contentAutocomplete" value="<? echo $_POST['submitter']; ?>" placeholder="Start typing username..." />
<script type="text/javascript">
$(document).ready(function () {
$("#contentAutocomplete").autocomplete({
source: "search_content.php?type=2",
minLength: 2
});
});
</script>
</td>
</tr>
<tr>
<td>Paysite:</td>
<td>
<select name="paysite">
<?php $rresult = dbQuery("SELECT * FROM `paysites` ORDER BY `name`", false); ?>
<? foreach ($rresult as $rrow) { ?>
<option<?php echo ($_POST['paysite'] == $rrow['record_num']) ? ' selected' : ''; ?> value="<?php echo $rrow['record_num']; ?>"><?php echo $rrow['name']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Categories:</td>
<td>
<select name="niche[]" multiple="multiple">
<?php $results = dbQuery("SELECT `record_num`, `name` FROM `niches` ORDER BY `name`", false); ?>
<?php foreach ($results as $_row) { ?>
<option value="<?php echo $_row['record_num']; ?>"<? echo in_array($_row['record_num'], (array) $_POST['niche']) ? ' selected' : ''; ?>><?php echo $_row['name']; ?></option>
<?php } ?>
</select>
<p class="hint">(Hold CTRL to make multiple selections)</p>
</td>
</tr>
<tr>
<td>Models:</td>
<td>
<select name="pornstar[]" multiple="multiple">
<?php $results = dbQuery("SELECT `record_num`, `name` FROM `pornstars` ORDER BY `name`", false); ?>
<?php foreach ($results as $_row) { ?>
<option value="<?php echo $_row['record_num']; ?>"<? echo in_array($_row['record_num'], (array) $_POST['pornstar']) ? ' selected' : ''; ?>><?php echo $_row['name']; ?></option>
<?php } ?>
</select>
<p class="hint">(Hold CTRL to make multiple selections)</p>
</td>
</tr>
<tr>
<td>VR Videos:</td>
<td>
<select name="vr">
<option value='0'>No</option>
<option value='1'>Yes</option>
</select>
</td>
</tr>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="formSubmit" value="1">
<button type="submit" class="btn action-save">Import</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php require "footer.php"; ?>