Beispiel #1
0
 /**
  * (non-PHPdoc)
  * @see SiteQ/Service/SiteQ_Service_AbstractService::query()
  */
 public function query()
 {
     $sPageSpeed = 'https://developers.google.com/_apps/pagespeed/run_pagespeed?url=' . urlencode($this->_sUrl) . '&format=json';
     $rCurl = curl_init();
     curl_setopt($rCurl, CURLOPT_URL, $sPageSpeed);
     curl_setopt($rCurl, CURLOPT_HEADER, 0);
     curl_setopt($rCurl, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($rCurl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0');
     $sResponse = curl_exec($rCurl);
     if ((int) curl_getinfo($rCurl, CURLINFO_HTTP_CODE) == 200) {
         $this->_mRaw = $sResponse;
         SiteQ_TextUI_Output::info($this->_sName . ' took ' . curl_getinfo($rCurl, CURLINFO_TOTAL_TIME) . ' seconds');
     } else {
         SiteQ_TextUI_Output::info($this->_sName . ' request failed!');
     }
     curl_close($rCurl);
     return $this;
 }
Beispiel #2
0
 /**
  * Run the Collector on all Services
  *
  * @return SiteQ_Collector
  */
 public function run()
 {
     foreach ($this->_aServices as $oService) {
         $this->_aResults[] = $oService->url($this->_aArguments['url'])->query()->parse()->get();
     }
     if (isset($this->_aArguments['report']) === true and count($this->_aArguments['report']) > 0) {
         foreach ($this->_aArguments['report'] as $type => $filename) {
             SiteQ_Report::write($type, $filename, $this->_aResults, $this->_aArguments);
             SiteQ_TextUI_Output::info('Report (' . $type . ') written to: ' . $filename);
         }
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Handle passed arguments
  *
  * @param array $argv
  *
  * @return SiteQ_TextUI_Command
  */
 protected function handleArguments(array $argv)
 {
     print SiteQ_TextUI_Command::printVersionString();
     try {
         $this->options = Console_Getopt::getopt($argv, 'p:', array_keys($this->longOptions));
     } catch (RuntimeException $e) {
         SiteQ_TextUI_Output::info($e->getMessage());
     }
     if ($this->options instanceof PEAR_Error) {
         SiteQ_TextUI_Output::error($this->options->getMessage());
     }
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case '--verbose':
                 $this->arguments['verbose'] = TRUE;
                 break;
             case '--quiet':
                 unset($this->arguments['report']['console']);
                 break;
             case '--help':
                 $this->showHelp();
                 exit(SiteQ_TextUI_Command::SUCCESS_EXIT);
                 break;
             case '--report-html':
                 $this->arguments['report']['html'] = $option[1];
                 break;
             case '--report-xml':
                 $this->arguments['report']['xml'] = $option[1];
                 break;
             case '--report-json':
                 $this->arguments['report']['json'] = $option[1];
                 break;
             case '--version':
                 exit(SiteQ_TextUI_Command::SUCCESS_EXIT);
                 break;
         }
     }
     if (!isset($this->options[1][0])) {
         $this->showHelp();
         SiteQ_TextUI_Output::error('URL expected');
     } else {
         $this->arguments['url'] = $this->options[1][0];
     }
     return $this;
 }