include_once(FWK_PATH.'common/curl.php');
/** @todo A faire et sortir du coup la méthode de commande d'enqêtes du WS **/
class MIntersud {
private $body = '';
private $header = '';
private $codeRetour = 0;
private $cookie=false;
private $reference = 0;
private $timeOut=0;
private $url='';
private $urlRacine='http://www.intersud.fr';
private $referer='';
private $curPage='';
public $siren;
function __construct() {
$this->partGetSession();
$this->partConnection();
}
function __destruct() {
$this->partSaveSession();
}
function getInfosDisponbiles($siren) {
$this->siren=$siren;
$this->partConnection();
return $this->partVitrine(true);
}
private function partConnection() {
if (!$this->wrncsrv2 || time()>$this->timeOut) {
$this->timeOut=time()+900;
$this->url=$this->urlRacine.'/index.ow';
$page=getUrl($this->url, '', '', $this->urlRacine, false, 'www.euridile.com');
$this->referer=$this->url;
$this->body=$page['body'];
$this->codeRetour=$page['code'];
$this->header=$page['header'];
//echo date('Y/m/d - H:i:s') ." - Initialisation URL = $this->url (Code retour = $this->codeRetour)
".EOL;
$fp=fopen('./euridile_connexion1.log', 'w');
fwrite($fp,print_r($page,true));
fclose($fp);
if (preg_match('//i', $this->body, $matches))
$this->url=$this->urlRacine.'/'.$matches[1];
else debugLog('E',"Erreur de communication - Redirection impossible sur ".$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
debugLog('I','Redirection trouvée sur la page '.$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
if (preg_match('/\.ow\?WRNCSRV2=(.*)$/i', $matches[1], $matches)) {
$this->wrncsrv2=$matches[1];
debugLog('I','Session partenaire WRNCSRV2='.$this->wrncsrv2,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
}
else debugLog('E','Impossible d\'identifier le numéro de session partenaire',__LINE__,__FILE__,__FUNCTION__,__CLASS__);
$page=getUrl($this->url, '', '',$this->referer, false, 'www.euridile.com');
$this->referer=$this->url;
$this->body=$page['body'];
$this->codeRetour=$page['code'];
$this->header=$page['header'];
debugLog('D',"Page d'accueil URL = $this->url (Code retour = $this->codeRetour)",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
$fp=fopen('./euridile_connexion2.log', 'w');
fwrite($fp,print_r($page,true));
fclose($fp);
if (preg_match('/