A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: display user ip within swf ???

Hybrid View

  1. #1
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39

    display user ip within swf ???

    I built a dynamic text box in a swf and have the jss code to get the user ip but cannot make it display in the swf.
    Is there another way without java? Or a correct way with java ?


    This part gets the IP (in javascript)
    var ip = '<!--#echo var="REMOTE_ADDR"-->';

    Can this information EVEN be delivered to swf dynamic text box and displayed ?



    Thanx DjXtraktor,
    BlaZed and

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    If the ip variable is working in javascript you could use this to pass it on into the flash movie. Then have a dynamic textfield named ip to display it.

    Code:
    <script language="javascript">
    var ip = '<!--#echo var="REMOTE_ADDR"-->';
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width=550 height=300>');
    document.write('<param name=movie value="movie.swf?ip=' + ip + '"> <param name=quality value=high> <param name=bgcolor value=#ffffff> <param name="menu" value="false">');
    document.write('<embed src="movie.swf?ip=' + ip + '" quality=high bgcolor=#ffffff menu=false width=550 height=300 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
    document.write('</object>');
    </script>

  3. #3
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    make the post above appear...

  4. #4
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    When I added the code to the html, it produced a second copy of my swf file. My swf is named user_info, I changed the dynamic text box variable name to ip . I then removed the original code leaving the code you provided I still could not retieve the IP
    ------------------------------------------------------
    <SCRIPT LANGUAGE="JavaScript">
    // This part gets the IP
    var ip = '<!--#echo var="REMOTE_ADDR"-->';
    // This part is for an alert box
    alert("Your IP address is "+ip);
    // This part is for the status bar
    window.defaultStatus = "Your IP address is "+ip;
    // This part is for the title bar
    document.write("<title>Your IP address is "+ip+"</title>");
    // End -->
    </script>
    ------------------------------------------------------

    I don't want the alert box, status bar or title bar. What I would like to do is display the IP in the dynamic text box within the flash. So the ip will appear in my swf along side the time, date, flash version,...

    I can't thank you enough for your assistance,
    DjXtraKtor
    Still BlaZed and

  5. #5
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Replace the object and embed tags for your movie with this,

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    var ip = '<!--#echo var="REMOTE_ADDR"-->';
    document.write('<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width=550 height=300>');
    document.write('<param name=movie value="movie.swf?ip=' + ip + '"> <param name=quality value=high> <param name=bgcolor value=#ffffff> <param name="menu" value="false">');
    document.write('<embed src="movie.swf?ip=' + ip + '" quality=high bgcolor=#ffffff menu=false width=550 height=300 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
    document.write('</object>');
    // End -->
    </script>
    I've never tried finding the users ip address, but if the variable is being created okay, then this should pass it to the movie. Note to change any parameters in these tags to match your movie, eg #version=6,0,0,0 if you used flash mx.

  6. #6
    Newbie Forever It Seems Dar's Avatar
    Join Date
    Aug 2002
    Location
    Columbus,OH
    Posts
    218
    I tried the script above in a new document and uploaded it to server and it didnt work form me.

  7. #7
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    Thank You catbert303 for all your help.

    After inputting the code from you and uploading it I then had a scroll box in my text box. I now know how to use jss to pass text to a swf. With your help and a little more research I realized the var ip script doesn't work unless it is in shtml. It needs ssi. I am now going to try to figure out how shtml works.

    Again thank You for all your help.

    DjXtraKtor
    Last edited by djxtraktor; 10-22-2002 at 08:31 PM.
    My name is DjXtraKtoR,
    and I'm a FLASH-O-HOLIK
    BlaZed and

  8. #8
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    I was writing a reply to catbert303 when you posted. The page must be shtml, needs server-side info. I changed the name on the server to*.shtml and lost my swf.

    Thank You,
    DjXtraKtor
    Last edited by djxtraktor; 10-24-2002 at 12:21 AM.
    My name is DjXtraKtoR,
    and I'm a FLASH-O-HOLIK
    BlaZed and

  9. #9
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Have you considered using PHP or ASP (if your server supports them) I think you can get the IP address like this in PHP (v 4.1.0 and later, for earlier versions use $HTTP_SERVER_VARS['REMOTE_ADDR'])

    $_SERVER['REMOTE_ADDR'];

    Then you can edit the param name="movie" tag like this,

    <param name="movie" value="filename.swf?ip=<?php echo $_SERVER['REMOTE_ADDR'];
    ; ?>">

    and the embed src

    <embed src="filename.swf?ip=<?php echo $_SERVER['REMOTE_ADDR'];
    ; ?>" etc...

    and in ASP, through Request.ServerVariables("REMOTE_ADDR")

    <param name="movie" value="filename.swf?ip=<%= Request.ServerVariables("REMOTE_ADDR") %>">

    and again the embed src

    <embed src="filename.swf?ip=<%= Request.ServerVariables("REMOTE_ADDR") %>" etc...

  10. #10
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    I've been trying to figure out php since your last
    post. I followed the tutorial
    http://www.flashkit.com/tutorials/Ba...-776/more2.php
    I followed it to a T , but all my localhost links prompt you to "open from location" or "save to disk" ???
    Thank you , (once I figure out this php, and kill a few pints,
    I'll get that ip into that flash),
    DjXtraKtor
    My name is DjXtraKtoR,
    and I'm a FLASH-O-HOLIK
    BlaZed and

  11. #11
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Does this happen even when you try to open the default apache page from just

    http://localhost ?

  12. #12
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    No, I can access localhost it's every link after that.
    The apache_1.3.27-win32-x86-no_src server install was o.k.;
    I followed the config for the php-4.2.3 but the "test/exercise"
    in the tutorial

    http://www.flashkit.com/tutorials/Ba...-776/more4.php returned
    the prompt, When I chose "Open" it displayed the code

    <?
    phpinfo();
    ?>
    in the file PHPInfo.php ( not the info the code is supposed to display).
    The same result for all the test/exercises for mysql-3.23.49-win,
    and phpMyAdmin-2.3.2 . I uninstalled and reinstalled all the
    programs (following the tutorial installs) 3 times all with the same result.
    Before I turned in last night I emailed the man who posted the
    tutorial, hoping for some insight , but have not heard back yet.
    I am not grasping the php install config at all. I haven't had time to work
    on my project or read up on php I've spent 2 days trying to configure the php ?!?!?
    ----------------------------------------------------------------
    "C:\Program Files\Apache Group\Apache\htdocs\ " is where my index page is. (Localhost)

    "C:\Program Files\Apache Group\Apache\htdocs\PHPInfo.php" is in this folder

    "C:\Program Files\Apache Group\Apache\htdocs\TestSQL.php" is there as well.

    along with, "C:\Program Files\Apache Group\Apache\htdocs\Admin" the folder for phpMyAdmin.

    --------------------------------------------------------------------

    DjXtraKtor
    Last edited by djxtraktor; 10-26-2002 at 04:19 PM.
    My name is DjXtraKtoR,
    and I'm a FLASH-O-HOLIK
    BlaZed and

  13. #13
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    It looks like they're installin PHP as a module in apache, maybe you'd have more luck if you tried PHP as a CGI.

    First make a copy of the file php4ts.dll (it should be in C:\php\ or wherever you put PHP) and copy this to C:\windows\system

    Go back to the orginal version of your httpd.conf file and make a new backup (just in case) open a copy of this in your text editor and search for the word ScriptAlias you should find something a little like this, somewhere in the file

    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/"

    Here add the line

    ScriptAlias /php/ "C:/php/"

    Next find the word AddType in the file

    Below any comments in the file add the line

    AddType application/x-httpd-php .php

    finally find the action section of the file, it may look a little like this

    #
    # Action lets you define media types that will execute a script whenever
    # a matching file is called. This eliminates the need for repeated URL
    # pathnames for oft-used CGI file processors.
    # Format: Action media/type /cgi-script/location
    # Format: Action handler-name /cgi-script/location
    #

    Add the line

    Action application/x-httpd-php "/php/php.exe"

    Save the file and restart Apache, hopefully this will work

  14. #14
    Member
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    39
    After I followed your instructoins I clicked on the
    http://localhost/MyFolder/ and the contents appeared.
    It worked !!!

    I then dropped the apache manual in
    C:\Program Files\Apache Group\Apache\htdocs\MyFolder
    If I click on the "manual" folder link in
    http://localhost/MyFolder/I can veiw the contents,
    but if I type the url manually into my browser
    http://localhost/MyFolder/manual
    I http 500 error ?? I tryed to access http://localhost/MyFolder/MyMainPage.html
    The page loads but the swf will not?
    The http://localhost/PHPInfo.php comes up blank\white ( from the tutorial test\excercise) .
    Should I un/re-install php, MySQL, and phpMyAdmin ?

    Thanx for all of your assistance, I will be reading all these manuals and documentation today to see what I've done or not
    I can't wait to get back to my flash.
    Thanx Again,

    DjXtraKtor

    ( it's 4:29 am after rollback ' to be continued...)
    My name is DjXtraKtoR,
    and I'm a FLASH-O-HOLIK
    BlaZed and

  15. #15
    SaphuA mosterdfles_flash's Avatar
    Join Date
    Jan 2002
    Location
    Tha Couch
    Posts
    935

    hmm

    I kinda dont understand this

    Can I please get a.zip file of all this stuff (only the ip getting thing including .fla)
    'How Art Is The Visual While We’re Artificial…'

    Mail & MSN
    My Not Finisched Page!
    Nick: SaphuA

  16. #16
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Could it be a problem with where Apache is looking for the files? The default set up for your document root directory I think would be

    C:\Program Files\Apache Group\Apache\htdocs\

    You can change this in your httpd.conf file to point to any directory you want to keep your files in, for example if you made a folder in the htdocs folder called PHPstuff,

    C:\Program Files\Apache Group\Apache\htdocs\PHPstuff\

    Serach for DocumentRoot in the httpd.conf file, and change this to your directory (remember paths in Apache use /'s) eg,

    DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs/PHPstuff" then find the <Directory...> section it should have a comment like this just before it,

    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    So do what the comment says, and edit the <Directory ... line to

    <Directory "C:/Program Files/Apache Group/Apache/htdocs/PHPstuff">

    Hope this helps

  17. #17
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222

    Re: hmm

    Originally posted by mosterdfles_flash
    I kinda dont understand this :)

    Can I please get a.zip file of all this stuff (only the ip getting thing including .fla)
    There isn't really anything that happens in the fla file, all you need here is a dynamic textbox with the variable name ip to display the IP Address. The actual work goes on in the server side script, this finds the users IP Address and creates the variable ip in the movie containing the IP Address.

    Here is a quick test file I made

    Code:
    <HTML>
    <HEAD>
    <TITLE>test_ip</TITLE>
    </HEAD>
    <BODY bgcolor="#FFFFFF">
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
     WIDTH=500 HEIGHT=400>
     <PARAM NAME=movie VALUE="test_ip.swf?ip=<?php echo $_SERVER['REMOTE_ADDR']; ?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="test_ip.swf?ip=<?php echo $_SERVER['REMOTE_ADDR']; ?>" quality=high bgcolor=#FFFFFF  WIDTH=500 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
    </OBJECT>
    </BODY>
    </HTML>
    Save it as test_ip.php and edit the filenames (test_ip.swf) to the filename of your movie (make sure this movie has the dynamic textbox in)
    To run it you need a server that can run PHP files, if you test on a local server you should probably see the IP address 127.0.0.1 appear in the textfield (this IP Address refers to the local machine)

  18. #18
    SaphuA mosterdfles_flash's Avatar
    Join Date
    Jan 2002
    Location
    Tha Couch
    Posts
    935

    ???

    uuhh...

    * I've made a test_ip.php in notepad
    * I've made a test_ip.swf with dynamic textfield called 'ip'
    * I've uploaded both of them on my pafe
    * And when I test it, it's not working?

    http://members.lycos.nl/saphua/test_ip.swf
    'How Art Is The Visual While We’re Artificial…'

    Mail & MSN
    My Not Finisched Page!
    Nick: SaphuA

  19. #19
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Does your server support PHP?
    If it doesn't this worn't work. Also if they're running an old version of PHP your PHP file would need to look like

    Code:
    <HTML>
    <HEAD>
    <TITLE>test_ip</TITLE>
    </HEAD>
    <BODY bgcolor="#FFFFFF">
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
     WIDTH=500 HEIGHT=400>
     <PARAM NAME=movie VALUE="test_ip.swf?ip=<?php echo $HTTP_SERVER_VARS['REMOTE_ADDR']; ?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="test_ip.swf?ip=<?php echo $HTTP_SERVER_VARS['REMOTE_ADDR']; ?>" quality=high bgcolor=#FFFFFF  WIDTH=500 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
    </OBJECT>
    </BODY>
    </HTML>
    A link to just the swf file won't do anything, since the IP address variable is created by the PHP page the movie is embeded in.

  20. #20
    SaphuA mosterdfles_flash's Avatar
    Join Date
    Jan 2002
    Location
    Tha Couch
    Posts
    935

    ??

    Can you please just send me an .zip of the files I've to upload?... I just cant find what I'm doing wrong :S
    'How Art Is The Visual While We’re Artificial…'

    Mail & MSN
    My Not Finisched Page!
    Nick: SaphuA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center