File: /home/httpd/html/freecams1.com/public_html/admin/export_content.php
<?php
ini_set('memory_limit', '128M');
require "db.php";
if ($_POST['contentData'] && $_POST['delimiter'] && $_POST['export_format']) {
$_POST = mysqli_real_escape_array($_POST);
if ($_POST['export_format'] === 'csv') {
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=content_export-' . date('Y-m-d-H-i-s') . '.csv');
$output = fopen('php://output', 'w');
$csv_values = explode(',', implode(',', $_POST['contentData']));
$csv_columns = array();
foreach ($csv_values as $value) {
$csv_columns[] = $value;
$mysql_fields .= $value . ', ';
}
$mysql_fields = substr($mysql_fields, 0, -2);
fputcsv($output, array_map('strtoupper', $csv_columns), $_POST['delimiter']);
$rows = dbQuery("SELECT * FROM content", false);
foreach ($rows as $row) {
$csv_fields = array();
if ($row['photos'] == '0') {
$link = generateUrl('video', $row['title'], $row['record_num']);
if($row['embed'] == ''){
$dirname = str_replace('.flv', '', $row['orig_filename']);
$subdir = $row['filename'][0] . '/' . $row['filename'][1] . '/' . $row['filename'][2] . '/' . $row['filename'][3] . '/' . $row['filename'][4] . '/';
$dirname = $subdir . $dirname;
$thumb = $thumb_url.'/'.$dirname.'/'.$row['orig_filename'].'-'.$row['main_thumb'].'.jpg';
$row['thumbnail'] = $thumb;
} else {
$row['thumbnail'] = $thumb_url.'/embedded/'.$row['record_num'].'.jpg';
}
} else {
$link = generateUrl('galleries', $row['title'], $row['record_num']);
$dirname = str_replace('.flv', '', $row['orig_filename']);
$subdir = $row['filename'][0] . '/' . $row['filename'][1] . '/' . $row['filename'][2] . '/' . $row['filename'][3] . '/' . $row['filename'][4] . '/';
$dirname = $subdir . $dirname;
$thumb = $gallery_url.'/'.$row['filename'].'/thumbs/'.$row['thumbfile'];
$row['thumbnail'] = $thumb;
}
$row['url'] = $link;
$mediaUrls = getMediaURLs($row);
$row['video_file_url'] = $mediaUrls['filename'];
$row['mobile_file_url'] = $mediaUrls['mobile'];
$row['trailer_file_url'] = $mediaUrls['trailer_filename'];
$row['mobile_filename'] = $row['mobile'];
foreach ($csv_columns as $value) {
$csv_fields[] = $row[$value];
}
fputcsv($output, $csv_fields, $_POST['delimiter']);
}
fclose($output);
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="export_content.php">Export Content</a></span>
</div>
</div>
<div class="content-outer">
<h2>Export<strong>Content</strong></h2>
<div class="content-inner">
<form action="" method="POST" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<table class="pagetable">
<thead>
<tr>
<th colspan="2">Export Criteria</th>
</tr>
</thead>
<tr>
<td>Content Data</td>
<td>
<?php
$contentData = array('title', 'slug', 'alternate_files', 'orig_filename', 'server', 'thumbnail', 'embed', 'description', 'paysite', 'keywords', 'pornstars', 'scheduled_date', 'date_added', 'encoded_date', 'rating', 'length', 'submitter', 'ip', 'approved', 'hotlinked', 'plug_url', 'enabled', 'main_thumb', 'xml', 'photos', 'pornstartmp', 'movie_width', 'movie_height', 'filesize', 'token', 'source_thumb_url', 'related', 'force_related', 'orig_csv_url', 'premium', 'other_data', 'filter', 'record_num', 'url', 'filename', 'video_file_url');
if ($encodeMobile) {
$contentData[] = 'mobile_filename';
$contentData[] = 'mobile_file_url';
}
if ($encodeTrailer) {
$contentData[] = 'trailer_filename';
$contentData[] = 'trailer_file_url';
}
?>
<select name="contentData[]" multiple="multiple">
<?php foreach ($contentData as $crow) { ?>
<option value="<?php echo $crow; ?>" selected="selected"><?php echo $crow; ?></option>
<?php } ?>
</select>
<p class="hint">(Hold CTRL to make multiple selections)</p>
</td>
</tr>
<tr>
<td>Field Delimiter</td>
<td>
<select name="delimiter">
<option value="|">|</option>
</select>
</td>
</tr>
<tr>
<td>Export format</td>
<td>
<select name="export_format">
<option value="csv">CSV</option>
</select>
</td>
</tr>
<tr class="item submit">
<td colspan="2">
<button type="submit" class="btn action-save no-process">Export</button>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php require "footer.php"; ?>