Using remote include config file and class in a local file

Using remote include config file and class in a local file

am 03.11.2009 09:35:34 von Anton Heuschen

Question is wrt to including a config file on an external server in a
local include

Lets say that on 127.0.0.1 I have test.php with

include http://200.200.1.1/Folder/Config.php

$obj = new RemoteClass()

do stuff


and on server 200.200.1.1 I have my Config.php file which is contains
the class RemoteClass() { echo "test" }



If I try to test it locally it says it cannot find RemoteClass ...


How can I include/require a config (or any other php classes file) on
my local running php script ?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using remote include config file and class in a local file

am 03.11.2009 10:13:26 von Devendra Jadhav

--001636d3422f2b3efe047773e8d3
Content-Type: text/plain; charset=ISO-8859-1

You are including file from external server and you are accessing it via
HTTP protocol. So it will include the output of
http://200.200.1.1/Folder/Config.php and the output of that script is
nothing.

If you want to see the output just put
http://200.200.1.1/Folder/Config.phpin browser and check.

btw what exactly you want to achieve by including external config file?

On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen wrote:

> Question is wrt to including a config file on an external server in a
> local include
>
> Lets say that on 127.0.0.1 I have test.php with
>
> include http://200.200.1.1/Folder/Config.php
>
> $obj = new RemoteClass()
>
> do stuff
>
>
> and on server 200.200.1.1 I have my Config.php file which is contains
> the class RemoteClass() { echo "test" }
>
>
>
> If I try to test it locally it says it cannot find RemoteClass ...
>
>
> How can I include/require a config (or any other php classes file) on
> my local running php script ?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Devendra Jadhav

--001636d3422f2b3efe047773e8d3--

Re: Using remote include config file and class in a local file

am 03.11.2009 10:14:28 von Cemal Eker

Including security warning from php.net/

"Remote file may be processed at the remote server (depending on the
file extension and the fact if the remote server runs PHP or not) but
it still has to produce a valid PHP script because it will be
processed at the local server. If the file from the remote server
should be processed there and outputted only, readfile() is much
better function to use. Otherwise, special care should be taken to
secure the remote script to produce a valid and desired code."

Deos the file produce a valid PHP script? Please make a HTTP request
and post output here. You should get valid PHP file.

If not you should fix the problem with two possible solutions.

By disabling PHP script execution on remote server. This could be
impossible if remote server runs an active PHP server.

Or by editing file to produce a valid PHP script. For example:
echo "class RemoteClass() { echo "test" }"
would produce a valid PHP script.


Cemal Eker




On Tue, Nov 3, 2009 at 10:35 AM, Anton Heuschen wrote:
> Question is wrt to including a config file on an external server in a
> local include
>
> Lets say that on 127.0.0.1 I have test.php with
>
> include http://200.200.1.1/Folder/Config.php
>
> $obj = new RemoteClass()
>
> do stuff
>
>
> and on server 200.200.1.1 I have my Config.php file which is contains
> the class RemoteClass() { echo "test" }
>
>
>
> If I try to test it locally it says it cannot find RemoteClass ...
>
>
> How can I include/require a config (or any other php classes file) on
> my local running php script ?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using remote include config file and class in a local file

am 03.11.2009 10:20:52 von Anton Heuschen

Yes your right ... realizing it ... the config file is a class I use
to connect to my Database .... I want to store this config on myt
hosting and then I can link to it and use it at my office, or at my PC
at home....

But I now realize including the php ...will just return a blank page
..... so its not like doing a include(/config.php) when its local ....

Anyway to do this ?



