Ahoj,
mám několik lokálních webů a pak jeden centrální, na kterém potřebuju kromě vlastních dat zobrazovat rovněž data ze všech lokálních webů. S tím, že centrální web nemůže přistupovat k lokálním databázím.
Chtěl bych znát Váš pohled na to, jak tuto situaci nejlépe vyřešit.
Díky Dušan
Fórum › PHP
Předávání informací mezi weby

Tak třeba na lokálním webu vygenerovat XML soubor a poté ho pomocí centrálního webu načíst a zpracovat.
Řeším podobný problém (a ještě jsem ho nevyřešil). Mám centrální server a dva další servery. Každý v různých částech světa. Potřebuju 1x týdně replikovat MySQL databázi z jednoho serveru na druhý. Zatím to dělám ručně, ale fat mne to nebaví. Nenašel jsem zatím řešení, jak přečíst databázi z jednoho serveru přímo na druhý, krom toho, že si ji stahnu do lokálního PC a pak ji uploaduju na druhý server.
PHP vám dalo FSOCKOPEN ! :)...
@ Dušan: Tu máš funkciu, ktorú používam ja...Je to z mojej triedy...
/**
* Sends POST request to website, returns array (Header request and result).
* Destination must start with protocol (e.g. http://)
*
* @param string $destination
* @param array $data
*
* @return array
*/
public static function sendPostRequest($destination, $data = array())
{
$_data = array();
while(list($param,$value) = each($data))
{ $_data[] = "$param=$value"; }
$request_string = implode("&",$_data);
$request_url = parse_url($destination);
$host = $request_url["host"];
$path = $request_url["path"];
$request = "POST $path HTTP/1.1 \r\n";
$request .= "Host: $host\r\n";
$request .= "Referer: \r\n"; ///TODO: Add Referer.
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-lenght:".strlen($request_string)."\r\n";
$request .= "Connection: close \r\n\r\n";
$request .= "$request_string";
$fp = fsockopen($host, 80);
fputs($fp, $request);
$result = '';
while(!feof($fp)) { $result .= fgets($fp, 128); }
fclose($fp);
return array($request, $result);
}
/**
* Sends GET request to website, returns array (header request and result).
* Destination must start with protocol (e.g. http://)
*
* @param string $destination
* @param array $data
*
* @return array
*/
public static function sendGetRequest($destination, $data = array())
{
$_data = array();
while(list($param,$value) = each($data))
{ $_data[] = "$param=$value"; }
$requestUrl = parse_url($destination);
$host = $requestUrl["host"];
$path = $requestUrl["path"];
$requestString = implode("&", $_data);
$requestString = "?" . $requestString;
$requestString = $path . $requestString;
$request = "GET $requestString HTTP/1.1\r\n";
$request .= "Host: $host\r\n";
$request .= "Referer: \r\n"; ///TODO: Add Referer.
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Connection: close \r\n\r\n";
$fp = fsockopen( $host, 80);
fputs($fp, $request);
$result = '';
while(!feof($fp)) { $result .= fgets($fp, 128); }
fclose($fp);
return array($request, $result);
}
@remmidemmi: Napíš php skript nech ti vyexportuje DB do SQL, zazipuj ho, pošli ho na centrálny server, tam ho rozbaľ a commitni! :)
To Cicero : no neco na tom je, ze by to slo tahle udelat majlem. To neni spatny napad :) Dik.

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Predavani dat mezi formy — založil Jirka
Předávání porměnných mezi objekty — založil Viracochi
Předávání parametrů mezi třídami — založil Jonasberg
Předávání proměnných mezi framy w — založil Petr
Předávání hodnot mezi aplikacemi — založil Sebix
Moderátoři diskuze