? Php * If reproduced, please indicate the author of: He Zhiqiang improved: SonyMusic [sonymusic@163.net] File: ubb. php remarks: it is an improvement. In fact, the core function parse () has been completely rewritten, and the idea is different. However, He Zhiqiang is still inspired by the examples, and the test examples include URLCHECK and other functions that He Zhiqiang still uses. /*
If any reprint is found, please indicate the author
Original Author: He Zhiqiang
Improved: SonyMusic [sonymusic@163.net]
File: ubb. php
Note: it is an improvement. In fact, the core function parse () has been completely rewritten, and the idea is different.
However, it is still inspired by the examples of He Zhiqiang, and there are several functions such as URLCHECK in the test examples that He Zhiqiang still uses. thank you, He Zhiqiang.
There is no color function yet, but I will add it.
If there are any bugs or inconveniences in the program, please MAIL me.
Thank you!
Improved functions:
Encode the string by UBB. Currently, this class only supports the following simple and practical encoding:
1. URL scheme
Http://phpuser.com/
Http: // header not required
Such as phpuser.com.
2. Email Reply
Sonymusic@163.net
3. image seek
Same as the URL link, the previous http can also be avoided.
4. text
Bold Chinese Italics Underline 1 heading word... 6 heading word
Note the following:
1. tags such as url, email, and img are case-insensitive.
2. a TAB key is not allowed in a tag, but spaces are allowed.
3. this class calls the htmlencode, htmlencode4textarea, emailcheck function, and urlcheck class.
4. nesting is supported after modification, but the url, email, and img tags are not allowed to be nested.
Technical Materials:
Ultimate Bulletin Board
Http://www.ultimatebb.com/
What is UBB Code
Http://www.scriptkeeper.com/ubb/ubbcode.html
*/
Include ("urlcheck. php ");
Include ("otherfunc. php"); // The content of these two files, which is appended to the end.
If ($ tag = "url") or ($ tag = "email") or ($ tag = "img ")) and ($ this-> call_time> 1 )){
Echo $ this-> call_time ."
";
Return $ parse; // if the tag cannot be nested, return directly
}
$ Parse2 = substr ($ parse, 0, $ pos); // before marking
$ Parse = substr ($ parse, $ pos + $ tag_len + 2); // after marking
If (! Isset ($ this-> tags [$ tag]) {
Echo "$ tag_start
";
$ Ret. = $ parse2. '['. $ tag_start. ']';
Continue; // if the flag is not supported
}
// Find the end mark of the corresponding pair
$ Eregi_ret = eregi ("\ [\/". $ tag. "\]", $ parse, $ eregi_arr );
If (! $ Eregi_ret ){
$ Ret. = $ parse2. '['. $ tag_start. ']';
Continue; // if there is no end mark for it
}
$ Pos = strpos ($ parse, $ eregi_arr [0]);
$ Value = substr ($ parse, 0, $ pos); // This is the content between the start and end tags.
$ Tag_end = substr ($ parse, $ pos + 2, $ tag_len );
$ Parse = substr ($ parse, $ pos + $ tag_len + 3); // content after the end mark
If ($ tag! = "Url") and ($ tag! = "Email") and ($ tag! = "Img ")){
$ Value = $ this-> parse ($ value );
}
File urlcheck. php content
// Urlcheck. php
Class urlcheck {
Var $ regex = array (// protocol name (note that it must be written in lower case) => corresponding regular expression
'Ftp '=>' $ this-> ftpurl ',
'File' => '$ this-> fileurl ',
'Http' => '$ this-> httpurl ',
'Http' => '$ this-> httpurl ',
'Gopher' => '$ this-> gopherurl ',
'News' => '$ this-> newsurl ',
'Nntp '=>' $ this-> nntpurl ',
'Telnet '=>' $ this-> telneturl ',
'Wais '=>' $ this-> waisurl'
);
Var $ lowalpha;
Var $ hialpha;
Var $ alpha;
Var $ digit;
Var $ safe;
Var $ extra;
Var $ national;
Var $ punctuation;
Var $ reserved;
Var $ hex;
Var $ escape;
Var $ unreserved;
Var $ uchar;
Var $ xchar;
Var $ digits;
Var $ urlpath;
Var $ password;
Var $ user;
Var $ port;
Var $ hostnumber;
Var $ alphadigit;
Var $ toplabel;
Var $ domainlabel;
Var $ hostname;
Var $ host;
Var $ hostport;
Var $ login;
// Ftp
Var $ ftptype;
Var $ fsegment;
Var $ fpath;
Var $ ftpurl;
// File
Var $ fileurl;
// Http, https
Var $ search;
Var $ hsegment;
Var $ hpath;
Var $ httpurl;
// Gopher
Var $ gopher_string;
Var $ selector;
Var $ gtype;
Var $ gopherurl;
// News
Var $ article;
Var $ group;
Var $ grouppart;
Var $ newsurl;
// Nntp
Var $ nntpurl;
// Telnet
Var $ telneturl;
// Wais
Var $ wpath;
Var $ wtype;
Var $ database;
Var $ waisdoc;
Var $ waisindex;
Var $ waisdatabase;
Var $ waisurl;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.