#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini '') $strClient=" AND idClient=".$argv[1]; else $strClient=''; $tabUtis=$iDb->select('utilisateurs', "login, idClient", "1 $strClient", false, MYSQL_ASSOC); foreach ($tabUtis as $tabUti) { $tabUser['_'.$tabUti['login']]=$tabUti['idClient']; } $nbCpt=count($tabUser); foreach ($tabUser as $login=>$idClient) { $iCpt++; $login=substr($login,1); if ($iCpt<128) continue; $tabLogs=$iDb->select( 'logs', "count(*) AS nb", "login='$login' AND page='identite' AND source IN(0,5)", false, MYSQL_ASSOC); $nbLim=$tabLogs[0]['nb']; for ($iLim=0;$iLim<=$nbLim;$iLim+=100000) { echo date('Y/m/d H:i:s')." - Compte $iCpt/$nbCpt : Traitement de '$login' $iLim/$nbLim ... "; $tabLogs=$iDb->select( 'logs', "id, login, page, siren, nic, params, idClient, test, actifInsee, source, raisonSociale, cp, ville, dateHeure*1 AS dateHeure", "login='$login' AND page='identite' AND source IN(0,5) LIMIT $iLim,100000", false, MYSQL_ASSOC); $nb=count($tabLogs); if ($nb==0) break; echo "$nb logs à traiter".EOL; foreach ($tabLogs as $tabLog) { $idLog=$tabLog['id']; $siren=$tabLog['siren']; $nic=$tabLog['nic']; $ref=$tabLogs['params']; if ($idClient==0 || $idClient==1 || $idClient==122 || $idClient==123) $test=1; else $test=0; $tabRdvInsee=array(); if ($siren>1000 && $nic>9) $strNic=" AND nic=$nic "; elseif ($siren==0 && $ref>0) $strNic=" AND id=$ref "; elseif ($siren>1000) $strNic=" AND siege=1 ORDER BY actif DESC, nic DESC "; else continue; $rep=$iDb2->select('jo.etablissements', 'siren, nic, actif, siege, raisonSociale, adr_cp, adr_ville, source', "siren=$siren $strNic", false, MYSQL_ASSOC); $tabRep=$rep[0]; $rs= $tabRep['raisonSociale']; $cp= $tabRep['adr_cp']; $vil=$tabRep['adr_ville']; $tabRdvInsee['source']=$tabRep['source']; if ($tabRep['actif']==0) { $tabRdvInsee['actifInsee']=0; } else { $tabRdvInsee['actifInsee']=1; if ($siren>1000 && $tabLog['dateHeure']>20090921000000) { $rep=$iDb2->select('jo.rncs_entrep', 'count(*) AS nb', "siren=$siren", false, MYSQL_ASSOC); $tabRep=$rep[0]; if ($tabRep['nb']>0) $tabRdvInsee['source']=5; } } $tabUpdate=array_merge($tabRdvInsee, array( 'idClient' => $idClient, 'test' => $test, 'raisonSociale' => $rs, 'cp' => $cp, 'ville' => $vil, 'dateHeure' => $tabLog['dateHeure'], )); //print_r($tabLog); //print_r($tabUpdate); //die(); $iDb2->update('logs', $tabUpdate, "id=$idLog"); } } } ?>