IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[GD] Différentes informations dans une image.


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2006
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 27
    Points : 18
    Points
    18
    Par défaut [GD] Différentes informations dans une image.
    Bonjour/bonsoir tout le monde =)

    Alors voilà : j'utilise la librairie GD qui affiche, par exemple un serveur est online ou offline.

    Donc j'ai mon script avec mon code GD :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <?php
    $char = file_get_contents("http://crow-online.com/status_image.php?type=char");
    $map = file_get_contents("http://crow-online.com/status_image.php?type=map");
    $login = file_get_contents("http://crow-online.com/status_image.php?type=login");
    $ppl = file_get_contents("http://crow-online.com/status_image.php?type=ppl");
    $max = file_get_contents("http://crow-online.com/status_image.php?type=max");
    header('Content-type: image/jpeg');
    $image = "satus.htm2.JPG";
    $url = "http://crow-online.com";
    $dune = "CroW - Customized Ragnarok Online World";
    $im = imagecreatefromjpeg($image);
        $textcolor = imagecolorallocate($im, 255, 255, 255); 
        $textcolor2 = imagecolorallocate($im, 0, 0, 0);
        ImageString ($im, 5, 150, 10, $dune, $textcolor);
        ImageString ($im, 4, 110, 40, $login, $textcolor);
        ImageString ($im, 4, 110, 52, $char, $textcolor);
        ImageString ($im, 4, 110, 64, $map, $textcolor);
        ImageString ($im, 4, 110, 76, $ppl, $textcolor);
        ImageString ($im, 4, 110, 95, $max, $textcolor);
        ImageString ($im, 4, 2, 170, $url, $textcolor2);
    Imagejpeg($im);
    ImageDestroy ($im);
    ?>
    Etle script avec les fonctions nécéssaire à ce que je veux faire de GD :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    <?php
     
     
    //Adresse IP de votre server ragnarok
    $ip='88.191.37.92';
     
    //Port du Login-server
    $lport=6900;
     
    //Port du Char-server
    $cport=6121;
     
    //Port du Map-server
    $mport=5121;
     
    //Login
    $account='Status';
     
    //Pass
    $passwd='server_img';
     
    //Timeout
    $timeout=2;
     
    //Debug mode (1 pour oui, 0 pour non)
    $debug=0;
     
     
    function status_check($ip,$port,$timeout) {
     
    //Verification du Status du Serveur
            $up = @fsockopen($ip,$port,$errno,$errstr,$timeout);
     
            if($up) {
    return "ONLINE";
    }
    else {
    return "OFFLINE";
    }
     
     
            @fclose($up);
    }
     
    //Original fonction by [Devil] for AthenaAdvanced
    //Edited by LebrEf for status script
    function usronline($ip,$port,$account,$passwd,$timeout,$debug) {
     
    if (!($fp = @fsockopen($ip,$port,$errno,$errstr,$timeout)))
    {
    if ($debug==1)  die( "Erreur 1");
     
    else return "0";
    }
    else {
    $in = pack("vVa24a24C",0x0064,9,$account,$passwd,3);
      fputs($fp, $in, strlen($in));
      fflush($fp);
      $assoc_array = unpack("vint", fread($fp,2));
     
    if ( $assoc_array['int'] != 0x0069){
     
    if ($debug==1)  die( "Erreur 2");
     
    else return "0";
     
     
    }
     
      $assoc_array = unpack("vint",fread($fp,2));
      $plen = ($assoc_array['int'] -= 4);
      fread($fp,43);
      $plen-=43;
      for (; $plen>0; $plen-=32){
      $assoc_array = unpack("x6/a20char/Vint",fread($fp,32));
      $name = $assoc_array['char'];
      //$name=substr($name,0,strpos($name,"\0")); // uncomment that line if you have more than one char server.
      $count = "".$assoc_array['int']."";
      return $count;
      }
      }
    }
    if($_GET['type'] == "login") {
    $lol = 'Login Server : '.status_check($ip,$lport,$timeout);
    echo $lol;
    }
    if($_GET['type'] == "char") {
    $lol = 'Char Server : '.status_check($ip,$cport,$timeout);
    echo $lol;
    }
    if($_GET['type'] == "map") {
    $lol = 'Map Server : '.status_check($ip,$mport,$timeout);
    echo $lol;
    }
    if($_GET['type'] == "ppl") {
    $lol = 'Joueurs : '.usronline($ip,$lport,$account,$passwd,$timeout,$debug);
    echo $lol;
    } if($_GET['type'] == "max") {
    if ($maxjoueur<.usronline($ip,$lport,$account,$passwd,$timeout,$debug)) { $maxjoueur=.usronline($ip,$lport,$account,$passwd,$timeout,$debug) }
    $lol = 'Pax Joueurs Connecté : '$maxjoueur;
    echo $lol;
    }
    ?>
    Donc le problème, c'est que dans le premier script, on voie l'adresse du script.
    Et dans le deuxième script, j'ai un parse error à la ligne 103, donc à la fin

    Donc merci de votre aide d'avance.


    Cordialement,
    Akenshiro.

  2. #2
    Expert confirmé
    Avatar de debug
    Profil pro
    Inscrit en
    Avril 2002
    Messages
    1 034
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 034
    Points : 4 093
    Points
    4 093
    Par défaut
    Alors PrivateJoke, je te conseille déjà de mettre en forme tes fichiers.... pour débugger tout ça c'est tout simplement illisible...

    Voila un code identé avec des trucs corrigés

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    <? php
    //Adresse IP de votre server ragnarok
    $ip='88.191.37.92';
     
    //Port du Login-server
    $lport=6900;
     
    //Port du Char-server
    $cport=6121;
     
    //Port du Map-server
    $mport=5121;
     
    //Login
    $account='Status';
     
    //Pass
    $passwd='server_img';
     
    //Timeout
    $timeout=2;
     
    //Debug mode (1 pour oui, 0 pour non)
    $debug=0;
     
    function status_check($ip,$port,$timeout) {
    	//Verification du Status du Serveur
        $up = @fsockopen($ip,$port,$errno,$errstr,$timeout);
     
    	if($up) {
    		return "ONLINE";
    	}
    	else {
    		return "OFFLINE";
    	}
    	@fclose($up);
    }
     
    //Original fonction by [Devil] for AthenaAdvanced
    //Edited by LebrEf for status script
    function usronline($ip,$port,$account,$passwd,$timeout,$debug) {
     
    	if (!($fp = @fsockopen($ip,$port,$errno,$errstr,$timeout)))
    	{
    		if ($debug==1)  die( "Erreur 1");
    		else return "0";
    	}
    	else {
    		$in = pack("vVa24a24C",0x0064,9,$account,$passwd,3);
    		fputs($fp, $in, strlen($in));
    		fflush($fp);
    		$assoc_array = unpack("vint", fread($fp,2));
     
    		if ( $assoc_array['int'] != 0x0069){
     
    			if ($debug==1)  die( "Erreur 2");
    			else return "0";
    		}
     
    		$assoc_array = unpack("vint",fread($fp,2));
    		$plen = ($assoc_array['int'] -= 4);
    		fread($fp,43);
    		$plen-=43;
    		for (; $plen>0; $plen-=32){
    			$assoc_array = unpack("x6/a20char/Vint",fread($fp,32));
    			$name = $assoc_array['char'];
    			//$name=substr($name,0,strpos($name,"\0")); // uncomment that line if you have more than one char server.
    			$count = "".$assoc_array['int']."";
    			return $count;
    		}
    	}	
    }
    if($_GET['type'] == "login") {
    	$lol = 'Login Server : '.status_check($ip,$lport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "char") {
    	$lol = 'Char Server : '.status_check($ip,$cport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "map")
    {
    	$lol = 'Map Server : '.status_check($ip,$mport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "ppl") {
    	$lol = 'Joueurs : '. usronline($ip,$lport,$account,$passwd,$timeout,$debug);
    	echo $lol;
    }
    if($_GET['type'] == "max") {
    	if ($maxjoueur < usronline($ip,$lport,$account,$passwd,$timeout,$debug)) { $maxjoueur= usronline($ip,$lport,$account,$passwd,$timeout,$debug); }
    	$lol = 'Pax Joueurs Connecté : ' . $maxjoueur;
    	echo $lol;
    }
    ?>
    Bon alors, y'a 1 truc qui me chiffone :

    ta boucle là :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for (; $plen>0; $plen-=32){
    il manque un paramètre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for ($plen= XX; $plen>0; $plen-=32){
    May the Troll, be with you
    (Que le troll soit avec toi)

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2006
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 27
    Points : 18
    Points
    18
    Par défaut
    Et bien merci pour tout debug, figure toi que j'avance :

    Donc aparament GD était mal instalé (merci OD) donc je l'ai réinstal.

    Et maintenant, j'ai cette erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    <br />
    <b>Warning</b>:  imagecreatefromjpeg(satus.htm2.JPG): failed to open stream: No such file or directory in <b>/var/www/status_im.php</b> on line <b>11</b><br />
    <br />
    <b>Warning</b>:  imagecolorallocate(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>12</b><br />
    <br />
     
    <b>Warning</b>:  imagecolorallocate(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>13</b><br />
    <br />
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>14</b><br />
    <br />
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>15</b><br />
     
    <br />
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>16</b><br />
    <br />
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>17</b><br />
    <br />
     
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>18</b><br />
    <br />
    <b>Warning</b>:  imagestring(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>20</b><br />
    <br />
    <b>Warning</b>:  imagejpeg(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>21</b><br />
     
    <br />
    <b>Warning</b>:  imagedestroy(): supplied argument is not a valid Image resource in <b>/var/www/status_im.php</b> on line <b>22</b><br />
    Alors, une idée ?

    Cordialement,
    Akenshiro.

  4. #4
    Expert confirmé
    Avatar de debug
    Profil pro
    Inscrit en
    Avril 2002
    Messages
    1 034
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2002
    Messages : 1 034
    Points : 4 093
    Points
    4 093
    Par défaut
    Et bien ca veux dire qu'il ne trouve pas le fichier : "satus.htm2.JPG"

    Vérifies que le fichier existe bien avec le même nom (minuscule/Majuscule c'est important).
    Ensuite vérifie que le fichier est bien dans le dossier www
    May the Troll, be with you
    (Que le troll soit avec toi)

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2006
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 27
    Points : 18
    Points
    18
    Par défaut
    Bon alors ca avance à grand pas.

    Ce que j'ai :
    Je peut maintenant voir le fond, ainsi que le itre que j'ai mis.

    Ce que j'ai n'ai pas ... :
    Toute les informations comme quoi le serveur est online ou pas.

    Je repost mes deux codes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    <?php
    $char = file_get_contents("http://88.191.36.92/status_i.php?type=char");
    $map = file_get_contents("http://88.191.36.92/status_i.php?type=map");
    $login = file_get_contents("http://88.191.36.92/status_i.php?type=login");
    $ppl = file_get_contents("http://88.191.36.92/status_i.php?type=ppl");
    $max = file_get_contents("http://88.191.36.92/status_i.php?type=max");
    header('Content-type: image/png');
    $image = "status.png";
    $url = "http://www.crow-online.com";
    $dune = "CroW - Customized Ragnarok Online World";
    //$im = imagecreatefrompng(500,150);
    $im= imagecreate(500,150);
        $textcolor = imagecolorallocate($im, 0, 0, 0); 
        $textcolor2 = imagecolorallocate($im, 255, 128, 0);
        ImageString ($im, 5, 75, 10, $dune, $textcolor2);
        ImageString ($im, 5, 75, 10, $login, $textcolor2);
        ImageString ($im, 4, 110, 52, $char, $textcolor2);
        ImageString ($im, 4, 110, 64, $map, $textcolor2);
        ImageString ($im, 4, 110, 76, $ppl, $textcolor2);
    //  ImageString ($im, 4, 110, 95, $max, $textcolor);
        ImageString ($im, 4, 2, 170, $url, $textcolor2);
    Imagepng($im);
    ImageDestroy ($im);
    ?>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    <? php
    //Adresse IP de votre server ragnarok
    $ip='88.191.37.92';
     
    //Port du Login-server
    $lport=6900;
     
    //Port du Char-server
    $cport=6121;
     
    //Port du Map-server
    $mport=5121;
     
    //Login
    $account='Status';
     
    //Pass
    $passwd='server_img';
     
    //Timeout
    $timeout=2;
     
    //Debug mode (1 pour oui, 0 pour non)
    $debug=0;
     
    function status_check($ip,$port,$timeout) {
    	//Verification du Status du Serveur
        $up = @fsockopen($ip,$port,$errno,$errstr,$timeout);
     
    	if($up) {
    		return "ONLINE";
    	}
    	else {
    		return "OFFLINE";
    	}
    	@fclose($up);
    }
     
    //Original fonction by [Devil] for AthenaAdvanced
    //Edited by LebrEf for status script
    function usronline($ip,$port,$account,$passwd,$timeout,$debug) {
     
    	if (!($fp = @fsockopen($ip,$port,$errno,$errstr,$timeout)))
    	{
    		if ($debug==1)  die( "Erreur 1");
    		else return "0";
    	}
    	else {
    		$in = pack("vVa24a24C",0x0064,9,$account,$passwd,3);
    		fputs($fp, $in, strlen($in));
    		fflush($fp);
    		$assoc_array = unpack("vint", fread($fp,2));
     
    		if ( $assoc_array['int'] != 0x0069){
     
    			if ($debug==1)  die( "Erreur 2");
    			else return "0";
    		}
     
    		$assoc_array = unpack("vint",fread($fp,2));
    		$plen = ($assoc_array['int'] -= 4);
    		fread($fp,43);
    		$plen-=43;
    		for (; $plen>0; $plen-=32){
    			$assoc_array = unpack("x6/a20char/Vint",fread($fp,32));
    			$name = $assoc_array['char'];
    			//$name=substr($name,0,strpos($name,"\0")); // uncomment that line if you have more than one char server.
    			$count = "".$assoc_array['int']."";
    			return $count;
    		}
    	}	
    }
    if($_GET['type'] == "login") {
    	$lol = 'Login Server : '.status_check($ip,$lport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "char") {
    	$lol = 'Char Server : '.status_check($ip,$cport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "map")
    {
    	$lol = 'Map Server : '.status_check($ip,$mport,$timeout);
    	echo $lol;
    }
    if($_GET['type'] == "ppl") {
    	$lol = 'Joueurs : '. usronline($ip,$lport,$account,$passwd,$timeout,$debug);
    	echo $lol;
    }
    if($_GET['type'] == "max") {
    	if ($maxjoueur < usronline($ip,$lport,$account,$passwd,$timeout,$debug)) { $maxjoueur= usronline($ip,$lport,$account,$passwd,$timeout,$debug); }
    	$lol = 'Pax Joueurs Connecté : ' . $maxjoueur;
    	echo $lol;
    }
    ?>
    Certes, je compte l'amélioré après, mais c'est déjà un début =)


    Merci encore debug.

    Cordialement,
    Akenshiro.

Discussions similaires

  1. Changer différentes couleurs dans une image
    Par cashmoney dans le forum Flex
    Réponses: 13
    Dernier message: 08/10/2009, 18h06
  2. Mesure d'information dans une image
    Par velkouby dans le forum Traitement d'images
    Réponses: 13
    Dernier message: 22/02/2008, 15h05
  3. [FLASH 5]un bouton dans une image pour revenir sur une scene
    Par patato valdes dans le forum Flash
    Réponses: 7
    Dernier message: 28/04/2004, 20h21
  4. Obtenir la position du curseur dans une Image
    Par bastoune dans le forum Composants VCL
    Réponses: 6
    Dernier message: 14/11/2003, 21h02
  5. faire un selection dans une image aves les APIs
    Par merahyazid dans le forum C++Builder
    Réponses: 3
    Dernier message: 30/04/2002, 10h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo