N
N
Nikita Sazonov2018-03-21 23:01:39
PHP
Nikita Sazonov, 2018-03-21 23:01:39

File connections from another server?

How to connect a file via PHP, which will be located on a separate hosting?
That is, for example, we include a file in script.php:
require ('file.php'); here's how to do it if this file.php is on a separate host (website), and connect it via a link or via FTP? The main thing is how best to ensure that there is a minimum of opportunity to access file.php through script.php
I'm not interested in a ready-made solution, but in the direction to the true path) what to use? what functions what library can be there?) Thanks in advance for the answers and advice)
Why is it not safe then ???

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
index0h, 2018-03-22
@index0h

I'm not interested in a ready-made solution, but in the direction to the true path

The true way is not to do so, from the word "absolutely". This is a flagrant security breach.

Y
Yuri, 2018-03-21
@LazyDev

Something like this:

<?php
eval(file_get_contents("http://site.ru/file.php"));

<?php
phpinfo();

But, on a third-party server, you need to disable the processing of php files, or place the code in a file with a different extension, for example, file.source.
FTP: ftp://site.ru/file.php
FTP with authentication: ftp://user:[email protected]/file.php
In general, this is not safe.

D
Denis, 2018-03-21
@sidni

in the most primitive and particular case

$file = file_get_contents('http://www.example.com/script.php');
file_put_contents('script.php', $file, FILE_APPEND);

S
Sanovskiy, 2018-03-22
@Sanovskiy

If you need a third party library use composer. It is insecure because the files on the remote host are not controlled by you.

A
abroabr, 2018-03-22
@abroabr

This is not done, because there is a big problem with the performance and stability of such a system .
If you need to receive something from another server, you get it from it via the API, and not in the form of a ready-made file with the source code of the program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question