You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 [PHP] Basic IP Image Generation on Fri Feb 25, 2011 3:33 am

Nova

avatar
Member
Loading
My only request is that you use this to learn not just to leech source code off me and not obtain any knowledge.

Example:



Requirements:

• A host with an image library such as GD or ImageMick (110mb.com is a site that has GD already configured.)

Code:

<?php
Header("Content-Type: image/png");

// Get the IP Address
$IP = $_SERVER['REMOTE_ADDR'];

// Set image width and height
$Width = 250;
$Height = 20;

// Create the image resource
$Image = ImageCreate($Width, $Height);

// Color Variables
$Black = ImageColorAllocate($Image, 0, 0, 0);
$Red = ImageColorAllocate($Image, 255, 0, 0);

// Make the image background black
ImageFill($Image, 0, 0, $Black);

// Add the IP string to the image
ImageString($Image, 3, 43, 3, "Your IP is: $IP", $Red);

// Output the created image in png format
ImagePng($Image);

// Free up resources
ImageDestroy($Image);

?>

2 Re: [PHP] Basic IP Image Generation on Fri Feb 25, 2011 3:59 am

MurdaH

avatar
Spoiler
Loading
Can you add an image as the background? instead of making it black?

3 Re: [PHP] Basic IP Image Generation on Fri Feb 25, 2011 11:53 pm

Nova

avatar
Member
Loading
[You must be registered and logged in to see this link.] wrote:Can you add an image as the background? instead of making it black?

You can, as you see in my signature, it's a different method though.

4 Re: [PHP] Basic IP Image Generation on Sat Feb 26, 2011 5:57 pm

The Professor

avatar
Contributor
Loading
[You must be registered and logged in to see this link.] wrote:My only request is that you use this to learn not just to leech source code off me

Huh? I don't see what's there to "leech" from an image that displays a remote IP address. All in all, this is a pretty common PHP script.

Thanks anyways.
I might use this when I get into php soon.

5 Re: [PHP] Basic IP Image Generation on Sun Feb 27, 2011 4:35 am

Prince

avatar
Fresh Meat
Loading
omg he has my ip impossible

6 Re: [PHP] Basic IP Image Generation on Sun Feb 27, 2011 4:38 am

Prince

avatar
Fresh Meat
Loading
how can i use this in such a image like yours

7 Re: [PHP] Basic IP Image Generation on Sun Feb 27, 2011 5:31 am

RepBot1

avatar
Fresh Meat
Loading
[You must be registered and logged in to see this link.] wrote:omg he has my ip impossible

omg he has ur IP hes gonna 1337 h4x you!!!11
No but seriously, welcome to the Internet.

[You must be registered and logged in to see this link.] wrote:how can i use this in such a image like yours

MurdaH asked a similar question to this.
The topic name is "Basic IP Image Generation".
He won't be explaining how do so, in this thread at least.

Sponsored content


Loading

View previous topic View next topic Back to top  Message [Page 1 of 1]

Related topics

Permissions in this forum:
You cannot reply to topics in this forum