I can not figure out how to synchronize my sync.php file, which should be located on the domain (site) of mysite.ru with my other project, which is located at sequrity.ru (for example). Actually the sync.php code itself:

<?php include "http://sequrity.ru/config.php"; include "http://sequrity.ru/modules/core.php"; //Checking if the visitor is in the Whitelist $wtable = $prefix . 'ip-whitelist'; $wquery = mysqli_query($connect, "SELECT ip FROM `$wtable` WHERE ip='$ip'"); $wrow = mysqli_num_rows($wquery); if ($wrow == "0") { //Ban System include "http://sequrity.ru/modules/ban-system.php"; //Checking if Project SECURITY is enabled $table = $prefix . 'settings'; $squery = mysqli_query($connect, "SELECT * FROM `$table`"); $srow = mysqli_fetch_assoc($squery); if ($srow['realtime_protection'] == "Yes") { include "http://sequrity.ru/modules/sqli-protection.php"; include "http://sequrity.ru/modules/massrequests-protection.php"; include "http://sequrity.ru/modules/spam-protection.php"; include "http://sequrity.ru/modules/content-protection.php"; include "http://sequrity.ru/modules/badbots-protection.php"; include "http://sequrity.ru/modules/fakebots-protection.php"; include "http://sequrity.ru/modules/headers-check.php"; include "http://sequrity.ru/modules/tor-detection.php"; } } include "http://sequrity.ru/modules/optimizations.php"; ?> 

    2 answers 2

    For a start it is worth emphasizing that

     include "http://sequrity.ru/config.php"; 

    Will not return to you the script of the file being called, but the result of its execution.

    In this case, you can solve this problem in several ways.

    1. Use git. This is the surest way to solve this problem.

    2. Use NFS (Network File System) is a network file system that allows users to access files and directories located on remote computers as if these files and directories were local. Ie you change the file in one file to which both websites are connected via the network.

    3. The above translated versions will help you only if you have a dedicated server. But if this is not the case, then most likely you are trying to synchronize these files manually. For a start it is worth emphasizing that these files must be transferred over the network in an encrypted state in order to avoid source code leaks. In addition, you need to determine exactly what files will be synchronized. This can be implemented as follows. On one server you have a file http://mysait.ru/get_encripted_file.php that returns the encrypted source code and over the other site sync.php who accepts, decrypts and stores.

    Here is an example of get_encripted_file.php

      /** * @param $string * @return string */ function encrypt($string) { $encrypt_method = "AES-256-CBC"; $secret_key = 'This is my secret key'; $secret_iv = 'This is my secret iv'; // hash $key = hash('sha256', $secret_key); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr(hash('sha256', $secret_iv), 0, 16); $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); return $output; } $sourceCode = file_get_contents('file_for_encrypt.php'); echo $encryptedSourceCode = encrypt($sourceCode); 

    And this is the sync.php code - in fact, this is the script that will download the script, decrypt and save it

     /** * @param $string * @return string */ function decrypt($string) { $encrypt_method = "AES-256-CBC"; $secret_key = 'This is my secret key'; $secret_iv = 'This is my secret iv'; // hash $key = hash('sha256', $secret_key); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr(hash('sha256', $secret_iv), 0, 16); $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); return $output; } $sourceCode = file_get_contents('http://mysait.ru/get_encripted_file.php'); file_put_contents('save_to_this_file.php', $sourceCode); 

      You can not do this, especially through the http protocol. The site should never produce the source scripts of the site - otherwise it would be a big security hole.

      What you can do to synchronize - for example, you can automatically or manually copy the necessary files from the server to the server, via ftp or ssh .