简体   繁体   中英

PHP Execute External File

I have a file located on my server and I want to remotely access that file from another server and execute source code of the file from another PHP file located on the another server.

I have had a look at “File_get_contents” however this only obtains the content displayed by that PHP file, as can be seen below.

So therefore is it possible for a PHP file from an external server to read the source code of the PHP file located on my server and execute the commands on the external server?

You can use an extension other than .php for the source file, then use file_get_contents (or similar) to retrieve the contents.

Not using the php extensions will prevent PHP from parsing it as code, and just send it over as text instead.

However, that will also make the source readable to anyone who navigates to the file in a browser, as well as introducing a possible major vulnerability. You should look into why this is necessary and if it can be avoided somehow (perhaps calling the file on the other server with GET or POSTed parameters).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM