FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Show People's IP In a Pic





SC__Programmer
This tut will show you how to make this...(without the site name,i make that by making it out of a pic)



Here's The Code:
Code:

<?php
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,0,0,0);
$textcolor = imagecolorallocate($img_number,255,255,255);

imagefill($img_number,0,0,$backcolor);
$ip = " Your IP Is $_SERVER[REMOTE_ADDR]";

Imagestring($img_number,10,5,5,$ip ,$textcolor);

header("Content-type: image/png");
imagepng($img_number);
?>


and thanks to mahirh heres how to make it into a .png pic Very Happy

Code:

1) Create A Folder And Call It Name.png

2) Make A File Named index.php Or Whatever Your Host Has For The Root File

3) Copy The Code Above And Paste It Into index.php

4) Navigate To The File http://yoursite.com/Name.png

If It Shows A Pic Then You've Done It Right!
Fire Boar
Incidentally, you can use .htaccess to tell PHP to parse a .jpg file. So you can put your PHP script in ip.jpg as a text file, and it would come out as a JPEG image.

Or you could use .htaccess mod_rewrite to rewrite requests for ip.jpg to ip.php. That's another way of doing it.
SC__Programmer
and can you explain how to do that?
jmraker
Through a rewrite rule (in .htaccess) which says when ip.jpg is requested treat it as if they typed ip.php
Code:
RewriteEngine On
RewriteRule ^ip.jpg$ ip.php [L]


Execute jpeg files as php (in .htaccess) which says treat all jpeg files as if they were php files
Code:
AddType application/x-httpd-php .jpg

or
Code:
AddType x-httpd-php .jpg

I wouldn't recommend the AddType one because if there's a other images someone could inject php into a comment or they might randomly contain a <? and it tries to execute the rest of the image and the image is sent corrupted
Fire Boar
What jmraker said. I'd recommend the AddType method only in a subdirectory - one which only contains images-that-are-PHP-scripts. AddType is a little cleaner if you have lots of images, and it doesn't require the mod_rewrite extension (which approximately 100% of servers have). Otherwise, RewriteRule is fine and probably the better option. RewriteRule might be better anyway, depending on what you're trying to achieve.
mahirh
Quote:
This forum doesnt support php pictures but websites and other forums will

this forum does , actually , i will explain:-
step 1
create a folder on your server with the extension of an image file
eg.- somerootfolder/img.png
step 2
now rename the script to index.php or default.php depending on your sever configurations and place it in the folder
step 3
try navigating into that folder through the internet to confirm it works
step 4
remove the forward slash at the end of the folder name so it reads like this
Code:
/img.png

step 5
embed it on frihost as well as the other phpbb forum which do have this kind of protection
eg-
Code:
[img]http://lualessons.frihost.org/ip.png[/img]

where ip.png is the folder
much, much simpler than the other options
SC__Programmer
thanks so much!just one more test....



if it works thats awesome Very Happy
cybersa
Thanks for the script.
Learning....
mahirh
well , the frihost rules say that these kinds of signatures in the frihost forums which show ip addresses may lead to bans... be careful . at least take the permission of a mod before using it as your signature
SC__Programmer
thanks for the tip,i must have missed that somewhere =\

i removed it from my sig,ill just put a link in it instead Wink
ogah
you also can make transparent background color
Code:

<?php
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,0,0,0);
$textcolor = imagecolorallocate($img_number,255,255,0);
$trans = imagecolorat($img_number, 0, 0);
imagecolortransparent($img_number, $trans);

imagefill($img_number,0,0,$backcolor);
$ip = " Your IP Is $_SERVER[REMOTE_ADDR]";

Imagestring($img_number,10,5,5,$ip ,$textcolor);


header("Content-type: image/png");
imagepng($img_number);
?>

you also can put other information like this
SC__Programmer
yeah,i dont really like the browser scripts because they are always wrong.everywhere i go to a browser script it says i have IE but i have Chrome =\
ogah
SC__Programmer wrote:
yeah,i dont really like the browser scripts because they are always wrong.everywhere i go to a browser script it says i have IE but i have Chrome =\


because you take browser information with javascript

if you take from php $_SERVER["HTTP_USER_AGENT"] you'll get true chrome user agent like this
Quote:

Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30
Related topics
Visitor ip PHP (E107)
a good Online photo albums...sharing with u
Pink Panther - The new pic.
CVS server on Windows
hoe krijg je een extern ip?
Sigs by AzTeK: 10 frih
What are your Firefox extensions
Dynamic Signature
Show ip adress from perl -script need help
IP Ban
Connect to a IP.
Firefox add ons
What is your favorite animal?
I just got a new Dog.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.