| Server IP : 208.122.213.31 / Your IP : 216.73.216.185 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/store.tiacyrusxxx.com/public_html/dev/ |
Upload File : |
<?php
if (isset($_POST['image']) && $_POST['image'] != "" && isset($_POST['x']) && is_numeric($_POST['x']) && isset($_POST['y']) && is_numeric($_POST['y']) && isset($_POST['w']) && is_numeric($_POST['w']) && isset($_POST['h']) && is_numeric($_POST['h']) && isset($_POST['filename']) && $_POST['filename'] != "") {
$image = filter_var($_POST['image'], FILTER_SANITIZE_STRING);
$callbackURL = filter_var($_POST['callbackURL'], FILTER_SANITIZE_STRING);
preg_match('/(.*)(\/.*\.(jpg|jpeg|png|gif))$/i', $image, $folder);
$image = '../../content/models/' . $image;
$imageinfo = getimagesize($image);
if ($imageinfo['mime'] == 'image/gif'){
$src_img = imagecreatefromgif($image);
} elseif (($imageinfo['mime'] == 'image/jpg') || ($imageinfo['mime'] == 'image/jpeg')) {
$src_img = imagecreatefromjpeg($image);
} elseif ($imageinfo['mime'] == 'image/png') {
$src_img = imagecreatefrompng($image);
}
$_POST['w'] = round($_POST['w']);
$_POST['h'] = round($_POST['h']);
$process = ImageCreateTrueColor($_POST['w'], $_POST['h']);
imagecopyresampled($process, $src_img, 0, 0, $_POST['x'], $_POST['y'], $_POST['w'], $_POST['h'], $_POST['w'], $_POST['h']);
if (isset($_POST['filename']) && $_POST['filename'] == 'main_image') {
$width = 600;
$height = 450;
} else {
$width = 193;
$height = 275;
}
$resized = ImageCreateTrueColor($width, $height);
imagecopyresampled($resized, $process, 0, 0, 0, 0, $width, $height, $_POST['w'], $_POST['h']);
imagejpeg($resized, 'content/models/' . $folder[1] . '/' . $_POST['filename'] . '.jpg', 90);
imagedestroy($process);
imagedestroy($resized);
if (isset($_POST['callbackURL']) && $_POST['callbackURL'] != "") {
header('Location: ' . $callbackURL . '&crop=complete');
} else {
$image = filter_var($_POST['image'], FILTER_SANITIZE_STRING);
}
} elseif (isset($_GET['image']) && $_GET['image'] != '') {
$image = filter_var($_GET['image'], FILTER_SANITIZE_STRING);
$image = str_replace("../", "", $image);
if (isset($_SERVER['HTTP_REFERER'])) {
$callbackURL = $_SERVER['HTTP_REFERER'];
} else {
$callbackURL = '';
}
} else {
exit('There was an error trying to process that image, please go back and try again.');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cropper</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/jquery.Jcrop.js"></script>
<script type="text/javascript">
<!--
jQuery(function($){
var jcrop_api,
boundx,
boundy,
$preview = $('#preview-pane'),
$pcnt = $('#preview-pane .preview-container'),
$pimg = $('#preview-pane .preview-container img'),
xsize = $pcnt.width(),
ysize = $pcnt.height();
console.log('init',[xsize,ysize]);
$('#target').Jcrop({
onChange: updatePreview,
onSelect: updatePreview,
aspectRatio: xsize / ysize,
boxWidth: 600
},function(){
var bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];
jcrop_api = this;
$preview.appendTo(jcrop_api.ui.holder);
});
function updatePreview(c) {
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
if (parseInt(c.w) > 0) {
var rx = xsize / c.w;
var ry = ysize / c.h;
$pimg.css({
width: Math.round(rx * boundx) + 'px',
height: Math.round(ry * boundy) + 'px',
marginLeft: '-' + Math.round(rx * c.x) + 'px',
marginTop: '-' + Math.round(ry * c.y) + 'px'
});
}
};
function checkCoords() {
if (parseInt($('#w').val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
});
// -->
</script>
<style type="text/css">
<!--
.jcrop-holder #preview-pane {
display: block;
position: absolute;
z-index: 2000;
<?php
if (isset($_GET['type']) && $_GET['type'] == 'mainimage') {
echo 'right: -620px;';
} else {
echo 'right: -220px;';
}
?>
}
#preview-pane .preview-container {
<?php
if (isset($_GET['type']) && $_GET['type'] == 'mainimage') {
echo 'width: 600px; height: 450px;';
} else {
echo 'width: 193px; height: 275px;';
}
?>
overflow: hidden;
}
// -->
</style>
</head>
<body>
<div style="margin-left: 20px; margin-right: 20px;">
<img src="view_crop.php?image=<?php echo $image; ?>" id="target">
<div id="preview-pane">
<div class="preview-container">
<img src="view_crop.php?image=<?php echo $image; ?>" class="jcrop-preview">
</div>
<form action="" method="POST" onsubmit="return checkCoords();">
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="hidden" name="image" value="<?php echo $image; ?>">
<input type="hidden" name="callbackURL" value="<?php echo $callbackURL; ?>">
<?php
if (isset($_GET['type']) && $_GET['type'] == 'mainimage') {
echo '<input type="hidden" name="filename" value="main_image">';
} else {
echo '<input type="hidden" name="filename" value="preview_thumbnail">';
}
?>
<input type="submit" value="Crop Image" style="margin-top: 15px; width: 193px; padding: 10px; background-color: #008cba; color: #fff; font-size: 16px; border: 1px solid #ededed;">
</form>
</div>
</div>
</body>
</html>