| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 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/model_admin/ |
Upload File : |
<?php
ini_set('max_execution_time', '300');
include ('../config.php');
dbConn();
include("auth.php");
include("model-header.php");
$msgSystem = '';
$imageCount = 0;
if (isset($_GET['crop']) && $_GET['crop'] != "") {
echo '<div style="text-align: center; font-size: 16px; margin: 10px; color: green;">Crop Successful</div>';
}
if (isset($_GET['content_id']) && is_numeric($_GET['content_id'])) {
$directory_sql = mysql_query("SELECT directory FROM cms_content WHERE content_id = '" . $_GET['content_id'] . "'") or die(mysql_error());
if (mysql_num_rows($directory_sql) > 0) {
$directory = mysql_fetch_object($directory_sql);
$explodedDirectory = explode("/", $directory->directory);
$filename = $explodedDirectory[0];
// Check for archive
if (isset($directory->directory) && $directory->directory != "" && isset($filename) && $filename != "") {
$archive = createArchive($directory->directory, $filename);
if (isset($archive) && $archive != "") {
$msgSystem .= $archive;
}
}
$allFiles = array_map('basename', glob('../../../content/models/' . $directory->directory . '/*'));
$fullsize_images = preg_grep('/\.(jpg|jpeg|png|gif)$/i', $allFiles);
// Check Total Photos and update if off
$totalPhotos = count($fullsize_images);
$num_photos_sql = mysql_query("SELECT num_photos FROM cms_content WHERE content_id = '" . $_GET['content_id'] . "'") or die(mysql_error());
if (mysql_num_rows($num_photos_sql) > 0) {
$num_photos = mysql_fetch_object($num_photos_sql);
if (isset($num_photos->num_photos) && $num_photos->num_photos != $totalPhotos) {
mysql_query("UPDATE cms_content SET num_photos = '" . $totalPhotos . "' WHERE content_id = '" . $_GET['content_id'] . "'") or die(mysql_error());
}
}
// Check for images that haven't been thumbnailed
$thumbnailDirectory = '../content/models/' . $directory->directory . '/tn';
if (!is_dir($thumbnailDirectory)) {
mkdir($thumbnailDirectory, 0777, TRUE);
}
$allThumbs = array_map('basename', glob($thumbnailDirectory . '/*'));
$thumbnails = preg_grep('/\.(jpg|jpeg|png|gif)$/i', $allThumbs);
$missing_thumbnails = array_udiff($fullsize_images, $thumbnails, 'strcasecmp');
if (count($missing_thumbnails) > 0) {
$alertOnce = TRUE;
$alertfinalOnce = TRUE;
foreach ($missing_thumbnails as $missing_thumbnail) {
if ($alertOnce) {
$msgSystem .= msgSystem("Thumbnail(s) not found.", "error");
$alertOnce = FALSE;
}
$src_img = imagecreatefromjpeg('../../../content/models/' . $directory->directory . '/' . $missing_thumbnail);
$imgx = imagesx($src_img);
$imgy = imagesy($src_img);
$resize_x = 141;
$resize_y = round(($imgy / $imgx) * 141);
$thumbnail_process = ImageCreateTrueColor($resize_x, $resize_y);
imagecopyresampled($thumbnail_process, $src_img, 0, 0, 0, 0, $resize_x, $resize_y, $imgx, $imgy);
imagejpeg($thumbnail_process, '../content/models/' . $directory->directory . '/tn/' . strtolower($missing_thumbnail), 90);
imagedestroy($thumbnail_process);
if (is_file('../content/models/' . $directory->directory . '/tn/' . strtolower($missing_thumbnail))) {
if ($alertfinalOnce) {
$msgSystem .= msgSystem("Thumbnail(s) Generated.", "success");
$alertfinalOnce = FALSE;
}
}
}
} else {
$msgSystem .= msgSystem("All thumbnails match.", "success");
}
// Check for Med images
$allMedium = array_map('basename', glob('../../../content/models/' . $directory->directory . '/med/*'));
$medium_images = preg_grep('/\.(jpg|jpeg|png|gif)$/i', $allMedium);
$missing_medium_images = array_udiff($fullsize_images, $medium_images, 'strcasecmp');
if (count($missing_medium_images) > 0) {
$alertOnce = TRUE;
$alertfinalOnce = TRUE;
foreach ($missing_medium_images as $missing_medium_image) {
if (!is_dir('../../../content/models/' . $directory->directory . '/med')) {
mkdir('../../../content/models/' . $directory->directory . '/med', 0755);
}
if ($alertOnce) {
$msgSystem .= msgSystem("Medium image(s) not found", "error");
$alertOnce = FALSE;
}
$src_img = imagecreatefromjpeg('../../../content/models/' . $directory->directory . '/' . $missing_medium_image);
$imgx = imagesx($src_img);
$imgy = imagesy($src_img);
if ($imgx > $imgy && $imgx > 1200) {
$resize_x = 1200;
$resize_y = round(($imgy / $imgx) * 1200);
} elseif ($imgy > $imgx && $imgy > 1200) {
$resize_x = round(($imgx / $imgy) * 1200);
$resize_y = 1200;
} else {
$resize_x = $imgx;
$resize_y = $imgy;
}
$medium_image_process = ImageCreateTrueColor($resize_x, $resize_y);
imagecopyresampled($medium_image_process, $src_img, 0, 0, 0, 0, $resize_x, $resize_y, $imgx, $imgy);
imagejpeg($medium_image_process, '../../../content/models/' . $directory->directory . '/med/' . strtolower($missing_medium_image), 75);
imagedestroy($medium_image_process);
if (is_file('../../../content/models/' . $directory->directory . '/med/' . strtolower($missing_medium_image))) {
if ($alertfinalOnce) {
$msgSystem .= msgSystem("Medium Image(s) Generated.", "success");
$alertfinalOnce = FALSE;
}
}
}
} else {
$msgSystem .= msgSystem("All Medium Images exist.", "success");
}
// Check for Small images
$allSmall = array_map('basename', glob('../../../content/models/' . $directory->directory . '/small/*'));
$small_images = preg_grep('/\.(jpg|jpeg|png|gif)$/i', $allSmall);
$missing_small_images = array_udiff($fullsize_images, $small_images, 'strcasecmp');
if (count($missing_small_images) > 0) {
$alertOnce = TRUE;
$alertfinalOnce = TRUE;
foreach ($missing_small_images as $missing_small_image) {
if (!is_dir('../../../content/models/' . $directory->directory . '/small')) {
mkdir('../../../content/models/' . $directory->directory . '/small', 0755);
}
if ($alertOnce) {
$msgSystem .= msgSystem("Small image(s) not found", "error");
$alertOnce = FALSE;
}
$src_img = imagecreatefromjpeg('../../../content/models/' . $directory->directory . '/' . $missing_small_image);
$imgx = imagesx($src_img);
$imgy = imagesy($src_img);
if ($imgx > $imgy && $imgx > 800) {
$resize_x = 800;
$resize_y = round(($imgy / $imgx) * 800);
} elseif ($imgy > $imgx && $imgy > 800) {
$resize_x = round(($imgx / $imgy) * 800);
$resize_y = 800;
} else {
$resize_x = $imgx;
$resize_y = $imgy;
}
$small_image_process = ImageCreateTrueColor($resize_x, $resize_y);
imagecopyresampled($small_image_process, $src_img, 0, 0, 0, 0, $resize_x, $resize_y, $imgx, $imgy);
imagejpeg($small_image_process, '../../../content/models/' . $directory->directory . '/small/' . strtolower($missing_small_image), 75);
imagedestroy($small_image_process);
if (is_file('../../../content/models/' . $directory->directory . '/small/' . strtolower($missing_small_image))) {
if ($alertfinalOnce) {
$msgSystem .= msgSystem("Small Image(s) Generated.", "success");
$alertfinalOnce = FALSE;
}
}
}
} else {
$msgSystem .= msgSystem("All Small Images exist.", "success");
}
echo '<div style="width: 1000px; margin-left: auto; margin-right: auto; margin-top: 20px;">';
if (isset($msgSystem)) {
echo $msgSystem;
}
foreach($fullsize_images as $image) {
if (preg_match('/preview_thumbnail/', $image) || preg_match('/main_image/', $image)) {
continue;
}
$fullsize_image = $directory->directory . "/" . $image;
echo '<div style="display: inline-block;"><img src="../content/models/' . $directory->directory . '/tn/' . strtolower($image) .'" style="padding: 8px; width: 150px;"><br /><a href="../crop.php?image=' . $fullsize_image .'&type=thumbnail" style="width: 120px; padding-top: 8px; padding-bottom: 8px; background-color: #008cba; color: #fff; font-size: 14px; border: 1px solid #ededed; text-decoration: none; display: block; text-align: center; margin-left: auto; margin-right: auto;">crop thumbnail</a><br /><a href="../crop.php?image=' . $fullsize_image .'&type=mainimage" style="width: 120px; padding-top: 8px; padding-bottom: 8px; background-color: #008cba; color: #fff; font-size: 14px; border: 1px solid #ededed; text-decoration: none; display: block; text-align: center; margin-left: auto; margin-right: auto;">crop main image</a></div>';
$imageCount++;
}
echo '</div>';
}
}
if ($imageCount == 0) {
echo 'Error: Nothing was found in that folder.';
}