0

Is it possible, to include PHP code in a separate file on another computer. If so, how?

For example:

On the first computer:

#Host 1 Script
$username = "dfgd";
$password = "sdff";

#Code I need help with

And then on the second:

#Host 2 Script

#Code which needs to be run on Host 1 which will manipulate $username and $password

Obviously, I would not be able to store the script on Host 2 in a .php file because when it is read, nothing would print out... But is it possible?

8
  • 3
    While it's not impossible, it sounds like a Really Bad Idea™. What do you need this for? Commented May 3, 2012 at 0:20
  • I'm writing a script which would be distributed to users. Users would fill in the usernames and passwords and other configuration options and then the actual code would be run of my server. Commented May 3, 2012 at 0:22
  • Is the code you're talking about meant to run on their computer, or do you want to run it on your server and then have the user's computer do something with the results? Commented May 3, 2012 at 0:25
  • @octern It's meant to run on their computer. I want the script to pull the code from my server and run it on their server. Commented May 3, 2012 at 0:28
  • 1
    In that case the code is nothing more than text. You could serve it over a regular http connection and have the script on their computer exec() it. That sounds like a security risk, though. If an attacker is able to direct them to a different site or tamper with the code they get from your site, the user's computer will then be executing arbitrary code with no restrictions. Commented May 3, 2012 at 0:33

2 Answers 2

1

As long as reading files over HTTP is enabled in the server, you can use include*() or require*() to read the file and execute the returned PHP. Simply tell the other system to not parse it in their PHP engine.

Sign up to request clarification or add additional context in comments.

Comments

0

Maybe you want to check how the soap works: soapclient, soapserver

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.