public function processRequest(MMapRequest $request, MMapResponse $response) { $urlName = $request->getGET('download'); if (is_array($urlName)) { exit; } $urlShare = new UrlShare(); $urlShare->setName($urlName); $urlShareController = UrlShareController::getInstance(); $urlShare = current($urlShareController->searchUrl($urlShare)); if ($urlShare) { if ($urlShare->getExpirationDate() < time()) { self::renderErrorMessage($response, 'Url Expired'); return; } $file = new UrlFile(); $file->setId($urlShare->getFileId()); $urlShareController->readFile($file); if ($file) { $fileName = basename($file->getPath()); $currentFile = FSI::getFile($file->getPath()); $size = $currentFile->getSize(); $unim = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $c = 0; while ($size >= 1024) { $c++; $size = $size / 1024; } $size = number_format($size, $c ? 2 : 0, ',', '.') . ' ' . $unim[$c]; if ($request->issetGET('wrongPassword')) { $wrongPassword = $request->getGET('wrongPassword'); } else { $wrongPassword = 0; } Kernel::exitSystemMode(); self::renderFoundFile($fileName, $size, $urlName, $response, $urlShare->getPassword(), $wrongPassword); } else { self::renderErrorMessage($response, 'File not available'); } } else { self::renderErrorMessage($response, 'File not available'); } }
public static function updateURL($params) { $urlId = $params['id']; $password = $params['password']; $expirationDate = $params['expirationDate']; $myProcManager = ProcManager::getInstance(); $myUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId(); $UrlShareController = UrlShareController::getInstance(); $urlShare = new UrlShare(); $urlShare->setId($urlId); $UrlShareController->readUrl($urlShare); $urlShare->setPassword($password); $urlShare->setExpirationDate($expirationDate); $UrlShareController->updateURL($urlShare); $urlFile = new UrlFile(); $urlFile->setId($urlShare->getFileId()); $UrlShareController->readFile($urlFile); $fileName = basename($urlFile->getPath()); }
public function processRequest(MMapRequest $request, MMapResponse $response) { $urlName = $request->getGET('downloadFile'); $urlShare = new UrlShare(); $urlShare->setName($urlName); $urlShareController = UrlShareController::getInstance(); $urlShare = current($urlShareController->searchUrl($urlShare)); if ($urlShare) { $passwordUrl = $urlShare->getPassword(); if ($passwordUrl) { $file = new UrlFile(); $file->setId($urlShare->getFileId()); $urlShareController->readFile($file); $passwordRequest = $request->getPOST('password'); if ($passwordRequest == $passwordUrl) { if ($file) { self::downloadFile($file->getPath(), $request, $response); self::registerDownload($urlShare); } else { self::renderNotFoundFile($response); } } else { if ($file) { $fileName = basename($file->getPath()); $currentFile = FSI::getFile($file->getPath()); $size = $currentFile->getSize(); $unim = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $c = 0; while ($size >= 1024) { $c++; $size = $size / 1024; } $size = number_format($size, $c ? 2 : 0, ',', '.') . ' ' . $unim[$c]; self::renderWrongPassword($fileName, $size, $urlName, $response, $urlShare->getPassword()); } else { self::renderNotFoundFile($response); } } } else { $file = new UrlFile(); $file->setId($urlShare->getFileId()); $urlShareController->readFile($file); if ($file) { self::downloadFile($file->getPath(), $request, $response); self::registerDownload($urlShare); } else { self::renderNotFoundFile($response); } } } else { self::renderNotFoundFile($response); } }