104 lines
3.4 KiB
PHP
104 lines
3.4 KiB
PHP
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
|
|
<?php
|
|
|
|
/** Reprise des logs pour les actes téléchargés
|
|
function wsLog() {}
|
|
|
|
include_once(FWK_PATH.'common/chiffres.php');
|
|
include_once(FWK_PATH.'common/dates.php');
|
|
include_once(INCLUDE_PATH.'insee/classMInsee.php');
|
|
include_once(INCLUDE_PATH.'partenaires/classMLiens.php');
|
|
include_once(FWK_PATH.'mail/sendMail.php');
|
|
|
|
$strInfoScript='Usage : '.basename($argv[0]). " <option> [FICHIERS]
|
|
Génération du cache des variables courantes si nécessaire.
|
|
|
|
Options :
|
|
-d Mode debug (Verbosité au maximum)
|
|
-f Forcer la re-Génération du cache
|
|
";
|
|
|
|
$modeDebug=$modeGeneration=false;
|
|
$argv=$_SERVER['argv'];
|
|
|
|
for ($i=1,$j=0; isset($argv[$i]); $i++) {
|
|
if (substr($argv[$i],0,1)=='-') {
|
|
switch (substr($argv[$i],1,1)) {
|
|
case 'd': $modeDebug=true; break;
|
|
case 'f': $modeGeneration=true; break;
|
|
case '-':
|
|
case '?': die($strInfoScript); break;
|
|
default: die('Option '. $argv[$i] . ' inconnue !'.EOL); break;
|
|
}
|
|
}// else $tabFichLigneCmd[]=$argv[$i];
|
|
}
|
|
|
|
$iInsee=new MInsee();
|
|
$iDb=new WDB('sdv1');
|
|
|
|
$dir = "/home/buzuk/";
|
|
// Ouvre un dossier bien connu, et liste tous les fichiers
|
|
if (is_dir($dir)) {
|
|
if ($dh = opendir($dir)) {
|
|
while (($file = readdir($dh)) !== false) {
|
|
if (!is_dir($file)) {
|
|
$tmp=explode('-', $file);
|
|
$type=$tmp[0];
|
|
$siren=$tmp[1];
|
|
$refDoc=strtr($file, array('.pdf'=>'','acte-'=>'','bilan-'=>''));
|
|
$refDoc=substr($refDoc,10);
|
|
echo "Fichier : $file, $type, $siren - ";
|
|
$ret=$iDb->select( 'logs', 'login, page, siren, nic, params, dateHeure',
|
|
"siren=$siren AND login<>'mricois' AND dateHeure BETWEEN '2010-02-19 19:00:00' AND '2010-02-24 09:00:00'", false, MYSQL_ASSOC);
|
|
$nbCmd=count($ret);
|
|
echo "$nbCmd commande(s)";//date('Y/m/d - H:i:s') ." - Recherche de tous les Cedex enregistrés à l'INSEE... $nbCedexInsee cedex.".EOL;
|
|
//*foreach ($ret as $i=>$siretCedex) {*
|
|
if ($nbCmd>0) {
|
|
$acte=$ret[0];
|
|
$page='greffe_'.$type.'s';
|
|
if ($iDb->insert('logs', array('login'=>$acte['login'],
|
|
'page'=>$page,
|
|
'siren'=>$siren,
|
|
'nic'=>$acte['nic'],
|
|
'params'=>$refDoc,
|
|
'dateHeure'=>$acte['dateHeure'])
|
|
))
|
|
echo " ==> REPRISE OK";
|
|
}
|
|
echo EOL;
|
|
}
|
|
}
|
|
closedir($dh);
|
|
}
|
|
}
|
|
die();
|
|
|
|
**/
|
|
|
|
$iDb=new WDB('sdv1');
|
|
|
|
$row = 1;
|
|
if (($handle = fopen("/root/logs/logs_mai.csv", "r")) !== FALSE) {
|
|
while (($data = fgetcsv($handle, 1024, ",")) !== FALSE) {
|
|
$num = count($data);
|
|
//echo "<p> $num champs à la ligne $row: <br /></p>\n";
|
|
$row++;
|
|
$params=str_replace('"','',$data[4]);
|
|
$tabInsert=array( 'login' => $data[0],
|
|
'page' => $data[1],
|
|
'siren' => $data[2],
|
|
'nic' => $data[3],
|
|
'params' => $params,
|
|
'dateHeure' => $data[5],
|
|
);
|
|
echo "$row/585292\t".$data[0].','.$data[1].','.$data[2].','.$data[3].','.$data[4].','.$data[5]."\t";
|
|
if ($iDb->insert('logs', $tabInsert)) echo "ok".EOL;
|
|
else die("KO !!!".EOL);
|
|
//die();
|
|
}
|
|
}
|
|
|
|
fclose($handle);
|
|
|
|
|
|
?>
|