public static function shortcut($config, $zipFn = null, $credentials = null, $idesServer = null, $LOG_LEVEL = Logger::WARNING)
 {
     assert(is_null($zipFn) xor is_null($credentials));
     $dm = new Downloader(null, $LOG_LEVEL);
     $cm = new ConfigManager($config, $dm, $LOG_LEVEL);
     $am = new AesManager();
     $rm = new RsaManager($cm, $am);
     if (is_null($zipFn)) {
         assert(is_array($credentials) && array_key_exists("username", $credentials) && array_key_exists("password", $credentials));
         assert(!is_null($idesServer) && in_array($idesServer, array("live", "test")));
         $sftp = SftpWrapper::getSFTP($idesServer);
         $sw = new SftpWrapper($sftp, $LOG_LEVEL);
         $err = $sw->login($credentials["username"], $credentials["password"]);
         if (!!$err) {
             throw new \Exception($err);
         }
         $remote = $sw->listLatest();
         if (array_key_exists("ZipBackupFolder", $cm->config)) {
             $zipFn = $cm->config["ZipBackupFolder"] . "/" . $remote;
         } else {
             $zipFn = Utils::myTempnam("zip");
             unlink($zipFn);
         }
         if (!file_exists($zipFn)) {
             $sw->get($remote, $zipFn);
         } else {
             $sw->log->debug("Using cached file '" . $zipFn . "'");
         }
     }
     $rx = new Receiver($cm, $rm);
     $rx->start();
     $rx->fromZip($zipFn);
     $rx->rm->decryptAesKey();
     $rx->fromEncrypted();
     $rx->fromCompressed();
     return $rx;
 }
 public function toUpload($upload, $emailTo = null, $swiftmailerConfig = null)
 {
     if (is_null($upload)) {
         return;
     }
     assert(is_array($upload) && array_key_exists("username", $upload) && array_key_exists("password", $upload));
     assert(!(is_null($emailTo) xor is_null($swiftmailerConfig)));
     $emailFrom = "";
     $emailName = "";
     $emailReply = "";
     if (!is_null($swiftmailerConfig)) {
         Transmitter::verifySwiftmailerConfig($swiftmailerConfig);
         $emailFrom = $swiftmailerConfig["reply"];
         $emailName = $swiftmailerConfig["name"];
         $emailReply = $swiftmailerConfig["reply"];
     }
     $sftp = SftpWrapper::getSFTP($this->fdi->getIsTest() ? "test" : "live");
     $sw = new SftpWrapper($sftp, $this->LOG_LEVEL);
     $subj = sprintf("IDES data: %s", date("Y-m-d H:i:s"));
     $err = $sw->login($upload["username"], $upload["password"]);
     if (!!$err) {
         if (!is_null($swiftmailerConfig)) {
             Utils::mail_wrapper($emailTo, $emailFrom, $emailName, $emailReply, $subj . " (upload error login)", $err, $swiftmailerConfig);
         }
         throw new \Exception($err);
     }
     $err = $sw->put($this->tf4, $this->file_name);
     #$err = "Uploading currently disabled";
     if (!!$err) {
         if (!is_null($swiftmailerConfig)) {
             Utils::mail_wrapper($emailTo, $emailFrom, $emailName, $emailReply, $subj . " (upload error file)", $err, $swiftmailerConfig);
         }
         throw new \Exception($err);
     }
     $msg = "Succeeded in uploading zip file";
     if (!is_null($swiftmailerConfig)) {
         Utils::mail_wrapper($emailTo, $emailFrom, $emailName, $emailReply, $subj . " (upload success)", $msg, $swiftmailerConfig);
     }
     $this->log->info($msg);
 }