演示:http://www.ayoyo.com.cn
功能说明:这个HACK可以把.JPG .GIF .PNG结尾的URL自动转换成[img][/img],这样就不用自己输入[img][/img],省了不少时间.
修改方法:打开/include/discuzcode.php
找到:
- function parseurl($message) {
- return preg_match("/\[code\].+?\[\/code\]/is", $message) ? $message :
- preg_replace( array(
- "/(?<=[^\]a-z0-9-="'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)/i",
- "/(?<=[^\]a-z0-9\/\-_.~?=:.])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/i"
- ), array(
- "[url]\\1\\3[/url]",
- "[email]\\0[/email]"
- ), ' '.$message);
- }
复制代码
替换成:
- //[HACK]自动解析图片URL By Ayoyo
- function parseurl($message) {
- return preg_match("/\[code\].+?\[\/code\]/is", $message) ? $message :
- preg_replace( array(
- "/(?<=[^\]a-z0-9-="'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)(.jpg|.png|.gif)/i",
- "/(?<=[^\]a-z0-9-="'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)/i",
- "/(?<=[^\]a-z0-9\/\-_.~?=:.])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/i"
- ), array(
- "[img]\\0[/img]",
- "[url]\\1\\3[/url]",
- "[email]\\0[/email]"
- ), ' '.$message);
- }
- //[HACK]自动解析图片URL By Ayoyo
复制代码
[ 本帖最后由 尐強 于 2006-4-30 07:19 编辑 ] |