ted_chou12 Posted January 6, 2007 Share Posted January 6, 2007 My question is exactly as my subject, is there any way that we can use php to achieve that? Or the page which is included should only be within the same server?ThanksTed Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 ;)[code=php:0]if(end(explode("/",$_SERVER['PHP_SELF']))=="name_of_this_page.php") die();[/code] Quote Link to comment Share on other sites More sharing options...
emehrkay Posted January 6, 2007 Share Posted January 6, 2007 yes. people tend to keep their ini, class and whatever other important files out of the webroot Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 yeah, why didn't I think of that? That would certainly be a little easier to control ;D Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 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"?ThanksTed Quote Link to comment Share on other sites More sharing options...
emehrkay Posted January 6, 2007 Share Posted January 6, 2007 im sorry, i read the question wrong. Disregard my previous anwser because i really dont know the answer to your question. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 okay, thanks anyways. Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 sure, you could use file_get_contents(), but that will give you an html page that PHP rendered -- not the source code. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 Now we're getting somewhere. What specific function is not working? Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 mail. Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted January 6, 2007 Author Share Posted January 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
michaellunsford Posted January 6, 2007 Share Posted January 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.