Copy codeThe Code is as follows:
<? Php
/*************************************** ******************************
* List of Public Functions
* Ubb, getip, GoIn, goback, IsInt, InString
* OurHome: http://iwind.org
* Http: // 10.13.31.90 /~ Coldwind
*
**/
/// // Ubb supports code functions /////////////////// /////////
Function ubb ($ Text ){
$ Text = trim ($ Text );
$ Text = htmlspecialchars ($ Text );
$ Text = ereg_replace ("\ n", "<br>", $ Text );
$ Text = preg_replace ("// \ t/is", "", $ Text );
$ Text = preg_replace ("/\ [h1 \] (. + ?) \ [\/H1 \]/is "," $ Text = preg_replace ("/\ [h2 \] (. + ?) \ [\/H2 \]/is "," $ Text = preg_replace ("/\ [h3 \] (. + ?) \ [\/H3 \]/is ","
$ Text = preg_replace ("/\ [h4 \] (. + ?) \ [\/H4 \]/is "," $ Text = preg_replace ("/\ [h5 \] (. + ?) \ [\/H5 \]/is "," $ Text = preg_replace ("/\ [h6 \] (. + ?) \ [\/H6 \]/is "," $ Text = preg_replace ("/\ [center \] (. + ?) \ [\/Center \]/is "," <center> \ 1 </center> ", $ Text );
$ Text = preg_replace ("/\ [url \] (http: \/. + ?) \ [\/Url \]/is "," <a href =\\ 1> \ 1 </a> ", $ Text );
$ Text = preg_replace ("/\ [url \] (. + ?) \ [\/Url \]/is "," <a href = \ "http: // \ 1 \"> http: // \ 1 </a> ", $ Text );
$ Text = preg_replace ("/\ [url = (http: \/. + ?) \] (. *) \ [\/Url \]/is "," <a href = \ 1> \ 2 </a> ", $ Text );
$ Text = preg_replace ("/\ [url = (. + ?) \] (. *) \ [\/Url \]/is "," <a href = http: // \ 1> \ 2 </a> ", $ Text );
$ Text = preg_replace ("/\ [img \] (. + ?) \ [\/Img \]/is "," ", $ Text );
$ Text = preg_replace ("/\ [color = (. + ?) \] (. + ?) \ [\/Color \]/is "," <font color = \ 1> \ 2 </font> ", $ Text );
$ Text = preg_replace ("/\ [size = (. + ?) \] (. + ?) \ [\/Size \]/is "," <font size = \ 1> \ 2 </font> ", $ Text );
$ Text = preg_replace ("/\ [sup \] (. + ?) \ [\/Sup \]/is "," <sup> \ 1 </sup> ", $ Text );
$ Text = preg_replace ("/\ [sub \] (. + ?) \ [\/Sub \]/is "," <sub> \ 1 </sub> ", $ Text );
$ Text = preg_replace ("/\ [pre \] (. + ?) \ [\/Pre \]/is "," <pre >\\ 1 </pre> ", $ Text );
$ Text = preg_replace ("/\ [email \] (. + ?) \ [\/Email \]/is "," <a href = \ 1> \ 1 </a> ", $ Text );
$ Text = preg_replace ("/\ [I \] (. + ?) \ [\/I \]/is "," <I >\\ 1 </I> ", $ Text );
$ Text = preg_replace ("/\ [B \] (. + ?) \ [\/B \]/is "," <B> \ 1 </B> ", $ Text );
$ Text = preg_replace ("/\ [quote \] (. + ?) \ [\/Quote \]/is "," <blockquote> <font size = '1' face = 'courier new'> quote: </font> $ Text = preg_replace ("/\ [code \] (. + ?) \ [\/Code \]/is "," <blockquote> <font size = '1' face = 'times New Roman '> code: </font> $ Text = preg_replace ("/\ [sig \] (. + ?) \ [\/Sig \]/is "," <div style = 'text-align: left; color: darkgreen; margin-left: 5% '> <br> ------------------------ <br> \ 1 <br> -------------------------- </div> ", $ Text );
Return $ Text;
}
//// // Obtain the IP address of the viewer //////////////////// /////////
Function getip (){
$ IP = getenv ('remote _ ADDR ');
$ IP _ = getenv ('HTTP _ X_FORWARDED_FOR ');
If ($ IP _! = "") & ($ IP _! = "Unknown") $ IP = $ IP _;
Return $ IP;
}
Function goback ($ num, $ saying ){
Echo "<table align = \" center \ "> <tr> <td> <a href = \" javascript: history. go (-1) \ "> $ saying </a> ";
}
//// // Determine whether a string contains a value in array /////////// //////
Function InString ($ array, $ string ){
While (list (, $ value) = each ($ array )){
If (eregi ($ value, $ string )){
Return true;
Exit;
}
}
}
/// // Link to a page //////////////// ///////////////////////
Function GoIn ($ addr, $ saying ){
Echo "<table align = \" center \ "> <tr> <td> <a href = \" $ addr \ "> $ saying </a> </td> </tr> </table> ";
}
/// // JS return ////////////////// ////////////////////////////
Function IsInt ($ string ){
If (ereg ("^ [0-9] {0, }$", $ string )){
Return true;
}
Else {
Return false;
}
}
?>