2021-11-09 08:30:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!function_exists('compressImage')) {
|
|
|
|
function compressImage($source, $destination, $quality)
|
|
|
|
{
|
|
|
|
// Get image info
|
|
|
|
$imgInfo = getimagesize($source);
|
|
|
|
$mime = $imgInfo['mime'];
|
|
|
|
|
|
|
|
// Create a new image from file
|
|
|
|
switch ($mime) {
|
|
|
|
case 'image/jpeg':
|
|
|
|
$image = imagecreatefromjpeg($source);
|
|
|
|
break;
|
|
|
|
case 'image/png':
|
|
|
|
$image = imagecreatefrompng($source);
|
|
|
|
break;
|
|
|
|
case 'image/gif':
|
|
|
|
$image = imagecreatefromgif($source);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$image = imagecreatefromjpeg($source);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save image
|
|
|
|
imagejpeg($image, $destination, $quality);
|
|
|
|
|
|
|
|
// Return compressed image
|
|
|
|
return $destination;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!function_exists('checkPassword')) {
|
|
|
|
function checkPassword($password, $encrypted_password, $salt)
|
|
|
|
{
|
|
|
|
$encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt);
|
|
|
|
return $encrypted_password_to_check == $encrypted_password;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!function_exists('generateTransactionCode')) {
|
|
|
|
function generateTransactionCode($length = 12)
|
|
|
|
{
|
|
|
|
$characters = '23456789ABCDEFGHJKLMNOPQRSTUVWXYZ';
|
|
|
|
$charactersLength = strlen($characters);
|
|
|
|
$randomString = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
|
|
}
|
|
|
|
return $randomString;
|
|
|
|
}
|
|
|
|
}
|
2022-04-13 06:46:28 +00:00
|
|
|
|
|
|
|
if (!function_exists('array_has_dupes')) {
|
|
|
|
function array_has_dupes(array $array)
|
|
|
|
{
|
|
|
|
return count($array) !== count(array_unique($array));
|
|
|
|
}
|
|
|
|
}
|