/** * Start a check * * @param string $code * @param string $url */ public function __construct($code, $url) { $magescanUrl = new Url(); $this->url = $magescanUrl->clean(urldecode($url)); $this->request = new Request($this->url, isset($_SERVER['ALLOW_INSECURE'])); call_user_func([$this, 'check' . ucwords($code)]); }
/** * Test a url that has query params */ public function testUrlQueryParams() { $sampleUrl = 'www.example.com?foo=bar'; $url = new Url(); $cleanUrl = $url->clean($sampleUrl); $this->assertSame('http://www.example.com/?foo=bar', $cleanUrl); }
/** * Initialize command * * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function initialize(InputInterface $input, OutputInterface $output) { $this->input = $input; $this->output = $output; $url = new Url(); try { $this->request = new Request($url->clean($input->getArgument('url')), $this->input->getOption('insecure')); } catch (\InvalidArgumentException $e) { // do nothing } $style = new OutputFormatterStyle('white', 'blue', ['bold']); $this->output->getFormatter()->setStyle('header', $style); }
/** * Execute command * * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $rows = []; $patch = new Patch(); $url = new Url(); $patch->setRequest($this->request); $patches = $patch->checkAll($url->clean($input->getArgument('url'))); foreach ($patches as $name => $result) { switch ($result) { case PATCH::PATCHED: $status = '<bg=green>Patched</bg=green>'; break; case PATCH::UNPATCHED: $status = '<error>Unpatched</error>'; break; default: $status = 'Unknown'; } $rows[] = [$name, $status]; } $this->out('Patches', [['type' => 'table', 'data' => [['Name', 'Status'], $rows]]]); }
* PHP version 5 * * @category MageScan * @package MageScan * @author Steve Robbins <*****@*****.**> * @copyright 2015 Steve Robbins * @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 * @link https://github.com/steverobbins/magescan */ require_once '../vendor/autoload.php'; use MageScan\Url; use MageScan\Request; $suggestUrl = ''; if (isset($_GET['url'])) { $url = $_GET['url']; $magescanUrl = new Url(); $url = $magescanUrl->clean(urldecode($_GET['url'])); $request = new Request(); $response = $request->fetch($url, array(CURLOPT_NOBODY => true)); if (isset($response->header['Location'])) { $suggestUrl = $response->header['Location']; } if (isset($response->header['location'])) { $suggestUrl = $response->header['location']; } $suggestUrl = trim($suggestUrl, '/'); } else { $url = false; } ?> <!DOCTYPE html>
/** * Validate and set url * * @param string $input * * @return void * @throws InvalidArgumentException */ protected function setUrl($input) { if (trim($input) == '') { throw new \InvalidArgumentException('Target URL not specified'); } $url = new Url(); $this->url = $url->clean($input); $request = $this->request; $response = $request->fetch($this->url, array(CURLOPT_NOBODY => true)); if ($response->code == 0) { throw new \InvalidArgumentException('Could not connect to URL: ' . $this->url); } if (isset($response->header['Location'])) { $this->url = $response->header['Location']; } }
/** * Start a check * * @param string $code * @param string $url */ public function __construct($code, $url) { $magescanUrl = new Url(); $this->url = $magescanUrl->clean(urldecode($url)); call_user_func(array($this, 'check' . ucwords($code))); }