10) { $pack = "1"; } if ($pack<0) { $pack = "1"; } //fontcolor $fontcolor = get_var('fontcolor', ''); $fontcolor = $diez . $fontcolor; //shadowcolor $shadowcolor = get_var('shadowcolor', ''); $shadowcolor = $diez . $shadowcolor; //shieldshadow $shieldshadow = get_var('shieldshadow', 0); //check smilie $smilie = get_var('smilie', ''); $nb_smilie = -2; $hdl = opendir( $mvModule_root_path . "/smiliz/p" . $pack . "/"); while($res = readdir($hdl)) { if(strtolower(substr($res, (strlen($res) - 3), 3)) == "png") $nb_smilie++; } closedir($hdl); //We have a random smilie ? mt_srand((double)microtime()*3216549); if ($smilie == "random") { $smilie = mt_rand(1,$nb_smilie); } if ( $smilie == 'standard' ) { $pack = 1; $smilie = 1; } //Here we are able to set a special custom font file... if you want ;-) $fontfile = ROOT_PATH . 'templates/common/fonts/times.ttf'; $fontheight = ''; $fontwidth = ''; $character_count = 0; $count_smilie = -1; if (version_compare(PHP_VERSION, '4.3.3', '>=')) { $gd_info = gd_info(); } else { $gd_info["FreeType Support"] = 1; } if ((!$gd_info["FreeType Support"]) || (!file_exists($fontfile))) { $fontwidth = 6; $fontheight = 8; } else { if ((!$fontheight) || (!$fontwidth)) { $fontwidth = imagefontwidth((int)$fontfile) + 1; $fontheight = imagefontheight((int)$fontfile); } } $fontheight += 2; //$text = get_var('text', '', true);// либо тупо вот-так $text = utf8_normalize_nfc(get_var('text', '', true)); // remove html code tags. $text = str_replace('%20', ' ', $text); $text = htmlspecialchars_decode($text); $text = stripslashes($text); $text = str_replace("<","<",$text); $text = str_replace(">",">",$text); while (mb_substr_count($text, "<")) { $text = preg_replace(mb_substr($text, mb_strpos($text, "<"), (mb_strpos($text, ">") - mb_strpos($text, "<") + 1)), "", $text); } // Have we some text to show ? if ($text == '') { $text = $lang['GENERAL_ERROR']; } //What if the text length is longer than 33 characters? if (mb_strlen($text) > 29) { //try to split them into single words $words = split(" ", $text); if (is_array($words)) { $i = 0; $output[$i] = ''; //Check the line lenght after each word foreach ($words as $word) { if ((mb_strlen($output[$i] . " " . $word) < 29) && (!mb_substr_count($word, "[SM"))) { $output[$i] .= " " . $word; } else { //limit the shield to 12 lines if ($i <= 11) { if ($character_count < mb_strlen($output[$i])) { $character_count = mb_strlen($output[$i]); } $i++; $output[$i] = $word; } } } } else { //sorry, no split possible, so we have to cut the line. $character_count = 33; $output[0] = mb_substr($text, 0, 30) . "..."; } } else { $character_count = mb_strlen($text); $output[0] = $text; } if (sizeof($output) > 12) { //we have more than 12 lines.... cut the last line. $output[12] = mb_substr($output[12], 0, 30) . "..."; } //Maybe we have to tweak here a bit. Depends on the font... $file = $mvModule_root_path . "/smiliz/p" . $pack . "/smiliz" . $smilie . ".png"; $size = getimagesize($file); $width = ($character_count * $fontwidth) + 5; $height = (sizeof($output) * $fontheight) + 18 + $size['1']; if ($width < 79) { $width = 79; } if ((($width /2) -5) < $size['0']) { $width = (($size['0'] * 2) + 10); } //Main work here $smili = imagecreatefrompng($mvModule_root_path . "/smiliz/p" . $pack . "/smiliz" . $smilie . ".png"); $droit1 = imagecreatefrompng($mvModule_root_path . "/smiliz/1-hautdroit.png"); $droit2 = imagecreatefrompng($mvModule_root_path . "/smiliz/2-hautdroit.png"); $droit3 = imagecreatefrompng($mvModule_root_path . "/smiliz/3-hautdroit.png"); $droit4 = imagecreatefrompng($mvModule_root_path . "/smiliz/4-hautdroit.png"); $droit5 = imagecreatefrompng($mvModule_root_path . "/smiliz/5-hautdroit.png"); $gauche1 = imagecreatefrompng($mvModule_root_path . "/smiliz/1-hautgauche.png"); $gauche2 = imagecreatefrompng($mvModule_root_path . "/smiliz/2-hautgauche.png"); $gauche3 = imagecreatefrompng($mvModule_root_path . "/smiliz/3-hautgauche.png"); $gauche4 = imagecreatefrompng($mvModule_root_path . "/smiliz/4-hautgauche.png"); $gauche5 = imagecreatefrompng($mvModule_root_path . "/smiliz/5-hautgauche.png"); $gauche6 = imagecreatefrompng($mvModule_root_path . "/smiliz/6-hautgauche.png"); $bulle = imagecreatefrompng($mvModule_root_path . "/smiliz/bulle.png"); $pensee = imagecreatefrompng($mvModule_root_path ."/smiliz/pensee.png"); $img = imagecreate($width,$height); $bgcolor = imagecolorallocate ($img, 111, 252, 134); $txtcolor = imagecolorallocate ($img, hexdec(substr(str_replace("#","",$fontcolor),0,2)), hexdec(substr(str_replace("#","",$fontcolor),2,2)), hexdec(substr(str_replace("#","",$fontcolor),4,2))); $txt2color = imagecolorallocate ($img, hexdec(substr(str_replace("#","",$shadowcolor),0,2)), hexdec(substr(str_replace("#","",$shadowcolor),2,2)), hexdec(substr(str_replace("#","",$shadowcolor),4,2))); $bocolor = imagecolorallocate ($img, 0, 0, 0); $schcolor = imagecolorallocate ($img, 255, 255, 255); $schatten1color = imagecolorallocate ($img, 235, 235, 235); $schatten2color = imagecolorallocate ($img, 219, 219, 219); $smiliefarbe = imagecolorsforindex($smili, imagecolorat($smili, 5, 14)); imagecopy ($img, $smili, ($width / 2 + 6), ($height - $size['1']), 0, 0, $size['0'], $size['1']); imagefilledrectangle ($img, 0, 0, $width, ($height - 1 - $size['1']), $schcolor); if($shieldshadow){ imagefilledpolygon($img, array((($width - 2) / 2 + ((($width - 2) / 4) - 3)), 0, (($width - 2) / 2 + ((($width - 2) / 4) + 3)), 0, (($width - 2) / 2 - ((($width - 2) / 4) - 3)), ($height - 2 - $size['1']), (($width - 2) / 2 - ((($width - 2) / 4) + 3)), ($height - 2 - $size['1'])), 4, $schatten1color); imagefilledpolygon($img, array((($width - 2) / 2 + ((($width - 2) / 4) + 4)), 0, ($width - 2), 0, ($width - 2), ($height - 2 - $size['1']), (($width - 2) / 2 - ((($width - 2) / 4) - 4)), ($height - 2 - $size['1'])), 4, $schatten2color); } $i = 0; while ($i < count($output)) { if (((!$gd_info["FreeType Support"]) || (!file_exists($fontfile)))) { if ($shadowcolor) { imagestring($img, 2, (($width - (mb_strlen(trim($output[$i])) * $fontwidth) - 2) / 2 + 1), ($i * $fontheight + 6), trim($output[$i]), $txt2color); } imagestring($img, 2, (($width - (mb_strlen(trim($output[$i])) * $fontwidth) - 2) / 2), ($i * $fontheight + 5), trim($output[$i]), $txtcolor); } else { if ($shadowcolor) { imagettftext($img, $fontheight, 0, (($width - (mb_strlen(trim($output[$i])) * $fontwidth) - 2) / 2 + 1), ($i * $fontheight + $fontheight + 7), $txt2color, $fontfile, trim($output[$i])); } imagettftext($img, $fontheight, 0, (($width - (mb_strlen(trim($output[$i])) * $fontwidth) - 2) / 2), ($i * $fontheight + $fontheight + 8), $txtcolor, $fontfile, trim($output[$i])); } $i++; } imageline ($img, 6, 0, ($width - 6), 0, $bocolor); imageline ($img, 0, 5, 0, ($height - 6 - $size['1']), $bocolor); imageline ($img, 6, ($height-1-$size['1']), ($width - 6), ($height-1-$size['1']), $bocolor); imageline ($img, ($width-1), 5, ($width-1), ($height - 6 - $size['1']), $bocolor); if($_GET['type'] == "pensee"){ imagecopy ($img, $pensee, ($width /2 -6), ($height +1 - $size['1']), 0,0,10,15); }else{ imagecopy ($img, $bulle, ($width /2 - 10), ($height -1 - $size['1']), 0,0,10,6); } imagecopy ($img, $gauche1, 0, 0, 0,0,6,1); imagecopy ($img, $gauche2, 0, 1, 0,0,5,1); imagecopy ($img, $gauche3, 0, 2, 0,0,3,1); imagecopy ($img, $gauche4, 0, 3, 0,0,2,2); imagecopy ($img, $gauche4, 0, ($height -$size['1'] - 6), 0,0,2,2); imagecopy ($img, $gauche3, 0, ($height -$size['1'] - 4), 0,0,3,1); imagecopy ($img, $gauche5, 0, ($height -$size['1'] - 3), 0,0,4,1); imagecopy ($img, $gauche6, 0, ($height -$size['1'] - 2), 0,0,7,2); imagecopy ($img, $droit1, ($width - 5), 0, 0,0,5,2); imagecopy ($img, $droit2, ($width - 3), 2, 0,0,3,1); imagecopy ($img, $droit3, ($width - 2), 3, 0,0,2,2); imagecopy ($img, $droit3, ($width - 2), ($height - $size['1'] - 6), 0,0,2,2); imagecopy ($img, $droit2, ($width - 3), ($height - $size['1'] - 4), 0,0,3,1); imagecopy ($img, $droit4, ($width - 4), ($height - $size['1'] - 3), 0,0,4,1); imagecopy ($img, $droit5, ($width - 6), ($height - $size['1'] - 2), 0,0,6,2); imagecolortransparent($img, $bgcolor); imageinterlace($img, 1); //Send the image to the browser header("Content-Type: image/png"); @Imagepng($img); ImageDestroy($img); ImageDestroy($smili); exit; ?>