Exemplo n.º 1
0
 /**
  * Initialize the Crawler
  *
  * @param Application $app
  */
 protected function initialize(Application $app)
 {
     $this->app = $app;
     // set the script start
     self::$script_start = microtime(true);
     // get the configuration
     $Config = new Configuration($app);
     self::$config = $Config->getConfiguration();
     // try to set the maximum execution time
     if (!ini_set('max_execution_time', self::$config['general']['max_execution_time'])) {
         $app['monolog']->addError("Can't set max_execution_time!", array(__METHOD__, __LINE__));
         $app['monolog.crawler']->addError("Can't set max_execution_time!", array(__METHOD__, __LINE__));
     }
     // get the really available max. execution time
     $max_execution_time = ini_get('max_execution_time');
     if ($max_execution_time < self::$config['general']['max_execution_time']) {
         $app['monolog']->addError(sprintf("Can't increase the max_execution_time from %s to %s seconds!", $max_execution_time, self::$config['general']['max_execution_time']), array(__METHOD__, __LINE__));
         $app['monolog.crawler']->addError(sprintf("Can't increase the max_execution_time from %s to %s seconds!", $max_execution_time, self::$config['general']['max_execution_time']), array(__METHOD__, __LINE__));
     }
     // set the limited execution time
     $limit_execution_time = $max_execution_time - self::$config['general']['buffer_execution_time'];
     if ($limit_execution_time < 0) {
         // 20 seconds should be always possible ...
         $limit_execution_time = 20;
     }
     self::$script_stop = self::$script_start + $limit_execution_time;
     // set index URL - always remove trailing slash
     self::$index_url = rtrim(self::$config['sitemap']['url']['index'][0], '/');
     self::$status = 'UNDEFINED';
     $this->CrawlerData = new CrawlerURL($app);
     // __destructor() doesn't get called on Fatal errors
     register_shutdown_function(array($this, 'shutdown'));
 }
Exemplo n.º 2
0
 /**
  * Initialize the class with the needed parameters
  *
  * @param Application $app
  */
 protected function initialize(Application $app)
 {
     parent::initialize($app);
     $cms = $this->app['request']->get('usage');
     self::$usage = is_null($cms) ? 'framework' : $cms;
     self::$usage_param = self::$usage != 'framework' ? '?usage=' . self::$usage : '';
     self::$language = $this->app['session']->get('CMS_LOCALE', 'en');
     // set the locale from the CMS locale
     if (self::$usage != 'framework') {
         $app['translator']->setLocale(self::$language);
     }
     $Configuration = new Configuration($app);
     self::$config = $Configuration->getConfiguration();
     // try to set the maximum execution time
     if (!ini_set('max_execution_time', self::$config['general']['max_execution_time'])) {
         $app['monolog']->addError("Can't set max_execution_time!", array(__METHOD__, __LINE__));
     }
 }