I am trying to find the IP address using as3 in adobe Flash professional cs5.5 and I think it is not possible from AS3 without using any server side technology(maybe I am wrong).
But I don't know any server side technology like PHP..etc.
Can anyone provide an example?
you can get the Local Machine using JavaScript. and also you can develop server side script which will retirve your local machine IP address from request header.
But as per your comments on your question I think you required your local machine IP. it will be get using javascript. But this IP address is not gateway or server side displayed one. Because in home or some fire wall / proxy user has different IP to access internet and local mahcine ip will be LAN IP.
and Javascript code you can call using the External Interface.
Please search for Javascript and ExternInterface code example you will find out many code example through google.
There's a simple and clean way to dynamically get the domain name, but not the IP, of the server hosting the SWF file.
You can use the domain property of the LocalConnection class.
try:
import flash.net.LocalConnection;
var lc:LocalConnection = new LocalConnection();
trace(lc.domain); // Outputs domain name of the hosting server, or `localhost` if ran locally.
Related
Scenario:
My company network has a machines with dedicated IP address. When we enter each IP on our browser within the company network, it takes us to the machine diagnostic page. What i am trying to accomplish is to access these machines remotely from our webserver. I tried adding a link on our website with 10.116.192.5 and it obviously didnt take me to the machine because i was out of that network. Is there anyway i can access these IP on my office network through our website?
I tried using cURL but that does not work with java applet. So i am trying to find an alternate solution to it.
Would using iframe work in this scenario?
Rephrasing the scenario: Trying to redirect our website URL to point to an internal IP address URL. So for instance, if a client types www.scada.example.net/userinfo on browser, this would redirect on the server side internally to x.x.x.x and display on the client side as www.scada.example.net/userinfo.
I want to send a value from my website to my arduino using httprequest.
as the image explain, i want to enter my site from a device (let's say mobile phone) and send a request to my arduino from my website (webserver)
so i'm having this problems:
1- how to address the arduino without dns, should i have a fixed ip address for my arduino, is there any way else ?
2- what is the PHP code that i need to let the website send the request ??
i know i can connect arduino to web using httpclient, but i want the reverse process, that is connect the website to arduino ( the website as client and a arduino as a server)
is there anyway to do that ?
thank you and sorry for my bad english
I've recently made a similar project with a Raspberry Pi. But this doesn't make a difference.
First be careful with my solution. Anybody can join on your device, if they have your IP and Port. It might be not the best solution, but it works pretty good.
So what I did is, I've set a DynDNS to my router, so that I doesn't have to change the IP in my script every time. You can get a DynDNS from your provider or you can use the free service No-IP. Next I set a static local IP adress to my arduino/pi via the settings on my router. Then I also set port-forwarding to the arduino/pi.
Then you should be able to access your arduino/pi via the internet. And if you have this, you can also control it via any website you want.
To accomplish an HTTP request in PHP, there will be a lot of possible solutions. But I prefer this:
$response = file_get_contents(YOUR_DYNDNSIP_AND_PORT)
https://www.w3schools.com/php/func_filesystem_file_get_contents.asp
You also can additionally can get a response via this function.
To protect your own network, you can use HTTP Basic Authentication, which you have to add a username and a password to the request. This make it difficulter to access your arduino.
I hope this might help you.
I would try to explain in diagrams
[REST SERVER] <--------> [JAVASCRIPT BASED WEBSITE] <--------> [USER]
192.168.0.2 192.168.0.3 192.168.0.123
How can I get the IP of the website that consumes the REST server instead of the USER's IP.
I tried using $_SERVER['REMOTE_ADDR'] and $_SERVER['HTTP_REFERRER'] but they both return the IP of the user.
Is it possible in the web? I'm using PHP for my REST server.
I'll assume here that you mean the website is hosted on 192.168.0.3. This means the user will be downloading the Javascript and HTML data from said server, and then execute it locally on 192.168.0.123. That Javascript is then going to make remote calls to the REST service from that local IP.
You want to know how to get the IP of the server that hosted the Javascript/HTML files before the client downloaded them, presumably in a reliable fashion. And the answer is that this is not possible. Because your actual schema looks like this:
[JAVASCRIPT BASED WEBSITE] <--------> [USER]
192.168.0.3 192.168.0.123
^
|
[REST SERVER] <--------------------------+
192.168.0.2
You cannot do this securely. You will have to make the javascript pass this to the server. And since javascript is run client side, this can be spoofed.
And even then, javascript does not have native functions to get you the IP address of the website. It can give you the domain name though. And then in, for example, PHP you can resolve this domain name to an IP address. Or have the javascript based web server give its IP address directly along. For example with the help of PHP, you can do in javascript: var myIP = '<?php echo $_SERVER['SERVER_ADDR']; ?>';
As a sidenote, the Origin header (can be spoofed) is ment for this purpose but a secure workaround would be some kind of handshake between JS server and REST server.
Javascript based webpage requests a token code via serverside, you put this token code into the javascript and send it to the rest server.
The rest server verifies the token code and then you know for sure where the javascript resides.
This is the only method of verifying the origin, it is not possible via plain IP addresses.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can a server find real client IP address?
I need to let my users find very quickly and easily their local (LAN) ip.
Our network has a squid proxy so all the users sit behind it (and this is a problem for internal ip detection: all php scrips I've tried are able - at best - to detect proxy's ip and not client's).
Any kind of language working on a LAMP server is welcome...
Also a simple EXE file on Windows could work as "plan b" but I couldn't find anything working.
Following #German Arlington's answer, I think your best bet is configuring Squid to send the X-Forwarded-For header along with HTTP requests:
If set to "on", Squid will append your client's IP address in the HTTP
requests it forwards. By default it looks like:
X-Forwarded-For: 192.1.2.3
Then you will be able to read the ip address in PHP via apache_request_headers()
<?php
$headers = apache_request_headers();
echo $headers["X-Forwarded-For"];
?>
Consider java applet loaded in browser.
Since java uses its own virtual environment, it will be able to show local Ip address to the clients.
Good way to start i guess -> http://reglos.de/myaddress/MyAddress.html
And for Java to obtain IP: How can i check System IP Address/Host Name in Java?
This way you wont have to change current environment. Otherwise it will probably involve squid reconfiguration.
From the comments you have posted i can see that the purpose of presenting the IP to the client is to make them read it to you and allow you to connect remotely. You have also mentioned that running an app on a client side is an option. This immediately pushed me towards BGInfo http://technet.microsoft.com/en-us/sysinternals/bb897557.aspx - especially if the clients operating system is Windows.
The easy Java aplet to put on a page:
function myIP(){ var vi="uses java to get the users local ip number"
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
return yip;
}//end myIP
alert("your machine's local network IP is "+ myIP())
You may be interested in
http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html
and generally in http headers that should contain the information you are looking for
i have php files on my computer and i can very well access those from IIS using eighter localhost or loop-back address . But now if i want to access the same file of php from another computer not in the LAN but in a different computer on the internet what should i do? i was thinking of IP address(static) as an option but then i was not successful in finding a way to do the same .
thanks in advance....
I don't completely understand your question. Is your problem
1) You don't have a static IP? Then:
There are services as "No-IP" where you can create redirects. At their site, you can create a free domain name (which is a static IP as well) such as yourdomain.no-ip.com. Then on your server computer you can run their tool. This tool updates the IP all the time so it will be always correct.
2) You don't know how to access the server from out of the LAN because the IP of your network is the same for all computers (if you're looking from the outside)? Then:
Check your router settings, normally at: http://192.168.1.1. There you will be able to define rules how to redirect requests from the outside. For http, you should redirect requests to port 80 to the IP of the server computer (note: you can even use an other port on the server computer)!