Jump to content

Is it possible to include/require a page that cannot be linked by relative path?


ted_chou12

Recommended Posts

I dont think i have the control of ini file but maybe i can try this:
if(end(explode("/",$_SERVER['PHP_SELF']))=="name_of_this_page.php") die();
but i dont understand it very much, if the page I am trying to include is http://test.com/test.php and my current page is http://test2.com/test.php, does it work for this eg? because both of them are in completely two different servers... and where would I put my url in? Instead of this "name_of_this_page.php"?
Thanks
Ted
Link to comment
Share on other sites

The code I provided detects the current file's filename. If the file is called directly, the filename is the same as that file's name (confused?). If it's "included" it will take on the calling file's name instead.

The bad news is I don't believe you can [code=php:0]include[/code] a file from another server. It would need to be on the local system.

Now, let me rephrase your original question to see if I have it right.
Can you display the contents of a remote web page on a different server?
Can you prevent anyone from directly accessing the original page?

let me know if that's what you want to know, or if I'm way off.
Link to comment
Share on other sites

em... I think the first one sounds more like it, I am not sure about the second one, I think you got my point, what I want to do is to include a php page of a foreign server, not a local one, so the page can only be located through a url address like "http://..." instead of a relative path such as "../images/type.php".
Do you get me?
Thanks
Link to comment
Share on other sites

so what you mean by that is file_get_contents() will only get the contents of that page, but does not run the php code, so its no different to a storage of text?
but I need to run something on a different server because my current one does not support a specific function.
Ted
Link to comment
Share on other sites

I was trying to get the url to send the variables and use header location to redirect the page in order to send mail through somewhere else, but header location is in the way, I dont know why it doesnt redirect, other than that, everything else should be fine... So I thought include or require might be another way to get through this, but it seems harder :-\
Ted
Link to comment
Share on other sites

well, depending on what you're trying to do, there are options. For example, most systems have some kind of public sendmail somewhere on the system. You might have to post a form to their controled environment. Just check with the admins.

If they don't allow mail -- you could hack it with a curl script or something, but it's probably easier to just switch hosts.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.