access xml website without domain name - php

I have problems accessing pages on xml without domain (access ip address directly)
this is my ip address : http://107.170.117.8/
this is xml page that i want to access : http://107.170.117.8/xml-reference/index.xml
i want to access directly xml without domain, but it seems can't.
So, is there anyway i can access xml page without domain?

If you can access a site via a domain name, but not an ip address, there may be a few reasons:
you might have the wrong ip address. It's common for a webserver to have multiple ip addresses.
the server might be configured to be using name based virtual hosts. This is probably the issue.
less commonly, the server might be using ipv6
The answer is within your question: use the domain.

Related

Why am i getting different ip by using get content - PHP

So why am I need my own ip by using get content? I want to use some tv channels which is m3u8 file and using m3u8?wmsAuthSign=code
wmsAuthSign code is changing everytime the page refresh it self and they are getting ip adrress inside of that code.
So i can't play the tv channel by my servers ip !
the code i gave down below is just an example :D
<?php
$myURL = "https://whatismyipaddress.com/ip-lookup";
$lines = file($myURL);
echo $lines[145];
?>
Is there any way that i can change it to my one ip adresse?
If you mean the client (browsers) IP:
That code is being executed on your server, so the machine fetching that URL is your server. The response then has your server's IP address.
If you want to get the IP address of the user that's accessing the server, you could use some of the $_SERVER variables (like $_SERVER['REMOTE_ADDR']) but due to the way the internet works, that may not be the user's IP address.
Your best bet there is to use javascript that runs on the user's browser to identify the user's IP address - though, since that is really under the user's control, you can't be certain it's accurate either.
If you mean you're getting the IP of a different server, not your web server: the method you're using only determines the IP address of the server acting as a gateway to the greater internet. If your web server is behind a firewall, you'll be getting the IP of the firewall. You may want to identify the web server's local IP address instead.
Because the server is executing the PHP code and is requesting the website, if you want to get the IP address of the current user see How to get the client IP address in PHP?

PHP: gethostbyaddr() returning an invalid url

I'm working a PHP script to try and resolve a vague URL (for example typing in facebook.com) as an absolute url (such as https://www.facebook.com); similar to what your browser does on a daily basis using PHP.
So far I've got the following code:
$link = gethostbyname("facebook.com");
This provides an IPV4 address, which works, but then when I reverse lookup using:
$link2 = gethostbyaddr($link);
I'm expecting to receive a valid URL like "https://www.facebook.com", but instead, I get garbage such as "'edge-star-mini-shv-13-atn1.facebook.com'"
This then breaks any hope of using fopen or curl to try and read the contents of the webpage.
Can anyone explain what's gone wrong here and how I can resolve it?
EDIT: Attempting an insecure URL like "google.co.uk" returns "'lhr25s10-in-f3.1e100.net'", so it's not something to do with secure HTTP (HTTPS)
gethostbyaddr gets a hostname, not a URL, for an IP address.
Multiple hostnames can be assigned to a single IP address.
gethostbyaddr will get the default one.
An HTTP server listening on that IP address will handle requests to all the hostnames.
An HTTP request includes a request header called Host which specifies which hostname you are asking for.
The HTTP server can pay attention to that header and serve up different content for different hostnames. This allows multiple websites to be hosted on a single IP address. This is very useful since IPv4 addresses are in limited supply and there are many, many websites.
You are getting the default hostname for the computer hosting facebook.com, but the webserver isn't hosting the website you want on that hostname.

viewing PHP file is restricted by IP (My IP), is there a way someone else to view it?

I have website and have one page for receiving some news (newly registered users, activity, etc.) and is restricted for everyone except for my IP (Page for only me to view).
I'm interested if there is a way that someone else can "fake" my IP and view this file?
P.S. I am aware of other ways of doing this.
Usually, you dont get fixed IPs, most provider give dynamic IPs. So if you restart your Router, your IP will change and make it impossible to access the page again. If you get a fixed IP, it should work. He can ofc. modify the IP, but then he wont get the response back.
Converting my comments to an answer.
It depends on how you are trying to get the client's IP address. If you are:
only using $_SERVER['REMOTE_ADDR'] to get the ip address
don't have a shared ip address
don't use a (shared) proxy
You should be just fine, because a possible attacker can technically spoof the ip address, but that would not work because, (as Andrey) rightfully pointed out to me the tcp handshake would simply fail.
Some caveats:
Your IP may change at some point effectively locking yourself out.
When you are behind a proxy / internal -> external router / vpn / otherwise shared ip other people in the same network might also have access
Never ever ever use $_SERVER['HTTP_X_FORWARDED_FOR '] because this can be spoofed easily.

Determining if a html request comes from inside the office using PHP

I am wondering about a certain server setup.
Lets say I have a web server running on my local network, which is accessible using an url such as www.example.com from within and also outside the network.
I would like my PHP website to be able to determine if a request comes from within the internal LAN or from the outside. I doubt that this will be possible using the IP address as the request will look as if it is coming from a public IP address, and not the internal one 192.168.x.x. Also the public IP might change from time to time.
Would this be possible, and how could i achieve this in PHP?
If your requests comes from inside the lan then the $_SERVER['REMOTE_ADDR'] will be from a private ip address group, if if comes from outside the lan it will not.
Unless you have a poorly configured internal network, but this will probably not be the case.
look here for the correct address groups
http://en.wikipedia.org/wiki/Private_network
If your internal dns server resolves example.com to the public ip then the requests will appear to come from the public ip as well, so if this is the case you also know that the request came from inside.
As long as you know what the external NAT IP range is for your office, you should be able to do this easily be accessing the $_SERVER['REMOTE_ADDR'] value.

PHP hosting and URL display

I have a site using PHP and MySQL. I have a domain name reserved by a domain name provider. I do not want to use the storage proposed by that provider to store my files, because it's really too expensive.
Let's say the domain name is : www.domainname.com
So... If I choose another provider (let's imagine it's free.fr) to store my site's files, what may I do, or what may I look for, to be able to have in my url bar :
http://www.domainname.com/onefolder/onegreatfile.php
instead of :
http://imhere.free.fr/innerfreefrfolder/onefolder/onegreatfile.php
If I activate the transparent redirection on my domain name, the url keeps being :
http://www.domainname.com
If I force the url bar to go to http://www.domainname.com/onefolder/onegreatfile.php
it returns a 404 not found error (The requested URL /onefolder/onegreatfile.php was not found on this server.)
The following is an oversimplification but it should be enough to get you where you need to go:
You'll want to sign up with a web host that allows you to use your domain name with their server. They will tell you what to set your name servers to so that any requests for www.domainname.com will result in the ip address of the server your files are stored on. Setting the name servers for your domain is usually done via a service provided by your registrar.
The transparent redirection you're referring to (some hosting sites call it Forwarding with Masking) is really just your hosted files displaying within an iframe on your owned domain name.
What you really need to look into is setting the DNS servers/Nameservers for your domain name to point to your hosted website/IP address.

Categories