ajaxchat2301 | Bonsoir,
J'ai récemment eu un soucis pour afficher des images en PHP mais Pascal le nain m'a été d'une grande aide. J'ai un autre script, qui est important, mais ce-dernier ne fonctionne pas et je ne comprends pas d'ou vient le problème. Le script en composé en plusieurs fichiers. Son but : une personne remplit un formulaire et selon le formulaire, une image s'affiche avec plusieurs autres images définies par des variables. Au départ, aucune image ne s'affichait. J'ai modifié le fichier .htaccess comme l'a conseillé le fichier readme.txt associé au script et l'image de fond s'affiche mais le reste : niente. C'est pourquoi j'en viens à vous en espérant trouver la solution à mon problème. Voici les sources des fichiers nécéssaires au script.
Le fichier statussig.php situé par exemple à la racine du site :
Code :
- <?php
- $url = "http://www.ici-il-y-a-ladresse-de-mon-site-comme-demande.com"; // Your website address
- $country = $_POST['country'];
- $habbo = $_POST['habboname'];
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Status Signature</title>
- <style type="text/css">
- <!--
- body,td,th {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 10px;
- color: #000000;
- }
- -->
- </style>
- </head>
- <body>
- <center>
- <form method="POST">
- <strong>Habbo Name</strong>
- <input type="text" name="habboname" size="20"><br>
- <br>
- <b>Country</b> <select size="1" name="country">
- <option value="au">Australia</option>
- <option value="ca">Canada</option>
- <option value="sg">Singapore</option>
- <option value="uk">United Kingdom</option>
- <option value="us">USA</option>
- </select><br><br>
- <input type="submit" value="Submit" name="send"></p>
- </form>
- <br>
- <?
- if($habbo){
- echo "<img src=\"$url/sig/$country/$habbo\" alt=\"Broken?\"><br /><br />";
- ?>
- <b>Direct Link:</b><br><input type="text" name="web" size="20" onFocus="this.select()" value="<? echo "$url/sig/$country/$habbo"; ?>"><br /><br />
- <b>Forum Code:</b><br><input type="text" name="web" size="20" onFocus="this.select()" value="[img]<? echo "$url/sig/$country/$habbo"; ?>[/img]"><br /><br />
- <b>Forum Code:</b><br><input type="text" name="web" size="20" onFocus="this.select()" value="<img src="<? echo "$url/sig/$country/$habbo"; ?>" >"><br /><br />
- <?
- }
- ?>
- <br><br>
- <i>Created by Hybride of Habbo Ring for you.<br>
- Feel free to remove this, it'll be our little secret ;-)</i><br><br>
- </center>
- </body>
- </html>
- <?
- ?>
|
La on crée un dossier sig ou il y a les fichiers suivants :
Le fichier habboClass.php :
Code :
- <?php
- class habboClass
- {
- var $data;
- var $habboname;
- var $hotel;
- var $private;
- function habboClass($habboname, $hotel)
- {
- $this->habboname = $habboname;
- $this->hotel = $hotel;
- $this->data = file_get_contents("http://habbo." . $hotel . "/home/" . $habboname);
- }
- function online()
- {
- if (eregi("habbo_online_anim.gif", $this->data))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function banned()
- {
- if (eregi("This page is not available anymore", $this->data))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function actual()
- {
- if (eregi('<div id="page-headline-text">Habbo Homes</div>', $this->data))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- function pageprivate()
- {
- if (eregi("marked this page as private.", $this->data))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function motto()
- {
- $motto = explode('<div class="profile-motto">', $this->data);
- $motto = explode('</div>', $motto[1]);
- $motto = trim($motto[0]);
- $motto = str_replace(' <div class="clear">', '', $motto);
- return $motto;
- }
- function badge()
- {
- if (eregi("c_images/album1584/", $this->data))
- {
- $badge = explode('http://images.habbohotel.' . $this->hotel .
- '/c_images/album1584/', $this->data);
- $badge = explode('.gif', $badge[1]);
- $badge = trim($badge[0]);
- $badge = "http://images.habbohotel." . $this->hotel . "/c_images/album1584/" . $badge .
- ".gif";
- return $badge;
- }
- else
- {
- return false;
- }
- }
- function figure()
- {
- $figure = "http://www.habbo.".$this->hotel."/habbo-imaging/avatarimage?user=".$this->habboname."&action=&direction=2&head_direction=3&gesture=sml&size=l&img_format=gif";
- return $figure;
- }
- function birthdate()
- {
- $birthdate = explode('<div class="birthday date">', $this->data);
- $birthdate = explode('</div>', $birthdate[1]);
- $birthdate = trim($birthdate[0]);
- return $birthdate;
- }
- function normal()
- {
- if (!$this->banned() and !$this->pageprivate() and $this->actual())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function name()
- {
- $name = explode('<span class="name-text">', $this->data);
- $name = explode('</span>', $name[1]);
- $name = trim($name[0]);
- return $name;
- }
- function groupbadge()
- {
- if (eregi("/habbo-imaging/badge/", $this->data))
- {
- $badge = explode('/habbo-imaging/badge/', $this->data);
- $badge = explode('.gif', $badge[1]);
- $badge = trim($badge[0]);
- $badge = "http://www.habbo." . $this->hotel . "/habbo-imaging/badge/" . $badge .
- ".gif";
- return $badge;
- }
- else
- {
- return false;
- }
- }
- }
- ?>
|
Différents fichiers selon l'hôtel. Je vous met par exemple habboProfile_au.php :
Code :
- <?php
- header("Content-type: image/png" );
- include ('habboClass.php');
- $habbo = $_GET['name'];
- //Data Retrieval
- $habboHome = new habboClass($habbo, 'com.au');
- if ($habboHome->banned())
- {
- $im = imagecreatefrompng("banned.png" );
- }
- elseif ($habboHome->pageprivate())
- {
- $im = imagecreatefrompng("private.png" );
- }
- elseif (!$habboHome->actual())
- {
- $im = imagecreatefrompng("exist.png" );
- }
- else
- {
- $im = imagecreatefrompng("profile.png" );
- $white = imagecolorallocate($im, 255, 255, 255);
- $fontbold = "volterb.ttf";
- $font = "volter.ttf";
- imagettftext($im, 7, 0, 103.5, 28.5, $white, $fontbold, "Name:" );
- imagettftext($im, 7, 0, 149.5, 28.5, $white, $font, $habboHome->name());
- $habboMotto = $habboHome->motto();
- $habboMotto = eregi_replace(">", ">", $habboMotto);
- $habboMotto = eregi_replace("<", "<", $habboMotto);
- imagettftext($im, 7, 0, 103.5, 58.5, $white, $fontbold, "Motto:" );
- imagettftext($im, 7, 0, 149.5, 58.5, $white, $font, $habboMotto);
- if ($habboHome->online())
- {
- $statusText = "Online";
- }
- else
- {
- $statusText = "Offline";
- }
- imagettftext($im, 7, 0, 240, 89, $white, $fontbold, "Status:" );
- imagettftext($im, 7, 0, 290, 89, $white, $font, $statusText);
- $habboFigure = $habboHome->figure();
- $habboFigure = imagecreatefromgif($habboFigure);
- imagecopy($im, $habboFigure, 16, 18.5, 0, 0, 64, 106);
- if($habboHome->badge()){
- $habboBadge = $habboHome->badge();
- $habboBadge = imagecreatefromgif($habboBadge);
- $halfBadgeX = imagesx($habboBadge) / 2;
- $halfBadgeY = imagesy($habboBadge) / 2;
- $centerX = 127.5 - $halfBadgeX;
- $centerY = 110.5 - $halfBadgeY;
- imagecopy($im, $habboBadge, $centerX, $centerY, 0, 0, imagesx($habboBadge),
- imagesy($habboBadge));
- if($habboHome->groupbadge()){
- $habboBadge = $habboHome->groupbadge();
- $habboGBadge = imagecreatefromgif($habboBadge);
- $halfGBadgeX = imagesx($habboGBadge) / 2;
- $halfGBadgeY = imagesy($habboGBadge) / 2;
- $centerX = 193.5 - $halfGBadgeX;
- $centerY = 110.5 - $halfGBadgeY;
- imagecopy($im, $habboGBadge, $centerX, $centerY, 0, 0, imagesx($habboGBadge),
- imagesy($habboGBadge));
- }
- }
- }
- //Create Image
- imagepng($im);
- imagedestroy($im);
- ?>
|
Le reste, ce sont les images du style private, banned, etc.
J'ai, dans mon fichier .htaccess, inséré les lignes suivantes :
RewriteEngine on
RewriteRule ^sig/au/([^\/]+)/?$ /sig/habboProfile_au.php?name=$1 [L]
RewriteRule ^sig/ca/([^\/]+)/?$ /sig/habboProfile_ca.php?name=$1 [L]
RewriteRule ^sig/sg/([^\/]+)/?$ /sig/habboProfile_sg.php?name=$1 [L]
RewriteRule ^sig/uk/([^\/]+)/?$ /sig/habboProfile_uk.php?name=$1 [L]
RewriteRule ^sig/us/([^\/]+)/?$ /sig/habboProfile_us.php?name=$1 [L]
Voici le fichier readme.txt si vous voulez en savoir plus :
------------------------------------------------------------------
INSTALLATION AND USE
------------------------------------------------------------------
Open your root directory (usually called 'www' or
'public_html') and upload all the contents of 'upload'
into it as seen. You should have:
http://www.yourwebsite.com/statussig.php and
http://www.yourwebsite.com/sig/
To see the script in action, type:
http://YOURSITE/sig/habboProfile.php?name=HABBONAME
The image displayed can be used as an image on a website
or as a link back but in order to use it on a forum
you must use .htaccess (explain further down).
habboClass.php is the file that collects the information
habboProfile.php is the file that creates the image
------------------------------------------------------------------
.HTACCESS
------------------------------------------------------------------
To make this script more universal and available to
use on forums, you must have access to your .htaccess.
This can be found in your root directory (usually 'www'
or 'public_html'). Make sure that it is set to 644.
Now simply add the following:
RewriteEngine on
RewriteRule ^sig/au/([^\/]+)/?$ /sig/habboProfile_au.php?name=$1 [L]
RewriteRule ^sig/ca/([^\/]+)/?$ /sig/habboProfile_ca.php?name=$1 [L]
RewriteRule ^sig/sg/([^\/]+)/?$ /sig/habboProfile_sg.php?name=$1 [L]
RewriteRule ^sig/uk/([^\/]+)/?$ /sig/habboProfile_uk.php?name=$1 [L]
RewriteRule ^sig/us/([^\/]+)/?$ /sig/habboProfile_us.php?name=$1 [L]
The new URL to display the image will now be:
http://YOURSITE/sig/COUNTRY/HABBONAME
------------------------------------------------------------------
GENERATOR
------------------------------------------------------------------
To setup and use the generator, simply open the statussig.php file
in your favourite editor and change the URL to your own website
adress and your done. |
Je sais que le problème parait compliqué du fait qu'il y a plusieurs fichiers mais j'aimerais vraiment pouvoir utiliser ce script. Je vous remercie d'avance pour votre aide précieuse. |