curlService = $curlService; } protected function configure(): void { } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); //$file = fopen('./DAB - Duravit.csv', 'r'); //$file = fopen('./DAB - Matki.csv', 'r'); $file = fopen('./DAB - VandB.csv', 'r'); $___retailers = []; $titleRow = 0; while (($retailer = fgetcsv($file)) !== FALSE) { print_r($retailer); if ($titleRow == 0) { $titleRow++; continue; } // $retailer = [ // 'name' => $name, // 'address' => $address, // 'postcode' => $postcode, // 'tel' => $tel, // 'website' => $website, // 'email' => $email // ]; //$website = $retailer[4]; $website = $retailer[6]; $parsed = parse_url($website); if (!isset($parsed['path']) || $parsed['path'] == '') { //if (!isset($parsed['host']) || $parsed['host'] == '') { $___retailers[] = [ $retailer[0], 'Unknown', 'N' ]; continue; } $url = 'http://' . $parsed['path']; //$parsed['host']; // $url = escapeshellarg($url); $command = "wget -N -T 5 --tries=2 -O - $url"; $output = ''; $content = ''; exec($command, $output, $returnCode); $counter = 0; while ($output == '') { $counter++; if ($counter > 5) { break; } sleep(1); } $content = implode($output); $ecomms = 'N'; if ($content != '') { if (preg_match("/Checkout\b|Cart\b/iU", $content, $matches)) { $ecomms = 'Y'; } } $___retailers[] = [ $retailer[0], $website, $ecomms ]; } fclose($file); //$fp = fopen('Duravit Ecomms.csv', 'w'); //$fp = fopen('Matki Ecomms.csv', 'w'); $fp = fopen('VandB Ecomms.csv', 'w'); fputcsv($fp, ['Name', 'Website', 'Ecomms'], ',', '"', ''); foreach ($___retailers as $___retailer) { fputcsv($fp, $___retailer, ',', '"', ''); } fclose($fp); $io->success('DAB2 run.'); return Command::SUCCESS; } }