Click to See Complete Forum and Search --> : Checking for access


SanderK
05-09-2006, 09:55 AM
Hi,

When requiring files, the required files usually have a if(!defined('FOO')) or some other code at the top to check if the file can be accessed. This is so that people can't directly access the files and break something.

Anyway, lately I've been trying out the new web-hype, Ajax. I've managed to create a script that updates a news item without having to reload the page. The thing is, I'm accessing this 'edit.php' file to make the database changes, but the 'define' method as mentioned won't work. When I define a variable in the first file and then use the XMLHTTPRequest to access another file, the accessed file won't find the variable defined. Using POST or GET to check for validity also isn't an option since everyone can see the Javascript files.

So, how are you supposed to know your files are being accessed with XMLHTTPRequest, and thus giving it access?

Thanks.

Huevoos
05-09-2006, 10:08 AM
you don't what I do is create a new file, include the functions lib and just call the function you need for the xm......est
I don't knowo if I'm being clear

chazzy
05-09-2006, 12:12 PM
So, how are you supposed to know your files are being accessed with XMLHTTPRequest, and thus giving it access?

Thanks.

To be honest, I'm not sure what you're asking. Are you trying to find out if a user can access a file or something else? if PHP can access the file, then php will access the file. should have nothing to do with having define in your code, that just checks if a variable/keyword is already defined. you can try to include external resources as well.