Bramus\MCS\Scanner::scan PHP Method

scan() public method

Scan entire website
public scan ( ) : void
return void
    public function scan()
    {
        // Add the root URL to the list of pages
        if ($this->rootUrl != '*') {
            $this->pages[] = $this->rootUrl;
        }
        // Give feedback on the CLI
        $this->logger->addNotice('Scanning ' . $this->rootUrl);
        // Current index at $this->pages
        $curPageIndex = 0;
        // Start looping
        while (true) {
            // Get the current pageUrl
            $curPageUrl = $this->pages[$curPageIndex];
            // Scan a single page. Returns the mixed content (if any)
            $mixedContent = $this->scanPage($curPageUrl);
            // Got mixed content
            if ($mixedContent) {
                // Add an alert for the URL
                $this->logger->addError(sprintf('%05d', $curPageIndex) . ' - ' . $curPageUrl);
                foreach ($mixedContent as $url) {
                    $this->logger->addWarning($url);
                }
            } else {
                $this->logger->addInfo(sprintf('%05d', $curPageIndex) . ' - ' . $curPageUrl);
            }
            // Done scanning all pages? Then quit! Otherwise: scan the next page
            if ($curPageIndex + 1 == sizeof($this->pages)) {
                break;
            } else {
                $curPageIndex++;
            }
        }
        // Give feedback on the CLI
        $this->logger->addNotice('Scanned ' . sizeof($this->pages) . ' pages for Mixed Content');
    }