partner/library/Paybox/Config.php

63 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2013-11-07 18:15:58 +01:00
<?php
class Paybox_Config
{
protected $PBX_SITE;
protected $PBX_RANG;
protected $PBX_IDENTIFIANT;
protected $KEY;
protected $SERVER;
2013-11-14 09:01:11 +01:00
protected $URL_PAIEMENT;
2013-11-15 09:24:12 +01:00
public function __construct($test = false)
2013-11-07 18:15:58 +01:00
{
2013-11-15 09:24:12 +01:00
if ($test === false) {
2013-11-07 18:15:58 +01:00
$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;
2013-11-14 09:01:11 +01:00
$this->URL_PAIEMENT = $serveur['url'];
2013-11-07 18:15:58 +01:00
return true;
break;
}
// else : La machine est disponible mais les services ne le sont pas.
}
if(!$serveurOK){
return false;
}
}
}