Include function across servers
Include function across servers
am 02.04.2007 15:53:33 von John Dillon
I ask this as I do not have two web sites on different servers to test
at the moment.
Does it work to use an include function in the php code on one site that
calls a function on the other site? If you include a file on a remote
server that runs a function, where does the function run - on the server
where the function is originally written or on the calling server? I am
thinking that if I write code, it is one way to make the functionality
available without actually disposing of the source code itself.
So the included functions might be variable values. Eg you could pass
back a whole calendar to the calling server, which then just prints on
the calling web site just by printing the returned variable. (I know
that in terms of getting data to mark up the calendar the database would
need to be fully referenced: user, password, server, and the calling
(shared) host for instance will ask for the remote IP address to add to
a white list.)
John
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 02.04.2007 22:20:59 von Micah Stevens
I'm not totally clear on what you're asking, so here's two options:
If you use the include() function, you're pulling the code from the
external server and running on the local server. If you're running an
HTTP call, say via an Ajax routine for example, the code runs on the
external server.
The difference is if you're grabbing the source from the external server
and running it on the local php interpreter, or if you're using the
external php setup.
This seems to be what you're asking, the answer in this case is, either
one could happen, it depends on your implementation. If you provide
details on the exact implementation then I can give a more exact answer.
HTH,
-Micah
On 04/02/2007 06:53 AM, ioannes wrote:
> I ask this as I do not have two web sites on different servers to test
> at the moment.
> Does it work to use an include function in the php code on one site
> that calls a function on the other site? If you include a file on a
> remote server that runs a function, where does the function run - on
> the server where the function is originally written or on the calling
> server? I am thinking that if I write code, it is one way to make the
> functionality available without actually disposing of the source code
> itself.
>
> So the included functions might be variable values. Eg you could pass
> back a whole calendar to the calling server, which then just prints on
> the calling web site just by printing the returned variable. (I know
> that in terms of getting data to mark up the calendar the database
> would need to be fully referenced: user, password, server, and the
> calling (shared) host for instance will ask for the remote IP address
> to add to a white list.)
>
> John
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 02.04.2007 22:31:22 von Tony Miceli
wouldn't that be very dangerous if someone could grab my code and run it on
their server?
i'm an intermediate php guy at best. for many reasons i would not want
someone including my files and running them on another server!!! i hope
there's no easy way to do that!!!!!
btw if files are outside of the route directory then that means only the
local files can all them and execute them, right??
thanks
tony
------------------------------------------------------------ --------------------
My email address has changed. It is now tony@tonymiceli.com Visit my website
----- Original Message -----
From: "Micah Stevens"
To:
Cc:
Sent: Monday, April 02, 2007 4:20 PM
Subject: Re: [PHP-DB] Include function across servers
> I'm not totally clear on what you're asking, so here's two options:
>
> If you use the include() function, you're pulling the code from the
> external server and running on the local server. If you're running an HTTP
> call, say via an Ajax routine for example, the code runs on the external
> server.
>
> The difference is if you're grabbing the source from the external server
> and running it on the local php interpreter, or if you're using the
> external php setup.
>
> This seems to be what you're asking, the answer in this case is, either
> one could happen, it depends on your implementation. If you provide
> details on the exact implementation then I can give a more exact answer.
>
> HTH,
> -Micah
>
> On 04/02/2007 06:53 AM, ioannes wrote:
>> I ask this as I do not have two web sites on different servers to test at
>> the moment.
>> Does it work to use an include function in the php code on one site that
>> calls a function on the other site? If you include a file on a remote
>> server that runs a function, where does the function run - on the server
>> where the function is originally written or on the calling server? I am
>> thinking that if I write code, it is one way to make the functionality
>> available without actually disposing of the source code itself.
>>
>> So the included functions might be variable values. Eg you could pass
>> back a whole calendar to the calling server, which then just prints on
>> the calling web site just by printing the returned variable. (I know
>> that in terms of getting data to mark up the calendar the database would
>> need to be fully referenced: user, password, server, and the calling
>> (shared) host for instance will ask for the remote IP address to add to a
>> white list.)
>>
>> John
>>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 00:24:13 von dmagick
Tony Miceli wrote:
> wouldn't that be very dangerous if someone could grab my code and run it
> on their server?
Yeh, pretty dangerous. That's how c99shell and a bunch of other scripts
work.
> i'm an intermediate php guy at best. for many reasons i would not want
> someone including my files and running them on another server!!! i hope
> there's no easy way to do that!!!!!
If they are named with an extension that isn't parsed by php (eg .txt),
then they will be executed on another server.
If they are parsed by php (ie .php) then including them remotely won't
work - it will include whatever your php script spits out (eg html).
> btw if files are outside of the route directory then that means only the
> local files can all them and execute them, right??
Right.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 00:26:19 von Tony Miceli
thanks for your reply. that's what i figured using common sense, but that's
not always the case with software.
cu
tony
------------------------------------------------------------ --------------------
My email address has changed. It is now tony@tonymiceli.com Visit my website
----- Original Message -----
From: "Chris"
To: "Tony Miceli"
Cc:
Sent: Monday, April 02, 2007 6:24 PM
Subject: Re: [PHP-DB] Include function across servers
> Tony Miceli wrote:
>> wouldn't that be very dangerous if someone could grab my code and run it
>> on their server?
>
> Yeh, pretty dangerous. That's how c99shell and a bunch of other scripts
> work.
>
>> i'm an intermediate php guy at best. for many reasons i would not want
>> someone including my files and running them on another server!!! i hope
>> there's no easy way to do that!!!!!
>
> If they are named with an extension that isn't parsed by php (eg .txt),
> then they will be executed on another server.
>
> If they are parsed by php (ie .php) then including them remotely won't
> work - it will include whatever your php script spits out (eg html).
>
>> btw if files are outside of the route directory then that means only the
>> local files can all them and execute them, right??
>
> Right.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 01:06:25 von John Dillon
I have a particular business application so just returning html is OK,
the output is the useful bit in this case. I understand from the
discussion that I can still run my code on my server in response to a
remote server requesting the result of a function in that file and that
result gets back to that server. So you can use include() to access the
result of a function on another server, sounds like.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 01:09:01 von Bastien Koert
use cURL to execute the remote code
Bastien
>From: ioannes
>Reply-To: ioannes@btinternet.com
>To: php-db@lists.php.net
>Subject: Re: [PHP-DB] Include function across servers
>Date: Tue, 03 Apr 2007 00:06:25 +0100
>
>I have a particular business application so just returning html is OK, the
>output is the useful bit in this case. I understand from the discussion
>that I can still run my code on my server in response to a remote server
>requesting the result of a function in that file and that result gets back
>to that server. So you can use include() to access the result of a
>function on another server, sounds like.
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
____________________________________________________________ _____
RealLiveMoms: Share your experience with Real Live Moms just like you
http://www.reallivemoms.ca/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 01:19:06 von dmagick
ioannes wrote:
> I have a particular business application so just returning html is OK,
> the output is the useful bit in this case. I understand from the
> discussion that I can still run my code on my server in response to a
> remote server requesting the result of a function in that file and that
> result gets back to that server. So you can use include() to access the
> result of a function on another server, sounds like.
You can include code, but you can't run a function from another server.
That code could include a function but that doesn't mean you'll get the
right results from it.
For example:
mysql_connect(....);
function get_categories()
{
$return = array();
$query = "select * from categories";
$result = mysql_query($query) or die("problem: " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$return[] = $row;
}
return $return;
}
?>
including that from a remote server will query your local database - it
will not query your remote database.
So I really suggest finding another way to do whatever you are trying to
do...
1) for security reasons (you don't want anyone else to be able to access
your database or anything else because if you can do it, so can I - plus
a lot of other things to get into your server)
2) for practicality reasons (eg the above)
3) for usability reasons (eg the remote server crashes, your
website/whatever is inaccessible because functionality can't be retrieved)
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Include function across servers
am 03.04.2007 16:53:39 von Micah Stevens
No. That would be to access the code. Include grabs an entire file.
Perhaps you should look into Ajax techniques.
-Micah
On 04/02/2007 04:06 PM, ioannes wrote:
> I have a particular business application so just returning html is OK,
> the output is the useful bit in this case. I understand from the
> discussion that I can still run my code on my server in response to a
> remote server requesting the result of a function in that file and
> that result gets back to that server. So you can use include() to
> access the result of a function on another server, sounds like.
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php