While replying to this
https://xoops.org/modules/newbb/viewtopic.php?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:
Quote:
$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,102,102,153);
$textcolor = imagecolorallocate($img_number,255,255,255);
imagefill($img_number,0,0,$backcolor);
$number = " Your IP is $_SERVER[REMOTE_ADDR]";
Imagestring($img_number,10,5,5,$number,$textcolor);
header("Content-type: image/jpeg");
imagejpeg($img_number);
?>
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!):
Quote:
has been logged!
Action will be taken on any abuse on this system.
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,
25);
-> this pair represents the
X and
Y lengths
$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!