Posted on: 2004/9/19 13:22
IP display hack
While replying to this https://xoops.org/modules/newbb/viewto ... hp?forum=7&topic_id=24674
, I came across a neat solution, to display a users IP on a page, by creating an image that displays the text "Your IP is xxx.xxx.xxx.xxx"
, using a PHP script, which I found on a web page, supposedly belonging to a MikeVL
1- create a file in /root/modules/contact/
and name it something like ipdisplay.php
Place the following code into the file:
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,102,102,153);
$textcolor = imagecolorallocate($img_number,255,255,255);
$number = " Your IP is $_SERVER[REMOTE_ADDR]";
2- Open the following template file in an editor /root/modules/contact/templates/contact_contactusform.html
In this file you will place an img-tag, using the ipdisplay.php file as source
Place the following in an apropriate location (though you might want to change the notification text!):
3- Go to Sys Admin -> Moudles, and update the contact module
Et voila! You should now be able to view the result.Making Changes to the PHP created Image
$img_number = imagecreate(275
-> this pair represents the X
$backcolor = imagecolorallocate($img_number,102,102,153
$textcolor = imagecolorallocate($img_number,255,255,255
-> these tupples are hex-colors (255,255,255=white;0,0,0=black)
To create a border around the image, for a more prominent look, one just needs to add this style attribute to the img tag: style="border:1px outset #000044; vertical-align:middle;"
I have implemented this hack with the contact+ module, but it can be applied with any module really (news, wiki, blog, forums, etc...).
Hope this might be of interest to a fellow XOOPser!