externallinks.php
来自「This mambot adds to the external links i」· PHP 代码 · 共 39 行
PHP
39 行
<?php/****************************************
* ExternalLinks mambot for Mambo/Joomla *
* Copyright (C) 2007 by Denis Ryabov *
* Homepage : http://joomup.com/ *
* Version : 1.0 *
* License : Released under GPL *
*****************************************/
defined( '_VALID_MOS' ) or die( 'Access denied.' );$_MAMBOTS->registerFunction( 'onPrepareContent', 'botExternalLinks' );function botExternalLinks( $published, &$row, &$params, $page=0 ){ global $database; if(!$published) return true; $row->text=preg_replace_callback('/<a (.*?)href=["\'](.*?)["\'](.*?)>/i', 'botExternalLinks_replacer', $row->text); return true;}function botExternalLinks_replacer($matches){ $link_pattern='/^(http:\/\/|)(www.|)([^\/]+)/i'; preg_match($link_pattern,$matches[2],$domain); preg_match($link_pattern,$_SERVER['HTTP_HOST'],$http); $target=''; if((isset($domain[3])) and (isset($http[3])) and ($domain[3]!==$http[3]) and (strpos($matches[1],'_blank')===false) and (strpos($matches[3],'_blank')===false)) $target=' target="_blank"'; return '<a href="'.$matches[2].'"'.$matches[1].$matches[3].$target.'>';}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?