Esempio n. 1
0
 /**
  * Parse the robots.txt text file to find the sitemap
  *
  * @return string
  */
 protected function getSitemapUrl()
 {
     $request = new Request();
     $response = $request->fetch($this->url . 'robots.txt');
     $sitemap = new Sitemap();
     $sitemap->setRequest($this->request);
     $sitemap = $sitemap->getSitemapFromRobotsTxt($response);
     if ($sitemap === false) {
         $this->output->writeln('<error>Sitemap is not declared in robots.txt</error>');
         return $this->url . 'sitemap.xml';
     }
     $this->output->writeln('<info>Sitemap is declared in robots.txt</info>');
     return (string) $sitemap;
 }
Esempio n. 2
0
 * @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>
<html>
<head>
    <meta charset="UTF-8">
Esempio n. 3
0
 /**
  * Check for a valid sitemap
  *
  * @return void
  */
 public function checkSitemap()
 {
     $rows = array();
     $request = new Request();
     $response = $request->fetch($this->url . 'robots.txt');
     $sitemap = new Sitemap();
     $sitemapUrl = $sitemap->getSitemapFromRobotsTxt($response);
     if ($sitemapUrl === false) {
         $rows[] = array('<span class="fail">Sitemap is not declared in <a href="' . $this->url . 'robots.txt" target="_blank">robots.txt</a></span>');
         $sitemapUrl = $this->url . 'sitemap.xml';
     } else {
         $rows[] = array('<span class="pass">Sitemap is declared in <a href="' . $this->url . 'robots.txt" target="_blank">robots.txt</a></span></span>');
     }
     $request = new Request();
     $response = $request->fetch((string) $sitemapUrl, array(CURLOPT_NOBODY => true, CURLOPT_FOLLOWLOCATION => true));
     if ($response->code == 200) {
         $rows[] = array('<span class="pass"><a href="' . $sitemapUrl . '" target="_blank">Sitemap</a> is accessible</span>');
     } else {
         $rows[] = array('<span class="fail"><a href="' . $sitemapUrl . '" target="_blank">Sitemap</a> is not accessible</span>');
     }
     $this->respond(array('body' => $rows));
 }
Esempio n. 4
0
 /**
  * Download the latest version of magescan
  *
  * @param string $filename
  *
  * @return void
  */
 protected function downloadLatestVersion($filename)
 {
     $request = new Request();
     $response = $request->fetch(self::URL_DOWNLOAD);
     return file_put_contents($filename, $response->body) !== false;
 }