* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent' ,'WBContent_SEO'); /** * Content component: SEO * * @version 1.2.0 * @package WB * @subpackage content */ class WBContent_SEO_Robots extends WBContent_SEO { /** * My Parameter List * @var array */ protected $config = array( 'disallow' => '', 'checkorigin' => 1, 'originhost' => '' ); /** * run * * run component * * @see sendAndExit() * @return array parameter list */ public function run() { $cnt = array('User-agent: *'); if (0 < $this->config['checkorigin']) { if (empty($this->config['originhost'])) { /** @var WBConfig */ $conf = WBClass::create('WBConfig'); $conf->load('config'); $this->config['originhost'] = $conf->get('page/server'); } $host = $this->req->getMeta('HTTP_HOST'); if ($host != $this->config['originhost']) { $cnt[] = 'Disallow: /'; $this->res->add(implode("\n", $cnt)); $this->sendAndExit('text/plain'); } } if (!is_array($this->config['disallow'])) { $this->config['disallow'] = trim($this->config['disallow']); if (empty($this->config['disallow'])) { $this->config['disallow'] = array(); } else { $this->config['disallow'] = array($this->config['disallow']); } } foreach ($this->config['disallow'] as $line) { $line = trim($line); if (empty($line)) { continue; } $cnt[] = sprintf('Disallow: %s', $line); } $this->res->add(implode("\n", $cnt)); $this->sendAndExit('text/plain'); } }