2012-10-16 07:44:31 +00:00
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
< ? php
/**
** Attention : Si ajout d ' une nouvelle source modifier la table articles !
** ALTER TABLE `articles` CHANGE `source` `source` ENUM ( 'A' , 'B' , 'D' , 'E' , 'H' ) NOT NULL DEFAULT 'A' ;
**/
include_once ( FWK_PATH . 'common/chiffres.php' );
include_once ( FWK_PATH . 'common/dates.php' );
include_once ( FWK_PATH . 'common/ftp.php' );
2013-06-19 08:24:49 +00:00
include_once ( FWK_PATH . 'mail/sendMail.php' );
2012-10-16 07:44:31 +00:00
$iDb = new WDB ( 'presse' );
2013-06-19 08:24:49 +00:00
$nbHugin = $nbActus = $nbDiRel = $nbEchos = $nbBusin = 0 ;
$doHugin = $doActus = $doEchos = $doBusin = $doAll = false ;
2012-10-16 07:44:31 +00:00
2013-06-19 08:24:49 +00:00
$strInfoProg = 'Usage : ' . basename ( $argv [ 0 ]) . " [OPTION]
Int<EFBFBD> gration des derniers communiqu<EFBFBD> s boursier .
Sans aucun param<EFBFBD> tre , r<EFBFBD> cup<EFBFBD> re les derniers communiqu<EFBFBD> s .
Sinon :
- v Mode bavard
- h Traite uniquement le diffuseur Hugin
- a idem ActuNews
- e idem Les Echos
- b idem BusinessWire
" ;
$argv = $_SERVER [ 'argv' ];
if ( $_SERVER [ 'argc' ] == 1 ) $doAll = true ;
else {
for ( $i = 1 ; isset ( $argv [ $i ]); $i ++ ) {
if ( substr ( $argv [ $i ], 0 , 1 ) == '-' ) {
switch ( substr ( $argv [ $i ], 1 , 1 )) {
case 'h' : $doHugin = true ; break ;
case 'a' : $doActus = true ; break ;
case 'e' : $doEchos = true ; break ;
case 'b' : $doBusin = true ; break ;
case 'v' : $modeDebug = true ; break ;
case '-' : die ( $strInfoProg ); break ;
default : die ( 'Option ' . $argv [ $i ] . " inconnue ! \n " ); break ;
}
}
}
}
if ( ! $doHugin && ! $doActus && ! $doEchos && ! $doBusin ) $doAll = true ;
$strMessage = date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux relatifs aux informations r<> glement<6E> es... " . EOL ;
/*
if ( $doHugin || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux Hugin... " . EOL ;
$ret = ftp_mget ( HUGIN_FTP_URL , HUGIN_FTP_USER , HUGIN_FTP_PASS , '*.xml' , HUGIN_LOCAL_DIR , true );
if ( $ret === false )
die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : R<> cup<75> ration des flux Hugin en FTP incorrecte ! " . EOL );
else {
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de la r<> cup<75> ration des flux Hugin en FTP ( $ret fichiers r<> cup<75> r<EFBFBD> s). " . EOL ;
echo $message ;
$strMessage .= $message ;
}
}
*/
if ( $doActus || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux ActusNews... " . EOL ;
$ret = ftp_mget ( ACTUSNEWS_FTP_URL , ACTUSNEWS_FTP_USER , ACTUSNEWS_FTP_PASS , '*.xml' , ACTUSNEWS_LOCAL_DIR , true );
if ( $ret === false )
die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : R<> cup<75> ration des flux ActusNews en FTP incorrecte ! " . EOL );
else {
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de la r<> cup<75> ration des flux ActusNews en FTP ( $ret fichiers r<> cup<75> r<EFBFBD> s). " . EOL ;
echo $message ;
$strMessage .= $message ;
}
}
/*
2012-10-16 07:44:31 +00:00
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux Di Release... " . EOL ;
$ret = ftp_mget ( DIRELEASE_FTP_URL , DIRELEASE_FTP_USER , DIRELEASE_FTP_PASS , '*.xml' , DIRELEASE_LOCAL_DIR , true );
if ( $ret === false )
die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : R<> cup<75> ration des flux Di Release en FTP incorrecte ! " . EOL );
2013-06-19 08:24:49 +00:00
else {
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de la r<> cup<75> ration des flux Di Release en FTP ( $ret fichiers r<> cup<75> r<EFBFBD> s). " . EOL ;
echo $message ;
$strMessage .= $message ;
} */
2012-10-16 07:44:31 +00:00
2013-06-19 08:24:49 +00:00
if ( $doBusin || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux BusinessWire... " . EOL ;
$dh = opendir ( BUSINESSWIRE_LOCAL_DIR_INCOMING );
$ret = 0 ;
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
if ( ! file_exists ( BUSINESSWIRE_LOCAL_DIR . $filename ) && filesize ( BUSINESSWIRE_LOCAL_DIR_INCOMING . $filename ) > 0 ) {
copy ( BUSINESSWIRE_LOCAL_DIR_INCOMING . $filename , BUSINESSWIRE_LOCAL_DIR . $filename );
$ret ++ ;
}
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de la r<> cup<75> ration des flux BusinessWire ( $ret fichiers copi<70> s). " . EOL ;
echo $message ;
$strMessage .= $message ;
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
if ( $doEchos || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de la r<> cup<75> ration des flux Les Echos... " . EOL ;
$ret = ftp_mget ( LESECHOS_FTP_URL , LESECHOS_FTP_USER , LESECHOS_FTP_PASS , 'syndication/*.xml' , LESECHOS_LOCAL_DIR , true );
if ( $ret === false )
die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : R<> cup<75> ration des flux Les Echos en FTP incorrecte ! " . EOL );
else {
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de la r<> cup<75> ration des flux Les Echos en FTP ( $ret fichiers r<> cup<75> r<EFBFBD> s). " . EOL ;
echo $message ;
$strMessage .= $message ;
}
}
2012-10-16 07:44:31 +00:00
/**
** INTEGRATION DES COMMUNIQUES " HUGIN "
**/
2013-06-19 08:24:49 +00:00
if ( $doHugin || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de l'int<6E> gration des flux Hugin... " . EOL ;
$tabFichier = array ();
$dh = opendir ( HUGIN_LOCAL_DIR );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
$tabFichier [] = $filename ;
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
foreach ( $tabFichier as $k => $nomFichier ) {
$tabTmp = file ( HUGIN_LOCAL_DIR . $nomFichier );
if ( ! $tabTmp ) die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Fichier local $nomFichier inexistant ! " . EOL );
if ( stripos ( $tabTmp [ 0 ], 'ISO-8859-1' ) > 0 ) $encoding = 'ISO-8859-1' ;
elseif ( stripos ( $tabTmp [ 0 ], 'UTF-8' ) > 0 ) $encoding = 'UTF-8' ;
else die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Encoding " . $tabTmp [ 0 ] . " non g<> r<EFBFBD> ! " . EOL );
$dom = @ new DomDocument2 ();
@ $dom -> load ( HUGIN_LOCAL_DIR . $nomFichier );
$pressReleaseId =@ $dom -> getValueFromTag ( 'PRESS_RELEASE_ID' );
$tabInsert = array ( 'companyId' => $dom -> getValueFromTag ( 'COMPANY_ID' ),
'companyName' => $dom -> getValueFromTag ( 'COMPANY_NAME' ),
'companyIsin' => $dom -> getValueFromTag ( 'COMPANY_ISIN' ),
'companySiren' => $dom -> getValueFromTag ( 'COMPANY_SIREN' ),
'companyRic' => $dom -> getValueFromTag ( 'COMPANY_RIC' ),
'companyLogoUrl' => $dom -> getValueFromTag ( 'URL1' ),
'companyWebSite' => $dom -> getValueFromTag ( 'URL2' ),
'companyProfile' => $dom -> getValueFromTag ( 'URL3' ),
'companyAnnualReport' => $dom -> getValueFromTag ( 'URL4' ),
'companyInfoActionnaires' => $dom -> getValueFromTag ( 'URL5' ),
'pressReleaseId' => $pressReleaseId ,
'pressReleaseDate' => $dom -> getValueFromTag ( 'PRESS_RELEASE_DATE_TIME' ),
'pressReleaseTitle' => $dom -> getValueFromTag ( 'PRESS_RELEASE_TITLE' ),
'pressReleaseText' => $dom -> getValueFromTag ( 'TEXT_FORMAT' ),
'pressReleaseHtml' => $dom -> getValueFromTag ( 'HTML_FORMAT' ),
'pressReleaseAttachments' => $dom -> getValueFromTag ( 'ATTACHMENTS_URL1' ),
'pressReleaseUrl' => $dom -> getValueFromTag ( 'PRESS_RELEASE_URL_CNG' ),
'indexAll' => $dom -> getValueFromTag ( 'INDEX_ALL' ),
'indexTheme' => $dom -> getValueFromTag ( 'INDEX_THEME' ),
'indexSector' => $dom -> getValueFromTag ( 'INDEX_SECTOR' ),
'indexCountry' => $dom -> getValueFromTag ( 'INDEX_COUNTRY' ),
'indexLanguage' => $dom -> getValueFromTag ( 'INDEX_LANGUAGE' ),
'indexMarketPlace' => $dom -> getValueFromTag ( 'INDEX_MARKET_PLACE' ),
'indexQuoteInd' => $dom -> getValueFromTag ( 'INDEX_QUOTE_INDICATOR' ),
'source' => 'H' ,
);
$ret = $iDb -> insert ( 'articles' , $tabInsert );
if ( ! $ret && $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - ERREUR " . $iDb -> getLastError () . EOL ;
print_r ( $tabInsert );
die ();
} elseif ( $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Communiqu<71> n<> $pressReleaseId enregistr<74> avec succ<63> s. " . EOL ;
$nbHugin ++ ;
}
unset ( $dom );
}
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de l'int<6E> gration des $nbHugin communiqu<71> s Hugin. " . EOL ;
echo $message ;
$strMessage .= $message ;
2012-10-16 07:44:31 +00:00
}
/**
** INTEGRATION DES COMMUNIQUES " ACTUSNEWS "
**/
2013-06-19 08:24:49 +00:00
if ( $doActus || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de l'int<6E> gration des flux ActusNews... " . EOL ;
$tabFichier = array ();
$dh = opendir ( ACTUSNEWS_LOCAL_DIR );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
$tabFichier [] = $filename ;
}
foreach ( $tabFichier as $k => $nomFichier ) {
$tabTmp = file ( ACTUSNEWS_LOCAL_DIR . $nomFichier );
if ( ! $tabTmp ) die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Fichier local $nomFichier inexistant ! " . EOL );
2012-10-16 07:44:31 +00:00
2013-06-19 08:24:49 +00:00
if ( stripos ( $tabTmp [ 0 ], 'ISO-8859-1' ) > 0 ) $encoding = 'ISO-8859-1' ;
elseif ( stripos ( $tabTmp [ 0 ], 'UTF-8' ) > 0 ) $encoding = 'UTF-8' ;
else die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Encoding " . $tabTmp [ 0 ] . " non g<> r<EFBFBD> ! " . EOL );
foreach ( $tabTmp as $i_ligne => $ligne ) {
if ( stripos ( $ligne , '<communique ' ) !== false ) { //<communique
//echo date ('Y/m/d - H:i:s')." - Premi<6D> re ligne du communiqu<71> ...".EOL;
if ( stripos ( $ligne , 'langue="FR"' ) > 0 ) {
//echo date ('Y/m/d - H:i:s')." - Communiqu<71> en fran<61> ais ($ligne).".EOL;
$french = true ;
} else {
//echo date ('Y/m/d - H:i:s')." - Langue non int<6E> gr<67> e en base ($ligne) !".EOL;
$french = false ;
break ;
}
2012-10-16 07:44:31 +00:00
break ;
}
2013-06-19 08:24:49 +00:00
}
if ( $french ) {
//echo date ('Y/m/d - H:i:s')." - Chargement du communiqu<71> ...".EOL;
$dom = @ new DomDocument2 ();
$dom -> load ( ACTUSNEWS_LOCAL_DIR . $nomFichier );
$pressReleaseId = $dom -> getValueFromTag ( 'id' );
$tabInsert = array ( //'companyId'=>$dom->getValueFromTag('COMPANY_ID'),
'companyName' => trim ( $dom -> getValueFromTag ( 'raisonsociale' )),
'companyIsin' => trim ( $dom -> getValueFromTag ( 'codeisin' )),
//'companySiren'=>$dom->getValueFromTag('COMPANY_SIREN'),
'companyRic' => trim ( $dom -> getValueFromTag ( 'code_reuters' )),
'companyLogoUrl' => trim ( $dom -> getValueFromTag ( 'logo' )),
'companyWebSite' => trim ( $dom -> getValueFromTag ( 'site' )),
//'companyProfile'=>$dom->getValueFromTag('URL3'),
//'companyAnnualReport'=>$dom->getValueFromTag('URL4'),
'companyInfoActionnaires' => trim ( $dom -> getValueFromTag ( 'site_investisseur' )),
'pressReleaseId' => $pressReleaseId ,
'pressReleaseDate' => trim ( $dom -> getValueFromTag ( 'miseajour' )),
'pressReleaseTitle' => trim ( $dom -> getValueFromTag ( 'titre' )),
'pressReleaseText' => trim ( strtr ( html_entity_decode ( strip_tags ( $dom -> getValueFromTag ( 'contenu' ))), array ( '’' => '<27> ' ))),
'pressReleaseHtml' => trim ( $dom -> getValueFromTag ( 'contenu' )),
'pressReleaseAttachments' => trim ( $dom -> getValueFromTag ( 'pdf' )),
//'pressReleaseUrl'=>$dom->getValueFromTag('PRESS_RELEASE_URL_CNG'),
/* 'indexAll' => $dom -> getValueFromTag ( 'INDEX_ALL' ),
'indexTheme' => $dom -> getValueFromTag ( 'INDEX_THEME' ),
'indexCountry' => $dom -> getValueFromTag ( 'INDEX_COUNTRY' ),
'indexLanguage' => $dom -> getValueFromTag ( 'INDEX_LANGUAGE' ),
*/
'indexQuoteInd' => trim ( $dom -> getValueFromTag ( 'indice' )),
'indexSector' => trim ( $dom -> getValueFromTag ( 'secteur' )),
'indexMarketPlace' => trim ( $dom -> getValueFromTag ( 'marche_cotation' )),
'source' => 'A' ,
'companyBloomberg' => trim ( $dom -> getValueFromTag ( 'code_bloomberg' )),
'companyMnemo' => trim ( $dom -> getValueFromTag ( 'mnemo' )),
'companyNbTitles' => trim ( $dom -> getValueFromTag ( 'nb_de_titres' )),
'companyFootsie' => trim ( $dom -> getValueFromTag ( 'footsie' )),
);
$ret = $iDb -> insert ( 'articles' , $tabInsert );
if ( ! $ret && $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - ERREUR " . $iDb -> getLastError () . EOL ;
print_r ( $tabInsert );
die ();
} elseif ( $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Communiqu<71> n<> $pressReleaseId enregistr<74> avec succ<63> s. " . EOL ;
$nbActus ++ ;
}
unset ( $dom );
2012-10-16 07:44:31 +00:00
}
}
2013-06-19 08:24:49 +00:00
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de l'int<6E> gration des $nbActus communiqu<71> s ActusNews. " . EOL ;
echo $message ;
$strMessage .= $message ;
2012-10-16 07:44:31 +00:00
}
/**
** INTEGRATION DES COMMUNIQUES " DIRELEASE "
**/
2013-06-19 08:24:49 +00:00
/* echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de l'int<6E> gration des flux DiRelease... " . EOL ;
2012-10-16 07:44:31 +00:00
$tabFichier = array ();
$dh = opendir ( DIRELEASE_LOCAL_DIR );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
$tabFichier [] = $filename ;
}
/** @ todo Pour DiRelease , Ne pas utiliser le parser XML mais uniquement des expr . r<EFBFBD> guli<EFBFBD> re car XML de merde .
** Prendre tous les ISIN et rechercher le SIREN .
2013-06-19 08:24:49 +00:00
**
2012-10-16 07:44:31 +00:00
foreach ( $tabFichier as $k => $nomFichier ) {
$strTmp = file_get_contents ( DIRELEASE_LOCAL_DIR . $nomFichier );
if ( stripos ( $strTmp , 'ISO-8859-1' ) > 0 ) $encoding = 'ISO-8859-1' ;
elseif ( stripos ( $strTmp , 'UTF-8' ) > 0 ) $encoding = 'UTF-8' ;
else die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Encoding non g<> r<EFBFBD> ! " . EOL );
if ( stripos ( $strTmp , 'langue="FR"' ) > 0 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Chargement du communiqu<71> en fran<61> ais ( $ligne ). " . EOL ;
preg_match ( '/<id>(.*)<\/id>/isU' , $strTmp , $matches );
$pressReleaseId = trim ( @ $matches [ 1 ]);
preg_match ( '/<raisonsociale>(.*)<\/raisonsociale>/isU' , $strTmp , $matches );
$raisonsociale = trim ( @ $matches [ 1 ]);
preg_match ( '/<codeisin>(.*)<\/codeisin>/isU' , $strTmp , $matches );
$codeisin = trim ( @ $matches [ 1 ]);
preg_match ( '/<code_reuters>(.*)<\/code_reuters>/isU' , $strTmp , $matches );
$code_reuters = trim ( @ $matches [ 1 ]);
preg_match ( '/<logo>(.*)<\/logo>/isU' , $strTmp , $matches );
$logo = trim ( @ $matches [ 1 ]);
preg_match ( '/<site>(.*)<\/site>/isU' , $strTmp , $matches );
$site = trim ( @ $matches [ 1 ]);
preg_match ( '/<site_investisseur>(.*)<\/site_investisseur>/isU' , $strTmp , $matches );
$site_investisseur = trim ( @ $matches [ 1 ]);
preg_match ( '/<logo>(.*)<\/logo>/isU' , $strTmp , $matches );
$logo = trim ( preg_replace ( '/\s/' , '' , @ $matches [ 1 ]));
preg_match ( '/<miseajour>(.*)<\/miseajour>/isU' , $strTmp , $matches );
$miseajour = trim ( @ $matches [ 1 ]);
preg_match ( '/<titre>(.*)<\/titre>/isU' , $strTmp , $matches );
$titre = trim ( @ $matches [ 1 ]);
preg_match ( '/<contenu>(.*)<\/contenu>/isU' , $strTmp , $matches );
$contenu = trim ( strtr ( @ $matches [ 1 ], array ( '<![CDATA[' => '' , ']]>' => '' )));
preg_match ( '/<pdf>(.*)<\/pdf>/isU' , $strTmp , $matches );
$pdf = preg_replace ( '/\s/' , '' , @ $matches [ 1 ]);
preg_match ( '/<indice>(.*)<\/indice>/isU' , $strTmp , $matches );
$indice = trim ( @ $matches [ 1 ]);
preg_match ( '/<secteur>(.*)<\/secteur>/isU' , $strTmp , $matches );
$secteur = trim ( @ $matches [ 1 ]);
preg_match ( '/<marche_cotation>(.*)<\/marche_cotation>/isU' , $strTmp , $matches );
$marche_cotation = trim ( @ $matches [ 1 ]);
preg_match ( '/<code_bloomberg>(.*)<\/code_bloomberg>/isU' , $strTmp , $matches );
$code_bloomberg = trim ( @ $matches [ 1 ]);
preg_match ( '/<mnemo>(.*)<\/mnemo>/isU' , $strTmp , $matches );
$mnemo = trim ( @ $matches [ 1 ]);
preg_match ( '/<nb_de_titres>(.*)<\/nb_de_titres>/isU' , $strTmp , $matches );
$nb_de_titres = trim ( @ $matches [ 1 ]);
preg_match ( '/<footsie>(.*)<\/footsie>/isU' , $strTmp , $matches );
$footsie = trim ( @ $matches [ 1 ]);
$tabInsert = array ( //'companyId'=>$dom->getValueFromTag('COMPANY_ID'),
'companyName' => $raisonsociale ,
'companyIsin' => $codeisin ,
//'companySiren'=>$dom->getValueFromTag('COMPANY_SIREN'),
'companyRic' => $code_reuters ,
'companyLogoUrl' => $logo ,
'companyWebSite' => $site ,
//'companyProfile'=>$dom->getValueFromTag('URL3'),
//'companyAnnualReport'=>$dom->getValueFromTag('URL4'),
'companyInfoActionnaires' => $site_investisseur ,
'pressReleaseId' => $pressReleaseId ,
'pressReleaseDate' => $miseajour ,
'pressReleaseTitle' => $titre ,
'pressReleaseText' => trim ( strtr ( html_entity_decode ( strip_tags ( $contenu )), array ( '’' => '<27> ' ))),
'pressReleaseHtml' => $contenu ,
'pressReleaseAttachments' => $pdf ,
'indexQuoteInd' => $indice ,
'indexSector' => $secteur ,
'indexMarketPlace' => $marche_cotation ,
'source' => 'D' ,
'companyBloomberg' => $code_bloomberg ,
'companyMnemo' => $mnemo ,
'companyNbTitles' => $nb_de_titres ,
'companyFootsie' => $footsie ,
);
$ret = $iDb -> insert ( 'articles' , $tabInsert );
if ( ! $ret && $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - ERREUR " . $iDb -> getLastError () . EOL ;
print_r ( $tabInsert );
die ();
} elseif ( $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Communiqu<71> n<> $pressReleaseId enregistr<74> avec succ<63> s. " . EOL ;
2013-06-19 08:24:49 +00:00
$nbDiRel ++ ;
2012-10-16 07:44:31 +00:00
}
unset ( $dom );
}
}
2013-06-19 08:24:49 +00:00
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de l'int<6E> gration des $nbDiRel communiqu<71> s DiRelease. " . EOL ;
echo $message ;
$strMessage .= $message ;
*/
2012-10-16 07:44:31 +00:00
/**
** INTEGRATION DES COMMUNIQUES " BUSINESSWIRE "
**/
2013-06-19 08:24:49 +00:00
if ( $doBusin || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de l'int<6E> gration des flux BusinessWire... " . EOL ;
$tabFichier = array ();
$dh = opendir ( BUSINESSWIRE_LOCAL_DIR );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
$tabFichier [] = $filename ;
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
foreach ( $tabFichier as $k => $nomFichier ) {
$tabTmp = file ( BUSINESSWIRE_LOCAL_DIR . $nomFichier );
$strTmp = implode ( " \n " , $tabTmp );
if ( ! $tabTmp ) die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Fichier local " . BUSINESSWIRE_LOCAL_DIR . " $nomFichier inexistant ! " . EOL );
/* if ( stripos ( $tabTmp [ 0 ], 'ISO-8859-1' ) > 0 ) $encoding = 'ISO-8859-1' ;
elseif ( stripos ( $tabTmp [ 0 ], 'UTF-8' ) > 0 ) $encoding = 'UTF-8' ;
elseif ( stripos ( $tabTmp [ 0 ], '<?xml version = \'1.0\'?>' )) $encoding = '?' ;
// <?xml version = '1.0'?>
else die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Encoding " . $tabTmp [ 0 ] . " non g<> r<EFBFBD> pour le fichier " . BUSINESSWIRE_LOCAL_DIR . " $nomFichier ! " . EOL ); */
/*< DateAndTime > 20070906 T190800 + 0000 </ DateAndTime >
< NewsService FormalName = " Business Wire " />
< NewsProduct FormalName = " BUSINESS WIRE " />
</ NewsEnvelope >
< NewsItem >
< Identification >
< NewsIdentifier >
< ProviderId > businesswire . com </ ProviderId >
< DateId > 20010714 </ DateId >
<> 20070906006073 </ NewsItemId >
< RevisionId PreviousRevision = " 0 " Update = " N " > 1 </ RevisionId >
< PublicIdentifier > urn : newsml : businesswire . com : 20010714 : 20070906006073 : 1 </ PublicIdentifier >
</ NewsIdentifier >
</ Identification >
< NewsManagement >
< NewsItemType FormalName = " News " />
< FirstCreated > 20070906 T190800 + 0000 </ FirstCreated >
< ThisRevisionCreated > 20070906 T190800 + 0000 </ ThisRevisionCreated >
< Status FormalName = " Usable " />
< AssociatedWith NewsItem = " businesswire.com:20010714:242009 " />
</ NewsManagement >
< NewsComponent >
< BasisForChoice Rank = " 1 " >./ NewsComponent / DescriptiveMetadata / Language </ BasisForChoice >
< NewsLines >
< CopyrightLine > Copyright Business Wire 2007 </ CopyrightLine >
</ NewsLines >
< AdministrativeMetadata >
< Source >
< Party FormalName = " CIT Group Inc. " />
</ Source >
< Contributor >
< Comment FormalName = " BWoffices " > NY </ Comment >
< Party FormalName = " DB " Scheme = " BWEditor " />
</ Contributor >
</ AdministrativeMetadata >
< DescriptiveMetadata >
< Language FormalName = " fr " />
< Genre FormalName = " Release " />
</ DescriptiveMetadata >
< Metadata >
< MetadataType FormalName = " BWKeywords " />
< Property FormalName = " BWCountryKeywords " Value = " United States " />
< Property FormalName = " BWRegionKeywords " Value = " Europe " />
< Property FormalName = " BWRegionKeywords " Value = " North America " />
< Property FormalName = " BWIndustryKeywords " Value = " Manufacturing " />
< Property FormalName = " BWIndustryKeywords " Value = " Aerospace " />
< Property FormalName = " BWCategoryKeywords " Value = " Product/Service " />
< Property FormalName = " BWIndustryKeywords " Value = " Professional Services " />
< Property FormalName = " BWIndustryKeywords " Value = " Finance " />
< Property FormalName = " BWStateKeywords " Value = " New York " />
< Property FormalName = " BWCountryKeywords " Value = " Ireland " />
</ Metadata >
< Metadata >
< MetadataType FormalName = " Securities Identifier " />
< Property FormalName = " " Value = " CIT " />
< Property FormalName = " Exchange " Value = " NYSE " />
< Property FormalName = " ISIN " Value = " US1255811085 " />
< Property FormalName = " SlugLine Display Order " Value = " 1 " />
</ Metadata >
< NewsComponent >
< BasisForChoice Rank = " 1 " >./ NewsComponent / Role </ BasisForChoice >
< NewsLines >
<> CIT consolide son engagement envers l ' <EFBFBD> conomie irlandaise et agrandit son centre op<EFBFBD> rationnel de Dublin </ HeadLine >*/
$dom = @ new DomDocument2 ();
$dom -> load ( BUSINESSWIRE_LOCAL_DIR . $nomFichier );
$pressReleaseId = $dom -> getValueFromTag ( 'NewsItemId' );
preg_match ( '/<Property FormalName="ISIN" Value="(.*)"\/>/i' , $strTmp , $matches );
$isin =@ $matches [ 1 ];
preg_match ( '/<Property FormalName="Exchange" Value="(.*)"\/>/i' , $strTmp , $matches );
$exchange =@ $matches [ 1 ];
preg_match ( '/<Property FormalName="Ticker Symbol" Value="(.*)"\/>/i' , $strTmp , $matches );
$mnemo =@ $matches [ 1 ];
preg_match ( '/<NewsLineType FormalName="ClickThru URL"(?:.*)<NewsLineText>(.*)<\/NewsLineText>/isU' , $strTmp , $matches );
$siteWeb =@ $matches [ 1 ];
preg_match ( '/<NewsComponent>(?:.*)<Role FormalName="Logo"\/>(?:.*)<ContentItem Duid="(?:.*)" Href="(.*)">(?:.*)<\/NewsComponent>/isU' , $strTmp , $matches );
$logo = urldecode ( @ $matches [ 1 ]);
preg_match ( '/<NewsComponent>(?:.*)<Role FormalName="Body"\/>(?:.*)<ContentItem (?:.*)<Format FormalName="XHTML"\/>(?:.*)<DataContent>(.*)<\/DataContent>/isU' , $strTmp , $matches );
$bodyHtml = utf8_decode ( @ $matches [ 1 ]);
preg_match ( '/<NewsComponent>(?:.*)<Role FormalName="Body"\/>(?:.*)<ContentItem (?:.*)<Format FormalName="BW-Text"\/>(?:.*)<DataContent>(.*)<\/DataContent>/isU' , $strTmp , $matches );
$bodyTxt = utf8_decode ( @ $matches [ 1 ]);
preg_match_all ( '/<Property FormalName="BWIndustryKeywords" Value="(.*)"\/>/iU' , $strTmp , $matches );
$industry =@ implode ( ';' , @ $matches [ 1 ]);
preg_match_all ( '/<Property FormalName="BWCategoryKeywords" Value="(.*)"\/>/iU' , $strTmp , $matches );
$category =@ implode ( ';' , @ $matches [ 1 ]);
preg_match_all ( '/<Property FormalName="BWCountryKeywords" Value="(.*)"\/>/iU' , $strTmp , $matches );
$country =@ implode ( ';' , @ $matches [ 1 ]);
preg_match ( '/<Language FormalName="(.*)"\/>/i' , $strTmp , $matches );
$language =@ $matches [ 1 ];
$tabInsert = array ( //'companyId'=>$dom->getValueFromTag('COMPANY_ID'),
'companyName' => $dom -> getValueFromTag ( 'SlugLine' ),
'companyIsin' => $isin ,
'companyMnemo' => $mnemo ,
'companyWebSite' => $siteWeb ,
'companyLogoUrl' => $logo ,
/* 'companySiren' => $dom -> getValueFromTag ( 'COMPANY_SIREN' ),
'companyRic' => $dom -> getValueFromTag ( 'COMPANY_RIC' ),
'companyProfile' => $dom -> getValueFromTag ( 'URL3' ),
'companyAnnualReport' => $dom -> getValueFromTag ( 'URL4' ),
'companyInfoActionnaires' => $dom -> getValueFromTag ( 'URL5' ), */
'pressReleaseId' => $pressReleaseId ,
'pressReleaseDate' => substr ( str_replace ( 'T' , '' , $dom -> getValueFromTag ( 'DateAndTime' )), 0 , 14 ), // 20070906T190800+0000
'pressReleaseTitle' => $dom -> getValueFromTag ( 'HeadLine' ),
'pressReleaseText' => $bodyTxt ,
'pressReleaseHtml' => $bodyHtml ,
'indexMarketPlace' => $exchange ,
'indexTheme' => $category ,
'indexSector' => $industry ,
'indexCountry' => $country ,
'indexLanguage' => $language ,
/*
'pressReleaseAttachments' => $dom -> getValueFromTag ( 'ATTACHMENTS_URL1' ),
'pressReleaseUrl' => $dom -> getValueFromTag ( 'PRESS_RELEASE_URL_CNG' ),
'indexAll' => $dom -> getValueFromTag ( 'INDEX_ALL' ),
'indexQuoteInd' => $dom -> getValueFromTag ( 'INDEX_QUOTE_INDICATOR' ), */
'source' => 'B' ,
);
2012-10-16 07:44:31 +00:00
$ret = $iDb -> insert ( 'articles' , $tabInsert );
if ( ! $ret && $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - ERREUR " . $iDb -> getLastError () . EOL ;
print_r ( $tabInsert );
die ();
} elseif ( $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Communiqu<71> n<> $pressReleaseId enregistr<74> avec succ<63> s. " . EOL ;
2013-06-19 08:24:49 +00:00
$nbBusin ++ ;
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
unset ( $dom );
}
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de l'int<6E> gration des $nbBusin communiqu<71> s BusinessWire. " . EOL ;
echo $message ;
$strMessage .= $message ;
}
/**
** INTEGRATION DES COMMUNIQUES " LES ECHOS "
**/
if ( $doEchos || $doAll ) {
echo date ( 'Y/m/d - H:i:s' ) . " - DEBUT de l'int<6E> gration des flux Les Echos... " . EOL ;
$tabFichier = array ();
$dh = opendir ( LESECHOS_LOCAL_DIR . 'syndication/' );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.xml' )
$tabFichier [] = $filename ;
}
foreach ( $tabFichier as $k => $nomFichier ) {
$tabTmp = file ( LESECHOS_LOCAL_DIR . 'syndication/' . $nomFichier );
if ( ! $tabTmp ) die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Fichier local $nomFichier inexistant ! " . EOL );
if ( stripos ( $tabTmp [ 0 ], 'ISO-8859-1' ) > 0 ) $encoding = 'ISO-8859-1' ;
elseif ( stripos ( $tabTmp [ 0 ], 'UTF-8' ) > 0 ) $encoding = 'UTF-8' ;
else die ( date ( 'Y/m/d - H:i:s' ) . " - ERREUR : Encoding " . $tabTmp [ 0 ] . " non g<> r<EFBFBD> ! " . EOL );
$dom = @ new DomDocument2 ();
$dom -> load ( LESECHOS_LOCAL_DIR . 'syndication/' . $nomFichier );
$pressReleaseId = $dom -> getValueFromTag ( 'CODE' );
$language = strtoupper ( $dom -> getValueFromTag ( 'PRESS_RELEASE_LANGUAGE' ));
$tabInsert = array ( //'companyId'=>$dom->getValueFromTag('COMPANY_ID'),
'companyName' => $dom -> getValueFromTag ( 'COMPANY_NAME' ),
'companyIsin' => $dom -> getValueFromTag ( 'COMPANY_ISIN' ),
//'companySiren'=>$dom->getValueFromTag('COMPANY_SIREN'),
//'companyRic'=>$dom->getValueFromTag('COMPANY_RIC'),
//'companyLogoUrl'=>$dom->getValueFromTag('URL1'),
//'companyWebSite'=>$dom->getValueFromTag('URL2'),
//'companyProfile'=>$dom->getValueFromTag('URL3'),
//'companyAnnualReport'=>$dom->getValueFromTag('URL4'),
//'companyInfoActionnaires'=>$dom->getValueFromTag('URL5'),
'pressReleaseId' => $pressReleaseId ,
'pressReleaseDate' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , $dom -> getValueFromTag ( 'PRESS_RELEASE_PUBDATE' )) . ' ' .
$dom -> getValueFromTag ( 'PRESS_RELEASE_PUBTIME' ),
'pressReleaseTitle' => $dom -> getValueFromTag ( 'PRESS_RELEASE_TITLE' ),
'pressReleaseText' => $dom -> getValueFromTag ( 'TEXT_FORMAT' ),
'pressReleaseHtml' => $dom -> getValueFromTag ( 'HTML_FORMAT' ),
'pressReleaseAttachments' => $dom -> getValueFromTag ( 'LINK_ORIGINAL' ),
'pressReleaseUrl' => $dom -> getValueFromTag ( 'LINK' ),
//'indexAll'=>$dom->getValueFromTag('INDEX_ALL'),
'indexTheme' => $dom -> getValueFromTag ( 'PRESS_RELEASE_THEME' ),
//'indexSector'=>$dom->getValueFromTag('INDEX_SECTOR'),
//'indexCountry'=>$dom->getValueFromTag('INDEX_COUNTRY'),
'indexLanguage' => $language ,
//'indexMarketPlace'=>$dom->getValueFromTag('INDEX_MARKET_PLACE'),
//'indexQuoteInd'=>$dom->getValueFromTag('INDEX_QUOTE_INDICATOR'),
'source' => 'E' ,
);
if ( $language == 'FR' ) {
$ret = $iDb -> insert ( 'articles' , $tabInsert );
if ( ! $ret && $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - ERREUR " . $iDb -> getLastError () . EOL ;
print_r ( $tabInsert );
die ();
} elseif ( $iDb -> getLastErrorNum () <> 1062 ) {
echo date ( 'Y/m/d - H:i:s' ) . " - Communiqu<71> n<> $pressReleaseId enregistr<74> avec succ<63> s. " . EOL ;
$nbEchos ++ ;
}
} else
echo date ( 'Y/m/d - H:i:s' ) . " - Langue du communiqu<71> non int<6E> gr<67> e en base ( $language ). " . EOL ;
unset ( $dom );
}
$message = date ( 'Y/m/d - H:i:s' ) . " - FIN de l'int<6E> gration des $nbEchos communiqu<71> s Les Echos. " . EOL ;
echo $message ;
$strMessage .= $message ;
2012-10-16 07:44:31 +00:00
}
2013-06-19 08:24:49 +00:00
sendMail ( 'webmaster@scores-decisions.com' , 'support@scores-decisions.com,ylenaour@scores-decisions.com' , " Int<EFBFBD> gration des informations r<> glement<6E> es " , $strMessage );
2012-10-16 07:44:31 +00:00
die ();
?>