Esto nos implica dos necesidades primordiales :

1 ) modificar installer
2 ) Crear funciones en el servidor original

EL codigo es simple pero por cuestiones tecnicas no conviene ponerlo en un gist. Lo pongo como php html entities encode, aunque hay varios htmlentities en linea, sugiero este :
https://mothereff.in/html-entities

Por cierto, por necesidades Tecnicas se recomienda no usar campos (bit) en mysql sino int . EN exportaciones de contenido se pueden crerar muchos problemas. Debe quedar claro que el código que sigue es borrador pero funcional.

Por simplicidad voy a codificar en el servidor AUTORIDAD a donde debe enviar por ftp. Hay borrador de como pasar el dato del server de cada instalación.

Installer.php en el server deseado, ojo que viene como htmlentities


<?php nocache(); echo "Installer v 0.001"; crearconfig(); require "configmysql.php"; // datos de conexion de tu sitio define ('FTPSERVER',"ftp.desiredserver.com"); define ('FTPUSER',"user"); define ('FTP_PWD',"password"); define ('PATH',"/public_html/"); define ('MAIN_REPO','http://your-auth-domain.com/shachecker.php'); echo "<h3>Checking versions of the files</h3>"; bringfile("php.ini"); bringfile("robots.txt"); bringfile("favicon.ico"); bringfile("index.php"); // you need create first the images directory bringfile("images/information_ico.png"); // you need create includes directory first bringfile("includes/javafile.js"); //bringfile(".htaccess"); // NOT UPDATE .htaccess, can create MANY problems echo "<h3>Checking data struct of the tables</h3>"; bringtable("USERS"); bringtable("OTHER_TABLE"); echo "<h3>Update is done, try to run it <a href='index.php' target='_blank'>index.php</a></h3>"; function bringfile($filename){ if (file_exists($filename)==1) $mysha=sha1_file($filename); $base64=base64_encode($filename); $theurl=MAIN_REPO ."/shachecker.php?filename=$base64"; $result=curl_download($theurl); $ex=explode("|",$result); if (sizeof($ex)<>3) die ("<li><font color='red'>$result <hr>Not valid response of $theurl, check the filename</font>"); $othersha=$ex[1]; //echo "<li>tamaño de ".sizeof($ex); //echo "<li>$result<li>$othersha"; if ($othersha==$mysha) echo "<li><font color='green'>$filename is in current version</font>"; if ($othersha<>$mysha) { echo "<li><font color='red'>$filename is not in current version</font>"; askforfile($filename); } //if ($mysha<>$othersha) } // bringfile function noCache() { header("Expires: Tue, 01 Jul 2001 06:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } function curl_download($url){ $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch) or die ("error in curl $url"); curl_close($ch); return $data; } function askforfile($filename){ $ftpdata="&to=".base64_encode(FTPSERVER."|".FTPUSER."|".FTP_PWD."|".PATH); $theurl=MAIN_REPO ."/shachecker.php?filename=".base64_encode($filename)."&please=send$ftpdata"; //die("<li>$theurl"); $result=curl_download($theurl); die ("<li><h2>response: $result</h2><hr>Continue with f5 if not resume itself <META http-equiv='refresh' content='0;URL=installer.php'>"); } // askforfile function asktable($tablename) { $theurl=MAIN_REPO ."/shachecker.php?tablename=".base64_encode($tablename); //die("<li>$theurl"); $result=curl_download($theurl); $result64=base64_decode($result); $allok='N'; if (left($result64,2)=='||' and right($result64,2)=="||" ) $allok='Y'; if ($allok=='N') die ("Error in table struct<hr>$result"); $sql=str_replace("||","",$result64); mysql_query($sql) or die ("Error creating table $tablename :<hr>".mysql_error()); die ("<li>Table $tablename created ... continue with f5 if not resume itself in 3 seconds < META http-equiv='refresh' content='0;URL=installer.php'>"); } // ask table function crearconfig(){ if (file_exists("configmysql.php")==1) return ; $content="<?php Define ('Z_IPSERVIDOR','localhost'); Define ('Z_USUARIODB',''); Define ('Z_PASSDB',''); Define ('Z_NOMBREBASE',''); ?" .">"; file_put_contents('configmysql.php',$content); echo "<li><font color='blue'>Config created</font>"; } // crear config function checktable($tablename){ $pass="N"; mysql_connect(Z_IPSERVIDOR,Z_USUARIODB,Z_PASSDB) or die ('Cant connect : ' . mysql_error()); mysql_select_db(Z_NOMBREBASE) or die ('Cant use database : ' . mysql_error()); $result=mysql_query("SHOW TABLES LIKE '$tablename'"); $numtables = mysql_num_rows($result); if ($numtables>0) $pass ="Y"; return $pass; } // checktable function bringtable($tablename){ $result=checktable($tablename); if ($result=='Y') { echo "<li><font color='green'>$tablename already exist</font>"; return; } if ($result<>'Y') { // no existe return asktable($tablename); } // result <>' y' } // bringtable function left($str, $length) { return substr($str, 0, $length); } function right($str, $length) { return substr($str, -$length); } ?>

shachecker.php en el server AUTORIDAD , ojo que viene como htmlentities


<?php $filename=base64_decode($_GET['filename']); if ($_GET['please']=='send') deliverfile($filename); $pass="file not exist|$filename"; if (file_exists($filename)==1) { $perms=fileperms($filename); $pass= $filename."|".sha1_file($filename)."|$perms"; } die ($pass); } IF ($_GET['tablename']){ $tablename=base64_decode($_GET['tablename']); //conectar(); include "configmysql.php"; mysql_connect(Z_IPSERVIDOR,Z_USUARIODB,Z_PASSDB) or die ('Cant connect : ' . mysql_error()); mysql_select_db(Z_NOMBREBASE) or die ('Cant use database : ' . mysql_error()); list($dummy,$data) = avalues3192("show create table $tablename"); $data="||$data||"; // || for not tamper $pass=base64_encode($data); die ($pass); } function deliverfile($filename){ $ftp_server="ftp.example.com"; // your domain DESIRED //$ftp_server="93.184.216.34"; // sometimes is better put the ip directly $ftp_user_name="your user"; $ftp_user_pass="your pass"; // a safe password $source=$filename; $target="public_html/$filename"; $conn_id = ftp_connect($ftp_server); // set up a connection to ftp server // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection and login result if ((!$conn_id) || (!$login_result)) { echo "<li>FTP connection has encountered an error! <br />Attempted to connect to $ftp_server for user $ftp_user_name...."; exit; } else { echo "<li>Connected to $ftp_server, for user $ftp_user_name"."....."; // upload the file to the path specified $upload = ftp_put($conn_id, $target, $source, FTP_BINARY); // check the upload status if (!$upload) { echo "<li>FTP upload has encountered an error!"; } else { echo "<li>Uploaded file with name $target to $ftp_server "; } } // close the FTP connection ftp_close($conn_id); die(); } // subir archivo por ftp function aValues3192($Qx){ $rsX = mysql_query($Qx) or SQL_ERROR("Avalues 3192",$Qx); $aDataX = array(); $Campos = mysql_num_fields($rsX); while ($regX = mysql_fetch_array($rsX, MYSQL_ASSOC)) { for($iX=0; $iX<$Campos; $iX++){ $aDataX[] = $regX[ mysql_field_name($rsX,$iX) ]; } } return $aDataX; } ?>