Add checkFtp cli
This commit is contained in:
parent
3f94d63d6a
commit
b4366f5599
57
checkFtp.php
Normal file
57
checkFtp.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/includes/config.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
define('FTP_STORAGE','/home/data/ftp');
|
||||
|
||||
//Vérifier montage FTP
|
||||
if (file_exists(FTP_STORAGE . DIRECTORY_SEPARATOR . 'test-presence-ftp')) {
|
||||
$msg = "Liste des fichiers sur le FTP :\n";
|
||||
//Liste des fichiers dans les repertoires
|
||||
if (is_dir(FTP_STORAGE)) {
|
||||
if ($dh = opendir(FTP_STORAGE)) {
|
||||
while (($client = readdir($dh)) !== false) {
|
||||
if ( $client !='.' && $client!= '..'
|
||||
&& !is_link(FTP_STORAGE . DIRECTORY_SEPARATOR . $client)
|
||||
&& is_dir(FTP_STORAGE . DIRECTORY_SEPARATOR . $client) ) {
|
||||
|
||||
$dirClient = FTP_STORAGE . DIRECTORY_SEPARATOR . $client . '/recv';
|
||||
|
||||
if ( file_exists($dirClient) ) {
|
||||
$msg.= "Dossier Client : ".$client."\n";
|
||||
if ($dhFile = opendir($dirClient) ) {
|
||||
while (($file = readdir($dhFile)) !== false) {
|
||||
|
||||
$today = date('Ymd');
|
||||
$fileCpt = 0;
|
||||
if ( $file !='.' && $file!= '..'
|
||||
&& is_file($dirClient . DIRECTORY_SEPARATOR . $file)
|
||||
&& preg_match('/_'.$today.'[0-9]{1,}\./', $file)) {
|
||||
$msg.= $file."\n";
|
||||
$fileCpt++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileCpt==0) {
|
||||
$msg.= "Aucun fichier.\n";
|
||||
}
|
||||
$msg.= "\n";
|
||||
closedir($dhFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
sendMail('supportdev@scores-decisions.com','support@scores-decisions.com',
|
||||
"[CHECK] - FTP ", $msg);
|
||||
|
||||
} else {
|
||||
sendMail(
|
||||
'supportdev@scores-decisions.com',
|
||||
'support@scores-decisions.com',
|
||||
"[CHECK] - FTP ",
|
||||
"FTP non monté sur la machine Batch (192.168.3.201). Vérifier que le FTP fonctionne!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user