2009/11/3 Devendra Jadhav :
> You are including file from external server and you are accessing it via
> HTTP protocol. So it will include the output of
> http://200.200.1.1/Folder/Config.php and the output of that script is
> nothing.
>
> If you want to see the output just put http://200.200.1.1/Folder/Config.php
> in browser and check.
>
> btw what exactly you want to achieve by including external config file?
>
> On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen wrote:
>>
>> Question is wrt to including a config file on an external server in a
>> local include
>>
>> Lets say that on 127.0.0.1 I have test.php with
>>
>> include http://200.200.1.1/Folder/Config.php
>>
>> $obj = new RemoteClass()
>>
>> do stuff
>>
>>
>> and on server 200.200.1.1 I have my Config.php file which is contains
>> the class RemoteClass() { echo "test" }
>>
>>
>>
>> If I try to test it locally it says it cannot find RemoteClass ...
>>
>>
>> How can I include/require a config (or any other php classes file) on
>> my local running php script ?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> --
> Devendra Jadhav
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using remote include config file and class in a local file

am 03.11.2009 10:22:57 von Devendra Jadhav

--0016369fa1bc280ab20477740a2f
Content-Type: text/plain; charset=ISO-8859-1

Check if allow_url_fopenis
set in php.ini otherwise you have to set it true by ini_set()

On Tue, Nov 3, 2009 at 2:44 PM, Cemal Eker wrote:

> Including security warning from php.net/
>
> "Remote file may be processed at the remote server (depending on the
> file extension and the fact if the remote server runs PHP or not) but
> it still has to produce a valid PHP script because it will be
> processed at the local server. If the file from the remote server
> should be processed there and outputted only, readfile() is much
> better function to use. Otherwise, special care should be taken to
> secure the remote script to produce a valid and desired code."
>
> Deos the file produce a valid PHP script? Please make a HTTP request
> and post output here. You should get valid PHP file.
>
> If not you should fix the problem with two possible solutions.
>
> By disabling PHP script execution on remote server. This could be
> impossible if remote server runs an active PHP server.
>
> Or by editing file to produce a valid PHP script. For example:
> echo "class RemoteClass() { echo "test" }"
> would produce a valid PHP script.
>
>
> Cemal Eker
>
>
>
>
> On Tue, Nov 3, 2009 at 10:35 AM, Anton Heuschen wrote:
> > Question is wrt to including a config file on an external server in a
> > local include
> >
> > Lets say that on 127.0.0.1 I have test.php with
> >
> > include http://200.200.1.1/Folder/Config.php
> >
> > $obj = new RemoteClass()
> >
> > do stuff
> >
> >
> > and on server 200.200.1.1 I have my Config.php file which is contains
> > the class RemoteClass() { echo "test" }
> >
> >
> >
> > If I try to test it locally it says it cannot find RemoteClass ...
> >
> >
> > How can I include/require a config (or any other php classes file) on
> > my local running php script ?
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Devendra Jadhav

--0016369fa1bc280ab20477740a2f--

Re: Using remote include config file and class in a local file

am 03.11.2009 10:33:20 von Devendra Jadhav

--001636d349b64a628c0477742f98
Content-Type: text/plain; charset=ISO-8859-1

You can you NFS to mount remote file system on your local system.

On Tue, Nov 3, 2009 at 2:50 PM, Anton Heuschen wrote:

> Yes your right ... realizing it ... the config file is a class I use
> to connect to my Database .... I want to store this config on myt
> hosting and then I can link to it and use it at my office, or at my PC
> at home....
>
> But I now realize including the php ...will just return a blank page
> .... so its not like doing a include(/config.php) when its local ....
>
> Anyway to do this ?
>
>
>
> 2009/11/3 Devendra Jadhav :
> > You are including file from external server and you are accessing it via
> > HTTP protocol. So it will include the output of
> > http://200.200.1.1/Folder/Config.php and the output of that script is
> > nothing.
> >
> > If you want to see the output just put
> http://200.200.1.1/Folder/Config.php
> > in browser and check.
> >
> > btw what exactly you want to achieve by including external config file?
> >
> > On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen
> wrote:
> >>
> >> Question is wrt to including a config file on an external server in a
> >> local include
> >>
> >> Lets say that on 127.0.0.1 I have test.php with
> >>
> >> include http://200.200.1.1/Folder/Config.php
> >>
> >> $obj = new RemoteClass()
> >>
> >> do stuff
> >>
> >>
> >> and on server 200.200.1.1 I have my Config.php file which is contains
> >> the class RemoteClass() { echo "test" }
> >>
> >>
> >>
> >> If I try to test it locally it says it cannot find RemoteClass ...
> >>
> >>
> >> How can I include/require a config (or any other php classes file) on
> >> my local running php script ?
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> >
> > --
> > Devendra Jadhav
> >
>



