Exemplo n.º 1
0
 /**
  * @param $file
  * @throws \RuntimeException
  * @return UploadedFile
  */
 public function getInput($file)
 {
     if (!file_exists($file)) {
         throw new \RuntimeException('File does not exist: ' . $file);
     }
     $objMapping = ['file' => $file];
     $uploadModel = new UploadedFile();
     $mapping = ['UPLOAD_SIZE' => 'size', 'UPLOAD_PERMS' => 'perms', 'UPLOAD_UID' => 'uid', 'UPLOAD_GID' => 'gid', 'UPLOAD_USER' => 'user', 'UPLOAD_GROUP' => 'group', 'UPLOAD_VUSER' => 'vUser'];
     foreach ($mapping as $export => $property) {
         if (isset($_SERVER[$export])) {
             switch ($property) {
                 case 'size':
                 case 'uid':
                 case 'gid':
                     $objMapping[$property] = (int) $_SERVER[$export];
                     break;
                 default:
                     $objMapping[$property] = $_SERVER[$export];
             }
         }
     }
     $authUser = $this->authApi->getUserData($objMapping['vUser']);
     if ($authUser) {
         $objMapping['fileHandler'] = $authUser->getFileHandler();
     }
     ObjectUtil::hydrateObject($uploadModel, $objMapping);
     return $uploadModel;
 }
Exemplo n.º 2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pureAuthd = new AuthHelper();
     $auth = $pureAuthd->getInput();
     $outputModel = $this->auth->getUserByLoginPassword($auth->getAccount(), $auth->getPassword());
     switch ($outputModel->getState()) {
         case AuthStateEnum::USER_AUTHORIZED:
             //$this->tracker->info(self::TRACKER_PREFIX . 'authorized', $outputModel->toArray());
             $this->logger->info('PureFTPd: user authorized', ['input' => $auth->jsonSerialize(), 'output' => $outputModel->toArray()]);
             break;
         case AuthStateEnum::USER_NOT_AUTHORIZED:
             //$this->tracker->info(self::TRACKER_PREFIX . 'notAuthorized', $auth->jsonSerialize());
             $this->logger->info('PureFTPd: user not authorized', ['input' => $auth->jsonSerialize(), 'output' => $outputModel->toArray()]);
             break;
         case AuthStateEnum::USER_NOT_FOUND:
             //$this->tracker->info(self::TRACKER_PREFIX . 'notFound', $auth->jsonSerialize());
             $this->logger->info('PureFTPd: user not found', ['input' => $auth->jsonSerialize(), 'output' => $outputModel->toArray()]);
             break;
     }
     $output->write($outputModel->toAuthString());
 }