File: /home/httpd/html/baretube.com.new/admin/add_model.php
<?
require "db.php";
if (isset($_POST['formSubmit'])) {
$_POST = array_map_array('trim', $_POST);
if ($_POST['name'] == "") {
setMessage('Model\'s "Name" is required!', 'error');
} else if (is_array(dbRow("SELECT `record_num` FROM `pornstars` WHERE `name` = '" . mysqli_real_escape_string($dblink, $_POST['name']) . "'"))) {
setMessage('This model name is already exists!', 'error');
}
if (!is_numeric($_POST['views']) || $_POST['views'] < 0) {
setMessage('"Views" must be positive integer!', 'error');
}
if ($_POST['dob'] != "" && strtotime($_POST['dob']) <= 0) {
setMessage('"Dob" is not valid date!', 'error');
}
if (!getMessages(false, 'error')) {
$insert_id = dbInsert('pornstars', array(
'name' => $_POST['name'],
'aka' => $_POST['aka'],
'dob' => $_POST['dob'],
'height' => $_POST['height'],
'weight' => $_POST['weight'],
'measurements' => $_POST['measurements'],
'hair' => $_POST['hair'],
'eyes' => $_POST['eyes'],
'ethnicity' => $_POST['ethnicity'],
'official_site_name' => $_POST['official_site_name'],
'official_site_url' => $_POST['official_site_url'],
'biography' => $_POST['biography'],
'views' => (int) $_POST['views'],
'custom' => serialize($_POST['custom']),
));
if (is_numeric($insert_id)) {
if ($_FILES['thumb']['tmp_name']) {
$model_thumb = "model{$insert_id}.jpg";
if (move_uploaded_file($_FILES['thumb']['tmp_name'], "$misc_path/$model_thumb")) {
dbUpdate('pornstars', array(
'thumb' => $model_thumb,
'record_num' => $insert_id,
));
} else {
setMessage('Cannot save model picture!', 'error');
}
}
foreach ($_POST['lang'] as $k => $v) {
dbInsert('pornstars_languages', array(
'pornstar' => $insert_id,
'language' => $k,
'data' => serialize($v),
), true);
}
setMessage('Model added. You can add another model now.');
header("Location: $_SERVER[REQUEST_URI]");
exit;
} else {
setMessage('Cannot create model!', 'error');
}
} else {
entities_walk($_POST);
}
}
?>
<? require "header.php"; ?>
<script>
$().ready(function () {
$('.lang-selection a').on('click', function (e) {
e.preventDefault();
$('.lang-selection').find('a.active').removeClass('active');
$(this).addClass('active');
var activeItems = $(this).attr('href').replace("#", "");
$('#languages').find('.langInput').hide();
$('#languages').find('.' + activeItems).show();
return false;
});
$('input[name=dob]').datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: "-60:+0"
});
});
</script>
<div class="content-page">
<div class="header-area">
<div class="breadcrumbs">
<a href="index.php">Admin Home</a>
<a href="models.php">Manage Models</a>
<span><a href="add_model.php">Add Model</a></span>
</div>
</div>
<div class="content-outer">
<h2>Add<strong>Model</strong></h2>
<div class="notification info">Please enter the model name, and (optionally) bio information below.</div>
<div class="content-inner">
<? echo getMessages(); ?>
<form action="" method="POST" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<input type="hidden" name="sponsor" value="<? echo $_REQUEST['id']; ?>" />
<table class="pagetable" id="languages">
<thead>
<tr>
<th colspan="2">Add New Model</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="lang-selection">
<ul class="tabs custom">
<li><a href="#baseLang" class="tab active">Default</a></li>
<? foreach ($languages as $l) { ?>
<li><a href="#<? echo $l['iso']; ?>" class="tab"><i class="flag-icon flag-icon-<? echo strtolower($l['iso']); ?>"></i><? echo $l['iso']; ?></a></li>
<? } ?>
</ul>
</td>
</tr>
<tr>
<td>Name</td>
<td><input name="name" type="text" value="<? echo $_POST['name']; ?>" required /></td>
</tr>
<tr>
<td>AKA</td>
<td><input name="aka" type="text" value="<? echo $_POST['aka']; ?>" /></td>
</tr>
<tr>
<td>Date Of Birth</td>
<td><input name="dob" type="text" value="<? echo $_POST['dob']; ?>" /></td>
</tr>
<tr>
<td>Height</td>
<td><input name="height" type="text" value="<? echo $_POST['height']; ?>" /></td>
</tr>
<tr>
<td>Weight</td>
<td><input name="weight" type="text" value="<? echo $_POST['weight']; ?>" /></td>
</tr>
<tr>
<td>Measurements</td>
<td><input name="measurements" type="text" value="<? echo $_POST['dob']; ?>" /></td>
</tr>
<tr>
<td>Hair Color</td>
<td>
<select name="hair">
<option value=""> - select - </option>
<? foreach (getFieldValues('models', 'hair_colors') as $option_id => $option_label) { ?>
<option value="<? echo $option_id; ?>"<? echo $option_id == $_POST['hair'] ? ' selected' : ''; ?>><? echo $option_label; ?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Eye Color</td>
<td>
<select name="eyes">
<option value=""> - select - </option>
<? foreach (getFieldValues('models', 'eye_colors') as $option_id => $option_label) { ?>
<option value="<? echo $option_id; ?>"<? echo $option_id == $_POST['eyes'] ? ' selected' : ''; ?>><? echo $option_label; ?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Ethnicity</td>
<td>
<select name="ethnicity">
<option value=""> - select - </option>
<? foreach (getFieldValues('models', 'ethnicities') as $option_id => $option_label) { ?>
<option value="<? echo $option_id; ?>"<? echo $option_id == $_POST['ethnicity'] ? ' selected' : ''; ?>><? echo $option_label; ?></option>
<? } ?>
</select>
</td>
</tr>
<tr>
<td>Official Site Name</td>
<td><input name="official_site_name" type="text" <? echo $_POST['official_site_name']; ?>/></td>
</tr>
<tr>
<td>Official Site URL</td>
<td><input name="official_site_url" type="text" <? echo $_POST['official_site_url']; ?>/></td>
</tr>
<tr class="baseLang langInput">
<td>Biography</td>
<td><textarea name="biography" cols="60" rows="5"><? echo $_POST['biography']; ?></textarea></td>
</tr>
<? foreach ($languages as $l) { ?>
<tr class="<? echo $l['iso']; ?> langInput" style="display: none;">
<td><i class="flag-icon flag-icon-<? echo strtolower($l['iso']); ?>"></i>Biography (<? echo $l['name']; ?>/<? echo $l['iso']; ?>)</td>
<td><textarea name="lang[<? echo $l['iso']; ?>][biography]" cols="35" rows="4"><? echo $_POST['lang'][$l['iso']]['biography']; ?></textarea></td>
</tr>
<? } ?>
<tr>
<td>Views</td>
<td><input name="views" type="number" value="<? echo (int) $_POST['views']; ?>" class="short" min="0" /></td>
</tr>
<tr>
<td>Thumb</td>
<td><input type="file" name="thumb" data-extensions="jpg,jpeg" /></td>
</tr>
<? foreach ($custom_pornstar_fields as $k => $v) { ?>
<tr>
<td><? echo $k; ?></td>
<td>
<? if (is_array($v)) { ?>
<select name="custom[<? echo $k; ?>]">
<? foreach ($v as $i) { ?>
<option<? echo $_POST['custom'][$k] == $i ? ' selected' : ''; ?>><? echo $i; ?></option>
<? } ?>
</select>
<? } else { ?>
<input type="text" name="custom[<? echo $k; ?>]" value="<? echo $_POST['custom'][$k]; ?>" />
<? } ?>
</td>
</tr>
<? } ?>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="formSubmit" value="1" />
<button type="submit" class="btn action-save">Save</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<? require "footer.php"; ?>