--
Devendra Jadhav

--001636d349b64a628c0477742f98--

Re: Using remote include config file and class in a local file

am 03.11.2009 10:39:43 von Anton Heuschen

Hmmm yes thats another way of doing it ... Im running a Ubuntu box
...so its quite possible (how will you mount if your on XP?)



2009/11/3 Devendra Jadhav :
> You can you NFS to mount remote file system on your local system.
>
> On Tue, Nov 3, 2009 at 2:50 PM, Anton Heuschen wrote:
>>
>> Yes your right ... realizing it ... the config file is a class I use
>> to connect to my Database .... I want to store this config on myt
>> hosting and then I can link to it and use it at my office, or at my PC
>> at home....
>>
>> But I now realize including the php ...will just return a blank page
>> .... so its not like doing a include(/config.php) when its local ....
>>
>> Anyway to do this ?
>>
>>
>>
>> 2009/11/3 Devendra Jadhav :
>> > You are including file from external server and you are accessing it via
>> > HTTP protocol. So it will include the output of
>> > http://200.200.1.1/Folder/Config.php and the output of that script is
>> > nothing.
>> >
>> > If you want to see the output just put
>> > http://200.200.1.1/Folder/Config.php
>> > in browser and check.
>> >
>> > btw what exactly you want to achieve by including external config file?
>> >
>> > On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen
>> > wrote:
>> >>
>> >> Question is wrt to including a config file on an external server in a
>> >> local include
>> >>
>> >> Lets say that on 127.0.0.1 I have test.php with
>> >>
>> >> include http://200.200.1.1/Folder/Config.php
>> >>
>> >> $obj = new RemoteClass()
>> >>
>> >> do stuff
>> >>
>> >>
>> >> and on server 200.200.1.1 I have my Config.php file which is contains
>> >> the class RemoteClass() { echo "test" }
>> >>
>> >>
>> >>
>> >> If I try to test it locally it says it cannot find RemoteClass ...
>> >>
>> >>
>> >> How can I include/require a config (or any other php classes file) on
>> >> my local running php script ?
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >
>> >
>> >
>> > --
>> > Devendra Jadhav
>> >
>
>
>
> --
> Devendra Jadhav
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using remote include config file and class in a local file

am 03.11.2009 11:10:33 von Devendra Jadhav

--001636920c136fa0e2047774b4b4
Content-Type: text/plain; charset=ISO-8859-1

No idea about NFS on windows. But you can mount samba share in XP

On Tue, Nov 3, 2009 at 3:09 PM, Anton Heuschen wrote:

