";
}
}
function getOptimizedImage($imagePath, $maxWidth = 800, $quality = 75) {
$basePath = 'admin/postimages/';
$originalImage = $basePath . $imagePath;
// Check if WebP version exists
$webpPath = $basePath . 'webp/' . pathinfo($imagePath, PATHINFO_FILENAME) . '.webp';
if (!file_exists(dirname($webpPath))) {
mkdir(dirname($webpPath), 0755, true);
}
// Create WebP version if it doesn't exist
if (!file_exists($webpPath) && file_exists($originalImage)) {
createWebPImage($originalImage, $webpPath, $quality);
}
// Return WebP if available, otherwise original
if (file_exists($webpPath)) {
return $webpPath;
}
return $originalImage;
}
function createWebPImage($sourcePath, $destPath, $quality = 75) {
$imageInfo = getimagesize($sourcePath);
if (!$imageInfo) return false;
list($width, $height, $type) = $imageInfo;
switch ($type) {
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($sourcePath);
break;
case IMAGETYPE_PNG:
$image = imagecreatefrompng($sourcePath);
imagepalettetotruecolor($image);
imagealphablending($image, true);
imagesavealpha($image, true);
break;
default:
return false;
}
if ($image) {
$result = imagewebp($image, $destPath, $quality);
imagedestroy($image);
return $result;
}
return false;
}
function getImageDimensions($imagePath) {
$fullPath = 'admin/postimages/' . $imagePath;
if (file_exists($fullPath)) {
$dimensions = getimagesize($fullPath);
if ($dimensions) {
return [
'width' => $dimensions[0],
'height' => $dimensions[1],
'ratio' => $dimensions[1] / $dimensions[0]
];
}
}
return ['width' => 800, 'height' => 600, 'ratio' => 0.75]; // Default fallback
}
// Caching headers function
function setStaticCachingHeaders() {
$request_uri = $_SERVER['REQUEST_URI'];
// Check if it's a static resource
if (preg_match('/\.(css|js|png|jpg|jpeg|gif|webp|ico|woff|woff2|svg)(\?.*)?$/i', $request_uri)) {
header('Cache-Control: public, max-age=31536000, immutable');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
header('Pragma: public');
}
}
?>
65221138 - 65266959 - 09122610233
شهریار خ ولیعصر بعد از بانک کشاورزی انتهای بن بست گلپونه مجتمع تیبا
Warning: Undefined variable $con in /home/pishroc8/public_html/includes/header.php on line 392
Fatal error: Uncaught TypeError: mysqli_set_charset(): Argument #1 ($mysql) must be of type mysqli, null given in /home/pishroc8/public_html/includes/header.php:392
Stack trace:
#0 /home/pishroc8/public_html/includes/header.php(392): mysqli_set_charset()
#1 /home/pishroc8/public_html/index.php(2): include('/home/pishroc8/...')
#2 {main}
thrown in /home/pishroc8/public_html/includes/header.php on line 392