isFile() || $fileinfo->getFilename() == '..' || $fileinfo->getFilename() == '.') { continue; } if(!preg_match($regex_file_in, $fileinfo->getFilename())) { continue; } $content = file_get_contents($fileinfo->getPath().'/'.$fileinfo->getFilename()); if(empty($content)) { continue; } $xml = new SimpleXMLElement($content); if((string) $xml->TypeMessage == 'REFART') { $file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier)); $file = $file[0].'.DAT'; $result = array(); foreach($xml->Listing->Message as $message) { $result[] = ((string) $message['bloquant'] == 'False'? '[W]': '[E]').' '.(string) $message['codeArticle'].' : '.(string) $message; } $result = nl2br(implode("\n", $result)); if($result != '') { Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'philea_syncreport` SET `report_date` = NOW(), `report_data` = "'.pSQL($result, TRUE).'" WHERE `filename` = "'.pSQL($file).'" LIMIT 1 '); } } elseif($xml->TypeMessage == 'CMDCLI') { $file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier)); $file = $file[0].'.DAT'; $result = array(); foreach($xml->Listing->Message as $message) { $result[] = ((string) $message['bloquant'] == 'False'? '[W]': '[E]').' '.(string) $message['ordrePreparation'].' : '.(string) $message; } $result = nl2br(implode("\n", $result)); if($result != '') { Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'philea_syncreport` SET `report_date` = NOW(), `report_data` = "'.pSQL($result, TRUE).'" WHERE `filename` = "'.pSQL($file).'" LIMIT 1 '); } } elseif($xml->TypeMessage == 'ANAPRO') { $file = explode('.', str_replace((string) $xml->TypeMessage.'_', '', (string) $xml->NomFichier)); $file = $file[0].'.DAT'; $result = array(); foreach($xml->Listing->Message as $message) { $result[] = ((string) $message['bloquant'] == 'False'? '[W]': '[E]').' '.(string) $message['reference'].' / '.(string) $message['referenceLigne'].' : '.(string) $message; } $result = nl2br(implode("\n", $result)); // if($result != '') { // Db::getInstance()->Execute(' // UPDATE `'._DB_PREFIX_.'logship_sync` // SET `report_date` = NOW(), // `report_data` = "'.pSQL($result, TRUE).'" // WHERE `sync` = "philea" // AND `filename` = "'.pSQL($file).'" // LIMIT 1 // '); // } } $repo_archive = dirname(__FILE__).'/archives/IN/REPORTS/'; $repo_paths = array(date('Y'), date('m')); foreach($repo_paths as $repo_path) { $repo_archive .= $repo_path.'/'; if(!file_exists($repo_archive)) { mkdir($repo_archive); } } copy($inFolder.$fileinfo->getFilename(), $repo_archive.$fileinfo->getFilename()); unlink($inFolder.$fileinfo->getFilename()); } }