UBB <?php
/*
If reproduced, please specify the author
Author: He Zhiqiang
File: ubb.php
Remark: Say is an improvement, in fact, the core function parse () has been completely rewritten, and the idea is not the same.
However, is still inspired by the He Zhiqiang example, and the test examples are urlcheck, and so on several functions are also used He Zhiqiang procedures, thank He Zhiqiang.
There are no color features yet, but I will join.
If there are any bugs or inconveniences in the program, please send me mail.
Thank you!
Improved functionality:
UBB encoding of strings, which currently supports only a few simple and useful encodings:
1. URL Walks connection
http://www.phpexe.com/
http://head can not need
Such as phpexe.com is also possible.
2. Email Walks connect
Demo@163.net
3. Picture Walks Connect
As with the URL link, the preceding HTTP can also not.
4. In terms of writing
Bold Word
Italic character
Underline
Inscription No. 1th Mark
...
Inscription No. 6th Mark
Note the following points:
1. Url,email,img and other labels are not case-insensitive.
2. The TAB key is not allowed in the label, but spaces allow.
3. The class will call the Htmlencode,htmlencode4textarea,emailcheck function and the Urlcheck class.
4. After the modification support nesting, but url,email,img these three tags are not allowed to nest.
Technical data:
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 contents of these two documents are attached at the end.
if (($tag = = "url") or ($tag = = "email") or ($tag = = "img")) and ($this->call_time>1)) {
echo $this->call_time. " <br> ";
return $parse;//If cannot be a tag that cannot be nested, go straight back
}
$parse 2 = substr ($parse, 0, $pos);//before Mark
$parse = substr ($parse, $pos + $tag _len+2);//after tag
if (!isset ($this->tags[$tag])) {
echo "$tag _start<br>";
$ret. = $parse 2. ' ['. $tag _start.] ';
continue;//if it's not a supported tag
}
Find the end tag for the corresponding
$eregi _ret=eregi ("\[\/". $tag. " \] ", $parse, $eregi _arr);
if (! $eregi _ret) {
$ret. = $parse 2. ' ['. $tag _start.] ';
continue;//If there is no end tag for the should
}
$pos =strpos ($parse, $eregi _arr[0]);
$value =substr ($parse, 0, $pos);//This is the content between the beginning and ending marks
$tag _end=substr ($parse, $pos +2, $tag _len);
$parse =substr ($parse, $pos + $tag _len+3);//after end tag content
if ($tag!= "url") and ($tag!= "email") and ($tag!= "img")) {
$value = $this->parse ($value);
}
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.