<?php
/*
Created by : Viral B. Upadhyaya
Created Date : Monday, 22 August 2005
*/
session_start();
include("../inc/general/common.inc");
define("USER_TEMPLATE_DIR","../user_temp_template");
define("FONT_DIR","../admin/fontfiles");
if(!empty($_SESSION['usertemplate']))
{
$usertplimagename = $_SESSION['ssnusertplimagename'];
$im = imagecreatefromjpeg(USER_TEMPLATE_DIR."/".$usertplimagename);
if($im)
{
/********************************************************************************************************************/
if(get_param("islogo") == 1 && get_param("lx") != "" && get_param("ly") != "")
{
$islogo = get_param("islogo");
$logox = get_param("lx");
$logoy = get_param("ly");
if(!empty($_SESSION['userid']))
{
$substremail = substr($_SESSION['useremail'],0,strpos($_SESSION['useremail'],"@"));
$userid = $substremail.$_SESSION['userid'];
}
else
{
$userid = "temp";
}
if(isset($_SESSION['ssnlogo']) && $_SESSION['ssnlogo'] != "")
{
if(strstr($_SESSION['ssnlogo'],"logo_temp_"))
{
$logofilename = "../user_upload_images/".$_SESSION['ssnlogo'];
}
elseif(strstr($_SESSION['ssnlogo'],"logo_".$userid."_"))
{
$logofilename = "../user_upload_images/".$_SESSION['ssnlogo'];
}
else
{
$logofilename = "../admin/logoimages/".$_SESSION['ssnlogo'];
}
$mainlgim = imagecreatetruecolor(75,75);
list($src_width,$src_height,$src_type) = getimagesize($logofilename);
if($src_type == 1)
{
$lgim = imagecreatefromgif($logofilename);
}
elseif($src_type == 2)
{
$lgim = imagecreatefromjpeg($logofilename);
}
if($lgim)
{
imagecopyresampled($mainlgim,$lgim,0,0,0,0,75,75,$src_width,$src_height);
}
if($mainlgim)
{
//imagecopymerge($im,$lgim,$logox,$logoy,0,0,$src_width,$src_height,100);
imagecopymerge($im,$mainlgim,$logox,$logoy,0,0,75,75,100);
imagedestroy($lgim);
imagedestroy($mainlgim);
}
}
}
/********************************************************************************************************************/
/**********************************************************************************************************************/
$usertpl_array = $_SESSION['usertemplate'];
foreach($usertpl_array as $key => $row)
{
$title_array = $usertpl_array['tpltitle_value'];
$fontcolor_array = $usertpl_array['tplfontcolor'];
$fontface_array = $usertpl_array['tplfontface'];
$fontfile_array = $usertpl_array['tplfontfile'];
$fonttype_array = $usertpl_array['tplfonttype'];
$fontsize_array = $usertpl_array['tplfontsize'];
$x_pos_array = $usertpl_array['tplx_pos'];
$y_pos_array = $usertpl_array['tply_pos'];
}
$titlecount = count($title_array);
for($i=0;$i<$titlecount;$i++)
{
/*************************/
/*if($fontcolor_array[$i] == "black")
{
$fontcolor_array[$i] = imagecolorallocate($im,0X00,0X00,0X00);
}
elseif($fontcolor_array[$i] == "white")
{
$fontcolor_array[$i] = imagecolorallocate($im,0XFF,0XFF,0XFF);
}
elseif($fontcolor_array[$i] == "red")
{
$fontcolor_array[$i] = imagecolorallocate($im,0XFF,0X00,0X00);
}
elseif($fontcolor_array[$i] == "green")
{
$fontcolor_array[$i] = imagecolorallocate($im,0X00,0XFF,0X00);
}
elseif($fontcolor_array[$i] == "blue")
{
$fontcolor_array[$i] = imagecolorallocate($im,0X00,0X00,0XFF);
}
elseif($fontcolor_array[$i] == "yellow")
{
$fontcolor_array[$i] = imagecolorallocate($im,0XFF,0XFF,0X00);
}
elseif($fontcolor_array[$i] == "gray")
{
$fontcolor_array[$i] = imagecolorallocate($im,0X66,0X66,0X66);
}*/
$fontcolor_array[$i] = chunk_split($fontcolor_array[$i],2,":");
$colcd = split(":",$fontcolor_array[$i]);
$fontcolor_array[$i] = imagecolorallocate($im,hexdec("0X".$colcd[0]),hexdec("0X".$colcd[1]),hexdec("0X".$colcd[2]));
/************************/
//imagettftext($im,$fontsize_array[$i],0,$x_pos_array[$i],$y_pos_array[$i],$fontcolor_array[$i],FONT_DIR."/".$fontfile_array[$i],$title_array[$i]);
imagettftext($im,$fontsize_array[$i],0,$x_pos_array[$i],$y_pos_array[$i],$fontcolor_array[$i],FONT_DIR."/".$fontfile_array[$i],stripslashes($title_array[$i]));
}
/********************************************************************************************************************/
$sql = "";
$sql = "select templateid, tempwidth, tempheight from tbltemplatemst where templateid=".$_SESSION['chosentemplate']['tplid'];
$db->query($sql);
$db->next_record();
$tplwidth = $db->f('tempwidth');
$tplheight = $db->f('tempheight');
$zoom = get_param("zoom");
if($zoom != "" && $zoom != 0 && $zoom >= 50 && $zoom <=150)
{
$tplwidth = $tplwidth * ($zoom/100);
$tplheight = $tplheight * ($zoom/100);
}
$mainimage = imagecreatetruecolor($tplwidth,$tplheight);
list($width,$height) = getimagesize(USER_TEMPLATE_DIR."/".$usertplimagename);
imagecopyresampled($mainimage,$im,0,0,0,0,$tplwidth,$tplheight,$width,$height);
//imagejpeg($im);
imagejpeg($mainimage);
imagedestroy($mainimage);
imagedestroy($im);
}
}
?>