> Tous les forumsForum des Webmasters

 Script en PHP
Statut du sujet : NON RESOLU Imprimer
 cc30
  Posté le 18/01/2006 @ 18:14  
 Petit astucien

569 Messages
Bonjour [smile], je cherche à apporter une option supplémentaire au script si dessous. [code]<?php /* Titre: Script simple de personnalisation de l'image de statut web2messenger Nouvelle version (lecture via fichier TXT) Title: Simple custom signature creator for web2messenger New version (reads TXT file) Author: Dhaya <http://www.web2messenger.com/d> Date: 29/12/2005 ChangeLog : 01/01/2006 Fixed a little bug concerning the erroneous status position if the nick has smileys Smileys change their size according to the font size used for nick or psm Fixed the smiley's bug (now shows the last smiley on nick and psm) HAPPY NEW YEAR !!! 30/12/2005 Added HTTP vars to positionnate nickname and personal status message Easier setup, improved font handling Supports smileys both in the nickname and the psm (still bugged) Supports quotes 29/12/2005 Added status support with http://www.bencastricum.nl/msn/status.php (removed) */ /******************************************************************************/ /*Configuration. /* Login web2messenger */ $login_w2m = "d"; /* Background filename (PNG only) */ $fond_signature = "msn0123.png"; /* Police name to use for the nickname */ $police_pseudo = "Gothic.TTF"; /* Police name to use for the psm */ $police_psm = "Gothici.TTF"; /******************************************************************************/ function IsIE() // Detects if IE is used to show the picture { $navigator_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); if (stristr($navigator_user_agent, "msie 4")||stristr($navigator_user_agent, "msie 5")||stristr($navigator_user_agent, "msie 6")) { return 'msie'; } else { return 'not-msie'; } } function imagettfrichtext($image, $size, $left, $top, $color, $font, $string) // Replace smileys' codes with their respective pictures { $smileys_from = array(":)",":-)",":D",":d",";)",";-)",":o",":O",":-O",":P",":p",":-p",":-P","(h)","(H)",":@",":-@",":$",":-$",":s",":S",":-S",":-s",":-(",":(",":'(",":|",":-|","(6)","(A)","(a)","(L)","(l)","(U)","(u)","(m)","(M)","(@)","(&)","(S)","(*)","(~)","(8)","(E)","(e)","(F)","(f)","(w)","(W)","(O)","(o)","(K)","(k)","(G)","(g)","(^)","(p)","(P)","(i)","(I)","(C)","(c)","(t)","(T)","({)","(})","(B)","(b)","(D)","(d)","(Z)","(z)","(x)","(X)","(y)","(Y)","(n)","(N)",":[",":-[","(?)","(%)","(#)","(R)","(r)",":-#","8o|","8-|","^o)",":-*","+o(","(sn)","(tu)","(pl)","(||)","(pi)","(so)","(au)","(ap)","(um)","(ip)","(co)","(mp)","(brb)","(st)","(yn)","(h5)","(mo)","(bah)",":^)","*-)","(li)","<:o)","8-)","(ci)","(xx)","(nah)"); $smileys_to = array("1","1","2","2","3","3","4","4","4","5","5","5","5","6","6","7","7","8","8","9","9","9","9","10","10","11","12","12","13","14","14","15","15","16","16","17","17","18","19","20","21","22","23","24","24","25","25","26","26","27","27","28","28","29","29","30","31","31","32","32","33","33","34","34","35","36","37","37","38","38","39","39","40","40","41","41","42","42","43","43","44","45","46","47","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79"); $string = explode(" ", $string); $isImage = 0; for ($i=0; $i<count($string);$i++) { $isImage = 0; for($j=0;$j<count($smileys_from);$j++) { if($smileys_from[$j] == $string[$i]) { $isImage = 1; $img_smiley[$i] = imagecreatefrompng("./smileys/".$smileys_to[$j].".png"); $resampled_size = $size * 1.9; $decalage = $size * 1.5; imagecopyresampled($image, $img_smiley[$i], $left, $top-$decalage, 0, 0, $resampled_size, $resampled_size, imagesx($img_smiley[$i]), imagesy($img_smiley[$i])); $left += $resampled_size + 5; } } if($isImage == 0) { $string_size = imagettfbbox($size, 0, $font, $string[$i]); imagettftext($image, $size, 0, $left, $top, $color, $font, $string[$i]); $left += $string_size[2] + 5; } } return $left; } // Initiate the background $img_fond = imagecreatefrompng($fond_signature); // Set the dimensions of the background $bg_width = imagesx($img_fond); $bg_height = imagesy($img_fond); // Creates an empty picture $image = imagecreatetruecolor($bg_width, $bg_height); // Copy the background picture on the empty one imagecopy($image, $img_fond, 0, 0, 0, 0, $bg_width, $bg_height); // Set HTTP vars $nck_s = @$_REQUEST['nck_s']; $nck_x = @$_REQUEST['nck_x']; $nck_y = @$_REQUEST['nck_y']; $psm_s = @$_REQUEST['psm_s']; $psm_x = @$_REQUEST['psm_x']; $psm_y = @$_REQUEST['psm_y']; if (!isset($nck_s)) $nck_s = "10"; if (!isset($nck_x)) $nck_x = "50"; if (!isset($nck_y)) $nck_y = "50"; if (!isset($psm_s)) $psm_s = "8"; if (!isset($psm_x)) $psm_x = "10"; if (!isset($psm_y)) $psm_y = "80"; // Takes nickname, psm and status from the TXT file $data = @file_get_contents("http://www.web2messenger.com/status/".$login_w2m.".txt"); if ($data <> "") { $chara_from = array("'"); $chara_to = array("'"); $data = explode("\n",$data); $pseudo = trim(str_replace($chara_from,$chara_to,html_entity_decode($data[0]))); $psm = @trim(str_replace($chara_from,$chara_to,html_entity_decode(substr($data[1], (strpos($data[1],"]")+1), strlen($data[1]))))); if (@$data[2] <> "") { $status = "(".$data[2].")"; } else { $status = ""; } } else { $pseudo = "Web2Messenger signature service is down atm..."; $psm = "...hope it will get better soon !"; $status = ""; } // Environment vars for GD putenv('GDFONTPATH=' . realpath('.')); $font_path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']; $font_path = str_replace(strrchr($font_path,"/"),"",$font_path)."/"; // Copy the strings on the picture $black = imagecolorallocate($image,0,0,0); $gray = imagecolorallocate($image, 100, 100, 100); $white = imagecolorallocate($image, 255, 255, 255); $taille_nick = imagettfrichtext($image, $nck_s, $nck_x, $nck_y, $black, $font_path.$police_pseudo, $pseudo); imagettftext($image, $nck_s, 0, $taille_nick, $nck_y, $gray, $font_path.$police_pseudo, $status); imagettfrichtext($image, $psm_s, $psm_x, $psm_y, $gray, $font_path.$police_psm, $psm); // Copyright (do NOT remove) $taille_copyright = imagettfbbox(7, 0, $font_path.$police_pseudo, "www.web2messenger.com"); imagettftext($image, 7, 0, ($bg_width- ($taille_copyright[2] - $taille_copyright[0])-4), 11, $white, $font_path.$police_pseudo, "www.web2messenger.com"); imagettftext($image, 7, 0, ($bg_width- ($taille_copyright[2] - $taille_copyright[0])- 5), 10, $black, $font_path.$police_pseudo, "www.web2messenger.com"); // Transform the PNG into 24Bit if shown on IE if (IsIE() == 'msie'){ imagetruecolortopalette ( $image, TRUE, 16777216); } // Modify header params and show the picture header("Content-Type: image/png"); imagepng($image); // Deletes pictures from the Memory imagedestroy($img_fond); imagedestroy($image); ?>[/code] Mes connaissances en PHP étant encore assez limitées je fais appelle à vous. Voilà, en fait il faudrait ajouter quelque chose permettant la mise en forme automatique du pseudo ( via le script ). Je m'explique : dans l'image si dessous [img]http://charles.cc30.free.fr/msg/index.php/image.png[/img] on vois des caractères tel que [code]·$[/code] suivis d'un chiffre ainsi que [code]·#[/code] ou encore [code]·&[/code] le tout est clos par [code]·0[/code] Le $ est le chiffre indique une couleur. Le # met en gras et le & met en italique. Ce que j'aimerais réaliser c'est que en fonction de cela le texte soit mis en couleur et en forme dans l'image générée. Alors comment faire ? Merci pour votre aide [smile].
 Afficher le profil de cc30 Envoyer un message privé à cc30
 
 
Publicité
 cc30  Posté le 21/01/2006 à 19:08  
Petit astucien

569 Messages
Up [smile]
Afficher le profil de cc30 Voir la configuration de cc30Envoyer un message privé à cc30
 Revenir en haut de la page
Haut de la page 
Inscrivez-vous !
- Posez vos questions

- Résolvez vos problèmes

- Aidez les autres

- Participez et créez vos discussions

- Dialoguez en privé avec d'autres membres

- Suivez vos sujets préférés

- Affichez les signatures des membres

TOUT EST GRATUIT !

Je crée mon compte



Vous avez besoin d'aide ?
Des centaines d'experts sont à votre disposition sur les forums PC Astuces pour vous aider gratuitement, 24h/24, 7j/7.

Les derniers sujets résolus !
 

 > Tous les forumsForum des Webmasters

 
Forum PC Astuces© 1997-2008 WebastucesAller en haut de la page