コード例 #1
0
ファイル: LineTest.php プロジェクト: pnaq57/zf2demo
 public function testCanReadLineWithEmptyAnswer()
 {
     $line = new Line('Where is Bryan ?', true);
     $line->setConsole($this->adapter);
     ob_start();
     $response = $line->show();
     $text = ob_get_clean();
     $this->assertEquals($text, "Where is Bryan ?");
     $this->assertEquals('', $response);
 }
コード例 #2
0
ファイル: Number.php プロジェクト: raZ3l/zf2
 /**
  * Show the prompt to user and return the answer.
  *
  * @return mixed
  */
 public function show()
 {
     /**
      * Ask for a number and validate it.
      */
     do {
         $valid = true;
         $number = parent::show();
         if ($number === "" && !$this->allowEmpty) {
             $valid = false;
         } elseif ($number === "") {
             $number = null;
         } elseif (!is_numeric($number)) {
             $this->getConsole()->writeLine("{$number} is not a number\n");
             $valid = false;
         } elseif (!$this->allowFloat && round($number) != $number) {
             $this->getConsole()->writeLine("Please enter a non-floating number, i.e. " . round($number) . "\n");
             $valid = false;
         } elseif ($this->max !== null && $number > $this->max) {
             $this->getConsole()->writeLine("Please enter a number not greater than " . $this->max . "\n");
             $valid = false;
         } elseif ($this->min !== null && $number < $this->min) {
             $this->getConsole()->writeLine("Please enter a number not smaller than " . $this->min . "\n");
             $valid = false;
         }
     } while (!$valid);
     /**
      * Cast proper type
      */
     if ($number !== null) {
         $number = $this->allowFloat ? (double) $number : (int) $number;
     }
     return $this->lastResponse = $number;
 }
コード例 #3
0
 public function createAction()
 {
     $applicationConfig = $this->getServiceLocator()->get('config');
     $config = $applicationConfig['zf-oauth2-doctrine']['default'];
     $console = $this->getServiceLocator()->get('console');
     $objectManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console.');
     }
     $client = $objectManager->getRepository($config['mapping']['Client']['entity'])->find($this->getRequest()->getParam('id'));
     if (!$client) {
         $console->write("Client not found", Color::RED);
         return;
     }
     // Get the subject
     $subject = Prompt\Line::prompt("The subject, usually a user_id.  Not required: ", true, 255);
     // Get public key path
     $publicKeyPath = '';
     while (!file_exists($publicKeyPath)) {
         $publicKeyPath = Prompt\Line::prompt("Public key path: ", false, 255);
     }
     $publicKey = file_get_contents($publicKeyPath);
     $jwt = new Entity\Jwt();
     $jwt->setClient($client);
     $jwt->setSubject($subject);
     $jwt->setPublicKey($publicKey);
     $objectManager->persist($jwt);
     $objectManager->flush();
     $console->write("JWT created\n", Color::GREEN);
 }
コード例 #4
0
ファイル: MultiInput.php プロジェクト: mahadazad/console-ex
 /**
  * @return array
  */
 public function show()
 {
     $inputs = array();
     $more = 'n';
     $valid = '';
     do {
         $tmpMsg = $this->message;
         do {
             // for input
             $input = Line::prompt($tmpMsg, $this->isOptional, 1500);
             $tmpMsg = $this->invalidMessage;
             $isValid = true;
             if (is_callable($this->validateCallback)) {
                 $isValid = call_user_func($this->validateCallback, $input);
                 if ($isValid) {
                     // is valid and callable given
                     $inputs[] = $input;
                 }
             } else {
                 // callable not given, store the input as is.
                 $inputs[] = $input;
             }
         } while (!$isValid && !empty($input) && $this->isOptional);
         // valid property given now continue
         if (!empty($input)) {
             // ask fore more
             $more = Char::prompt($this->moreMessage, 'yn', true, false, false);
         }
     } while ($more == 'y' && !empty($input));
     return $this->lastResponse = $inputs;
 }
コード例 #5
0
 /**
  * Interactive database setup.
  * WILL OUTPUT VIA CONSOLE!
  *
  * @param  boolean $overwrite Overwrite existing config
  * @return string
  */
 public function setup($overwrite = false)
 {
     /**
      * Output console usage
      */
     if (!$this->console) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     $this->console->writeLine("ZF2 Phinx Module - Interactive Setup", self::GREEN);
     /**
      * Check for existing config
      */
     $zfConfig = $this->config['phinx-module']['zf2-config'];
     $phinxConfig = $this->config['phinx-module']['phinx-config'];
     if (!$overwrite && (file_exists($zfConfig) || file_exists($phinxConfig))) {
         if (file_exists($zfConfig) && !file_exists($phinxConfig)) {
             $this->sync();
             $this->console->writeLine("ZF2 Config found but Phinx config missing => Config Synced.");
         } else {
             $this->console->writeLine("Existing config file(s) found, unable to continue!", self::LIGHT_RED);
             $this->console->writeLine("Use the --overwrite flag to replace existing config.", self::LIGHT_RED);
         }
         return;
     }
     /**
      * Ask questions
      */
     $loop = true;
     while ($loop) {
         $this->console->writeLine("MySQL Database connection details:");
         $host = Prompt\Line::prompt("Hostname? [localhost] ", true) ?: 'localhost';
         $port = Prompt\Line::prompt("Port? [3306] ", true) ?: 3306;
         $user = Prompt\Line::prompt("Username? ");
         $pass = Prompt\Line::prompt("Password? ");
         $dbname = Prompt\Line::prompt("Database name? ");
         $loop = !Prompt\Confirm::prompt("Save these details? [y/n]");
     }
     /**
      * Build config
      */
     $config = new Config(array('db' => array('dsn' => "mysql:host={$host};dbname={$dbname}", 'username' => $user, 'password' => $pass, 'port' => $port)));
     $writer = new PhpArray();
     $writer->toFile($zfConfig, $config);
     $this->console->writeLine();
     $this->console->writeLine("ZF2 Config file written: {$zfConfig}");
     /**
      * Write Phinx config
      */
     $migrations = $this->config['phinx-module']['migrations'];
     $this->writePhinxConfig('mysql', $host, $user, $pass, $dbname, $port, $migrations);
     $this->console->writeLine("Phinx Config file written: {$phinxConfig}");
 }
コード例 #6
0
ファイル: SingleInput.php プロジェクト: mahadazad/console-ex
 /**
  * @return string
  */
 public function show()
 {
     $input = '';
     $valid = '';
     $tmpMsg = $this->message;
     do {
         $input = Line::prompt($tmpMsg, !$this->isRequired, 1500);
         $tmpMsg = $this->invalidMsg;
         $isValid = true;
         if (is_callable($this->validateCallback)) {
             $isValid = call_user_func($this->validateCallback, $input);
         }
     } while (!$isValid && $this->isRequired);
     return $this->lastResponse = $input;
 }
コード例 #7
0
ファイル: SetupController.php プロジェクト: mkhuramj/ToDo-Web
 /**
  * Iterate through some keys and prompt the user for the values, descend if needed.
  *
  * @param $array
  * @param bool|string $title
  * @return array
  */
 protected function collectValues($array, $title = false)
 {
     if ($title) {
         echo "For " . ucwords($title) . PHP_EOL;
     }
     $result = [];
     foreach ($array as $field => $value) {
         if (is_array($value)) {
             $value = $this->collectValues($value, $field);
         } else {
             $value = Prompt\Line::prompt(ucwords(str_replace('_', ' ', $field)) . ': ', false);
         }
         $result[$field] = $value;
     }
     return $result;
 }
コード例 #8
0
 public function consoleModuleAction()
 {
     $request = $this->getRequest();
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     if (!$request instanceof ConsoleRequest) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     $module = $request->getParam('moduleName');
     $entity = $request->getParam('tableName');
     $entitymanager = $request->getParam('entityManager');
     if ($module == false) {
         $module = Line::prompt('Please Enter the Name of the Module: ', false, 100);
     }
     if ($entity == false) {
         $entity = Line::prompt('Please Enter the Name of the The Table, the Module should be created from: ', false, 100);
     }
     if ($entitymanager == false) {
         $entitymanager = Line::prompt('Please Enter a entity-manager (default:doctrine.entitymanager.orm_default): ', true, 100);
         // If no entitymanager given, we set an default
         if ($entitymanager == false) {
             $entitymanager = 'doctrine.entitymanager.orm_default';
         }
     }
     // Check on a valid entitymanager
     $em = $this->getServiceLocator()->get($entitymanager);
     if (!is_a($em, 'Doctrine\\ORM\\EntityManager')) {
         return 'Exit: Invalid Entitymanager';
     }
     $filepath = 'module/' . $module;
     if (is_dir($filepath)) {
         if (!Confirm::prompt('Module filepath exists. Overwrite? [y/n]', 'y', 'n')) {
             return 'EXIT: Module exists.';
         }
     }
     if (!is_dir($filepath) and !mkdir($filepath, 0777, true)) {
         return 'EXIT: Directory could not be created.';
     }
     // All Validated, we generate now.
     $this->setEntitymanager($entitymanager);
     $this->setFilepath($filepath);
     $this->setNamespace($module);
     $this->setTables(array($entity));
     $this->generate();
     return 'Module successfully created';
 }
