chris collins Posted April 15, 2006 Share Posted April 15, 2006 I am looking for a way to assign a unique image for each unique IP that visits my site, and display it on the page. This should be easy, correct? Of course, I am a newbie, so I wouldn't know. If someone could point me in the right direction :)Chris Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/ Share on other sites More sharing options...
Caesar Posted April 15, 2006 Share Posted April 15, 2006 If you are merely assigning images to predefined IP's (You already know the IP's you will be assigning the images to) then yes, it is very easy. Paste your code here and maybe we can help you implement it into your existing site. You can do this using only PHP...or you can use PHP/MySQL. Depends on how your site is set up and how you manage your site's visitors. Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/#findComment-27135 Share on other sites More sharing options...
chris collins Posted April 15, 2006 Author Share Posted April 15, 2006 [!--quoteo(post=364959:date=Apr 14 2006, 07:57 PM:name=Caesar)--][div class=\'quotetop\']QUOTE(Caesar @ Apr 14 2006, 07:57 PM) [snapback]364959[/snapback][/div][div class=\'quotemain\'][!--quotec--]If you are merely assigning images to predefined IP's (You already know the IP's you will be assigning the images to) then yes, it is very easy. Paste your code here and maybe we can help you implement it into your existing site. You can do this using only PHP...or you can use PHP/MySQL. Depends on how your site is set up and how you manage your site's visitors.[/quote]Right, I will have predefined IP's that I will be using. I really haven't created any code yet. I plan to display the images into table cells or something. I'd rather use only PHP if possible, although I can create a database if necessary.... Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/#findComment-27141 Share on other sites More sharing options...
chris collins Posted April 15, 2006 Author Share Posted April 15, 2006 OK here is the script I want to use, if possible:[code]<?php$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);?>[/code]and it is called with this:[code]<img src="http://yoursite/image.php" border="1">[/code]Instead of displaying the IP of the person viewing the page (which I want it to do as well), I want each IP associated with a picture, which I will set up. What do you all think?Chris Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/#findComment-27277 Share on other sites More sharing options...
redbullmarky Posted April 15, 2006 Share Posted April 15, 2006 you could have an array of IP's/images. so:[code]<?php// extend this array for all your ip's+corresponding images.$ip2img = array("123.456.789.012"=>"an_image.jpg", "200.123.150.234"=>"another_image.jpg");$ip = $_SERVER['REMOTE_ADDR'];$file = $ip2img[$ip];$img_number = imagecreatefromjpeg($file);$number = " Your IP is $_SERVER[REMOTE_ADDR]";Imagestring($img_number,10,5,5,$number,$textcolor);header("Content-type: image/jpeg");imagejpeg($img_number);?>[/code]obviously this is not exactly how you want the code, as i'm not 100% sure what you need, but it should get you started.cheersMark Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/#findComment-27281 Share on other sites More sharing options...
chris collins Posted April 15, 2006 Author Share Posted April 15, 2006 [!--quoteo(post=365111:date=Apr 15 2006, 11:41 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 15 2006, 11:41 AM) [snapback]365111[/snapback][/div][div class=\'quotemain\'][!--quotec--]you could have an array of IP's/images. so:[code]<?php// extend this array for all your ip's+corresponding images.$ip2img = array("123.456.789.012"=>"an_image.jpg", "200.123.150.234"=>"another_image.jpg");$ip = $_SERVER['REMOTE_ADDR'];$file = $ip2img[$ip];$img_number = imagecreatefromjpeg($file);$number = " Your IP is $_SERVER[REMOTE_ADDR]";Imagestring($img_number,10,5,5,$number,$textcolor);header("Content-type: image/jpeg");imagejpeg($img_number);?>[/code]obviously this is not exactly how you want the code, as i'm not 100% sure what you need, but it should get you started.cheersMark[/quote]Thanks Mark, I'll see what I can do with that :) Quote Link to comment https://forums.phpfreaks.com/topic/7449-ip-addressimage-combo/#findComment-27289 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.