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'); } }
/** * Update urlShare info (if any) when we move/rename a file * @param <String> $filename */ protected static function updateUrlShare($source, $target) { /** * Execute a search to detect if this file has Url */ $urlShareController = UrlShareController::getInstance(); $filepath = $source; $filename = basename($filepath); $shareFile = new UrlFile(); $shareFile->setPath($filepath); $founded = $urlShareController->searchFile($shareFile); if ($founded) { $founded = current($founded); } else { return; } $founded->setPath($target); $urlShareController->updateFile($founded); }
private function registerDownload($urlShare) { $urlShareController = UrlShareController::getInstance(); $urlShare->setLastDownloadDate(time()); $urlShareController->updateUrl($urlShare); }
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()); }
protected static function init() { self::$Logger = Logger::getLogger('system.frameworks.UrlShare.UrlShareController'); }