PvH
2008-07-10 10:04:36
Hey everyone:)
I am quite new to php, and I am trying to make a dynamic image of Eduard and my FightCaver.
It works fine, though there are 6 stats missing:s
Here is the image I have:
http://pvh.freehostia.com/scriptstatz4.php
I am not that good with images and things, but Eduard and I liked it:p
I think the problem is that it doesn't get the variables good on the srl webpage.
If you fix my problem, I'll rep++ you:rolleyes:
Thanks a lot:)
PvH
The code:
[php]<?php
header('Content-type: image/png');
function str_between($str, $betw, $betw2)
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
return '';
}
$contents=file_get_contents('http://stats.srl-forums.com/index.php?action=view_script&id=918');
$ran=str_between($contents,'Worked : <strong> ','.</strong>');
$var1=str_between($contents,'Rounds : <strong>','</strong>');
$var2=str_between($contents,'Level-ups : <strong>','</strong>');
$var3=str_between($contents,'Entered cave : <strong>','</strong>');
$var4=str_between($contents,'Got Unstuck : <strong>','</strong>');
$var5=str_between($contents,'Special Attacks : <strong>','</strong>');
$var6=str_between($contents,'Slept times : <strong>','</strong>');
$im = imagecreatefrompng ('http://pvh.freehostia.com/fightcaver.PNG');
$color = imagecolorallocate($im, 255, 255, 0);
imagestring($im,2,35,25,'Time ran:',$color);
imagestring($im,2,35,40,'Rounds:',$color);
imagestring($im,2,35,55,'Level-ups:',$color);
imagestring($im,2,35,70,'Entered cave:',$color);
imagestring($im,2,35,85,'Got Unstuck:',$color);
imagestring($im,2,35,100,'Special Attacks:',$color);
imagestring($im,2,35,115,'Slept times:',$color);
$color = imagecolorallocate($im,255,255,0);
imagestring($im,2,150,25,$ran,$color);
imagestring($im,2,150,40,$Var1,$color);
imagestring($im,2,150,55,$Var2,$color);
imagestring($im,2,150,70,$Var3,$color);
imagestring($im,2,150,85,$Var4,$color);
imagestring($im,2,150,10,$Var5,$color);
imagestring($im,2,150,115,$Var6,$color);
imagepng($im);
imagedestroy($im);
?> [/php]
I am quite new to php, and I am trying to make a dynamic image of Eduard and my FightCaver.
It works fine, though there are 6 stats missing:s
Here is the image I have:
http://pvh.freehostia.com/scriptstatz4.php
I am not that good with images and things, but Eduard and I liked it:p
I think the problem is that it doesn't get the variables good on the srl webpage.
If you fix my problem, I'll rep++ you:rolleyes:
Thanks a lot:)
PvH
The code:
[php]<?php
header('Content-type: image/png');
function str_between($str, $betw, $betw2)
{
$str = " " . $str;
$pos = strpos($str, $betw);
if ($pos > 0)
{
$str2 = substr($str, $pos + strlen($betw));
$pos2 = strpos($str2, $betw2);
if ($pos2 == 0)
return '';
return substr($str2, 0, $pos2);
}
else
return '';
}
$contents=file_get_contents('http://stats.srl-forums.com/index.php?action=view_script&id=918');
$ran=str_between($contents,'Worked : <strong> ','.</strong>');
$var1=str_between($contents,'Rounds : <strong>','</strong>');
$var2=str_between($contents,'Level-ups : <strong>','</strong>');
$var3=str_between($contents,'Entered cave : <strong>','</strong>');
$var4=str_between($contents,'Got Unstuck : <strong>','</strong>');
$var5=str_between($contents,'Special Attacks : <strong>','</strong>');
$var6=str_between($contents,'Slept times : <strong>','</strong>');
$im = imagecreatefrompng ('http://pvh.freehostia.com/fightcaver.PNG');
$color = imagecolorallocate($im, 255, 255, 0);
imagestring($im,2,35,25,'Time ran:',$color);
imagestring($im,2,35,40,'Rounds:',$color);
imagestring($im,2,35,55,'Level-ups:',$color);
imagestring($im,2,35,70,'Entered cave:',$color);
imagestring($im,2,35,85,'Got Unstuck:',$color);
imagestring($im,2,35,100,'Special Attacks:',$color);
imagestring($im,2,35,115,'Slept times:',$color);
$color = imagecolorallocate($im,255,255,0);
imagestring($im,2,150,25,$ran,$color);
imagestring($im,2,150,40,$Var1,$color);
imagestring($im,2,150,55,$Var2,$color);
imagestring($im,2,150,70,$Var3,$color);
imagestring($im,2,150,85,$Var4,$color);
imagestring($im,2,150,10,$Var5,$color);
imagestring($im,2,150,115,$Var6,$color);
imagepng($im);
imagedestroy($im);
?> [/php]