File: /home/httpd/html/freecams1.com/public_html/admin/edit_model.php
<?
require "db.php";
if (!is_numeric($_GET['id'])) {
exit();
}
$id = (int) $_GET['id'];
$row = dbRow("SELECT * FROM `pornstars` WHERE `record_num` = '$id'");
if (!is_array($row)) {
setMessage("Model ID $id does not exist!", 'error');
pageNotFound(true);
}
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']) . "' AND `record_num` != '$id'"))) {
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')) {
dbUpdate('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']),
'record_num' => $id,
));
if ($_FILES['thumb']['tmp_name']) {
$model_thumb = "model{$id}.jpg";
if (file_exists("$misc_path/$model_thumb")) {
@unlink("$misc_path/$model_thumb");
}
if (move_uploaded_file($_FILES['thumb']['tmp_name'], "$misc_path/$model_thumb")) {
dbUpdate('pornstars', array(
'thumb' => $model_thumb,
'record_num' => $id,
));
} else {
setMessage('Cannot save model picture!', 'error');
}
}
foreach ($_POST['lang'] as $k => $v) {
dbInsert('pornstars_languages', array(
'pornstar' => $id,
'language' => $k,
'data' => serialize($v),
), false, true);
}
setMessage('Model updated');
header("Location: $_SERVER[REQUEST_URI]");
exit;
}
}
$row['custom'] = unserialize($row['custom']);
$langInfo = array();
$langData = dbQuery("SELECT * FROM `pornstars_languages` WHERE `pornstar` = '$id'", false);
foreach ($langData as $langRow) {
$langInfo[$langRow['language']] = unserialize($langRow['data']);
}
$_POST += $row;
$_POST['lang'] = array();
$_POST['lang'] += $langInfo;
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>
<span><a href="models.php">Manage Models</a></span>
</div>
</div>
<div class="content-outer">
<h2>Edit<strong>Model</strong></h2>
<div class="content-inner">
<? echo getMessages(); ?>
<form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
<table class="pagetable" id="languages">
<thead>
<tr>
<th colspan="2">Edit Model - <? echo $_POST['name']; ?></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['measurements']; ?>" /></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'] || $option_label == $_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'] || $option_label == $_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" value="<? echo $_POST['official_site_name']; ?>" /></td>
</tr>
<tr>
<td>Official Site URL</td>
<td><input name="official_site_url" type="text" value="<? 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>
<? 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>
<td>Thumb</td>
<td><input type="file" name="thumb" data-extensions="jpg,jpeg" /></td>
</tr>
<?php if (!empty($_POST['thumb']) && file_exists("$misc_path/{$_POST['thumb']}")) { ?>
<tr>
<td>Current Avatar</td>
<td><img src="<?php echo "$misc_url/{$_POST['thumb']}?time=" . time(); ?>" /></td>
</tr>
<?php } ?>
<tr class="item submit">
<td colspan="2">
<input type="hidden" name="id" value="<? echo $id; ?>" />
<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"; ?>