コード例 #9
0
 public function dropAction()
 {
     $console = $this->getConsole();
     $objectManagerAlias = 'doctrine.entitymanager.orm_default';
     /** @var EntityManager $objectManager */
     $objectManager = $this->getServiceLocator()->get($objectManagerAlias);
     // Collect table names
     $tables = array_map(function (Table $table) {
         return $table->getName();
     }, $objectManager->getConnection()->getSchemaManager()->listTables());
     // Display prompt
     if (strtolower(Prompt\Line::prompt('Are you sure you want to DROP ' . count($tables) . ' tables from the database? [type yes] ')) !== 'yes') {
         $console->writeLine('Aborting');
         return;
     }
     // Truncate tables
     if (file_exists(__DIR__ . '/../../../../../data/Database/rollnapi.db')) {
         @unlink(__DIR__ . '/../../../../../data/Database/rollnapi.db');
     }
     $console->writeLine('All done! Tables have been dropped.', ColorInterface::GREEN);
 }
コード例 #10
0
 public function createAction()
 {
     $applicationConfig = $this->getServiceLocator()->get('config');
     $config = $applicationConfig['zf-oauth2-doctrine']['default'];
     $console = $this->getServiceLocator()->get('console');
     $objectManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console.');
     }
     if (!$client) {
         $console->write("Client not found", Color::RED);
         return;
     }
     $client = $objectManager->getRepository($config['mapping']['Client']['entity'])->find($this->getRequest()->getParam('id'));
     // Get public key path
     $publicKeyPath = '';
     while (!file_exists($publicKeyPath)) {
         $publicKeyPath = Prompt\Line::prompt("Public key path: ", false, 255);
     }
     $publicKey = file_get_contents($publicKeyPath);
     // Get private key path
     $privateKeyPath = '';
     while (!file_exists($privateKeyPath)) {
         $privateKeyPath = Prompt\Line::prompt("Private key path: ", false, 255);
     }
     $privateKey = file_get_contents($privateKeyPath);
     $options = array(0 => 'HS256', 1 => 'HS384', 2 => 'HS512', 3 => 'RS256', 4 => 'RS384', 5 => 'RS512');
     $encryptionAlgorithm = Prompt\Select::prompt("Encryption Algorithm: ", $options, false, false);
     $publicKeyEntity = new Entity\PublicKey();
     $publicKeyEntity->setClient($client);
     $publicKeyEntity->setPublicKey($publicKey);
     $publicKeyEntity->setPrivateKey($privateKey);
     $publicKeyEntity->setEncryptionAlgorithm($options[$encryptionAlgorithm]);
     $objectManager->persist($publicKeyEntity);
     $objectManager->flush();
     $console->write("Public key created\n", Color::GREEN);
 }
コード例 #11
0
 public function updateAction()
 {
     $config = $this->config['zf-oauth2-doctrine']['default'];
     $console = $this->console;
     $objectManager = $this->objectManager;
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console.');
     }
     $scopeEntity = $objectManager->getRepository($config['mapping']['Scope']['entity'])->find($this->getRequest()->getParam('id'));
     // Get the Scope
     $console->write("Current Value: " . $scopeEntity->getScope() . "\n", Color::CYAN);
     $scope = Prompt\Line::prompt("Scope: ", false);
     $scopeEntity->setScope($scope);
     $currentDefault = $scopeEntity->getIsDefault() ? 'Y' : 'N';
     $console->write("Current Value: " . $currentDefault . "\n", Color::CYAN);
     $default = Prompt\Confirm::prompt('Is this a default scope? [y/n] ', 'y', 'n');
     $scopeEntity->setIsDefault($default == 'y');
     $objectManager->flush();
     $console->write("Scope updated\n", Color::GREEN);
 }
コード例 #12
0
 public function generateAction()
 {
     $console = $this->getServiceLocator()->get('console');
     $jwtService = new Jwt();
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console.');
     }
     $privateKeyPath = '';
     while (!file_exists($privateKeyPath)) {
         $privateKeyPath = Prompt\Line::prompt("Private Key path: ", false, 255);
     }
     $privateKey = file_get_contents($privateKeyPath);
     $iss = Prompt\Line::prompt("(iss) The issuer, usually the client_id: ", false, 255);
     $sub = Prompt\Line::prompt("(sub) The subject, usually a user_id: ", true, 255);
     $aud = Prompt\Line::prompt("(aud) The audience, usually the URI for the oauth server.  Not required.: ", true, 255);
     $exp = Prompt\Line::prompt("(exp) The expiration date in seconds since epoch. If the current time is" . " greater than the exp, the JWT is invalid.  Not required: ", true, 255);
     $nbf = Prompt\Line::prompt('(nbt) The "not before" time in seconds since epoch. If the current time is' . 'less than the nbf, the JWT is invalid.  Not required: ', true, 255);
     $jti = Prompt\Line::prompt('(jti) The "jwt token identifier", or nonce for this JWT.  Not Required: ', true, 255);
     $console->write($jwtService->generate($privateKey, $iss, $sub, $aud, $exp, $nbf, $jti) . "\n", Color::YELLOW);
 }
コード例 #13
0
 public function updateAction()
 {
     $applicationConfig = $this->getServiceLocator()->get('config');
     $config = $applicationConfig['zf-oauth2-doctrine']['default'];
     $console = $this->getServiceLocator()->get('console');
     $objectManager = $this->getServiceLocator()->get($config['object_manager']);
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new RuntimeException('You can only use this action from a console.');
     }
     $clientEntity = $objectManager->getRepository($config['mapping']['Client']['entity'])->find($this->getRequest()->getParam('id'));
     if (!$clientEntity) {
         $console->write("Client not found", Color::RED);
         return;
     }
     // Get the User
     while (true) {
         if ($clientEntity->getUser()) {
             $console->write("Current Value: " . $clientEntity->getUser()->getId() . "\n", Color::CYAN);
         } else {
             $console->write("Current Value: none\n", Color::CYAN);
         }
         $userId = Prompt\Line::prompt("User ID.  Not required. ? for list: ", true, 255);
         if ($userId == '?') {
             $users = $objectManager->getRepository($config['mapping']['User']['entity'])->findAll();
             foreach ($users as $user) {
                 $console->write($user->getId() . "\t" . $user->getEmail() . "\n", Color::CYAN);
             }
             continue;
         }
         if ($userId) {
             $user = $objectManager->getRepository($config['mapping']['User']['entity'])->find($userId);
             if (!$user) {
                 $console->write("User ID {$userId} not found.\n", Color::RED);
                 continue;
             }
             $clientEntity->setUser($user);
         }
         break;
     }
     // Get the client id
     $clientId = '';
     while (!$clientId) {
         $console->write("Current Value: " . $clientEntity->getClientId() . "\n", Color::CYAN);
         $clientId = Prompt\Line::prompt("Client ID: ", false, 255);
         $client = $objectManager->getRepository($config['mapping']['Client']['entity'])->findOneBy(array('clientId' => $clientId));
         if ($client && $client->getId() !== $clientEntity->getId()) {
             $console->write('Client ID ' . $clientId . ' already exists', Color::RED);
             $clientId = '';
         }
     }
     $clientEntity->setClientId($clientId);
     // Get the client secret
     $secret = '';
     $secretVerify = false;
     while ($secret !== $secretVerify) {
         $secretPrompt = new Prompt\Password("Secret: ");
         $secret = $secretPrompt->show();
         $secretPrompt = new Prompt\Password("Verify Secret: ");
         $secretVerify = $secretPrompt->show();
         if ($secret !== $secretVerify) {
             $console->write("Password verification does not match.  Please try again.\n", Color::YELLOW);
             continue;
         }
         $bcrypt = new Bcrypt();
         $bcrypt->setCost(14);
         $clientEntity->setSecret($bcrypt->create($secret));
     }
     // Get the Redirect URI
     $console->write("Current Value: " . $clientEntity->getRedirectUri() . "\n", Color::CYAN);
     $redirectUri = Prompt\Line::prompt("Redirect URI.  Not required: ", true, 255);
     $clientEntity->setRedirectUri($redirectUri);
     // Get Grant Type(s)
     $console->write("Current Value: " . implode(',', $clientEntity->getGrantType()) . "\n", Color::CYAN);
     $console->write("Default Grant Types\n", Color::YELLOW);
     $console->write("authorization_code\n", Color::CYAN);
     $console->write("access_token\n", Color::CYAN);
     $console->write("refresh_token\n", Color::CYAN);
     $console->write("urn:ietf:params:oauth:grant-type:jwt-bearer\n", Color::CYAN);
     $grantType = Prompt\Line::prompt("Grant Types, comma delimited.  Not required: ", true, 255);
     $clientEntity->setGrantType(explode(',', $grantType));
     // Add scope(s)
     $clientScopes = new ArrayCollection();
     while (true) {
         if (sizeof($clientEntity->getScope())) {
             $console->write("Current Scope(s)\n", Color::YELLOW);
             foreach ($clientEntity->getScope() as $scope) {
                 $console->write($scope->getScope() . "\n", Color::CYAN);
             }
         }
         $scopeArray = $objectManager->getRepository($config['mapping']['Scope']['entity'])->findBy(array(), array('id' => 'ASC'));
         $scopes = new ArrayCollection();
         foreach ($scopeArray as $scope) {
             if (!$clientScopes->contains($scope)) {
                 $scopes->add($scope);
             }
         }
         $options = array(0 => 'Done Selecting Scopes');
         foreach ($scopes as $scope) {
             $options[$scope->getId()] = $scope->getScope();
         }
         if (!$options) {
             $console->write("No Scopes exist.\n", Color::RED);
             break;
         }
         if (sizeof($clientScopes)) {
             $console->write("Selected Scopes\n", Color::YELLOW);
             foreach ($clientScopes as $scope) {
                 $console->write($scope->getScope() . "\n", Color::CYAN);
             }
         }
         $answer = Prompt\Select::prompt('Select Scope(s): ', $options, false, false);
         if (!$answer) {
             foreach ($clientEntity->getScope() as $scope) {
                 $scope->removeClient($clientEntity);
                 $clientEntity->removeScope($scope);
             }
             foreach ($clientScopes as $scope) {
                 $scope->addClient($clientEntity);
                 $clientEntity->addScope($scope);
             }
             break;
         } else {
             foreach ($scopes as $scope) {
                 if ($scope->getId() == $answer) {
                     $clientScopes->add($scope);
                     echo "{$answer} selected\n";
                     break;
                 }
             }
         }
     }
     $objectManager->flush();
     $console->write("Client updated\n", Color::GREEN);
 }
