SRL Archive - Web Development

Dynamic script stats image fails:s


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]

ZephyrsFury

2008-07-10 11:37:20

Your variables are declared as lowercase:

[php]
$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>');
[/php]

but you use them as uppercase:

[php]
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);
[/php]

PvH

2008-07-10 11:38:03

Thanks a lot Zeph.
You are my hero:D
Rep++ for you:)

P.s.
I'm so dumb -.- xD

ZephyrsFury

2008-07-10 11:39:05

From: pvh
Thanks a lot Zeph.
You are my hero:D
Rep++ for you:)

P.s.
I'm so dumb -.- xD


Hehe and I don't know any PHP. :D

MylesMadness

2008-07-12 08:55:30

Free hostia let you use file_get_contents? I tried like 2 weeks ago and it told me to gtfo

PvH

2008-07-12 12:17:19

From: Mylesmadness
Free hostia let you use file_get_contents? I tried like 2 weeks ago and it told me to gtfo


Yep they do, create the file in notepad. save it as <name>.php, and set it other box to save to all;)