GIF89a;
| Direktori : /home/serb/public_html/m/lib/ |
| Current File : /home/serb/public_html/m/lib/functions.php |
<?
// crop to any size
function forceConstraints($srcFile, $srcType, $dstType, $dstWidth, $dstHeight, $dstPath)
{
if ($srcType == "image/jpeg")
$handle = @imagecreatefromjpeg($srcFile);
else if ($srcType == "image/png")
$handle = @imagecreatefrompng($srcFile);
else if ($srcType == "image/gif")
$handle = @imagecreatefromgif($srcFile);
else
return false;
if (!$handle)
return false;
$srcWidth = @imagesx($handle);
$srcHeight = @imagesy($handle);
if ($srcWidth >= $dstWidth && $srcHeight >= $dstHeight)
{
$newHandle = @imagecreatetruecolor($dstWidth, $dstHeight);
if (!$newHandle)
return false;
if($srcHeight < $srcWidth)
{
$ratio = (double)($srcHeight / $dstHeight);
$cpyWidth = round($dstWidth * $ratio);
if ($cpyWidth > $srcWidth)
{
$ratio = (double)($srcWidth / $dstWidth);
$cpyWidth = $srcWidth;
$cpyHeight = round($dstHeight * $ratio);
$xOffset = 0;
$yOffset = round(($srcHeight - $cpyHeight) / 2);
} else {
$cpyHeight = $srcHeight;
$xOffset = round(($srcWidth - $cpyWidth) / 2);
$yOffset = 0;
}
} else {
$ratio = (double)($srcWidth / $dstWidth);
$cpyHeight = round($dstHeight * $ratio);
if ($cpyHeight > $srcHeight)
{
$ratio = (double)($srcHeight / $dstHeight);
$cpyHeight = $srcHeight;
$cpyWidth = round($dstWidth * $ratio);
$xOffset = round(($srcWidth - $cpyWidth) / 2);
$yOffset = 0;
} else {
$cpyWidth = $srcWidth;
$xOffset = 0;
$yOffset = round(($srcHeight - $cpyHeight) / 2);
}
}
if (!@imagecopyresampled($newHandle, $handle, 0, 0, $xOffset, $yOffset, $dstWidth, $dstHeight, $cpyWidth, $cpyHeight))
return false;
@imagedestroy($handle);
if ($dstType == "png")
@imagepng($newHandle, $dstPath.".png");
else if ($dstType == "jpg")
@imagejpeg($newHandle, $dstPath.".jpg", 90);
else if ($dstType == "gif")
@imagegif($newHandle, $dstPath.".gif");
else
return false;
@imagedestroy($newHandle);
return true;
} else {
return "Sorry, that image is too small. The image must be at least ".$dstWidth."x".$dstHeight." pixels in size.";
}
}
//make image grayscaled
function make_grey_jpg($source,$dest)
{
$im = imagecreatefromjpeg($source);
imagefilter($im, IMG_FILTER_GRAYSCALE);
//imagejpeg($im);
imagejpeg($im, $dest, 90);
imagedestroy($im);
}
function make_grey_gif($source,$dest)
{
$im = imagecreatefromgif($source);
imagefilter($im, IMG_FILTER_GRAYSCALE);
//imagejpeg($im);
imagegif($im, $dest, 90);
imagedestroy($im);
}
function create_grey($input,$output,$type)
{
if($type==1)
$bild = imagecreatefromgif($input);
if($type==2)
$bild = imagecreatefromjpeg($input);
if($type==3)
$bild = imagecreatefrompng($input);
$x = imagesx($bild);
$y = imagesy($bild);
for($i=0; $i<$y; $i++)
{
for($j=0; $j<$x; $j++)
{
$pos = imagecolorat($bild, $j, $i);
$f = imagecolorsforindex($bild, $pos);
$gst = $f["red"]*0.15 + $f["green"]*0.5 + $f["blue"]*0.35;
$col = imagecolorresolve($bild, $gst, $gst, $gst);
imagesetpixel($bild, $j, $i, $col);
}
}
if($type==1)
imagegif($bild,$output);
elseif($type==2)
imagejpeg($bild,$output,90);
elseif($type==3)
imagepng($bild,$output);
}
//==============================================for admin portion=====================
function get_catname($str)
{
$sql="select main_cat_name from va_main_category where main_cat_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['main_cat_name'];
return $p_name;
}
function get_cat($str)
{
$sql="select cat_name from va_category where cat_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['cat_name'];
return $p_name;
}
function get_product($str)
{
$sql="select name from va_product where p_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['name'];
return $p_name;
}
function get_uname($str)
{
$sql="select u_name from va_user_login where user_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['u_name'];
return $p_name;
}
function get_product_image($str)
{
$sql="select image from va_product where p_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['image'];
return $p_name;
}
function get_make($str)
{
$sql="select make_name from va_category_make where make_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['make_name'];
return $p_name;
}
function get_model($str)
{
$sql="select model_name from va_category_model where model_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['model_name'];
return $p_name;
}
function get_style($str)
{
$sql="select style_name from va_category_style where style_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['style_name'];
return $p_name;
}
function get_type($str)
{
$sql="select type_name from va_category_type where type_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['type_name'];
return $p_name;
}
function get_job_type($str)
{
$sql="select name from va_job_type where id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['name'];
return $p_name;
}
function get_parent_name($str)
{
if($str!=0)
{
$sql="select cat_name from va_category where parent_id='$str'";
$rs=execute_query($sql);
$row=mysql_fetch_array($rs);
$p_name=$row['cat_name'];
}
else
{
$p_name="Not Available";
}
return $p_name;
}
function get_total($str)
{
$sql="select cat_id from va_category where parent_id='$str'";
$rs=execute_query($sql);
$row=mysql_num_rows($rs);
$p_name=$row;
return $p_name;
}
function get_total1($str)
{
$sql="select cat_id from va_category where maincat_id='$str'";
$rs=execute_query($sql);
$row=mysql_num_rows($rs);
$p_name=$row;
return $p_name;
}
function get_total_item($str)
{
$sql="select * from va_watchlist where user_id='$str'";
$res=execute_query($sql);
$row=mysql_num_rows($res);
$p_name=$row;
return $p_name;
}
function grab_image($filename,$outfile,$image_format, $width, $height,$c)
{
// Media Size
$size = $width. "x". $height;
$ffmpegcmd1 = "../bin/ffmpeg -i $filename -vframes 1 -ss 00:00:0$c -an -vcodec $image_format -f rawvideo -s $size $outfile";
if(OS_VERSION=="WINDOWS")
$ffmpegcmd1 =str_replace("/", "\\",$ffmpegcmd1);
$ret = shell_exec($ffmpegcmd1);
//print("<br>ret: $ret");
// Execute this command using exec command or any other tool to grab image from converted flv file.
return $outfile;
}
function grab_image1($filename,$outfile,$image_format, $width, $height,$c)
{
// Media Size
$size = $width. "x". $height;
$ffmpegcmd1 = "bin/ffmpeg -i $filename -vframes 1 -ss 00:00:0$c -an -vcodec $image_format -f rawvideo -s $size $outfile";
if(OS_VERSION=="WINDOWS")
$ffmpegcmd1 =str_replace("/", "\\",$ffmpegcmd1);
$ret = shell_exec($ffmpegcmd1);
//print("<br>ret: $ret");
// Execute this command using exec command or any other tool to grab image from converted flv file.
return $outfile;
}
function recursive($id,$cl)
{
static $cat = array();
static $count = 0;
$count++;
++$cl;
$color[1]="#777777";
$color[2]="#888888";
$color[3]="#999999";
$rec_sql="SELECT * FROM page_content WHERE parent=$id ORDER BY id";
$result = execute_query($rec_sql);
while($row = mysql_fetch_assoc($result))
{
$cat[$row['id']] =str_repeat(" ",$count-1)." ".$row['eng_menu']."$color[$cl]";
recursive($row['id'],$cl);
}
$count--;
return $cat;
}
function recursive_name($id)
{
static $cat = array();
static $count = 0;
$count++;
$rec_sql="SELECT * FROM page_content WHERE id=$id ORDER BY id";
$result = execute_query($rec_sql);
while($row = mysql_fetch_assoc($result))
{
$cat[$row['parent']] = $row['eng_menu'];
recursive_name($row['parent']);
}
$count--;
return $cat;
}
function recursive_name1($id,$l_id)
{
static $cat = array();
static $count = 0;
$count++;
$rec_sql="SELECT * FROM page_content WHERE id=$id ORDER BY id";
$result = execute_query($rec_sql);
while($row = mysql_fetch_assoc($result))
{
if($l_id==2)
{
$cat[$row['parent']] = $row['ger_title'];
}
else
{
$cat[$row['parent']] = $row['title'];
}
recursive_name1($row['parent'],$l_id);
}
$count--;
return $cat;
}
function get_user_id_from_ad($escort_id)
{
$select_query = "SELECT user_id FROM escort_details WHERE id = '".$escort_id."'";
$select_result = execute_query($select_query);
$select_row = mysql_fetch_array($select_result);
return $select_row['user_id'];
}
function increase_impression($escort_id)
{
$update_query = "UPDATE escort_details SET `impression_count` = `impression_count`+1 WHERE id = '".$escort_id."'";
execute_query($update_query);
$user_id = get_user_id_from_ad($escort_id);
$report_insert_query = "INSERT INTO `USER_IMPRESSION_REPORT` SET
ad_id = '".$escort_id."'
, user_id = '".$user_id."'
, ip_address = '".$_SERVER['REMOTE_ADDR']."'
, add_date = now()
";
execute_query($report_insert_query);
}
function increase_email_sent_count($user_id)
{
$update_query = "UPDATE user_info SET `email_count` = `email_count`+1 WHERE userid = '".$user_id."'";
execute_query($update_query);
}
function get_ad_total_visits()
{
$report_query = "SELECT COUNT(id) AS TOTAL_VISITS FROM `USER_AD_REPORT` WHERE user_id = '".$_SESSION['userid']."'";
$report_result = execute_query($report_query);
$report_row = mysql_fetch_array($report_result);
return $report_row['TOTAL_VISITS'];
}
function get_ad_total_impression()
{
$report_query = "SELECT COUNT(id) AS TOTAL_IMPRESSIONS FROM `USER_IMPRESSION_REPORT` WHERE user_id = '".$_SESSION['userid']."'";
$report_result = execute_query($report_query);
$report_row = mysql_fetch_array($report_result);
return $report_row['TOTAL_IMPRESSIONS'];
}
function get_user_total_emails()
{
$report_query = "SELECT email_count FROM `user_info` WHERE userid = '".$_SESSION['userid']."'";
$report_result = execute_query($report_query);
$report_row = mysql_fetch_array($report_result);
return $report_row['email_count'];
}
?>