コード例 #14
0
ファイル: Console.php プロジェクト: zource/zource
 public function groupCreateAction()
 {
     $name = $this->params('name');
     while (!$name) {
         $name = Line::prompt('Please enter the name of the group: ');
     }
     $group = new Group($name);
     $this->entityManager->persist($group);
     $this->entityManager->flush($group);
     $this->getConsole()->writeLine('Group created with id ' . $group->getId()->toString());
     return 0;
 }
コード例 #15
0
 public function consoleEntityAction()
 {
     $request = $this->getRequest();
     // Make sure that we are running in a console and the user has not tricked our
     // application into running this action from a public web server.
     if (!$request instanceof ConsoleRequest) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     $all = $request->getParam('all');
     $entity = $request->getParam('entityName');
     $namespace = $request->getParam('namespace');
     $filepath = $request->getParam('dir');
     $entitymanager = $request->getParam('entityManager');
     // If we have no Parameters given, well ask the user
     if (!isset($entity) and $all === false) {
         $char = Char::prompt('Do you want do create one Model (o) or All Models (a)?', 'ao', true, false, true);
         if ($char == 'o') {
             $entity = Line::prompt('Please Enter the Name of the Entity to be created: ', false, 100);
         } else {
             $all = true;
         }
     }
     if ($namespace == false) {
         $namespace = Line::prompt('Please Enter the Name of Namespace to be used: ', false, 100);
     }
     if ($filepath == false) {
         $filepath = Line::prompt('Please Enter a File-Path for the Entity-Files: (std: "Entities") ', true, 100);
         // If no filepath given, we set an default filepath
         if (empty($filepath)) {
             $filepath = 'Entities';
         }
     }
     if (!is_dir($filepath)) {
         if (Confirm::prompt('Directory ' . $filepath . ' does not exist. Create? [y/n]', 'y', 'n')) {
             if (!mkdir($filepath, 0777, true)) {
                 return 'EXIT: Directory could not be created.';
             }
         } else {
             return 'EXIT: Invalid Directory.';
         }
     }
     if ($entitymanager == false) {
         $entitymanager = Line::prompt('Please Enter a entity-manager (default:doctrine.entitymanager.orm_default): ', true, 100);
         // If no entitymanager given, we set an default
         if ($entitymanager == false) {
             $entitymanager = 'doctrine.entitymanager.orm_default';
         }
     }
     // Check on a valid entitymanager
     try {
         $em = $this->getServiceLocator()->get($entitymanager);
         if (!is_a($em, 'Doctrine\\ORM\\EntityManager')) {
             throw new ServiceNotFoundException();
         }
     } catch (ServiceNotFoundException $e) {
         return 'Exit: Invalid Entitymanager';
     }
     // All Validated, we generate now.
     $this->setEntitymanager($entitymanager);
     $this->setFilepath($filepath);
     $this->setNamespace($namespace);
     if ($all === true) {
         $tables = array();
     } else {
         $tables = array($entity);
     }
     $this->setTables($tables);
     $this->generate();
     return 'Files successfully created' . "\n";
 }
