public function executeIndex(dmWebRequest $request) { $this->sitemap = $this->getService('xml_sitemap_generator')->setOption('domain', $this->getRequest()->getAbsoluteUrlRoot()); if ($this->getUser()->can('system')) { $this->shellUser = dmConfig::canSystemCall() ? exec('whoami') : 'www-data'; $this->phpCli = dmConfig::canSystemCall() ? sfToolkit::getPhpCli() : '/path/to/php'; $this->rootDir = sfConfig::get('sf_root_dir'); $this->domainName = $this->getRequest()->getHost(); } }
protected function doReload() { if (dmConfig::canSystemCall()) { $filesystem = $this->getService('filesystem'); if (!$filesystem->sf('dm:search-update')) { throw new dmException(implode("\n", array($filesystem->getLastExec('command'), $filesystem->getLastExec('output'), 'return code : ' . $filesystem->getLastExec('return')))); } } else { $browser = $this->getService('web_browser'); $url = $this->getHelper()->link('app:front/+/dmFront/reloadSearchIndex')->getHref(); touch(sfConfig::get('sf_cache_dir') . '/dm/search_index_' . time()); $browser->get($url); if (200 != $browser->getResponseCode()) { throw new dmException('The reload search index call returned the code ' . $browser->getResponseCode()); } $response = $browser->getResponseText(); if ('ok' != $response) { throw new dmException('An error occured: ' . $response); } } }
protected function useThread() { if ('auto' == $this->getOption('use_thread')) { $useThread = false; if (dmConfig::canSystemCall()) { $apacheMemoryLimit = dmString::convertBytes(ini_get('memory_limit')); if ($apacheMemoryLimit < 64 * 1024 * 1024) { $filesystem = $this->serviceContainer->getService('filesystem'); if ($filesystem->exec('php -r "die(ini_get(\'memory_limit\'));"')) { $cliMemoryLimit = dmString::convertBytes($filesystem->getLastExec('output')); $useThread = $cliMemoryLimit >= $apacheMemoryLimit; } } } $this->setOption('use_thread', $useThread); } return $this->getOption('use_thread'); }