$decrypted = array();
 $decrypt_failed = array();
 foreach ($files as $file) {
     $raw_filename = $file['filename'];
     $xml_filename = str_replace('.gpg', '', $raw_filename);
     $decrypt_path = $file['type'] == 'PCL' ? SP_NECKERMANN_INVOICE_PATH : SP_NECKERMANN_DECRYPT_PATH;
     $archive_ext_path = $file['type'] == 'PCL' ? 'pcl' : 'xml';
     $encrypted_file = SP_NECKERMANN_DOWNLOAD_PATH . $raw_filename;
     $decrypted_file = $decrypt_path . $xml_filename;
     //$shell_string = "gpg --output $decrypted_file --passphrase $passphrase --decrypt $encrypted_file";
     $shell_string = "echo {$passphrase}|gpg --output {$decrypted_file} --batch --passphrase-fd 0 --decrypt {$encrypted_file}";
     shell_exec($shell_string);
     $status = file_exists($decrypted_file);
     if ($status) {
         $decrypted[] = $raw_filename;
         $class_jd->updateDownloadDecrypted($file['jng_sp_download_id']);
         $raw_archived_file = $archived_path . 'raw/' . $raw_filename;
         $xml_archived_file = $archived_path . $archive_ext_path . '/' . $xml_filename;
         rename($encrypted_file, $raw_archived_file);
         if ($decrypt_path == SP_NECKERMANN_INVOICE_PATH) {
             $shell_unzip = array();
             $shell_unzip[] = 'cd ' . $decrypt_path;
             $shell_unzip[] = 'tar -zxf ' . $xml_filename;
             shell_exec(implode("\n", $shell_unzip));
             rename($decrypted_file, $xml_archived_file);
             $class_jd->updateDownloadImported($file['jng_sp_download_id']);
         } else {
             copy($decrypted_file, $xml_archived_file);
         }
     } else {
         $decrypt_failed[] = $raw_filename;