From 356837b136132292b4d27a06549a71d2b2b1f97e Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 24 Apr 2019 12:26:25 +0200 Subject: [PATCH] add Process component --- composer.json | 3 ++- src/Deblan/Command/CheckCommand.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 42c1e6b..453b609 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ } }, "require": { - "symfony/console": "^4.2" + "symfony/console": "^4.2", + "symfony/process": "^4.2" } } diff --git a/src/Deblan/Command/CheckCommand.php b/src/Deblan/Command/CheckCommand.php index 6a55db2..03ff634 100644 --- a/src/Deblan/Command/CheckCommand.php +++ b/src/Deblan/Command/CheckCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Command\Command as BaseCommand; use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Process\Process; /** * class CheckCommand. @@ -83,7 +84,16 @@ class CheckCommand extends BaseCommand protected function check($domain) { - $whois = shell_exec(sprintf('whois %s', escapeshellarg($domain))); + $process = new Process(['whois', $domain]); + $process->run(); + + if (!$process->isSuccessful()) { + $this->fails[] = [$domain, 'FAIL']; + + return; + } + + $whois = $process->getOutput(); preg_match('/Expiry Date: ([^\s]+)/i', $whois, $match);