HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //home/httpd/mech_ftp/baretube.com/admin/export_models.php
<?php
require "db.php";

if ($_POST['modelsData'] && $_POST['delimiter'] && $_POST['export_format']) {
    $_POST = mysql_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=models_export-'.date('Y-m-d-H-i-s').'.csv');

        $output = fopen('php://output', 'w');

        $csv_values = explode(',', implode(',', $_POST['modelsData']));
        $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 pornstars",false);

        foreach($rows as $row) { 
            $csv_fields = array();
            $link = generateUrl('pornstar', $row['name'], $row['record_num']);
            $row['url'] = $link;
            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_models.php">Export Models</a></span>  
        </div>
    </div>
    
    <div class="content-outer">
        
        <h2>Export<strong>Models</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>
                    <tbody>
                        <tr>
                            <td>Models Data</td>
                            <td>
                                <? $modelsData = array('name', 'aka', 'dob', 'height', 'weight', 'measurements', 'hair', 'eyes', 'ethnicity', 'official_site_name', 'official_site_url', 'biography', 'thumb', 'rating', 'rank', 'views', 'custom', 'record_num', 'url'); ?>
                                <select name="modelsData[]" multiple="multiple">
                                    <? foreach ($modelsData as $mrow) { ?>
                                        <option value="<? echo $mrow; ?>" selected="selected"><? echo $mrow; ?></option>
                                    <? } ?>
                                </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>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
<?php require "footer.php"; ?>