Created
July 3, 2014 09:04
-
-
Save daliborgogic/ae4a7e33c9925f6b4eed to your computer and use it in GitHub Desktop.
img
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ob_start(); | |
session_start(); | |
include '../../php/connection.php'; | |
//========================================= FUNCTIONALITIES ============================ | |
$name=addslashes($_POST['name']); | |
$surname=addslashes($_POST['surname']); | |
$email=addslashes($_POST['email']); | |
$mobile=addslashes($_POST['mobile']); | |
$picture_url=addslashes($_POST['picture_url']); | |
$picture_url = explode('temp/',$picture_url); | |
$picture_url = $picture_url[1]; | |
$images_sticker = $_POST['images_sticker']; | |
$images_sticker = json_decode($images_sticker); | |
$images_frame = $_POST['images_frame']; | |
$images_frame = json_decode($images_frame); | |
$text_element = $_POST['text_element']; | |
$text_element = json_decode($text_element); | |
if($name!=''){ | |
if($surname!=''){ | |
if($email!=''){ | |
if($mobile!=''){ | |
copy("../../temp/".$picture_url,"../../pictures/user/pictures/".$picture_url); | |
//===========================DODAVANJE ELEMENATA NA SLIKU STICKER======================================= | |
$image_to_display = imagecreatetruecolor(410, 410); | |
$white = imagecolorallocate($image_to_display, 255, 255, 255); | |
imagefill($image_to_display, 0, 0, $white); | |
$images_fronte = '../../pictures/user/pictures/'.$picture_url; | |
$source_image = imagecreatefromjpeg($images_fronte); | |
imagecopy ( $image_to_display , $source_image , 0 , 0 , 0 , 0 , 410 , 410 ); | |
for($i=0;$i<sizeof($images_sticker);$i++){ | |
$image_src = $images_sticker[$i][0]; | |
$image_src = str_replace('http://localhost/fitness_first_app_2/fitness_first_app/','../../',$image_src); | |
$image_width = $images_sticker[$i][1]; | |
$image_height = $images_sticker[$i][2]; | |
$image_top = $images_sticker[$i][3]; | |
$image_top = $image_top-19; | |
$image_left = $images_sticker[$i][4]; | |
$image_left = $image_left-19; | |
$slika_ext = explode('.',$image_src); | |
$slika_ext = $slika_ext[sizeof($slika_ext)-1]; | |
switch(strtolower($slika_ext)){ | |
case 'jpg': {$slika_nalepiti = imagecreatefromjpeg($image_src);}; break; | |
case 'jpeg': {$slika_nalepiti = imagecreatefromjpeg($image_src);}; break; | |
case 'gif': {$slika_nalepiti = imagecreatefromgif($image_src);}; break; | |
case 'png': {$slika_nalepiti = imagecreatefrompng($image_src);}; break; | |
} | |
list($image_old_width,$image_old_height) = getimagesize($image_src); | |
imagecopyresampled($image_to_display,$slika_nalepiti,$image_left,$image_top,0,0,$image_width,$image_height,'100','100'); | |
} | |
for($i=0;$i<sizeof($text_element);$i++){ | |
//=================EXPLODE BOJE========================== | |
$boja = explode(',',$text_element[$i][4]); | |
$boja_1 = explode('rgb(',$boja[0]); | |
$boja_1 = $boja_1[1]; | |
$boja_2 = $boja[1]; | |
$boja_3 = explode(')',$boja[2]); | |
$boja_3 = $boja_3[0]; | |
$velicina = explode('px',$text_element[$i][0]); | |
$velicina = $velicina[0]; | |
$velicina *= 0.7; | |
$black = imagecolorallocate($image_to_display,$boja_1,$boja_2,$boja_3); | |
//=============================OLJACA problem ============================ | |
//=============================OLJACA problem ============================ | |
$propotion = (($velicina/0.7)*19)/48; | |
$text_element[$i][11] = str_replace('px','',$text_element[$i][8]); | |
$number_of_letters = $text_element[$i][8]/$propotion; | |
$tekst = $text_element[$i][7]; | |
$promenjiva_tekst = ''; | |
$counter = 0; | |
//=============================OLJACA problem ============================ | |
$font = '../../fonts/arial.ttf'; | |
//$tekst = explode('<br />',$fronte[$i][9]); | |
//$promenjiva_tekst = ''; | |
//$counter = 0; | |
//for($k = 0;$k<sizeof($tekst);$k++){ | |
//$temp = $tekst[$k]; | |
//$tekst[$k] = wordwrap($tekst[$k],$number_of_letters,'\n',true); | |
//if($temp == $tekst[$k]){ | |
$temp = $tekst; | |
$tekst = wordwrap($tekst,$number_of_letters,'\n',true); | |
if($temp == $tekst){ | |
imagettftext($image_to_display, $velicina, 0,$text_element[$i][6] , $text_element[$i][5] + 50*$velicina/48 + $counter*$velicina + 5, $black, $font, html_entity_decode($tekst)); | |
$counter++; | |
}else{ | |
$tekst = explode('\n',$tekst); | |
for($b = 0;$b<sizeof($tekst);$b++){ | |
imagettftext($image_to_display, $velicina, 0,$text_element[$i][6] , $text_element[$i][5] + 50*$velicina/48 + (50*$velicina/48)*$b + $counter*$velicina + 5, $black, $font, html_entity_decode($tekst[$b])); | |
$counter++; | |
} | |
} | |
//imagettftext($image_to_display, $velicina, 0,$text_element[$i][6] , $text_element[$i][5]+25, $black, $font, $text_element[$i][7]); | |
} | |
//$fronte_slika = 'fronte_'.time().'.jpg'; | |
imagejpeg($image_to_display,'../../pictures/user/pictures/'.$picture_url); | |
//============================ | |
//===========================DODAVANJE ELEMENATA NA SLIKU STICKER======================================= | |
$image_to_display = imagecreatetruecolor(410, 410); | |
$white = imagecolorallocate($image_to_display, 255, 255, 255); | |
imagefill($image_to_display, 0, 0, $white); | |
$images_fronte = '../../pictures/user/pictures/'.$picture_url; | |
$source_image = imagecreatefromjpeg($images_fronte); | |
imagecopy ( $image_to_display , $source_image , 0 , 0 , 0 , 0 , 410 , 410 ); | |
for($i=0;$i<sizeof($images_frame);$i++){ | |
$image_src = $images_frame[$i][0]; | |
$image_src = str_replace('http://localhost/fitness_first_app_2/fitness_first_app/','../../',$image_src); | |
$image_width = $images_frame[$i][1]; | |
$image_height = $images_frame[$i][2]; | |
$image_top = $images_frame[$i][3]; | |
$image_left = $images_frame[$i][4]; | |
$slika_ext = explode('.',$image_src); | |
$slika_ext = $slika_ext[sizeof($slika_ext)-1]; | |
switch(strtolower($slika_ext)){ | |
case 'jpg': {$slika_nalepiti = imagecreatefromjpeg($image_src);}; break; | |
case 'jpeg': {$slika_nalepiti = imagecreatefromjpeg($image_src);}; break; | |
case 'gif': {$slika_nalepiti = imagecreatefromgif($image_src);}; break; | |
case 'png': {$slika_nalepiti = imagecreatefrompng($image_src);}; break; | |
} | |
list($image_old_width,$image_old_height) = getimagesize($image_src); | |
imagecopyresampled($image_to_display,$slika_nalepiti,$image_left,$image_top,0,0,$image_width,$image_height,'410','410'); | |
} | |
imagejpeg($image_to_display,'../../pictures/user/pictures/'.$picture_url); | |
//============================ | |
$sql="INSERT INTO user VALUES(NULL,'".$name."','".$surname."','".$email."','".$mobile."','".$picture_url."')"; | |
mysql_query($sql); | |
echo '|success|Uspesno ste dodali novu obavezu'; | |
}else{ | |
echo 'error|Please insert mobile'; | |
} | |
}else{ | |
echo 'error|Pleas insert email'; | |
} | |
}else{ | |
echo 'error|Please insert surname'; | |
} | |
}else{ | |
echo 'error|Please insert name'; | |
} | |
ob_flush(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment