Пример #1
0
 /**
  * get the page
  *
  * @return string html code of the page
  * @throws FileSharingException
  */
 public function getPage()
 {
     $hash = isset($this->uriParams["hash"]) ? contrexx_input2raw($this->uriParams["hash"]) : '';
     $check = isset($this->uriParams["check"]) ? contrexx_input2raw($this->uriParams["check"]) : '';
     $uploadId = isset($this->uriParams["uploadId"]) ? contrexx_input2raw($this->uriParams["uploadId"]) : 0;
     if (!empty($uploadId)) {
         $this->files = $this->getSharedFiles($uploadId);
     }
     $act = isset($this->uriParams["act"]) ? $this->uriParams["act"] : '';
     switch ($act) {
         case "image":
             $this->loadImage($hash);
             break;
         default:
             try {
                 if (!empty($hash) && !empty($check)) {
                     $fileDeleted = $this->deleteFile($hash, $check);
                 } elseif (!empty($hash)) {
                     $this->downloadFile($hash);
                 } else {
                     if (empty($this->files) && is_array($this->files)) {
                         throw new FileSharingException('no_files_uploaded');
                     }
                 }
                 $this->objTemplate->hideBlock('error_file_not_found');
                 $this->objTemplate->hideBlock('error_no_files_uploaded');
             } catch (FileSharingException $e) {
                 switch ($e->getMessage()) {
                     case 'file_not_found':
                         $this->objTemplate->touchBlock('error_file_not_found');
                         $this->objTemplate->hideBlock('error_no_files_uploaded');
                         break;
                     case 'no_files_uploaded':
                         $this->objTemplate->touchBlock('error_no_files_uploaded');
                         $this->objTemplate->hideBlock('error_file_not_found');
                         break;
                 }
             }
             // don't show for delete page
             if (empty($hash) || isset($fileDeleted) && $fileDeleted) {
                 $this->uploadPage();
             }
             break;
     }
     FileSharingLib::cleanUp();
     return $this->objTemplate->get();
 }