Hi all,

ok this is quite general in a sense but there's no other approperiate forum to put this so here goes:

When thinking how the langauges resolve IP when given a hostname, am I right to say that client-side languages like javascript uses the local computer's host file and then DNS, while server-side lanauges like PHP uses the server's host file and DNS?

as in http://sg2.php.net/gethostbyaddr and http://sg2.php.net/gethostbyname?

in a shared hosting environment, is it possible to create a host file only for individual user for linux and windows environment? such that the above php functions returns the values in the host file?

many thanks in advance.

Regards
Jake

Hosts configuration file have global scope -address translation for any user- and it is stored on one location e.g. /etc/hosts, for that reason you cannot create individual configuration files. For example, it is possible to build a script to delete that file and copy the file suitable for that user, that change will affect every user on that server. By the way, hosts file only contain IP numbers and host names, there isn't a way to put user names there.

Thanks for your answer. =)

By the way, hosts file only contain IP numbers and host names, there isn't a way to put user names there.

I was only thinking maybe there's a way to put an overriding host file in .../usr/etc/hosts so that the system checks there before the global one.

Anyway, would we good to know why you want to access a host file. If you want to block some domains you can do it directly from .htaccess files.

Anyway, would we good to know why you want to access a host file. If you want to block some domains you can do it directly from .htaccess files.

initially i needed to block out access to some websites on the local windows systems, hence I used the host file method to "alter" the IP addresses. (i do not know any other way)

then I began thinking more about it and wonder if it is possible to "spoof" domain IPs resolved by client side or server side languages.

I think you cannot use Javascript to access local files by default, that would be the law of the jungle, a giant security hole... easy to spoof or block client domains, phishing and browser hijacking would be everyday issue for many users.

Today, Internet Explorer have security levels and some topics like ActiveX execution is into a more controlled ambient, disabled by default or prompting to user some confirmation.

For that reason, ActiveX from Javascript less used today.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.