コード例 #16
0
ファイル: ToolsController.php プロジェクト: arbi/MyCode
 /**
  * Generate report about unsed files and lost data in database
  */
 public function reportUnusedFilesAction()
 {
     // get params
     if ($this->getRequest()->getParam('only-locations-images')) {
         $this->onlyLocationImages = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-building-maps')) {
         $this->onlyBuildingMaps = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-office-maps')) {
         $this->onlyOfficeMaps = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-profiles-images')) {
         $this->onlyProfileImages = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-apartments-images')) {
         $this->onlyApartmentImages = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-blog-images')) {
         $this->onlyBlogImages = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-documents')) {
         $this->onlyDocuments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-purchase-order-attachments')) {
         $this->onlyPurchaseOrder = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-purchase-order-item-attachments')) {
         $this->onlyPurchaseOrderItems = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-users-documents')) {
         $this->onlyUsersDocuments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-jobs-documents')) {
         $this->onlyJobsDocuments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-booking-documents')) {
         $this->onlyBookingDocuments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-money-account-documents')) {
         $this->onlyMoneyAccountDocuments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-task-attachments')) {
         $this->onlyTaskAttachments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-parking-attachments')) {
         $this->onlyParkingAttachments = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('only-apartel-images')) {
         $this->onlyApartelImages = true;
         $this->withOutParams = false;
     }
     if ($this->getRequest()->getParam('remove-from-disk')) {
         $this->removeFromDisk = true;
     }
     $table = new Table(['columnWidths' => [4, 71, 71]]);
     $table->appendRow(['#', 'on Disk', 'on Database']);
     // array of unused files in disk - for delete it!
     $unusedFiles = [];
     /**
      * Locations
      */
     if ($this->onlyLocationImages or $this->withOutParams) {
         $locationImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_LOCATIONS_PATH;
         if (!is_readable($locationImagesPath)) {
             echo "Folder does not exist: " . $locationImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $locationsDiskData = array_diff(scandir($locationImagesPath), ['.', '..']);
             $locationsDiskArray = [];
             foreach ($locationsDiskData as $locationDisk) {
                 $thisFilesList = array_diff(scandir($locationImagesPath . $locationDisk), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $locationsDiskArray[$locationDisk][] = $file;
                 }
             }
             $locationsDbData = $this->getLocationsData();
             foreach ($locationsDbData as $locationDb) {
                 $cover_image = $locationImagesPath . $locationDb->getId() . '/' . $locationDb->getCover_image();
                 $thumbnail = $locationImagesPath . $locationDb->getId() . '/' . $locationDb->getThumbnail();
                 if (!empty($locationDb->getCover_image()) && $locationDb->getCover_image() !== null && !is_file($cover_image)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_LOCATION_DETAILS . '.id: ' . $locationDb->getId() . PHP_EOL . 'name: ' . $locationDb->getName() . PHP_EOL . 'cover_image: ' . PHP_EOL . $cover_image]);
                 } elseif (!empty($locationDb->getCover_image()) && $locationDb->getCover_image() !== null) {
                     $filename = explode('_', $locationDb->getCover_image())[0];
                     foreach ($locationsDiskArray[$locationDb->getId()] as $locationFileKey => $locationFile) {
                         if (strstr($locationFile, $filename)) {
                             unset($locationsDiskArray[$locationDb->getId()][$locationFileKey]);
                         }
                     }
                 }
                 if (!empty($locationDb->getThumbnail()) && $locationDb->getThumbnail() !== null && !is_file($thumbnail)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_LOCATION_DETAILS . '.id: ' . $locationDb->getId() . PHP_EOL . 'name: ' . $locationDb->getName() . PHP_EOL . 'thumbnail: ' . PHP_EOL . $thumbnail]);
                 } elseif (!empty($locationDb->getThumbnail()) && $locationDb->getThumbnail() !== null) {
                     $filename = explode('_', $locationDb->getThumbnail())[0];
                     foreach ($locationsDiskArray[$locationDb->getId()] as $locationFileKey => $locationFile) {
                         if (strstr($locationFile, $filename)) {
                             unset($locationsDiskArray[$locationDb->getId()][$locationFileKey]);
                         }
                     }
                 }
             }
             foreach ($locationsDiskArray as $folder => $locationDisk) {
                 foreach ($locationDisk as $locationDiskFiles) {
                     $unusedLocationFile = $locationImagesPath . $folder . '/' . $locationDiskFiles;
                     $unusedFiles[] = $unusedLocationFile;
                     if (is_dir($unusedLocationFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Location' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedLocationFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Location' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedLocationFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Profiles
      */
     if ($this->onlyProfileImages or $this->withOutParams) {
         $profileImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_PROFILE_PATH;
         if (!is_readable($profileImagesPath)) {
             echo "Folder does not exist: " . $profileImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $profilesDiskData = array_diff(scandir($profileImagesPath), ['.', '..']);
             $profilesDiskArray = [];
             foreach ($profilesDiskData as $profileDisk) {
                 $thisFilesList = array_diff(scandir($profileImagesPath . $profileDisk . '/'), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $profilesDiskArray[$profileDisk][] = $file;
                 }
             }
             $profilesDbData = $this->getProfilesData();
             foreach ($profilesDbData as $profileDb) {
                 $avatar = $profileImagesPath . $profileDb->getId() . '/' . $profileDb->getAvatar();
                 if (!empty($profileDb->getAvatar()) and $profileDb->getAvatar() !== null and !is_file($avatar)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_BACKOFFICE_USERS . '.id: ' . $profileDb->getId() . PHP_EOL . 'user name: ' . $profileDb->getFirstName() . ' ' . $profileDb->getLastName() . PHP_EOL . 'avatar: ' . PHP_EOL . $avatar]);
                 } elseif (!empty($profileDb->getAvatar()) and $profileDb->getAvatar() !== null) {
                     $filename = explode('_', $profileDb->getAvatar())[0];
                     foreach ($profilesDiskArray[$profileDb->getId()] as $profileFileKey => $profileFile) {
                         if (strstr($profileFile, $filename)) {
                             unset($profilesDiskArray[$profileDb->getId()][$profileFileKey]);
                         }
                     }
                 }
             }
             foreach ($profilesDiskArray as $folder => $profileDisk) {
                 foreach ($profileDisk as $profileDiskFiles) {
                     $unusedProfileFile = $profileImagesPath . $folder . '/' . $profileDiskFiles;
                     $unusedFiles[] = $unusedProfileFile;
                     if (is_dir($unusedProfileFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Profile' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedProfileFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Profile' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedProfileFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Apartment Images
      */
     if ($this->onlyApartmentImages or $this->withOutParams) {
         $apartmentImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_APARTMENT;
         if (!is_readable($apartmentImagesPath)) {
             echo "Folder does not exist: " . $apartmentImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $apartmentsDiskData = array_diff(scandir($apartmentImagesPath), ['.', '..']);
             $apartmentsDiskArray = [];
             foreach ($apartmentsDiskData as $apartmentDisk) {
                 $thisFilesList = array_diff(scandir($apartmentImagesPath . $apartmentDisk . '/'), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $apartmentsDiskArray[$apartmentDisk][] = $file;
                 }
             }
             $apartmentsDbData = $this->getApartmentsData();
             foreach ($apartmentsDbData as $apartmentDb) {
                 $dbImageResult = [];
                 $apartmentThumbsSizes = ['445', '555', '780', '96'];
                 if (isset($apartmentsDiskArray[$apartmentDb->getApartmentId()]) && count($apartmentsDiskArray[$apartmentDb->getApartmentId()])) {
                     for ($i = 1; $i <= 32; $i++) {
                         $imgId = 'img' . $i;
                         $getImgActionId = 'getImg' . $i;
                         if (!empty($apartmentDb->{$getImgActionId}()) and $apartmentDb->{$getImgActionId}() !== null) {
                             $dbImageResult[$i]['has_original'] = false;
                             $dbImageResult[$i]['has_thumbs'] = [];
                             $filenameFromDb = explode('/', $apartmentDb->{$getImgActionId}())[3];
                             $fileOriginNameFromDb = explode('orig', $filenameFromDb)[0];
                             foreach ($apartmentsDiskArray[$apartmentDb->getApartmentId()] as $apartmentFileKey => $apartmentFile) {
                                 foreach ($apartmentThumbsSizes as $size) {
                                     if (strstr($apartmentFile, $fileOriginNameFromDb . $size)) {
                                         unset($apartmentsDiskArray[$apartmentDb->getApartmentId()][$apartmentFileKey]);
                                         $dbImageResult[$i]['has_thumbs'][] = $size;
                                     }
                                 }
                                 if ($apartmentFile == $filenameFromDb) {
                                     unset($apartmentsDiskArray[$apartmentDb->getApartmentId()][$apartmentFileKey]);
                                     $dbImageResult[$i]['has_original'] = $apartmentDb->{$getImgActionId}();
                                 }
                             }
                         }
                     }
                     foreach ($dbImageResult as $imgId => $imgValues) {
                         $doesNotHaveThis = '';
                         $getImgActionId = 'getImg' . $imgId;
                         if (!$imgValues['has_original']) {
                             $doesNotHaveThis .= PHP_EOL . 'original: ' . substr($apartmentImagesPath, 0, -1) . $apartmentDb->{$getImgActionId}();
                         }
                         $hasNoThumb = array_diff($apartmentThumbsSizes, $imgValues['has_thumbs']);
                         if (count($hasNoThumb)) {
                             $filenameFromDb = explode('/', $apartmentDb->{$getImgActionId}())[3];
                             $fileOriginNameFromDb = explode('orig', $filenameFromDb)[0];
                             foreach ($hasNoThumb as $thumbSize) {
                                 $thumsImagePath = $apartmentImagesPath . $apartmentDb->getApartmentId() . '/' . $fileOriginNameFromDb . $thumbSize . '.jpg';
                                 $doesNotHaveThis .= PHP_EOL . 'thumb: ' . $thumsImagePath;
                             }
                         }
                         if (!empty($doesNotHaveThis)) {
                             $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_APARTMENT_IMAGES . '.apartment_id: ' . $apartmentDb->getApartmentId() . PHP_EOL . $imgId . ': ' . $doesNotHaveThis]);
                         }
                     }
                 } elseif (!empty($apartmentDb->getImg1())) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_APARTMENT_IMAGES . '.apartment_id: ' . $apartmentDb->getApartmentId() . PHP_EOL . '!!!' . PHP_EOL . 'Apartment images folder empty or not exist' . PHP_EOL . 'But apartment has attached images in database']);
                 }
             }
             foreach ($apartmentsDiskArray as $folder => $apartmentDisk) {
                 foreach ($apartmentDisk as $apartmentDiskFiles) {
                     if ($apartmentDiskFiles === 'map') {
                         continue;
                     }
                     $unusedApartmentImagesFile = $apartmentImagesPath . $folder . '/' . $apartmentDiskFiles;
                     $unusedFiles[] = $unusedApartmentImagesFile;
                     if (is_dir($unusedApartmentImagesFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Apartment' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedApartmentImagesFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Apartment' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedApartmentImagesFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Documents
      */
     if ($this->onlyDocuments or $this->withOutParams) {
         $documentUploadsPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_DOCUMENTS;
         if (!is_readable($documentUploadsPath)) {
             echo "Folder does not exist: " . $documentUploadsPath . PHP_EOL . PHP_EOL;
         } else {
             $docsDiskData = array_diff(scandir($documentUploadsPath), ['.', '..']);
             $docsDiskArray = [];
             foreach ($docsDiskData as $docDiskYear) {
                 $yearFilesList = array_diff(scandir($documentUploadsPath . $docDiskYear), ['.', '..']);
                 foreach ($yearFilesList as $docDiskMonth) {
                     $monthFilesList = array_diff(scandir($documentUploadsPath . $docDiskYear . '/' . $docDiskMonth), ['.', '..']);
                     foreach ($monthFilesList as $docDiskDay) {
                         $dayFilesList = array_diff(scandir($documentUploadsPath . $docDiskYear . '/' . $docDiskMonth . '/' . $docDiskDay), ['.', '..']);
                         foreach ($dayFilesList as $file) {
                             $docsDiskArray[$docDiskYear . '/' . $docDiskMonth . '/' . $docDiskDay][] = $file;
                         }
                     }
                 }
             }
             $docsDbData = $this->getDocumentsData();
             /** @var \DDD\Domain\Document\Document $docDb */
             foreach ($docsDbData as $docDb) {
                 $dateFolder = date('Y/m/j', strtotime($docDb->getCreatedDate()));
                 $attachment = $documentUploadsPath . $dateFolder . '/' . $docDb->getAttachment();
                 if (!empty($docDb->getAttachment()) and $docDb->getAttachment() !== null) {
                     if (!is_file($attachment)) {
                         $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_DOCUMENTS . '.apartment_id: ' . $docDb->getID() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                     } else {
                         $filename = $docDb->getAttachment();
                         foreach ($docsDiskArray[$dateFolder] as $docFileKey => $docFile) {
                             if ($docFile === $filename) {
                                 unset($docsDiskArray[$dateFolder][$docFileKey]);
                             }
                         }
                     }
                 }
             }
             foreach ($docsDiskArray as $dateFolder => $docFiles) {
                 foreach ($docFiles as $key => $docFile) {
                     $unusedDocumentFile = $documentUploadsPath . $dateFolder . '/' . $docFile;
                     $unusedFiles[] = $unusedDocumentFile;
                     if (is_dir($unusedDocumentFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Apartment Documents' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedDocumentFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Apartment Documents' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedDocumentFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Apartment Maps
      */
     if ($this->onlyBuildingMaps or $this->withOutParams) {
         $buildingImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_BUILDING;
         if (!is_readable($buildingImagesPath)) {
             echo "Folder does not exist: " . $buildingImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $buildingDiskData = array_diff(scandir($buildingImagesPath), ['.', '..']);
             $mapsDiskArray = [];
             foreach ($buildingDiskData as $buildingId) {
                 if (is_dir($buildingImagesPath . $buildingId . '/map')) {
                     $thisFilesList = array_diff(scandir($buildingImagesPath . $buildingId . '/map'), ['.', '..']);
                     if (count($thisFilesList)) {
                         foreach ($thisFilesList as $file) {
                             $mapsDiskArray[$buildingId][] = $file;
                         }
                     }
                 }
             }
             $mapsDbData = $this->getBuildingsMapsData();
             foreach ($mapsDbData as $mapsDb) {
                 $file = substr($buildingImagesPath, 0, -1) . '/' . $mapsDb['building_id'] . '/map/' . $mapsDb['map_attachment'];
                 if (!empty($mapsDb['map_attachment']) && $mapsDb['map_attachment'] !== null and !is_file($file)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_BUILDING_DETAILS . '.id: ' . $mapsDb['id'] . PHP_EOL . DbTables::TBL_BUILDING_DETAILS . '.apartment_group_id: ' . $mapsDb['building_id'] . PHP_EOL . 'img: ' . PHP_EOL . $file]);
                 } elseif (!empty($mapsDb['map_attachment']) and $mapsDb['map_attachment'] !== null) {
                     foreach ($mapsDiskArray[$mapsDb['building_id']] as $mapsFileKey => $mapsFile) {
                         if ($mapsFile == $mapsDb['map_attachment']) {
                             unset($mapsDiskArray[$mapsDb['building_id']][$mapsFileKey]);
                         }
                     }
                 }
             }
             foreach ($mapsDiskArray as $folder => $mapsDisk) {
                 foreach ($mapsDisk as $mapsDiskFile) {
                     $unusedMapsFile = $buildingImagesPath . $folder . '/map/' . $mapsDiskFile;
                     $unusedFiles[] = $unusedMapsFile;
                     if (is_dir($unusedMapsFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Building Maps' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedMapsFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Building Maps' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedMapsFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Apartment Maps
      */
     if ($this->onlyOfficeMaps or $this->withOutParams) {
         $officeImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_OFFICE;
         if (!is_readable($officeImagesPath)) {
             echo "Folder does not exist: " . $officeImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $officeDiskData = array_diff(scandir($officeImagesPath), ['.', '..']);
             $mapsDiskArray = [];
             foreach ($officeDiskData as $officeId) {
                 if (is_dir($officeImagesPath . $officeId)) {
                     $thisFilesList = array_diff(scandir($officeImagesPath . $officeId), ['.', '..']);
                     if (count($thisFilesList)) {
                         foreach ($thisFilesList as $file) {
                             $mapsDiskArray[$officeId][] = $file;
                         }
                     }
                 }
             }
             $mapsDbData = $this->getOfficeMapsData();
             foreach ($mapsDbData as $mapsDb) {
                 $file = substr($officeImagesPath, 0, -1) . '/' . $mapsDb->getId() . '/map/' . $mapsDb->getMapAttachment();
                 if (!empty($mapsDb->getMapAttachment()) && $mapsDb->getMapAttachment() !== null and !is_file($file)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_OFFICES . '.id: ' . $mapsDb->getId() . PHP_EOL . 'img: ' . PHP_EOL . $file]);
                 } elseif (!empty($mapsDb->getMapAttachment()) and $mapsDb->getMapAttachment() !== null) {
                     foreach ($mapsDiskArray[$mapsDb->getId()] as $mapsFileKey => $mapsFile) {
                         if ($mapsFile == $mapsDb->getMapAttachment()) {
                             unset($mapsDiskArray[$mapsDb->getId()][$mapsFileKey]);
                         }
                     }
                 }
             }
             foreach ($mapsDiskArray as $folder => $mapsDisk) {
                 foreach ($mapsDisk as $mapsDiskFile) {
                     $unusedMapsFile = $officeImagesPath . $folder . '/map/' . $mapsDiskFile;
                     $unusedFiles[] = $unusedMapsFile;
                     if (is_dir($unusedMapsFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Office Maps' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedMapsFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Office Maps' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedMapsFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Blog
      */
     if ($this->onlyBlogImages or $this->withOutParams) {
         $blogImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_BLOG_PATH;
         if (!is_readable($blogImagesPath)) {
             echo "Folder does not exist: " . $blogImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $blogsDiskData = array_diff(scandir($blogImagesPath), ['.', '..']);
             $blogsDiskArray = [];
             foreach ($blogsDiskData as $blogDisk) {
                 $thisFilesList = array_diff(scandir($blogImagesPath . $blogDisk), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $blogsDiskArray[$blogDisk][] = $file;
                 }
             }
             $blogsDbData = $this->getBlogsData();
             foreach ($blogsDbData as $blogDb) {
                 $img = substr(DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT, 0, -1) . $blogDb->getImg();
                 if (!empty($blogDb->getImg()) and $blogDb->getImg() !== null and !is_file($img)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_BLOG_POSTS . '.id: ' . $blogDb->getId() . PHP_EOL . 'img: ' . PHP_EOL . $img]);
                 } elseif (!empty($blogDb->getImg()) and $blogDb->getImg() !== null) {
                     $filename = explode('_', explode('/', $blogDb->getImg())[3])[0];
                     foreach ($blogsDiskArray[$blogDb->getId()] as $blogFileKey => $blogFile) {
                         if (strstr($blogFile, $filename)) {
                             unset($blogsDiskArray[$blogDb->getId()][$blogFileKey]);
                         }
                     }
                 }
             }
             foreach ($blogsDiskArray as $folder => $blogDisk) {
                 foreach ($blogDisk as $blogDiskFiles) {
                     $unusedBlogFile = $blogImagesPath . $folder . '/' . $blogDiskFiles;
                     $unusedFiles[] = $unusedBlogFile;
                     if (is_dir($unusedBlogFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Blogs' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedBlogFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Blogs' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedBlogFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Users Documents
      */
     if ($this->onlyUsersDocuments or $this->withOutParams) {
         $userUploadsPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_USER_DOCUMENTS;
         if (!is_readable($userUploadsPath)) {
             echo "Folder does not exist: " . $userUploadsPath . PHP_EOL . PHP_EOL;
         } else {
             $usersDocsDiskData = array_diff(scandir($userUploadsPath), ['.', '..']);
             $usersDocsDiskArray = [];
             foreach ($usersDocsDiskData as $userDocDisk) {
                 $thisFilesList = array_diff(scandir($userUploadsPath . $userDocDisk), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $usersDocsDiskArray[$userDocDisk][] = $file;
                 }
             }
             $usersDocsDbData = $this->getUsersDocumentsData();
             foreach ($usersDocsDbData as $userDocDb) {
                 $attachment = $userUploadsPath . $userDocDb->getUserId() . '/' . $userDocDb->getAttachment();
                 if (!empty($userDocDb->getAttachment()) and $userDocDb->getAttachment() !== null and !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', 'ga_bo_user_documents.id: ' . $userDocDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($userDocDb->getAttachment()) and $userDocDb->getAttachment() !== null) {
                     $filename = $userDocDb->getAttachment();
                     foreach ($usersDocsDiskArray[$userDocDb->getUserId()] as $userDocFileKey => $userDocFile) {
                         if ($userDocFile === $filename) {
                             unset($usersDocsDiskArray[$userDocDb->getUserId()][$userDocFileKey]);
                         }
                     }
                 }
             }
             foreach ($usersDocsDiskArray as $folder => $userDocDisk) {
                 foreach ($userDocDisk as $userDocDiskFiles) {
                     $unusedUserDocumentsFile = $userUploadsPath . $folder . '/' . $userDocDiskFiles;
                     $unusedFiles[] = $unusedUserDocumentsFile;
                     if (is_dir($unusedUserDocumentsFile)) {
                         $table->appendRow([$this->runCounter(), 'type: User Documents' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedUserDocumentsFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: User Documents' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedUserDocumentsFile, 'x']);
                     }
                 }
             }
         }
     }
     /**
      * Jobs Documents
      */
     if ($this->onlyJobsDocuments or $this->withOutParams) {
         $applicantUploadsPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_HR_APPLICANT_DOCUMENTS;
         if (!is_readable($applicantUploadsPath)) {
             echo "Folder does not exist: " . $applicantUploadsPath . PHP_EOL . PHP_EOL;
         } else {
             $jobsDocsDiskData = array_diff(scandir($applicantUploadsPath), ['.', '..']);
             $jobsDocsDiskArray = [];
             foreach ($jobsDocsDiskData as $jobDocDiskYear) {
                 $yearFilesList = array_diff(scandir($applicantUploadsPath . $jobDocDiskYear), ['.', '..']);
                 foreach ($yearFilesList as $jobDocDiskMonth) {
                     $monthFilesList = array_diff(scandir($applicantUploadsPath . $jobDocDiskYear . '/' . $jobDocDiskMonth), ['.', '..']);
                     foreach ($monthFilesList as $file) {
                         $jobsDocsDiskArray[$jobDocDiskYear][$jobDocDiskMonth][] = $file;
                     }
                 }
             }
             $jobsDocsDbData = $this->getJobsDocumentsData();
             foreach ($jobsDocsDbData as $jobDocDb) {
                 $attachmentDate = explode('-', $jobDocDb->getDateApplied());
                 $attachment = $applicantUploadsPath . $attachmentDate[0] . '/' . $attachmentDate[1] . '/' . $jobDocDb->getCvFileName();
                 if (!empty($jobDocDb->getCvFileName()) and $jobDocDb->getCvFileName() !== null and !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', 'ga_hr_applicants.id: ' . $jobDocDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($jobDocDb->getCvFileName()) and $jobDocDb->getCvFileName() !== null) {
                     $filename = $jobDocDb->getCvFileName();
                     foreach ($jobsDocsDiskArray[$attachmentDate[0]][$attachmentDate[1]] as $jobDocFileKey => $jobDocFile) {
                         if ($jobDocFile === $filename) {
                             unset($jobsDocsDiskArray[$attachmentDate[0]][$attachmentDate[1]][$jobDocFileKey]);
                         }
                     }
                 }
             }
             foreach ($jobsDocsDiskArray as $year => $monthFiles) {
                 foreach ($monthFiles as $month => $jobDocDiskFiles) {
                     foreach ($jobDocDiskFiles as $fileKey => $jobDocDiskFile) {
                         $unusedJobDocumentFile = $applicantUploadsPath . $year . '/' . $month . '/' . $jobDocDiskFile;
                         $unusedFiles[] = $unusedJobDocumentFile;
                         if (is_dir($unusedJobDocumentFile)) {
                             $table->appendRow([$this->runCounter(), 'type: Applicant Documents' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedJobDocumentFile, 'x']);
                         } else {
                             $table->appendRow([$this->runCounter(), 'type: Applicant Documents' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedJobDocumentFile, 'x']);
                         }
                     }
                 }
             }
         }
     }
     /**
      * Booking attached documents
      */
     if ($this->onlyBookingDocuments || $this->withOutParams) {
         $bookingDocFolder = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_BOOKING_DOCUMENTS;
         if (!is_readable($bookingDocFolder)) {
             echo "Folder does not exist: " . $bookingDocFolder . PHP_EOL . PHP_EOL;
         } else {
             $bookingDocsDiskData = array_diff(scandir($bookingDocFolder), ['.', '..']);
             $bookingDocsDiskArray = [];
             foreach ($bookingDocsDiskData as $bookingDocDiskYear) {
                 $yearFilesList = array_diff(scandir($bookingDocFolder . $bookingDocDiskYear), ['.', '..']);
                 foreach ($yearFilesList as $bookingDocDiskMonth) {
                     $monthFilesList = array_diff(scandir($bookingDocFolder . $bookingDocDiskYear . '/' . $bookingDocDiskMonth), ['.', '..']);
                     foreach ($monthFilesList as $BookingsList) {
                         $bookingsList = array_diff(scandir($bookingDocFolder . $bookingDocDiskYear . '/' . $bookingDocDiskMonth . '/' . $BookingsList), ['.', '..']);
                         foreach ($bookingsList as $bookingDocsList) {
                             $docList = array_diff(scandir($bookingDocFolder . $bookingDocDiskYear . '/' . $bookingDocDiskMonth . '/' . $BookingsList . '/' . $bookingDocsList), ['.', '..']);
                             foreach ($docList as $file) {
                                 $bookingDocsDiskArray[$bookingDocDiskYear][$bookingDocDiskMonth][$BookingsList][$bookingDocsList][] = $file;
                             }
                         }
                     }
                 }
             }
             $bookingsDocsDbData = $this->getReservationAttachmentsData();
             foreach ($bookingsDocsDbData as $bookingDocDb) {
                 $createdDate = $bookingDocDb->getCreatedDate();
                 $year = date('Y', strtotime($createdDate));
                 $month = date('m', strtotime($createdDate));
                 $attachment = $bookingDocFolder . $year . '/' . $month . '/' . $bookingDocDb->getReservationId() . '/' . $bookingDocDb->getDocId() . '/' . $bookingDocDb->getAttachment();
                 if (!empty($bookingDocDb->getAttachment()) && $bookingDocDb->getAttachment() !== null && !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', 'ga_reservation_attachment_items.id: ' . $bookingDocDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($bookingDocDb->getAttachment()) && $bookingDocDb->getAttachment() !== null) {
                     $filename = $bookingDocDb->getAttachment();
                     foreach ($bookingDocsDiskArray[$year][$month][$bookingDocDb->getReservationId()] as $bookingDocFileKey => $bookingDocFile) {
                         foreach ($bookingDocFile as $docFiles => $bookDocFile) {
                             if ($bookDocFile === $filename) {
                                 unset($bookingDocsDiskArray[$year][$month][$bookingDocDb->getReservationId()][$bookingDocFileKey][$docFiles]);
                             }
                         }
                     }
                 }
             }
             foreach ($bookingDocsDiskArray as $year => $monthFiles) {
                 foreach ($monthFiles as $month => $booksId) {
                     foreach ($booksId as $bookId => $docsId) {
                         foreach ($docsId as $bookingDocId => $bookingFileList) {
                             foreach ($bookingFileList as $bookingFileKey => $bookingDiskFile) {
                                 $unusedBookingDocFile = $bookingDocFolder . $year . '/' . $month . '/' . $bookId . '/' . $bookingDocId . '/' . $bookingDiskFile;
                                 $unusedFiles[] = $unusedBookingDocFile;
                                 if (is_dir($unusedBookingDocFile)) {
                                     $table->appendRow([$this->runCounter(), 'type: Booking Documents' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedBookingDocFile, 'x']);
                                 } else {
                                     $table->appendRow([$this->runCounter(), 'type: Booking Documents' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedBookingDocFile, 'x']);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * Money Account attached documents
      */
     if ($this->onlyMoneyAccountDocuments || $this->withOutParams) {
         $moneyAccountDocFolder = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_MONEY_ACCOUNT_DOCUMENTS;
         if (!is_readable($moneyAccountDocFolder)) {
             echo "Folder does not exist: " . $moneyAccountDocFolder . PHP_EOL . PHP_EOL;
         } else {
             $moneyAccountDocsDiskData = array_diff(scandir($moneyAccountDocFolder), ['.', '..']);
             $moneyAccountDocsDiskArray = [];
             foreach ($moneyAccountDocsDiskData as $moneyAccountDocDiskYear) {
                 $yearFilesList = array_diff(scandir($moneyAccountDocFolder . $moneyAccountDocDiskYear), ['.', '..']);
                 foreach ($yearFilesList as $moneyAccountDocDiskMonth) {
                     $monthFilesList = array_diff(scandir($moneyAccountDocFolder . $moneyAccountDocDiskYear . '/' . $moneyAccountDocDiskMonth), ['.', '..']);
                     foreach ($monthFilesList as $MoneyAccountsList) {
                         $moneyAccountsList = array_diff(scandir($moneyAccountDocFolder . $moneyAccountDocDiskYear . '/' . $moneyAccountDocDiskMonth . '/' . $MoneyAccountsList), ['.', '..']);
                         foreach ($moneyAccountsList as $moneyAccountsDocsList) {
                             $docList = array_diff(scandir($moneyAccountDocFolder . $moneyAccountDocDiskYear . '/' . $moneyAccountDocDiskMonth . '/' . $MoneyAccountsList . '/' . $moneyAccountsDocsList), ['.', '..']);
                             foreach ($docList as $file) {
                                 $moneyAccountDocsDiskArray[$moneyAccountDocDiskYear][$moneyAccountDocDiskMonth][$MoneyAccountsList][$moneyAccountsDocsList][] = $file;
                             }
                         }
                     }
                 }
             }
             $moneyAccountsDocsDbData = $this->getMoneyAccountAttachmentsData();
             foreach ($moneyAccountsDocsDbData as $moneyAccountDocDb) {
                 $createdDate = $moneyAccountDocDb->getCreatedDate();
                 $year = date('Y', strtotime($createdDate));
                 $month = date('m', strtotime($createdDate));
                 $attachment = $moneyAccountDocFolder . $year . '/' . $month . '/' . $moneyAccountDocDb->getMoneyAccountId() . '/' . $moneyAccountDocDb->getDocId() . '/' . $moneyAccountDocDb->getAttachment();
                 if (!empty($moneyAccountDocDb->getAttachment()) && $moneyAccountDocDb->getAttachment() !== null && !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_MONEY_ACCOUNT_ATTACHMENT_ITEMS . '.id: ' . $moneyAccountDocDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($moneyAccountDocDb->getAttachment()) && $moneyAccountDocDb->getAttachment() !== null) {
                     $filename = $moneyAccountDocDb->getAttachment();
                     foreach ($moneyAccountDocsDiskArray[$year][$month][$moneyAccountDocDb->getMoneyAccountId()] as $moneyAccountDocFileKey => $moneyAccountDocFile) {
                         foreach ($moneyAccountDocFile as $docFiles => $monAccDocFile) {
                             if ($monAccDocFile === $filename) {
                                 unset($moneyAccountDocsDiskArray[$year][$month][$moneyAccountDocDb->getMoneyAccountId()][$moneyAccountDocFileKey][$docFiles]);
                             }
                         }
                     }
                 }
             }
             foreach ($moneyAccountDocsDiskArray as $year => $monthFiles) {
                 foreach ($monthFiles as $month => $monacsId) {
                     foreach ($monacsId as $monacId => $docsId) {
                         foreach ($docsId as $moneyAccountDocId => $moneyAccountFileList) {
                             foreach ($moneyAccountFileList as $moneyAccountFileKey => $moneyAccountDiskFile) {
                                 $unusedMoneyAccountDocFile = $moneyAccountDocFolder . $year . '/' . $month . '/' . $monacId . '/' . $moneyAccountDocId . '/' . $moneyAccountDiskFile;
                                 $unusedFiles[] = $unusedMoneyAccountDocFile;
                                 if (is_dir($unusedMoneyAccountDocFile)) {
                                     $table->appendRow([$this->runCounter(), 'type: Money Account Documents' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedMoneyAccountDocFile, 'x']);
                                 } else {
                                     $table->appendRow([$this->runCounter(), 'type: Money Account Documents' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedMoneyAccountDocFile, 'x']);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * Task attachments
      */
     if ($this->onlyTaskAttachments || $this->withOutParams) {
         $taskAttachmentsFolder = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_UPLOADS_ROOT . DirectoryStructure::FS_UPLOADS_TASK_ATTACHMENTS;
         if (!is_readable($taskAttachmentsFolder)) {
             echo "Folder does not exist: " . $taskAttachmentsFolder . PHP_EOL . PHP_EOL;
         } else {
             $taskAttachmentsDiskData = array_diff(scandir($taskAttachmentsFolder), ['.', '..']);
             $taskAttachmentsDiskArray = [];
             foreach ($taskAttachmentsDiskData as $year) {
                 $monthList = array_diff(scandir($taskAttachmentsFolder . $year), ['.', '..']);
                 foreach ($monthList as $month) {
                     $dayList = array_diff(scandir($taskAttachmentsFolder . $year . '/' . $month), ['.', '..']);
                     foreach ($dayList as $day) {
                         $idList = array_diff(scandir($taskAttachmentsFolder . $year . '/' . $month . '/' . $day), ['.', '..']);
                         foreach ($idList as $id) {
                             $taskAttachmentsList = array_diff(scandir($taskAttachmentsFolder . $year . '/' . $month . '/' . $day . '/' . $id), ['.', '..']);
                             foreach ($taskAttachmentsList as $file) {
                                 $taskAttachmentsDiskArray[$year][$month][$day][$id][] = $file;
                             }
                         }
                     }
                 }
             }
             $taskAttachmentsDbData = $this->getTaskAttachmentsData();
             foreach ($taskAttachmentsDbData as $taskAttachmentDb) {
                 $attachmentDate = explode('/', $taskAttachmentDb->getPath());
                 $attachment = $taskAttachmentsFolder . $taskAttachmentDb->getPath() . '/' . $taskAttachmentDb->getTaskId() . '/' . $taskAttachmentDb->getFile();
                 if (!empty($taskAttachmentDb->getFile()) and !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', 'ga_task_attachments.id: ' . $taskAttachmentDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($taskAttachmentDb->getFile())) {
                     $filename = $taskAttachmentDb->getFile();
                     $key = array_search($filename, $taskAttachmentsDiskArray[$attachmentDate[0]][$attachmentDate[1]][$attachmentDate[2]][$taskAttachmentDb->getTaskId()]);
                     if ($key !== false) {
                         unset($taskAttachmentsDiskArray[$attachmentDate[0]][$attachmentDate[1]][$attachmentDate[2]][$taskAttachmentDb->getTaskId()][$key]);
                     }
                 }
             }
             if (count($taskAttachmentsDiskArray)) {
                 foreach ($taskAttachmentsDiskArray as $year => $monthFiles) {
                     foreach ($monthFiles as $month => $dayFiles) {
                         foreach ($dayFiles as $day => $idFiles) {
                             foreach ($idFiles as $taskId => $files) {
                                 foreach ($files as $file) {
                                     $unusedTaskAttachmentFile = $taskAttachmentsFolder . $year . '/' . $month . '/' . $day . '/' . $taskId . '/' . $file;
                                     $unusedFiles[] = $unusedTaskAttachmentFile;
                                     if (is_dir($unusedTaskAttachmentFile)) {
                                         $table->appendRow([$this->runCounter(), 'type: Task Attachments' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedTaskAttachmentFile, 'x']);
                                     } else {
                                         $table->appendRow([$this->runCounter(), 'type: Task Attachments' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedTaskAttachmentFile, 'x']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * Parking attachments
      */
     if ($this->onlyParkingAttachments || $this->withOutParams) {
         $parkingAttachmentsFolder = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_PARKING_ATTACHMENTS;
         if (!is_readable($parkingAttachmentsFolder)) {
             echo "Folder does not exist: " . $parkingAttachmentsFolder . PHP_EOL . PHP_EOL;
         } else {
             $parkingAttachmentsDiskData = array_diff(scandir($parkingAttachmentsFolder), ['.', '..']);
             $parkingAttachmentsDiskArray = [];
             foreach ($parkingAttachmentsDiskData as $id) {
                 $parkingAttachmentsList = array_diff(scandir($parkingAttachmentsFolder . $id), ['.', '..']);
                 foreach ($parkingAttachmentsList as $file) {
                     $parkingAttachmentsDiskArray[$id][] = $file;
                 }
             }
             $parkingAttachmentsDbData = $this->getParkingAttachmentsData();
             foreach ($parkingAttachmentsDbData as $parkingAttachmentDb) {
                 $attachment = $parkingAttachmentsFolder . '/' . $parkingAttachmentDb->getId() . '/' . $parkingAttachmentDb->getParkingPermit();
                 if (!empty($parkingAttachmentDb->getParkingPermit()) and !is_file($attachment)) {
                     $table->appendRow([$this->runCounter(), 'x', 'ga_parking_attachments.id: ' . $parkingAttachmentDb->getId() . PHP_EOL . 'attachment: ' . PHP_EOL . $attachment]);
                 } elseif (!empty($parkingAttachmentDb->getParkingPermit())) {
                     $filename = $parkingAttachmentDb->getParkingPermit();
                     $key = array_search($filename, $parkingAttachmentsDiskArray[$parkingAttachmentDb->getId()]);
                     if ($key !== false) {
                         unset($parkingAttachmentsDiskArray[$parkingAttachmentDb->getId()][$key]);
                     }
                 }
             }
             if (count($parkingAttachmentsDiskArray)) {
                 foreach ($parkingAttachmentsDiskArray as $parkingId => $files) {
                     foreach ($files as $file) {
                         $unusedParkingAttachmentFile = $parkingAttachmentsFolder . $parkingId . '/' . $file;
                         $unusedFiles[] = $unusedParkingAttachmentFile;
                         if (is_dir($unusedParkingAttachmentFile)) {
                             $table->appendRow([$this->runCounter(), 'type: Parking Attachments' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedParkingAttachmentFile, 'x']);
                         } else {
                             $table->appendRow([$this->runCounter(), 'type: Parking Attachments' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedParkingAttachmentFile, 'x']);
                         }
                     }
                 }
             }
         }
     }
     // Apartel Images
     if ($this->onlyApartelImages || $this->withOutParams) {
         $apartelImagesPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_APARTEL_BG_IMAGE;
         if (!is_readable($apartelImagesPath)) {
             echo "Folder does not exist: " . $apartelImagesPath . PHP_EOL . PHP_EOL;
         } else {
             $apartelImagesDiskData = array_diff(scandir($apartelImagesPath), ['.', '..']);
             $apartelImagesDiskArray = [];
             foreach ($apartelImagesDiskData as $apartelImageDisk) {
                 $thisFilesList = array_diff(scandir($apartelImagesPath . $apartelImageDisk), ['.', '..']);
                 foreach ($thisFilesList as $file) {
                     $apartelImagesDiskArray[$apartelImageDisk][] = $file;
                 }
             }
             $apartelImagesDbData = $this->getApartelImagesData();
             foreach ($apartelImagesDbData as $apartelImageDb) {
                 /**
                  * @var \DDD\Domain\Apartel\Details\Details $apartelImageDb
                  */
                 $bgImage = $apartelImagesPath . $apartelImageDb->getApartelId() . '/' . $apartelImageDb->getBgImage();
                 if (!empty($apartelImageDb->getBgImage()) && $apartelImageDb->getBgImage() !== null && !is_file($bgImage)) {
                     $table->appendRow([$this->runCounter(), 'x', DbTables::TBL_APARTELS_DETAILS . '.id: ' . $apartelImageDb->getId() . PHP_EOL . 'apartel id: ' . $apartelImageDb->getApartelId() . PHP_EOL . 'cover_image: ' . PHP_EOL . $bgImage]);
                 } elseif (!empty($apartelImageDb->getBgImage()) && $apartelImageDb->getBgImage() !== null) {
                     $filename = explode('_', $apartelImageDb->getBgImage())[0];
                     foreach ($apartelImagesDiskArray[$apartelImageDb->getApartelId()] as $apartelFileKey => $apartelFile) {
                         if (strstr($apartelFile, $filename)) {
                             unset($apartelImagesDiskArray[$apartelImageDb->getApartelId()][$apartelFileKey]);
                         }
                     }
                 }
             }
             foreach ($apartelImagesDiskArray as $folder => $apartelDisk) {
                 foreach ($apartelDisk as $apartelDiskFiles) {
                     $unusedApartelFile = $apartelImagesPath . $folder . '/' . $apartelDiskFiles;
                     $unusedFiles[] = $unusedApartelFile;
                     if (is_dir($unusedApartelFile)) {
                         $table->appendRow([$this->runCounter(), 'type: Apartel Image' . PHP_EOL . '-=!=- UNKNOWN FOLDER -=!=- ' . PHP_EOL . $unusedApartelFile, 'x']);
                     } else {
                         $table->appendRow([$this->runCounter(), 'type: Apartel Image' . PHP_EOL . 'filename: ' . PHP_EOL . $unusedApartelFile, 'x']);
                     }
                 }
             }
         }
     }
     // Purchase Order
     if ($this->onlyPurchaseOrder || $this->withOutParams) {
         $this->matchAttachments($table, ['id' => 'id', 'date' => 'date', 'filename' => 'filename', 'dir' => '/ginosi/uploads/expense', 'type' => 'Purchase Order Attachment ', 'depth' => 4, 'sql' => '
                 select
                     ga_expense.id as id,
                     ga_expense.date_created as date,
                     ga_expense_attachments.filename
                 from ga_expense_attachments
                     left join ga_expense on ga_expense.id = ga_expense_attachments.expense_id
             ']);
     }
     // Purchase Order Items
     if ($this->onlyPurchaseOrderItems || $this->withOutParams) {
         $this->matchAttachments($table, ['id' => 'id', 'filename' => 'filename', 'dir' => '/ginosi/uploads/expense/items', 'type' => 'Purchase Order Item Attachment ', 'depth' => 5, 'sql' => '
                 select
                     filename
                 from ga_expense_item_attachments
                 where expense_id IS NOT NULL
             ']);
         $this->matchAttachments($table, ['id' => 'id', 'filename' => 'filename', 'dir' => '/ginosi/uploads/expense/items_tmp', 'type' => 'Purchase Order Temporary Items Attachment ', 'depth' => 1, 'sql' => '
                 select
                     filename
                 from ga_expense_item_attachments
                 where expense_id IS NULL
             ']);
     }
     echo PHP_EOL . 'Rendering table...' . PHP_EOL;
     sleep(1);
     echo $table;
     /**
      * REMOVE UNUSED FILES FROM DISK
      */
     if (count($unusedFiles) > 0 and $this->removeFromDisk) {
         echo PHP_EOL;
         echo "!!! WARNING !!!";
         if (Prompt\Confirm::prompt(PHP_EOL . 'Are you absolutely sure you want to permanently delete unused files from hard disk? You have already created backup copy of these files? [y/n]' . PHP_EOL, 'y', 'n')) {
             echo PHP_EOL;
             $secretWord = Prompt\Line::prompt('Please say the magic word and press [ENTER]: ', false, 30);
             echo PHP_EOL . PHP_EOL;
             if ($secretWord === 'please') {
                 echo "go go go..." . PHP_EOL;
                 foreach ($unusedFiles as $fileToRemove) {
                     if (is_writable($fileToRemove)) {
                         if (is_dir($fileToRemove)) {
                             $this->delTree($fileToRemove);
                         } else {
                             unlink($fileToRemove);
                         }
                         echo "Removed: " . $fileToRemove . PHP_EOL;
                     } else {
                         echo "Cannot remove file (permissions denied): " . $fileToRemove . PHP_EOL;
                     }
                 }
             } else {
                 echo "Wrong! Try again :P" . PHP_EOL;
             }
         } else {
             echo "You chose NO :(" . PHP_EOL;
         }
     }
     echo PHP_EOL . 'Reporting done!' . PHP_EOL . PHP_EOL;
 }
コード例 #17
0
ファイル: install.php プロジェクト: tillk/vufind
/**
 * readline() does not exist on Windows.  This is a simple wrapper for portability.
 *
 * @param string $prompt Prompt to display to the user.
 *
 * @return string        User-entered response.
 */
function getInput($prompt)
{
    return \Zend\Console\Prompt\Line::prompt($prompt, true);
}
コード例 #18
0
ファイル: Markdown.php プロジェクト: bravadomizzou/dewdrop
 public function ask($promptText, $allowEmpty = false)
 {
     $prompt = new LinePrompt($promptText, $allowEmpty);
     $prompt->setConsole($this->console);
     return $prompt->show();
 }
コード例 #19
0
<?php

/**
 * @var \OpsWay\AppManager\Service\Manager $this
 */
$console = $this->getServiceLocator()->get('console');
//$console->clear();
/**
 * @var \Zend\Mvc\Controller\AbstractActionController $controller
 */
$controller = $e->getParam('controller');
$consoleParams = [];
parse_str($controller->getRequest()->getParam('params', ''), $consoleParams);
// SETUP LOCAL CONFIG
$localConfig = new \Zend\Config\Config(include getcwd() . '/config/autoload/local.php.dist', true);
$dbConfig = $localConfig->doctrine->connection->orm_default->params;
foreach (['host', 'port', 'user', 'password', 'dbname'] as $pName) {
    if (isset($consoleParams['db']) && isset($consoleParams['db'][$pName])) {
        $dbConfig->{$pName} = $consoleParams['db'][$pName];
    } else {
        $dbConfig->{$pName} = ($value = \Zend\Console\Prompt\Line::prompt("DATABASE. Please enter {$pName} [" . $dbConfig->{$pName} . "]:", true, 100)) ? $value : $dbConfig->{$pName};
    }
}
$writer = new \Zend\Config\Writer\PhpArray();
$writer->setUseBracketArraySyntax(true);
$writer->toFile(getcwd() . '/config/autoload/local/db.local.php', $localConfig);
$console->writeLine('Database configuration file created!');
コード例 #20
0
ファイル: Console.php プロジェクト: nomaanp/zf2rapid
 /**
  * Write a customizable line prompt
  *
  * @param $message
  *
  * @return string
  */
 public function writeLinePrompt($message)
 {
     $this->writeLine();
     // write prompt badge
     $this->writeBadge('badge_pick', Color::RED);
     // output prompt
     $prompt = new Line($this->translator->translate($message), false);
     $answer = $prompt->show();
     $this->writeLine();
     return $answer;
 }
コード例 #21
0
ファイル: Help.php プロジェクト: ocramius/ocramius
 /**
  * @param $question
  * @param ConsoleAdapter $console
  *
  * @return string|null
  */
 private function askUrlQuestion($question, ConsoleAdapter $console)
 {
     $console->writeLine($question . ' (URL)', ColorInterface::CYAN);
     $prompt = new Line('');
     $prompt->setConsole($console);
     $url = $prompt->show();
     if (!(new Uri(['allowRelative' => false]))->isValid($url)) {
         $console->writeLine('The provided URL "' . $url . '" doesn\'t seem to be valid!', ColorInterface::RED);
         return null;
     }
     return $url;
 }
コード例 #22
0
 public function addAction()
 {
     /** @var \Zend\Console\Request $request */
     $request = $this->getRequest();
     /** @var \Continuous\DeployAgent\Application\Application $application */
     $application = $this->getServiceLocator()->get('application/application');
     // provider param
     if ($request->getParam('provider')) {
         /** @var \Continuous\DeployAgent\Provider\Continuousphp $provider */
         $provider = $this->getServiceLocator()->get('provider/' . $request->getParam('provider'));
     } else {
         $providers = ["continuousphp"];
         $providerKey = Select::prompt("Select a provider:", $providers);
         /** @var \Continuous\DeployAgent\Provider\Continuousphp $provider */
         $provider = $this->getServiceLocator()->get('provider/' . $providers[$providerKey]);
     }
     $application->setProvider($provider);
     // token param
     if (!($token = $request->getParam('token'))) {
         $token = Line::prompt("Enter a valid continuousphp access token: ");
     }
     $provider->setToken($token);
     // project param
     if ($request->getParam('repository-provider') && $request->getParam('repository')) {
         $provider->setRepositoryProvider($request->getParam('repository-provider'))->setRepository($request->getParam('repository'));
     } else {
         $this->getConsole()->writeLine('Querying API for your projects...', ColorInterface::LIGHT_CYAN);
         $projects = $provider->getProjects();
         $projectOptions = [];
         foreach ($projects as $entry) {
             $projectOptions[] = $entry['_embedded']['provider']['uniqueIdentifier'] . '/' . $entry['url'];
         }
         if ($projectOptions) {
             $projectKey = Select::prompt("Select a project:", $projectOptions, false, true);
             $project = $projects[$projectKey];
             $provider->setProject($project);
         } else {
             $this->getConsole()->writeLine('There is no project to setup in your continuousphp account', ColorInterface::LIGHT_RED);
             return false;
         }
     }
     // pipeline param
     if (!($reference = $request->getParam('pipeline'))) {
         $this->getConsole()->writeLine('Querying API for your project pipelines...', ColorInterface::LIGHT_CYAN);
         $referenceOptions = $provider->getReferences();
         $referenceKey = Select::prompt("Select a pipeline:", $referenceOptions, false, true);
         $reference = $referenceOptions[$referenceKey];
     }
     $provider->setReference($reference);
     // name param
     if (!($name = $request->getParam('name'))) {
         $name = Line::prompt("Enter an application name: ");
     }
     $application->setName($name);
     // destination param
     if (!($path = $request->getParam('path'))) {
         $path = Line::prompt("Enter the application path: ");
     }
     $application->setPath($path);
     /** @var \Continuous\DeployAgent\Application\ApplicationManager $applicationManager */
     $applicationManager = $this->getServiceLocator()->get('application/application-manager');
     $applicationManager->persist($application);
     return false;
 }
コード例 #23
0
 public function createAction()
 {
     $request = $this->getRequest();
     if (!$request instanceof ConsoleRequest) {
         throw new \RuntimeException('This action can only be used from a console!');
     }
     try {
         $console = Console::getInstance();
     } catch (ConsoleException $e) {
         throw new \RuntimeException('This action can only be used from a console!');
     }
     $this->setValidatorService($this->getServiceLocator()->get('loslicense.validator'));
     $outputFile = $request->getParam('outputFile', null);
     $writer = new \LosLicense\Config\Writer\PhpArray();
     $writer->setUseBracketArraySyntax(true);
     $options = ['Trial', 'Personal', 'Standard'];
     $type = Select::prompt('License type?', $options, false, true);
     $valid_from = Line::prompt("\nValid from (Enter to not set one) YYYY-MM-DD HH:II:SS ? ", true, 20);
     $valid_until = Line::prompt("\nValid until (Enter to not set one) YYYY-MM-DD HH:II:SS ? ", true, 20);
     $customer = Line::prompt("\nCustomer? ", true, 100);
     $options = $this->getServiceLocator()->get('loslicense.options');
     $features = $options->getFeatures();
     $checked = Checkbox::prompt("\nFeatures? (Enter to finish) ", array_keys($features), true, true);
     $sign = false;
     if (Confirm::prompt("\nSign the license? [y/n] ", 'y', 'n')) {
         $sign = true;
     }
     if (Confirm::prompt("\nConfirm the license creation? [y/n] ", 'y', 'n')) {
         $config = new \Zend\Config\Config([], true);
         if ($type == 0) {
             $config->type = License::LICENSE_TRIAL;
             $license = new TrialLicense();
         } elseif ($type == 1) {
             $config->type = License::LICENSE_PERSONAL;
             $license = new PersonalLicense();
         } else {
             $config->type = License::LICENSE_STANDARD;
             $license = new StandardLicense();
         }
         $license->setType($config->type);
         if (!empty($valid_from)) {
             $from = new \DateTime($valid_from);
             $config->valid_from = $from->format('Y-m-d H:i:s');
             $license->setValidFrom($config->valid_from);
         }
         if (!empty($valid_until)) {
             $until = new \DateTime($valid_until);
             $config->valid_until = $until->format('Y-m-d H:i:s');
             $license->setValidUntil($config->valid_until);
         }
         if (!empty($customer)) {
             $config->customer = $customer;
             $license->setCustomer($config->customer);
         }
         if (!empty($checked)) {
             $config->features = [];
             $licenseFeatures = [];
             foreach ($features as $feature => $value) {
                 if (in_array($feature, $checked)) {
                     if ($value === null) {
                         $config->features->{$feature} = null;
                         $licenseFeatures[$feature] = null;
                     } else {
                         $config->features->{$feature} = $value;
                         $licenseFeatures[$feature] = $value;
                     }
                 }
             }
             $license->setFeatures($licenseFeatures);
         }
         if ($sign) {
             $signature = $this->getValidatorService()->signLicense($license);
             $config->signature = $signature;
         }
         if ($outputFile) {
             $writer->toFile($outputFile, $config);
         } else {
             echo $writer->toString($config);
         }
         $console->writeLine("License created", Color::GREEN);
     }
 }