3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /*************************************************************** * Copyright notice * * (c) 2007 Dmitry Dulepov <dmitry@typo3.org> * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * [CLASS/FUNCTION INDEX of SCRIPT] */ /** * Content post-processing functions. * * @author Dmitry Dulepov <dmitry@typo3.org> * @package TYPO3 * @subpackage tx_robots */ class tx_robots_postproc { /** * Checks for indexing flags * * @param array $params Unused * @param object $pObj Reference to TSFE */ function contentPostProcOutput(&$params, &$pObj) { // Only if flags are non-zero and <meta name="robots"> is not set already if ($GLOBALS['TSFE']->page['tx_robots_flags'] && false !== ($pos = stripos($pObj->content, '</head>')) && !preg_match('/<meta[^>]*\sname=([\'"])?robots\1/i', $pObj->content)) { $values = array(1 => 'index', 2 => 'follow'); if ($GLOBALS['TSFE']->page['tx_robots_flags'] & 1) { $values[1] = 'noindex'; } if ($GLOBALS['TSFE']->page['tx_robots_flags'] & 2) { $values[2] = 'nofollow'; } $pObj->content = substr($pObj->content, 0, $pos) . '<meta name="robots" content="' . implode(',', $values) . '" />' . chr(10) . substr($pObj->content, $pos); } } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/robots/class.tx_robots_postproc.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/robots/class.tx_robots_postproc.php']); } ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0