Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Images > GD
GD Forum d'entraide pour l'extension GD permettant de manipuler des images en PHP. Avant de poster -> tutoriels GD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 16/11/2006, 17h40   #1
Invité régulier
 
Inscription : août 2006
Messages : 27
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 27
Points : 7
Points : 7
Par défaut 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 :
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 :
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.
~~PriVate JoKe~~ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/11/2006, 20h34   #2
Membre chevronné
 
Avatar de debug
 
Inscription : avril 2002
Messages : 1 034
Détails du profil
Informations forums :
Inscription : avril 2002
Messages : 1 034
Points : 792
Points : 792
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 :
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 :
for (; $plen>0; $plen-=32){
il manque un paramètre

Code :
for ($plen= XX; $plen>0; $plen-=32){
__________________
May the Troll, be with you
(Que le troll soit avec toi)
debug est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/11/2006, 21h22   #3
Invité régulier
 
Inscription : août 2006
Messages : 27
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 27
Points : 7
Points : 7
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 :
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.
~~PriVate JoKe~~ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/11/2006, 21h56   #4
Membre chevronné
 
Avatar de debug
 
Inscription : avril 2002
Messages : 1 034
Détails du profil
Informations forums :
Inscription : avril 2002
Messages : 1 034
Points : 792
Points : 792
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)
debug est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/11/2006, 22h29   #5
Invité régulier
 
Inscription : août 2006
Messages : 27
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 27
Points : 7
Points : 7
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 :
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 :
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.
~~PriVate JoKe~~ est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h29.


 
 
 
 
Partenaires

Hébergement Web