The example of this article for everyone to share the PHP file multi-server Synchronization tool, the specific content is as follows
<?phpheader (' content-type:text/html;charset=utf-8 ');//File name: PHP file Multi-Server Synchronization tool//File role: This file is located on the server as the primary server, The server where the other files are located can be diverted or backed up. This article requires a jquery library. You can also chain someone else's//Last modified: 2016-06-30//by:strwei if (!empty ($_post[' files '))) sync (); function sync () {$aFiles = explode ("\ n", $_post[' files ');//var_dump ($aFiles); exit; foreach ($aFiles as $k = + $v) {if (strlen ($v) <= 5) unset ($aFiles [$k]); } array_filter ($aFiles); if (empty ($aFiles)) {echo ' no files '; exit; } $aFTPServers = Array (' server1 ' = = Array (' strwei.com ', ' FTP user name ', ' ftp password ', ' Open ftp default directory '),//FTP address, username, password, F TP Open this site when the default directory//' server2 ' = = Array (' Yy.9.je ', ' FTP user name ', ' ftp password ', ' open ftp in default directory '),); $aAbortFile = Array (' robots.txt '); $aErrors = Array (); $iError = count ($aErrors); $aSuc = Array (); foreach ($aFTPServers as $ftp) {$conn = Ftp_connect ($ftp [0]); if (empty ($conn)) {$iError = $iError + 1; Array_push ($aErrors, $iError. ", Server $ftp Unable to connect"); Continue } $login = Ftp_login ($conn, $ftp [1], $FTP [2]); if (empty ($login)) {$iError = $iError + 1; Array_push ($aErrors, $iError. ", server $ftp [0] cannot log in"); Continue } $ftp _root = "; if (!empty ($ftp [3])) $ftp _root = Ftp_chdir ($conn, $ftp [3]); $ftp _root = ftp_pwd ($conn); if (substr ($ftp _root,-1) = = = '/') $ftp _root = substr ($ftp _root, 0,-1); foreach ($aFiles as $k = + $v) {$s = basename ($v); if (In_array ($s, $aAbortFile)) {$iError = $iError + 1; Array_push ($aErrors, $iError. ", file $v not allow synchronization"); Continue } if (!file_exists ('. '). $v)) {$iError = $iError + 1; Array_push ($aErrors, $iError. ", file $v does not exist"); Continue } $upload = Ftp_put ($conn, $ftp _root. $v, '. '. $v, ftp_binary); if (empty ($upload)) {$iError = $iError + 1; Array_push ($aErrors, $iError. ", File $v upload failed"); Continue } array_push ($aSuc, $v); }} if (Empty ($aErrors)) {echo ' Upload succeeded: '. Implode (', ', $ASUC); Exit } Echo Implode ('
', $aErrors); Exit;} $CC = ' \ r \ n '; Echo <<
</span> EOF;? ></pre></p>
The above is the whole content of this article, I hope that you learn PHP programming help.
The above describes the PHP server PHP file Multi-server synchronization program, including the content of the PHP server, I hope that the PHP tutorial interested in a friend helpful.