Click to See Complete Forum and Search --> : Simple IP detect script not working


Spamn
12-06-2003, 06:09 PM
I was trying to put a simple IP detect script into one of my web pages and it would not work. I looked it over hundreds of times. I asked tons of people and no one could figure out why it wouldln't work. Just for reference, here is the coding i used..

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var ip = '<!--#echo var="REMOTE_ADDR"-->';
alert("Your IP address is "+ip);
window.defaultStatus = "Your IP address is "+ip;
// End -->
</script>

Whenever you view the page, the message box pops up and reads Your IP address is <!--#echo var="REMOTE_ADDR"-->

Someone suggested that I try and download some kind of activex or java update. I looked and looked and looked and found nothing.

Then, I copied the code and went to geocities.com. I made an html page and pasted the coding into there. I tried it out, and it worked. So the problem can't be my coding, because it worked on the geocities server.

The server I was trying to host it on is my PC. I am running Apache and I host right out of port 80. For some reason, whenever I try and host that html page with that coding, it will not run that script. The exact page will work on geocities though..

I"m lost. Is there somthing I need to download in able for my serving system to be able to run those scripts?

I'd appreciate any help.

Thank you
Sam Beckring

fredmv
12-06-2003, 06:41 PM
That appears to be using SSI — does the file have a .shtml (or other associated) extension?

Spamn
12-06-2003, 07:51 PM
I have tried .html and .shtml

Neither work.
I went to geocities and put the exact same script into an html page and it worked. I don't get it.

Spamn
12-06-2003, 07:54 PM
Is there any way to do an IP detect without using SSI? I haven't seen any scripts that do that.

Bigjohn
12-06-2003, 07:55 PM
if you're testing it from a server on the same PC it may not be able to detect "remote_addr".

have you tried from another PC on the network?

John

Spamn
12-06-2003, 08:01 PM
I am hosting the site from my computer, from my house. I have DSL. I am the only computer. This script will not work for anyone who tries to view that page.

Here, have fun with my bandwidth..

www.gotoofast.com/blah.shtml

pyro
12-06-2003, 08:04 PM
SSI probably do not work on your server, then...

Spamn
12-06-2003, 08:06 PM
Is there any other way to do IP detect? Without using SSI?

pyro
12-06-2003, 08:12 PM
PHP, ASP, etc... All will require that the various language will be installed.

Spamn
12-06-2003, 08:16 PM
Sorry for my ignorance, but I am new to programming and coding. I just started HTML about two months ago. Can you eloborate or tell me where to get more information.

pyro
12-06-2003, 08:19 PM
What server are you using? If it is apache, I can explain how to enable SSI. If you want PHP, go to http://www.php.net/ and download PHP and then follow the installlation file.

Spamn
12-06-2003, 08:21 PM
It is indeed Apache. I believe the version I am running is 2.0.48

Thank you very much, Pyro.

pyro
12-06-2003, 08:29 PM
Ok, I'm running 1.3.29 (as PHP's support for 2.0.48 is currently "experimental"), but it should be the same or close.

Open your httpd.conf. Now, make sure that this line is uncommented (should be, as a default).

AddModule mod_include.c

Now, you want to put

Options +Includes

In a <Directory> section. I used this one:

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

Now, just look for these lines:

#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtmlMake sure they are uncommented, as shown above. Now just save the file and restart your server. .shtml files should now be parsed for SSI.

Spamn
12-06-2003, 08:41 PM
I don't know if it is because we are running different versions, or what, but I can't find that file. I'm sorry to make you eloborate so much, but pretend you are talking to someone that has no idea what you are talking about, because that's what I am.

Once I locate that file, how exactly do I modify it? You said "Now, you want to put Options +Includes"

Where exaclty do I put that?
I'm sorry, I'm just completely lost. If you could be more specific and tell me where and what to put, I would appreciate it. Again, I apologize for my ignorance.

Spamn
12-06-2003, 08:56 PM
I found the file and I understand what you are talking about except for ONE thing.. I cannot find that line. I don't know if if it's just because the versions are different.

pyro
12-06-2003, 10:26 PM
Which line can you not find?

Spamn
12-07-2003, 01:05 AM
You said to locate "AddModule mod_include.c" I cannot find that line.

htayC
12-08-2003, 05:22 PM
Hi Spamn, check out this site. It has many resources for different languages :D

http://www.w3schools.com

modifier_guy
12-08-2003, 11:53 PM
i tried to use it to but it dint work it does the same thing to spamm ? and i really wnat an IP logger

Spamn
12-10-2003, 10:36 AM
Ok.. 2.0.48 doesn't have mod_include. I downloaded 1.0.39 and now I have it, but I am not sure on what to do with it.

Where do I put Options +Includes

and where do I put <Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

pyro
12-10-2003, 10:58 AM
Originally posted by Spamn
and where do I put <Directory />
Options FollowSymLinks
AllowOverride None
</Directory> That (or something similar) should already be there. Add the Options +Includes to that section.

Spamn
12-12-2003, 03:08 PM
Ok... I got the older version and I changed the httpd.conf file. It still doesn't work. I made sure to restart the server afterwards. Here are the changes I made...


<Directory />
Options FollowSymLinks
AllowOverride None
Options +Includes
</Directory>


# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml

Is that all correct?

pyro
12-12-2003, 03:11 PM
Is this line uncommented:

AddModule mod_include.c

Spamn
12-12-2003, 03:24 PM
Yes, it was by default.

pyro
12-12-2003, 03:27 PM
Did you add Optoins +Includes to an existing <Directory /> section, or did you try to add a new one?

Spamn
12-12-2003, 04:09 PM
I added it to an existing one. This is EXACTLY what i did..

<Directory />
Options FollowSymLinks
AllowOverride None
Options +Includes
</Directory>

pyro
12-12-2003, 04:34 PM
Hmm... looks good. You did remember to restart the server, right?

Spamn
12-12-2003, 04:35 PM
Yep. I still get the same message when I try to run that IP Detect script. I know the scipt is correct...

pyro
12-12-2003, 04:37 PM
What was the error message? You did use a .shtml extention, right?

Spamn
12-12-2003, 04:40 PM
Yeah, it's .shtml

It is supposed to popup a message box that says
"Your IP Address is ##.##.###.###"

The numbers being the viiewer's IP address. Instead the message box says

"Your IP address is <!--#echo var="REMOTE_ADDR"-->"