> Hmmm yes thats another way of doing it ... Im running a Ubuntu box
> ..so its quite possible (how will you mount if your on XP?)
>
>
>
> 2009/11/3 Devendra Jadhav :
> > You can you NFS to mount remote file system on your local system.
> >
> > On Tue, Nov 3, 2009 at 2:50 PM, Anton Heuschen
> wrote:
> >>
> >> Yes your right ... realizing it ... the config file is a class I use
> >> to connect to my Database .... I want to store this config on myt
> >> hosting and then I can link to it and use it at my office, or at my PC
> >> at home....
> >>
> >> But I now realize including the php ...will just return a blank page
> >> .... so its not like doing a include(/config.php) when its local ....
> >>
> >> Anyway to do this ?
> >>
> >>
> >>
> >> 2009/11/3 Devendra Jadhav :
> >> > You are including file from external server and you are accessing it
> via
> >> > HTTP protocol. So it will include the output of
> >> > http://200.200.1.1/Folder/Config.php and the output of that script is
> >> > nothing.
> >> >
> >> > If you want to see the output just put
> >> > http://200.200.1.1/Folder/Config.php
> >> > in browser and check.
> >> >
> >> > btw what exactly you want to achieve by including external config
> file?
> >> >
> >> > On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen
> >> > wrote:
> >> >>
> >> >> Question is wrt to including a config file on an external server in a
> >> >> local include
> >> >>
> >> >> Lets say that on 127.0.0.1 I have test.php with
> >> >>
> >> >> include http://200.200.1.1/Folder/Config.php
> >> >>
> >> >> $obj = new RemoteClass()
> >> >>
> >> >> do stuff
> >> >>
> >> >>
> >> >> and on server 200.200.1.1 I have my Config.php file which is contains
> >> >> the class RemoteClass() { echo "test" }
> >> >>
> >> >>
> >> >>
> >> >> If I try to test it locally it says it cannot find RemoteClass ...
> >> >>
> >> >>
> >> >> How can I include/require a config (or any other php classes file) on
> >> >> my local running php script ?
> >> >>
> >> >> --
> >> >> PHP General Mailing List (http://www.php.net/)
> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Devendra Jadhav
> >> >
> >
> >
> >
> > --
> > Devendra Jadhav
> >
>



--
Devendra Jadhav

--001636920c136fa0e2047774b4b4--

RE: Using remote include config file and class in a local file

am 03.11.2009 15:43:41 von Mert Oztekin

--_000_E2C046087E10D943811A0BD0A4E8316D1BD2E81D8Aankaraanado lu_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Why dont you try returning config variables as string from remote server.

Something like :
"http://192.XXX.XXX.XXX/getconfig.php?token=3D123&encoded=3D xxxxxxxxxxxx"

And the getconfig.php file can be like

/// validate if request is from a friendly server something like the follow=
ing 2 if statements
if(!$_GET["token"] || !$_GET["encoded"])
return;
if(md5($_GET["token"]) !=3D $_GET["encoded"]) /// just for example. Dont =
use md5 it can be broken easly. Try to code your own encryption function
return;

echo 'server=3D"DBServer";user=3D"username";pass=3D"password";dbn ame=3D"dat=
abaseName"';
?>

And in your requester script you should request remote address content by a=
dding your token and encoded variables. And parse the returning string.


-----Original Message-----
From: Devendra Jadhav [mailto:devendra.in@gmail.com]
Sent: Tuesday, November 03, 2009 12:11 PM
To: Anton Heuschen
Cc: PHP General List
Subject: Re: [PHP] Using remote include config file and class in a local fi=
le

No idea about NFS on windows. But you can mount samba share in XP

On Tue, Nov 3, 2009 at 3:09 PM, Anton Heuschen wrote:

> Hmmm yes thats another way of doing it ... Im running a Ubuntu box
> ..so its quite possible (how will you mount if your on XP?)
>
>
>
> 2009/11/3 Devendra Jadhav :
> > You can you NFS to mount remote file system on your local system.
> >
> > On Tue, Nov 3, 2009 at 2:50 PM, Anton Heuschen
> wrote:
> >>
> >> Yes your right ... realizing it ... the config file is a class I use
> >> to connect to my Database .... I want to store this config on myt
> >> hosting and then I can link to it and use it at my office, or at my PC
> >> at home....
> >>
> >> But I now realize including the php ...will just return a blank page
> >> .... so its not like doing a include(/config.php) when its local ....
> >>
> >> Anyway to do this ?
> >>
> >>
> >>
> >> 2009/11/3 Devendra Jadhav :
> >> > You are including file from external server and you are accessing it
> via
> >> > HTTP protocol. So it will include the output of
> >> > http://200.200.1.1/Folder/Config.php and the output of that script i=
s
> >> > nothing.
> >> >
> >> > If you want to see the output just put
> >> > http://200.200.1.1/Folder/Config.php
> >> > in browser and check.
> >> >
> >> > btw what exactly you want to achieve by including external config
> file?
> >> >
> >> > On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen
> >> > wrote:
> >> >>
> >> >> Question is wrt to including a config file on an external server in=
a
> >> >> local include
> >> >>
> >> >> Lets say that on 127.0.0.1 I have test.php with
> >> >>
> >> >> include http://200.200.1.1/Folder/Config.php
> >> >>
> >> >> $obj =3D new RemoteClass()
> >> >>
> >> >> do stuff
> >> >>
> >> >>
> >> >> and on server 200.200.1.1 I have my Config.php file which is contai=
ns
> >> >> the class RemoteClass() { echo "test" }
> >> >>
> >> >>
> >> >>
> >> >> If I try to test it locally it says it cannot find RemoteClass ...
> >> >>
> >> >>
> >> >> How can I include/require a config (or any other php classes file) =
on
> >> >> my local running php script ?
> >> >>
> >> >> --
> >> >> PHP General Mailing List (http://www.php.net/)
> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Devendra Jadhav
> >> >
> >
> >
> >
> > --
> > Devendra Jadhav
> >
>



--
Devendra Jadhav



________________________________
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir v=
e gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendirin=
iz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili o=
larak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketi=
miz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?nda=
n, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bil=
gisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individu=
al(s) stated in this message. If you received this message in error, please=
immediately notify the sender and delete it from your system. Our company =
has no legal responsibility for the contents of the message and its attachm=
ents. Our company shall have no liability for any changes or late receiving=
, loss of integrity and confidentiality, viruses and any damages caused in =
anyway to your computer system.

--_000_E2C046087E10D943811A0BD0A4E8316D1BD2E81D8Aankaraanado lu_--

Re: Using remote include config file and class in a local file

am 03.11.2009 15:58:41 von Shawn McKenzie

Anton Heuschen wrote:
> Question is wrt to including a config file on an external server in a
> local include
>
> Lets say that on 127.0.0.1 I have test.php with
>
> include http://200.200.1.1/Folder/Config.php
>
> $obj = new RemoteClass()
>
> do stuff
>
>
> and on server 200.200.1.1 I have my Config.php file which is contains
> the class RemoteClass() { echo "test" }
>
>
>
> If I try to test it locally it says it cannot find RemoteClass ...
>
>
> How can I include/require a config (or any other php classes file) on
> my local running php script ?

As others have said, you are receiving the output of the config.php
after it has been parsed by PHP on the remote server. You could try
naming it config.cfg, config.conf, config.ini, config.inc, etc...

--
Thanks!
-Shawn
http://www.spidean.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Using remote include config file and class in a local file

am 04.11.2009 16:37:02 von Nathan Rixham

Shawn McKenzie wrote:
> Anton Heuschen wrote:
>> Question is wrt to including a config file on an external server in a
>> local include
>>
>> Lets say that on 127.0.0.1 I have test.php with
>>
>> include http://200.200.1.1/Folder/Config.php
>>
>> $obj = new RemoteClass()
>>
>> do stuff
>>
>>
>> and on server 200.200.1.1 I have my Config.php file which is contains
>> the class RemoteClass() { echo "test" }
>>
>>
>>
>> If I try to test it locally it says it cannot find RemoteClass ...
>>
>>
>> How can I include/require a config (or any other php classes file) on
>> my local running php script ?
>
> As others have said, you are receiving the output of the config.php
> after it has been parsed by PHP on the remote server. You could try
> naming it config.cfg, config.conf, config.ini, config.inc, etc...
>

multiple choice
- why not use PHAR
- on remote server enable .phps (php source)
- remove "SetHandler application/x-httpd-php" in you apache conf (if on
apache, and obviously realise this won't let any php scripts run through
http)
- mount the remote file system locally

and.. why? normal approach would be to expose the remote functionality
needed as a web service and call it via SOAP/RPC/REST etc

however.. always fancied the idea of a central server for php libs that
can be included at runtime (with some local cache'ing and version
checking) - would make most sense if we all used a single version of the
same libs & only one copy etc etc

regards

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php