calling included remote functions

This is a discussion on calling included remote functions within the PHP Language forums, part of the PHP Programming Forums category; at one centraldomain.com, I have central.php, which consists of this: <?php function square($num) { return $num * $num; } ?&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2005
juglesh
 
Posts: n/a
Default calling included remote functions

at one centraldomain.com, I have central.php, which consists of this:
<?php
function square($num)
{ return $num * $num;
}
?>

at outerdomain.com, I have test.php, which consists of this:
<?php
include "http://www.centraldomain.com/central.php";
echo square(4); // outputs '16'.
?>

outerdomain.com/test.php =
"Fatal error: Call to undefined function: square() in blah/blah/test.php on
line 12"

wha'appen'? I thought you could call included functions? Hmm... if I put
central.php on the outerdomain.com, it works. No calling functions from
files included remotely?

--
juglesh




Reply With Quote
  #2 (permalink)  
Old 02-24-2005
Geoff Berrow
 
Posts: n/a
Default Re: calling included remote functions

I noticed that Message-ID: <UrmdnUfGd9wr_oDfRVn-qg@comcast.com> from
juglesh contained the following:

>No calling functions from
>files included remotely?


Absolutely! Think about it.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
  #3 (permalink)  
Old 02-24-2005
Derek Fountain
 
Posts: n/a
Default Re: calling included remote functions

juglesh wrote:
> wha'appen'? I thought you could call included functions? Hmm... if I put
> central.php on the outerdomain.com, it works. No calling functions from
> files included remotely?


Think about what's happening. The local server goes to the remote server and
asks for a file with a PHP suffix. The remote server reads the file off the
disk and, because it's a PHP file, executes it. It then delivers to the
local server the result of that execution, exactly as if the file had been
requested by a browser. What result is your central.php file going to
provide when executed? An empty string I think. Not what you want...

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>
Reply With Quote
  #4 (permalink)  
Old 02-24-2005
Oli Filth
 
Posts: n/a
Default Re: calling included remote functions

There's a thread from a while ago that was about this.

http://groups-beta.google.com/group/...c848c4e9417f5/

--
Oli

Reply With Quote
  #5 (permalink)  
Old 02-24-2005
Robin
 
Posts: n/a
Default Re: calling included remote functions

juglesh wrote:
> No calling functions from files included remotely?


If the local server could include a remote php file as the original php
rather than the interpreted php (usually html) then anyone could:

<?php
include('http://www.somedomain.com/db.php');

foreach ($GLOBALS as $k=>$v) { echo "$k => $v"; }
?>

and most likely discover somedomains sql username and password.

More over, if the php service on one server could request a copy of the
code from another, everybody's code would be public.

Robin
Reply With Quote
  #6 (permalink)  
Old 02-24-2005
Rushi
 
Posts: n/a
Default Re: calling included remote functions

It would be fun if something like this happened :) We would have a lot
of "semi-script kiddies"...
Robin wrote:
> juglesh wrote:
> > No calling functions from files included remotely?

>
> If the local server could include a remote php file as the original

php
> rather than the interpreted php (usually html) then anyone could:
>
> <?php
> include('http://www.somedomain.com/db.php');
>
> foreach ($GLOBALS as $k=>$v) { echo "$k => $v"; }
> ?>
>
> and most likely discover somedomains sql username and password.
>
> More over, if the php service on one server could request a copy of

the
> code from another, everybody's code would be public.
>
> Robin


Reply With Quote
  #7 (permalink)  
Old 02-25-2005
juglesh
 
Posts: n/a
Default Re: calling included remote functions


"Oli Filth" <catch@olifilth.co.uk> wrote in message
news:1109237604.611168.220130@g14g2000cwa.googlegr oups.com...
> There's a thread from a while ago that was about this.
>
> http://groups-beta.google.com/group/...c848c4e9417f5/


hrmm... Well, before I go trying the stuff in that link, let me tell you
what my big plan is.

