| Server IP : 104.21.37.246 / Your IP : 104.23.243.32 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/cp648411/www/kainumber.com/wallpaper/home/ |
Upload File : |
<?php
include('../include/class.php');
date_default_timezone_set("Asia/Bangkok");
//putenv('GDFONTPATH=' . realpath('.'));
$date = date("YmdHis");
function image_type($bg){
if(!list($w, $h) = getimagesize($bg)) return "Unsupported picture type1!";
$type = strtolower(substr(strrchr($bg,"."),1));
if($type == 'jpeg') $type = 'jpg';
switch($type){
case 'bmp': $img = imagecreatefromwbmp($bg); break;
case 'gif': $img = imagecreatefromgif($bg); break;
case 'jpg': $img = imagecreatefromjpeg($bg); break;
case 'png': $img = imagecreatefrompng($bg); break;
default : return "Unsupported picture type!";
}
return $img;
}
$list = array('table'=>'wallpapers','where'=>'id = "'.$_GET['id'].'" AND status = "1"');
$view = $view_db->view($list);
$row1 = $view_db->q($view);
/*
if($row1['date2']=='sun'){$bg = "../../redbag/wallpaper/".$row1['bg_sun'];}
if($row1['date2']=='mon'){$bg = "../../redbag/wallpaper/".$row1['bg_mon'];}
if($row1['date2']=='tue'){$bg = "../../redbag/wallpaper/".$row1['bg_tue'];}
if($row1['date2']=='wed'){$bg = "../../redbag/wallpaper/".$row1['bg_wed'];}
if($row1['date2']=='thu'){$bg = "../../redbag/wallpaper/".$row1['bg_thu'];}
if($row1['date2']=='fri'){$bg = "../../redbag/wallpaper/".$row1['bg_fri'];}
if($row1['date2']=='sat'){$bg = "../../redbag/wallpaper/".$row1['bg_sat'];}
if($row1['date2']=='other'){
if($row1['type']==1){
if($row1['image_free']!=''){
$bg = "../../redbag/wallpaper/".$row1['image_free'];
}else{
$bg = "../../redbag/wallpaper/".$row1['image'];
}
}else{
$bg = "../../redbag/wallpaper/".$row1['image'];
}
}
*/
$bg = "../../redbag/wallpaper/".$row1['image_free'];
$img = image_type($bg);
$text_detail = explode(',',$row1['detail_text']);
$color = explode(',',$row1['font_color']);
$fontColor = imagecolorallocate($img, $color[0], $color[1], $color[2]);
$angle = 0;
$iWidth = imagesx($img);
$iHeight = imagesy($img);
$bottomY = $row1['position2'];
$jpeg_bg = image_type($bg);
list($newwidth, $newheight) = getimagesize($bg);
$img = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($img, $jpeg_bg, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);
/*
echo $iWidth.'<br>';
echo $iHeight.'<br>';
echo $bg;
echo "<pre>";
print_r($img);
echo "</pre>";
exit();
$png_bg = image_type($src);
//list($newwidth2, $newheight2) = getimagesize($src);
imagecopyresampled($img, $png_bg, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);
*/
$icon1 = explode(",",$row1['detail_icon1']);
if($icon1[5]<>0){
$png3 = image_type('../../redbag/wallpaper/'.$icon1[2]);
list($width3, $height3) = getimagesize('../../redbag/wallpaper/'.$icon1[2]);
imagecopyresampled($img, $png3, $icon1[0], $icon1[1], 0, 0, $width3, $height3, $width3, $height3); //l,t,r,b
}
$icon2 = explode(",",$row1['detail_icon2']);
if($icon2[5]<>0){
$png4 = image_type('../../redbag/wallpaper/'.$icon2[2]);
list($width4, $height4) = getimagesize('../../redbag/wallpaper/'.$icon2[2]);
imagecopyresampled($img, $png4, $icon2[0], $icon2[1], 0, 0, $width4, $height4, $width4, $height4); //l,t,r,b
}
$icon3 = explode(",",$row1['detail_icon3']);
if($icon3[5]<>0){
$png5 = image_type('../../redbag/wallpaper/'.$icon3[2]);
list($width5, $height5) = getimagesize('../../redbag/wallpaper/'.$icon3[2]);
imagecopyresampled($img, $png5, $icon3[0], $icon3[1], 0, 0, $width5, $height5, $width5, $height5); //l,t,r,b
}
$icon4 = explode(",",$row1['detail_icon4']);
if($icon4[5]<>0){
$png6 = image_type('../../redbag/wallpaper/'.$icon4[2]);
list($width6, $height6) = getimagesize('../../redbag/wallpaper/'.$icon4[2]);
imagecopyresampled($img, $png6, $icon4[0], $icon4[1], 0, 0, $width6, $height6, $width6, $height6); //l,t,r,b
}
$random1 = explode(",",$row1['detail_random1']);
if($random1[5]==1){
$fontFile_random1 = realpath('../../fonts/'.$random1[2]); // CHANGE TO YOUR OWN!
$fontSize_random1 = $random1[3];
$color_random1 = explode(',',$row1['font_color_random1']);
$fontColor_random1 = imagecolorallocate($img, $color_random1[0], $color_random1[1], $color_random1[2]);
$angle_random1 = 0;
$txt_random1 = $random1[4];
$txt_random1 = mb_convert_encoding($txt_random1, 'HTML-ENTITIES', 'UTF-8');
$txttxt_random1 = preg_replace('~^(&([a-zA-Z0-9]);)~', htmlentities('${1}'), $txt_random1);
$tSize_random1 = imagettfbbox($fontSize_random1, $angle_random1, $fontFile_random1, $txt_random1);
$tWidth_random1 = max([$tSize_random1[2], $tSize_random1[4]]) - min([$tSize_random1[0], $tSize_random1[6]]);
$tHeight_random1 = max([$tWidth_random1[5], $tWidth_random1[7]]) - min([$tWidth_random1[1], $tWidth_random1[3]]);
$positionX_random1 =$random1[0];
$positionY_random1 =$random1[1];
imagettftext($img, $fontSize_random1, $angle_random1, $positionX_random1, $positionY_random1, $fontColor_random1, $fontFile_random1, $txt_random1);
}
$random2 = explode(",",$row1['detail_random2']);
if($random2[5]==1){
$fontFile_random2 = realpath('../../fonts/'.$random2[2]); // CHANGE TO YOUR OWN!
$fontSize_random2 = $random2[3];
$color_random2 = explode(',',$row1['font_color_random2']);
$fontColor_random2 = imagecolorallocate($img, $color_random2[0], $color_random2[1], $color_random2[2]);
$angle_random2 = 0;
$txt_random2 = $random2[4];
$txt_random2 = mb_convert_encoding($txt_random2, 'HTML-ENTITIES', 'UTF-8');
$txttxt_random2 = preg_replace('~^(&([a-zA-Z0-9]);)~', htmlentities('${1}'), $txt_random2);
$tSize_random2 = imagettfbbox($fontSize_random2, $angle_random2, $fontFile_random2, $txt_random2);
$tWidth_random2 = max([$tSize_random2[2], $tSize_random2[4]]) - min([$tSize_random2[0], $tSize_random2[6]]);
$tHeight_random2 = max([$tWidth_random2[5], $tWidth_random2[7]]) - min([$tWidth_random2[1], $tWidth_random2[3]]);
$positionX_random2 =$random2[0];
$positionY_random2 =$random2[1];
imagettftext($img, $fontSize_random2, $angle_random2, $positionX_random2, $positionY_random2, $fontColor_random2, $fontFile_random2, $txt_random2);
}
$random3 = explode(",",$row1['detail_random3']);
if($random3[5]==1){
$fontFile_random3 = realpath('../../fonts/'.$random3[2]); // CHANGE TO YOUR OWN!
$fontSize_random3 = $random3[3];
$color_random3 = explode(',',$row1['font_color_random3']);
$fontColor_random3 = imagecolorallocate($img, $color_random3[0], $color_random3[1], $color_random3[2]);
$angle_random3 = 0;
$txt_random3 = $random3[4];
$txt_random3 = mb_convert_encoding($txt_random3, 'HTML-ENTITIES', 'UTF-8');
$txttxt_random3 = preg_replace('~^(&([a-zA-Z0-9]);)~', htmlentities('${1}'), $txt_random3);
$tSize_random3 = imagettfbbox($fontSize_random3, $angle_random3, $fontFile_random3, $txt_random3);
$tWidth_random3 = max([$tSize_random3[2], $tSize_random3[4]]) - min([$tSize_random3[0], $tSize_random3[6]]);
$tHeight_random3 = max([$tWidth_random3[5], $tWidth_random3[7]]) - min([$tWidth_random3[1], $tWidth_random3[3]]);
$positionX_random3 =$random3[0];
$positionY_random3 =$random3[1];
imagettftext($img, $fontSize_random3, $angle_random3, $positionX_random3, $positionY_random3, $fontColor_random3, $fontFile_random3, $txt_random3);
}
$random4 = explode(",",$row1['detail_random4']);
if($random4[5]==1){
$fontFile_random4 = realpath('../../fonts/'.$random4[2]); // CHANGE TO YOUR OWN!
$fontSize_random4 = $random4[3];
$color_random4 = explode(',',$row1['font_color_random4']);
$fontColor_random4 = imagecolorallocate($img, $color_random4[0], $color_random4[1], $color_random4[2]);
$angle_random4 = 0;
$txt_random4 = $random4[4];
$txt_random4 = mb_convert_encoding($txt_random4, 'HTML-ENTITIES', 'UTF-8');
$txttxt_random4 = preg_replace('~^(&([a-zA-Z0-9]);)~', htmlentities('${1}'), $txt_random4);
$tSize_random4 = imagettfbbox($fontSize_random4, $angle_random4, $fontFile_random4, $txt_random4);
$tWidth_random4 = max([$tSize_random4[2], $tSize_random4[4]]) - min([$tSize_random4[0], $tSize_random4[6]]);
$tHeight_random4 = max([$tWidth_random4[5], $tWidth_random4[7]]) - min([$tWidth_random4[1], $tWidth_random4[3]]);
$positionX_random4 =$random4[0];
$positionY_random4 =$random4[1];
imagettftext($img, $fontSize_random4, $angle_random4, $positionX_random4, $positionY_random4, $fontColor_random4, $fontFile_random4, $txt_random4);
}
$random5 = explode(",",$row1['detail_random5']);
if($random5[5]==1){
$fontFile_random5 = realpath('../../fonts/'.$random5[2]); // CHANGE TO YOUR OWN!
$fontSize_random5 = $random5[3];
$color_random5 = explode(',',$row1['font_color_random5']);
$fontColor_random5 = imagecolorallocate($img, $color_random5[0], $color_random5[1], $color_random5[2]);
$angle_random5 = 0;
$txt_random5 = $random5[4];
$txt_random5 = mb_convert_encoding($txt_random5, 'HTML-ENTITIES', 'UTF-8');
$txttxt_random5 = preg_replace('~^(&([a-zA-Z0-9]);)~', htmlentities('${1}'), $txt_random5);
$tSize_random5 = imagettfbbox($fontSize_random5, $angle_random5, $fontFile_random5, $txt_random5);
$tWidth_random5 = max([$tSize_random5[2], $tSize_random5[4]]) - min([$tSize_random5[0], $tSize_random5[6]]);
$tHeight_random5 = max([$tWidth_random5[5], $tWidth_random5[7]]) - min([$tWidth_random5[1], $tWidth_random5[3]]);
$positionX_random5 =$random5[0];
$positionY_random5 =$random5[1];
imagettftext($img, $fontSize_random5, $angle_random5, $positionX_random5, $positionY_random5, $fontColor_random5, $fontFile_random5, $txt_random5);
}
/*
echo $bg;
echo "<pre>";
print_r($img);
echo "</pre>";
exit();
*/
function properText($text){
$text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
$text = preg_replace('~^(&([a-zA-Z0-9]);)~',htmlentities('${1}'),$text);
return($text);
}
//exit();
// (E) OUTPUT IMAGE
$namefile='wallmoo-'.$date;
header("Content-type: image/jpeg");
header('Content-disposition: attachment; filename='.$namefile.'.jpg');
readfile(imagejpeg($img));
$name_table4='wal_log_order';
$id_order=@$_GET['id'];
$type=3;
$status='success';
$sql = array('table'=>$name_table4,'count'=>'MAX(id) AS max_id');
$view_sql = $view_db->view($sql);
$row = $view_db->q($view_sql);
$max_id = $row['max_id'];
if($max_id==''){
$max_id=1;
}else{
$max_id=$max_id+1;
}
$list = array(
'table'=>$name_table4,
'id'=>"'".$max_id."'",
'id_order'=>"'".$id_order."'",
'type'=>"'".$type."'",
'datetime'=>"'".@$datetime."'",
'status'=>"'".$status."'"
);
$add = $actiondata_db->add_db($list);
imagejpeg($img);
imagedestroy($img);
?>