PDA

View Full Version : Get an image banked?



Raskolnikov
01-13-2008, 05:55 PM
I am trying to make an image that will show how many randoms your script has encountered. I have a problem though. How will I bank the image so that it will keep updating?

Edit: I mean, how will I save the image so that not only the image is just there but I want it to keep updating with new info? Do I do an unending loop?

mastaraymond
01-13-2008, 06:15 PM
What language are you programming in?

Raskolnikov
01-13-2008, 06:47 PM
Php

XcanadamanX
01-13-2008, 10:08 PM
you have to make a dynamic image. you have to use the GD library and mysql. i figure you know that. this is the way i did it:


$nav = $_SERVER["REQUEST_URI"];
$script = $_SERVER["SCRIPT_NAME"];
$nav = ereg_replace("^$script", "", $nav);
$nav = str_replace("%20"," ",$nav);
$vars = explode("/", $nav);
$ID = strtolower($vars[1]);

so when you go say my site: www.xcanadamanx.phpnet.us/stats/statssigs.php/1.png it will read the 1. the $ID will be 1. and then you just do a mysql query and find the id 1 and get the infromation you need and then create the image.




imagettftext($im,8.0,0,47,63,$black,$font,$Time);
imagettftext($im,8.0,0,46,61,$white,$font,$Time);
imagettftext($im,8.0,0,47,86,$black,$font,$OldB);
imagettftext($im,8.0,0,46,84,$white,$font,$OldB);
imagettftext($im,8.0,0,50,109,$black,$font,$OldC);
imagettftext($im,8.0,0,49,107,$white,$font,$OldC);
imagettftext($im,8.0,0,154,86,$black,$font,$OldE);
imagettftext($im,8.0,0,153,84,$white,$font,$OldE);
imagettftext($im,8.0,0,168,109,$black,$font,$OldLe );
imagettftext($im,8.0,0,167,107,$white,$font,$OldLe );
imagettftext($im,8.0,0,7,128,$white,$font,$User);
header("Content-type: image/png");
imagepng($im);
imageDestroy($im);

hope this helps.

Raskolnikov
01-14-2008, 11:43 PM
But I mean how do I get the script to automatically save the image?

XcanadamanX
01-18-2008, 02:36 AM
imagepng($im,file);

im guessing you mean this?saves the picture to file

Daniel
01-18-2008, 07:16 AM
imagepng($im,file);

im guessing you mean this?saves the picture to file
This is also a thing that has puzzled me.

How can a picture change? Because i am very interested in learning this too.

XcanadamanX
01-18-2008, 12:58 PM
how can it change? maybe i dont understand because i just got up like 5 mins ago. could you rephrase it? do you mean how can you make it change or how does it change.

Raskolnikov
01-18-2008, 11:22 PM
I have a php 5 book and it has an appendix. The appendix holds most of the functions in php.

imagepng($im);

You see that it only has one parameter. I don't think you can save for some reason. Maybe there is a way to do it by accessing photobucket and doing it that way?

XcanadamanX
01-19-2008, 01:35 AM
go to php.net and look up imagepng

heres the link: http://ca3.php.net/manual/en/function.imagepng.php

Raskolnikov
01-24-2008, 05:15 AM
Oh, sorry. My book isn't that in depth :D. Hmm, still, something's wrong. I am using get and post but it isn't working. I have one webpage that has a form, then it sends to the other page. For some reason it isn't working. I tried the trim function too... Like I would use a get variable to put in the script id. Can someone give me the code to do that, soz, I'm a noob :(

Cut em2 it

XcanadamanX
01-24-2008, 01:11 PM
Get and Post? show me the code. ill see what i can come up with.

Raskolnikov
01-25-2008, 02:35 AM
MM, let me get it.

Edit: And I've tried both get and post...


<?
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
header('Content-type: image/png');
$that = $_GET["Script id"];
$that = ltrim($that);
$wherescript = "http://stats.srl-forums.com/index.php?action=view_script&id=".that;
$curlclient = curl_init($wherescript);
curl_setopt($curlclient, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($curlclient);
$logins = get_string_between($data, 'Logged In : <strong>', '</strong>');
$frogs = get_string_between($data, 'Frogs : <strong>', '</strong>');
if ($frogs == "") {
$frogs = "0";
}
$boxes = get_string_between($data, 'Boxes : <strong>', '</strong>');
if ($boxes == "") {
$boxes = "0";
}
$oldmen = get_string_between($data, 'Oldmen : <strong>', '</strong>');
if ($oldmen == " ") {
$oldmen = "0";
}
$worked = get_string_between($data, 'Worked : <strong>', '</strong>');
$name = get_string_between($data, 'Total Randoms Solved by ', '</td>');
$lastconnection = get_string_between($data, 'Last Connection : <strong>', '</strong>');
$im = imagecreatefrompng('http://i237.photobucket.com/albums/ff60/cut_em2/thing-1.png');
$color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 55, 6, $name, $color);
imagestring($im, 4, 11, 89, "Solved or encountered ".$oldmen." oldmen.", $color);
imagestring($im, 4, 11, 49, "Logged in ".$logins." times.", $color);
imagestring($im, 4, 11, 69, "Solved ".$boxes." boxes.", $color);
imagestring($im, 4, 11, 109, "Solved ".$frogs." frogs.", $color);
imagestring($im, 4, 11, 129, "Worked for".$worked, $color);
imagestring($im, 4, 11, 149, "Last con.: ".$lastconnection, $color);
imagepng($im);
imagedestroy($im);
echo("Your image has been saved at http://cutfiles.mygamesonline.org/". $that . ".png");
?>


This is the non-form one.

Here is the form one:


<form action="curltest.php" method="get">
Script Id: <input type="text" name="Script id" />
<input type="submit" />
</form>


Thanks,
Cut em2 it

XcanadamanX
01-25-2008, 07:00 PM
first thing i saw:

$wherescript = "http://stats.srl-forums.com/index.php?action=view_script&id=".that;
shouldnt it be

$wherescript = "http://stats.srl-forums.com/index.php?action=view_script&id=".$that;

and

imagepng($im);
should be

imagepng($im,"http://cutfiles.mygamesonline.org/". $that . ".png");

Raskolnikov
01-26-2008, 12:25 AM
Ahhh, whoops, let me check if it works now.