3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6

preferences:
215.81 ms | 406 KiB | 314 Q