/    Sign up×
Community /Pin to ProfileBookmark

include $_SERVER issue

Hi guys – see below for code. here’s what I’m trying to do – I want to redirect the template of contact.php to other template file on different server. How do I do that??

[CODE]<?php
include $_SERVER[‘DOCUMENT_ROOT’].”/Templates/contact.php”;
openhead();
?>[/CODE]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 29.2009 — Firstly, include()-ing a file from another server is [i]very[/i] dangerous unless you have complete control of the file being included from that server. It can be done by using a URL instead of a file path, [b]if[/b] your host has the [url=http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include]allow_url_include[/url] configuration option enabled (which is generally a bad idea because of the above-mentioned security issues). And after all that, even if you can include it, if the remote server treats it as a PHP file and parses and executes it there, all your calling file would receive is any output generated by it -- it is not the same thing as including from the local file system in that case.

If you do not truly need to include it (process it as PHP code) but just need the output from it, you might be better served to grab the output from it via the cURL functions, and then echo the result. (Or you can use file_get_contents() if your host has allow_url_fopen enabled, though that may be less portable due to that configuration issue.)
Copy linkTweet thisAlerts:
@JiroauthorJan 29.2009 — Firstly, include()-ing a file from another server is [i]very[/i] dangerous unless you have complete control of the file being included from that server. It can be done by using a URL instead of a file path, [b]if[/b] your host has the [url=http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include]allow_url_include[/url] configuration option enabled (which is generally a bad idea because of the above-mentioned security issues). And after all that, even if you can include it, if the remote server treats it as a PHP file and parses and executes it there, all your calling file would receive is any output generated by it -- it is not the same thing as including from the local file system in that case.

If you do not truly need to include it (process it as PHP code) but just need the output from it, you might be better served to grab the output from it via the cURL functions, and then echo the result. (Or you can use file_get_contents() if your host has allow_url_fopen enabled, though that may be less portable due to that configuration issue.)[/QUOTE]


yes I do have control on both servers. One is for LIVE and other is for DEV.
Copy linkTweet thisAlerts:
@NogDogJan 29.2009 — Does the file that you want to include have PHP code in it that needs to be processed by the including file? If so you'll probably have to give it a non-php file suffix so that the server does not parse it, but rather just serves up the un-parsed source code. This, of course, has obvious security implications if there's anything in that source code you don't want a 3rd party to see and that server is accessible via HTTP by such 3rd parties.
Copy linkTweet thisAlerts:
@JiroauthorJan 29.2009 — Does the file that you want to include have PHP code in it that needs to be processed by the including file? If so you'll probably have to give it a non-php file suffix so that the server does not parse it, but rather just serves up the un-parsed source code. This, of course, has obvious security implications if there's anything in that source code you don't want a 3rd party to see and that server is accessible via HTTP by such 3rd parties.[/QUOTE]

yes it does. It's a regular template header file.
×

Success!

Help @Jiro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...