I have a script that I would like to deploy over several websites. And
if/when I want to tweak the code, I don't want to have to go updating all
the sites. The scripts in question must be run on the 'satellite' sites
(unless of course I want everybody's picture galleries displaying *my* trip
to Disneyland!)

So, how would you go about this? I guess in this circumstance, I could
dream up a way to do it with dreamweaver templates...

oh, ps, I tried including a .inc file like on that thread above, and that
wasn't working either. can you do like getfilecontents, and then spit it
out for php to process? over remote sites(probly not, eh). But that was
early this morning, pre-coffee.

--
thanks, juglesh


Reply With Quote
  #8 (permalink)  
Old 02-25-2005
Geoff Berrow
 
Posts: n/a
Default Re: calling included remote functions

I noticed that Message-ID: <iaadnT-hcesrEYPfRVn-pw@comcast.com> from
juglesh contained the following:

>I have a script that I would like to deploy over several websites. And
>if/when I want to tweak the code, I don't want to have to go updating all
>the sites. The scripts in question must be run on the 'satellite' sites
>(unless of course I want everybody's picture galleries displaying *my* trip
>to Disneyland!)


Remember
input->process->output.

In other words you send information to the processing script (e.g.
location of photo directory, number of photos to display or it could
handle database queries). This script then takes that information and
processes it creating and outputting the html necessary to create the
viewing page. If the photo links were absolute there is no reason why
pone script could not serve any number of sites. Security may be an
issue to avoid the script being used by unauthorised users.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
  #9 (permalink)  
Old 02-25-2005
juglesh
 
Posts: n/a
Default Re: calling included remote functions


"Geoff Berrow" <bl@ckdog.co.uk> wrote in message
news:0slt11pjgs0v4n796okl8ic95tm6hhfd6m@4ax.com...
>I noticed that Message-ID: <iaadnT-hcesrEYPfRVn-pw@comcast.com> from
> juglesh contained the following:
>
>>I have a script that I would like to deploy over several websites. And
>>if/when I want to tweak the code, I don't want to have to go updating all
>>the sites. The scripts in question must be run on the 'satellite' sites
>>(unless of course I want everybody's picture galleries displaying *my*
>>trip
>>to Disneyland!)

>
> Remember
> input->process->output.
>
> In other words you send information to the processing script (e.g.
> location of photo directory, number of photos to display or it could
> handle database queries). This script then takes that information and
> processes it creating and outputting the html necessary to create the
> viewing page. If the photo links were absolute there is no reason why
> pone script could not serve any number of sites. Security may be an
> issue to avoid the script being used by unauthorised users.


the script that will run on the central domain needs to do several readirs,
is_files, etc. Testing with is_file is not working.

satellite domain:
test.php=
include "http://www.centraldomain.com/central.php";

central domain:
central.php=
if
(is_file("http://www.satelitedomain.com/aFileThatExists.php")){
echo "file read";
}else{echo "not read";}

output of satelitedomain.com/test.php= not read

something about
http://us4.php.net/manual/en/functio...r-register.php ?

--
thanks for your time
juglesh



Reply With Quote
  #10 (permalink)  
Old 02-25-2005
Geoff Berrow
 
Posts: n/a
Default Re: calling included remote functions

I noticed that Message-ID: <3OGdnaLDhNO-BYLfRVn-iQ@comcast.com> from
juglesh contained the following:

>the script that will run on the central domain needs to do several readirs,
>is_files, etc. Testing with is_file is not working.


From the manual on include:

If "URL fopen wrappers" are enabled in PHP (which they are in the
default configuration), you can specify the file to be included using a
URL (via HTTP or other supported wrapper - see Appendix L for a list of
protocols) instead of a local pathname. If the target server interprets
the target file as PHP code, variables may be passed to the included
file using a URL request string as used with HTTP GET. This is not
strictly speaking the same thing as including the file and having it
inherit the parent file's variable scope; the script is actually being
run on the remote server and the result is then being included into the
local script.



--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:49 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0