✏️ 正在编辑: Linkify.fnc.php
路径:
/home/eblama1/sms.karnplayinland.com/ProgramFunctions/Linkify.fnc.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * Linkify function * * @package RosarioSIS * @subpackage ProgramFunctions */ /** * Linkify * Transforms the URLs present a in text to anchors tags * and truncate the link text of URLs > 100 chars * * @example $text_linkified = Linkify( $text ); * * @link http://stackoverflow.com/questions/15928606/php-converting-text-links-to-anchor-tags * * @param string $text Text to linkify. * * @return string Linkified text */ function Linkify( $text ) { $pattern = '((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,8}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))'; return preg_replace_callback( "#$pattern#i", function( $matches ) { $input = $matches[0]; $url = preg_match( '!^https?://!i', $input ) ? $input : "http://$input"; if ( mb_strlen( $input ) > 100 && ! mb_strpos( $input, ' ' ) ) { $separator = '...'; $maxlength = 97; // 100 - $separator length. $input = substr_replace( $input, $separator, ( $maxlength / 2 ), ( mb_strlen( $input ) - $maxlength ) ); } return '<a href="' . URLEscape( $url ) . '" target="_blank">' . $input . '</a>'; }, $text ); }
💾 保存文件
← 返回文件管理器