63 lines
1.2 KiB
PHP
63 lines
1.2 KiB
PHP
<?php
|
|
class Paybox_Config
|
|
{
|
|
protected $PBX_SITE;
|
|
|
|
protected $PBX_RANG;
|
|
|
|
protected $PBX_IDENTIFIANT;
|
|
|
|
protected $KEY;
|
|
|
|
protected $SERVER;
|
|
|
|
protected $URL_PAIEMENT;
|
|
|
|
public function __construct($test = false)
|
|
{
|
|
if ($test === false) {
|
|
$config = new Paybox_Config_Prod();
|
|
} else {
|
|
$config = new Paybox_Config_Test();
|
|
}
|
|
|
|
foreach ( $config->variables as $var => $value ) {
|
|
$this->{'PBX_'.$var} = $value;
|
|
}
|
|
|
|
$this->KEY = $config->key;
|
|
$this->SERVER = $config->server;
|
|
|
|
}
|
|
|
|
/**
|
|
* Check server availability and set the paiement url
|
|
* @return boolean
|
|
*/
|
|
public function checkservers()
|
|
{
|
|
$serveurOK = "";
|
|
foreach($this->SERVER as $serveur)
|
|
{
|
|
$doc = new DOMDocument();
|
|
$doc->loadHTMLFile($serveur['ping']);
|
|
$server_status = "";
|
|
$element = $doc->getElementById('server_status');
|
|
if($element){
|
|
$server_status = $element->textContent;
|
|
}
|
|
if($server_status == "OK"){
|
|
//Le serveur est prêt et les services opérationnels
|
|
$serveurOK = $serveur;
|
|
$this->URL_PAIEMENT = $serveur['url'];
|
|
return true;
|
|
break;
|
|
}
|
|
// else : La machine est disponible mais les services ne le sont pas.
|
|
}
|
|
if(!$serveurOK){
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} |