Detecting IP-address

:cool: How do i detect the IP address of the one that’s visiting my web-site? Is there a way? Please help

you can’t do it in flash on its own, you’ll need a little PHP or ASP.
With php the command is:

$HTTP_SERVER_VARS[“REMOTE_ADDR”]

let me know if you need more info

What’s the differnce from the loadSound(path,value)? If value is true or false? Does it make a differnece and what is the most reccomended on the internet?

if you have value set to true, the sound you load will stream. That is the sound will begin playing before it has finished loading. If you have the value set to false flash waits for the sound to load completely before it begins playing it.

Its useful to have it set to true for large/long sounds as you won’t have to wait ages while the whole file is downloaded for it to begin playing

Thanks a lot for everything, and are you sure there’s no way of detecting the Ip-address in Flash MX?

yeah 100% sure :nerd:

Ok, thanks, but i don’t have PHP where can i get it?

PHP is a free language, but it isn’t much good to you as it needs to be installed on your server. Check with your site hosts to find out if they have it installed on your server. Anyone can write a php script, all you need to do is create a new textfile and change its extension from .txt to .php and then open it up in notepad or similar. This is the php script that’ll return a users IP for you:


<?

print "IP=$HTTP_SERVER_VARS["REMOTE_ADDR"]";

?>

save this to a file called IPReturn.php

if you create a new flash movie with a dynamic textfield on the stage with variable named ‘IP’. In the first frame put:
this.loadVariables(“IPReturn.php”);

now if you upload your movie and php script to a web server with php installed when you access the movie it’ll display your IP address in the dynamic textfield

if you want an introduction to php try posting in the Server-Side/Scripting forum for expert advice

Thanks a lot, when i finish my web site- in about a month, please come: www.NikiniWebDesign.go.ro, it will be made in flash mx, aniway, now, can you please help me on how to save that ip into a text file and later to check for it in the same text file

you can save ip’s to a textfile with php. This is the script to do it:

<?
$filename = “Log.txt”;
$fp = fopen($filename, “a”);
$IP = $_SERVER[“REMOTE_ADDR”];
$DateStamp = date(“F j, Y, g:i a”);
$Log = $HTTP_SERVER_VARS[“REMOTE_ADDR”] . " visited on " . $DateStamp . "
";
fputs($fp, $Log);
fclose($fp);
?>

which saves each visitors IP and the date and time (according to the server) to a text file called Log.txt, to run this script from flash you’d use loadVariables or loadVariablesNum as before

Ok, thanks a lot, now please tell me how do i check if an ip has came before? and if you please, can you please tell me the whole code to write and where to write?

there’s an easier way to detect if someone has visited before, and that is to use a sharedObject which works like a cookie, saving a small file on the users computer.

Put this script in the first frame of your movie:


Cookie = sharedObject.getLocal("VisitCheck");
if(Cookie.data.Check) {
      // this code is executed on revisiting the site
}else {
      // this code is executed on the first visit
}
_root.Cookie.data.Check = true;
_root.Cookie.flush();

hope this helps

You have just become my best friend, thanks a lot…, if you need some help and i can possibly help you then tell me how…

heh heh, no problem
glad I could be a help :wink:

God, thanks a lot, i tested the code, and it works, how can i save for the new users a name and if they visit again they already have a name

you can save anything you like to the sharedObject, all data is accessed through the data method:

if you had a variable ‘Name’ that the user has entered their name into you would save it to the cookie like this:


// note the cookie has already been loaded using
// Cookie = sharedObject.getLocal("VisitCheck");
Cookie.data.Name = Name;

and recalling it is just as easy:


SavedName = Cookie.data.Name;

if no name has been saved SavedName will be set to undefined

sorry, when I do what you has said, the php file doesn’t work --> the flash file doen’t work too

It erro:
Parse error: parse error, unexpected ‘"’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/local/psa/home/vhosts/u2u.us/httpdocs/portal/counter.php on line

http://www.u2u.us/portal/counter.php

how do I fix it ? thanks

ok, well the php really doen not work, it’s true, but the flash thing works, really does…but i’m till searching for a method to detect the ip address directly from flash, there simply has to be a way… i think

hix, it doesn’t work too, http://www.u2u.us/portal/counter.swf
can I get your sample source please ?