Forum Moderators: coopster

Message Too Old, No Replies

include php function from different server

include php function from different server

         

berts milsky

3:52 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



I want to protect my source code in the cms i have written by including files on a different server to my clients'. when i include a file on a different server i cannot get the function on that file to work. see the following:

File on server 1: [example1.com...]

<?php
$path = "http://www.example2.com/";
require $path."file2.php";
TestFunction();
?>

File on server 2: [example2.com...]

<?php
function TestFunction(){
echo "Test works";
}
?>

When i call [example1.com...] i get the following error:

Fatal error: Call to undefined function: TestFunction()

Is there a way i can do this? or any suggestions on how to protect my logic simply and easily?

gcarn

5:47 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



I don't believe that you can take a function from a php file on another server.

That's one of the nice things about php, its all processed server side... so you should not ever be able to read the php code in a php file on another server.

eelixduppy

5:50 pm on Jul 18, 2008 (gmt 0)



Hello and Welcome to WebmasterWorod, berts milsky! :)

As gcarn said, the file will be parsed on the other sever before it is sent over in the include. In order to do this you'd have to get rid of the .php extension so it isn't parsed as PHP on the remote server, however, this will enable other people to see the source code for that particular PHP file on the server. If this is something you are willing to have then try this approach, otherwise, it's best to make a copy of the file on the other server and put it in the includes directory on the server you need the function definitions in.