CSDN博客

img bjbs_270

我所用的PHP函数

发表于2004/9/26 13:24:00  1170人阅读

分类: PHP技术文章

$string = "连接http://www.phpx.com 站点";
//连接后需要有个空格或回车。

$string =  eregi_replace("http://([^ ,/r/n]*)","<a href=//0 target=_blank>//0</a>",$string);
$string =  eregi_replace("ftp://([^ ,/r/n]*)","<a href=//0 target=_blank>//0</a>",$string);

print $string;

<?php
//------------------------  全局用的函数 ------------------------------------------
function query($vars,$table,$condition)
{
 $sql="select $vars from $table $condition";
 $result=mysql_query($sql) or die(mysql_error());
 return $result;
}
//-------------------------- END ------------------------------------------------
/*********************************  字段处理  ************************************/
function TextFilter($str)
 {
        $str = chop($str); 
  $str = quotemeta($str);
     $str = nl2br( htmlspecialchars( $str) );
  $str = addslashes($str);
     return $str;
     }
//------------------------取出数据时的处理情况----------------------------------------
function opentext($str)
{
 $str=StripSlashes($str);
 $str=StripSlashes($str);
 $str=nl2br($str);
    return $str;
}
/***********************************  截取指定长度字段的函数   *******************************************/
function ChgTitle($title,$length)
 {
   //$length = 46;
   if (strlen($title)>$length)
    {
         $temp = 0;
         for($i=0; $i<$length; $i++)
           if (ord($title[$i]) > 128)// ord($str)是用来判断字符是为汉字或为字母大于128刚为汉字
              $temp++;
         if ($temp%2 == 0)
            $title = substr($title,0,$length)."..."; //从开始到被截取处的之间的字元总长为偶数
         else
            $title = substr($title,0,$length+1)."..."; //从开始到被截取处的之间的字元总长为奇数
    }
    return $title;
 }
/****************************    showShort()处理字段的函数  **********************************/
Function csubstr($str,$start,$len)
{
    $strlen=strlen($str);
    $clen=0;
    for($i=0;$i<$strlen;$i++,$clen++)
    {
       if ($clen>=$start+$len)
       break;
       if(ord(substr($str,$i,1))>0xa0)
         {
           if ($clen>=$start)
           $tmpstr.=substr($str,$i,2);
           $i++;
         }
       else
        {
         if ($clen>=$start)
         $tmpstr.=substr($str,$i,1);
        }
    }
  return $tmpstr;
}
Function showShort($str,$len)
   {
     $tempstr = csubstr($str,0,$len);
  //---------- 在此调用上面的函数 --------------
     if ($str<>$tempstr)
        $tempstr .= "..."; //要以什么结尾,修改这里就可以.
     return $tempstr;
   }
//-----------------------     分页函数     ------------------------------------
function listpage($list_page,$page,$query,$table,$condition)
{
 //---------------------   $pages        总页数 ------------------------
 //---------------------   $start        起始页 ------------------------
 //---------------------   $page         当前页 ------------------------
 //---------------------   $pre          前一页 ------------------------
 //---------------------   $next         下一页 ------------------------
 //---------------------   $list_page    每页要显示的条数  --------------
 //---------------------   $table        所要查询的表 ------------------
 //---------------------   $condition    查询的条件 --------------------
 $result=mysql_query($query) or die(mysql_error());
 
$num=@mysql_num_rows($result);
 if($num<$page_list)
 { $pages="1";}
 else
 {
$pages=@ceil($num/$list_page);}
 if(!isset($stard))
 { $stard="0"; }
 if(!isset($page)){ $page=1;}
 $start=($page-1)*$list_page;
 $pre=$page-1;
 $next=$page+1;
 $sql="select * from $table  $condition limit $start,$list_page";
 $result1=mysql_query($sql);
 
$numm=@mysql_num_rows($result1);
 $array=array();
    $array[0] = $page."|".$pages."|".$pre."|".$next;
 $i =1 ;
 while(
$arr=@mysql_fetch_array($result1))
 {
  $array[$i]=$arr;
  $i++;
 }
 return $array;
}
//------------------------  分页显示为 |<< < ..[1].2.3.4.5.6 ..> >>|  -----------------
function number_show($array,$condition)
{
 //------------------  $page   第几页 -------------------------------
 //------------------  $page   总页数 -------------------------------
 //------------------  $page   跳转的条件 ---------------------------
 //---  说明:此程序还要提高一节来实现显示如:|<<...<< n-2,n-1,n,n+1,n+2>>...>>| (其中的n为自动添加的)
 $arr=explode("|",$array);
    $page=$arr[0];
 $pages=$arr[1];
 $pre=$arr[2];
 $next=$arr[3];
 echo "总页数($pages): ";
 if($page>0&&$page<=$pages)
 {
  if($page>3)
  {
      echo "<a href=$PHP_SELF?page=1&$condition title=首页><<&nbsp;第一页&nbsp;</a>...";
  }
  if($page>1)
  {
   echo "<a href=$PHP_SELF?page=$pre&$condition title=上一页>&nbsp;<<</a>";
  }
  $page1=$page-2;
  $page2=$page-1;
  $page3=$page+1;
  $page4=$page+2;
  if($page1>0)
  {
  echo "&nbsp;<a href=$PHP_SELF?page=$page1&$condition>$page1</a>";
  }
  if($page2>0)
  {
  echo "&nbsp;<a href=$PHP_SELF?page=$page2&$condition>$page2</a>";
  }
  echo "&nbsp;[$page]";
  if($pages>=$page3)
  //if($page3!=$pages)
  {
  echo "&nbsp;<a href=$PHP_SELF?page=$page3&$condition>$page3</a>"; 
  }
  //if((($pages+1)>$page4)&&($pages!=$page))
  if($pages>=$page4)
  {
  echo "&nbsp;<a href=$PHP_SELF?page=$page4&$condition>$page4</a>";
  }
  if(($pages-$page-2)>0)
  {
   echo "&nbsp;<a href=$PHP_SELF?page=$next&$condition title=下一页>>></a>";
  }
  if(($pages-$page-3)>0)
  {
   echo "&nbsp;...<a href=$PHP_SELF?page=$pages&$condition title=尾页>最后一页>></a>";
  }
 }
}
function online()
{
 //-------------  $update_time 用户在线的更新的时间-------------------------
 session_start();
 $SID=session_id();
 $ip = getenv('REMOTE_ADDR');
 if($SESSION["name"]!="")
 {  
      $result=mysql_query("select count(userid) from $table4 where userid='$SESSION[name]'");
  
$num=@mysql_result($result,"0");
   if($num!=0)
  {
           $result=mysql_query("update $table4 set time='$time' where userid='$SESSION[name]'",$dbh);
           bbs_log($table4,$PHP_SELF,"update");
     if(!$result){ echo mysql_error();}
       }
   else
     {
  
$result=@mysql_query("insert into $table4 (SID,userid,ip,time) values ('$SID','$SESSION[name]','$ip','$time')",$dbh);
   bbs_log($table4,$PHP_SELF,"insert");
   if(!$result){ echo mysql_error();}
     }
 }
 else
 {
   $userid="guest";
   //$SESSION["name"]="guest";
      $result=mysql_query("select count(ip) from $table4 where ip='$ip'");
  
$num=@mysql_result($result,"0");
   if($num!=0)
  {
    $result=mysql_query("update $table4 set time='$time' where ip='$ip'");
    bbs_log($table4,$PHP_SELF,"update");
  }
   else
  {
   
$result=@mysql_query("insert into $table4 (SID,userid,ip,time) values ('$SID','guest','$ip','$time')",$dbh);
    bbs_log($table4,$PHP_SELF,"insert");
    if(!$result){ echo "guest";/*echo mysql_error();*/}
     }
 }
 $del_time=$time-$update_times;
 
$upde=@mysql_query("delete from $table4 where time<'$del_time'",$dbh);
 bbs_log($table4,$PHP_SELF,"delete");
}

//---------------------------------    UBB代码处理     -------------------------------------------
/*
粗体
 [b]文本[/b]   文本
斜体
 [i]文本[/i]   文本
下划线
 [u]文本[/u]   文本
字体大小
 [size=3]文本[/size]   文本
字体颜色
 [color=red]文本[/color]  文本
[color=#887766]文本[/color]  文本
嵌套运用
 [b][i][size=3][color=#889900]这是字体例子[/color][/size][/i][/b]
输入网址
 [url=网址]网站名称[/url] 如:[url=http://zjshl.8800.org]山顶洞人[/url]
输入邮箱
[email]simple[/email]  如:<a href=mailto:simple>simple</a>
还可以使用表情
[quote]simple[/quote]
[code]simple[/code]
[sig]simple[/sig]
自动判断网址
 网址后面必须是空格、回车、中文或者无任何字符
PHP语法加亮
 [php]
echo "hello world";
[/php]
echo "hello word";
*/
//---------------------------------   END UBB   ----------------------------------------
// ####################### 清除HTML代码 #######################
function html_clean($content){
 $content = htmlspecialchars($content);
 $content = str_replace("/n", "<br>", $content);
 $content = str_replace("  ", "&nbsp;&nbsp;", $content);
 $content = str_replace("/t", '&nbsp;&nbsp;&nbsp;&nbsp;', $content);
 return $content;
}
function ubb($Text) {
  $Text=htmlspecialchars($Text);
  $Text=ereg_replace("/r/n","<br>",$Text);
  $Text=ereg_replace("/r","<br>",$Text);
  $Text=nl2br($Text);
  $Text=preg_replace("///t/is","  ",$Text);
  $Text=preg_replace("//[h1/](.+?)/[//h1/]/is","<h1>//1</h1>",$Text);
  $Text=preg_replace("//[h2/](.+?)/[//h2/]/is","<h2>//1</h2>",$Text);
  $Text=preg_replace("//[h3/](.+?)/[//h3/]/is","<h3>//1</h3>",$Text);
  $Text=preg_replace("//[h4/](.+?)/[//h4/]/is","<h4>//1</h4>",$Text);
  $Text=preg_replace("//[h5/](.+?)/[//h5/]/is","<h5>//1</h5>",$Text);
  $Text=preg_replace("//[h6/](.+?)/[//h6/]/is","<h6>//1</h6>",$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","<img src=//1><br>/n",$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=mailto://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("//[u/](.+?)/[//u/]/is","<u>//1</u>",$Text);
  //------------ 表情按钮的替换-------------------------------
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///1.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///2.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///3.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///4.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///5.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///6.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///7.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///8.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///9.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///10.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///11.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///12.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///13.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///14.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///15.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///16.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///17.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///18.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///19.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///20.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///21.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///22.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///23.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///24.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///25.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///26.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///27.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///28.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///29.gif border=0 hspace=0 vspace=0>",$Text);
  $Text=preg_replace("//[:([0-9]{1,2})/]/U","<img src=images/icons///30.gif border=0 hspace=0 vspace=0>",$Text);  //------------- PHP 代码处理 ----------------
  $Text=preg_replace("//[php/](.+?)/[//php/]/is","&&lt;?
//1 ?&gt;",$Text);
  //------------------- 引用处理程序
  $Text=preg_replace("//[quote/](.+?)/[//quote/]/is","<TABLE bgColor=#eeffff border=1 borderColorDark=white  borderColorLight=#777777 cellSpacing=0 height=80 width=600><TBODY><TR><TD vAlign=top><FONT color=#999999><P>//1</P></FONT></TD></TR></TBODY></TABLE>", $Text);
  //------------------- flash 处理程序  -----------
  $Text=preg_replace("//[flash/](.+?)/[//flash/]/is","<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width=500 height=400><param name=movie value=//1><param name=quality value=high><embed src=//1 quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width=500 height=400></embed></object>", $Text);
  //------------------ real 播放器处理程序 ---------
  $Text=preg_replace("//[real/](.+?)/[//real/]/is","<object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA            height=285 id=RAOCX name=rmplay width=356><param name=SRC value=//1><param name=CONSOLE value=Clip1>  <param name=CONTROLS value=imagewindow><param name=AUTOSTART value=true><embed  src=//1  autostart=true             controls=ImageWindow console=Clip1 pluginspage=http://www.real.com width=356 height=285></embed></object><object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA height=27 id=video1 width=356><param name=_ExtentX value=7276>    <param name=_ExtentY value=1058><param name=AUTOSTART value=0><param name=SHUFFLE value=0><param name=PREFETCH value=0><param name=NOLABELS value=0><param name=CONTROLS value=ControlPanel><param name=CONSOLE value=Clip1><param name=LOOP value=0><param name=NUMLOOP value=0><param name=CENTER value=0><param name=MAINTAINASPECT value=0><param name=BACKGROUNDCOLOR value=#ffffff><embed type=audio/x-pn-realaudio-plugin console=Clip1controls=ControlPanel height=27 width=356 autostart=0 _extentx=7276 _extenty=1058 shuffle=0 prefetch=0 nolabels=0 loop=0 numloop=0 center=0 maintainaspect=0 backgroundcolor=#ffffff></embed></object>", $Text);
  //------------------ Media 播放器处理程序 --------
  $Text=preg_replace("//[media/](.+?)/[//media/]/is","<object align=middle class=OBJECT classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 height=320 id=MediaPlayer width=356><param name=ShowStatusBar value=-1><param name=Filename value=//1 <embed type=application/x-oleobject  codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=//1 width=356 height=320></embed></object>", $Text);
  $Text=preg_replace("//[code/](.+?)/[//code/]/is","<blockquote><font size='1' face='Times New Roman'>code:</font><hr color='lightblue'><i>//1</i><hr color='lightblue'></blockquote>", $Text);  
   $Text=preg_replace("//[sig/](.+?)/[//sig/]/is","<div style='text-align: left; color: darkgreen; margin-left: 5%'><br><br>--------------------------<br>//1<br>--------------------------</div>", $Text);
return $Text;
}
//----------------------- 用于修改资料的时候对UBB代码进行反解 -------------------
function unubb($Text)
{
  $Text=str_replace("&nbsp;"," ",$Text);
  $Text=str_replace("<br>","/n",$Text);
  $Text=str_replace("<br>/n","/n",$Text);
  //----------------- 引用部分字段处理的反编  -------------------------
  $Text = eregi_replace(quotemeta("<TABLE bgColor=#eeffff border=1 borderColorDark=white  borderColorLight=#777777 cellSpacing=0 height=80 width=600><TBODY><TR><TD vAlign=top><FONT color=#999999><P>"),"[quote]",$Text);
  $Text = eregi_replace(quotemeta("</P></FONT></TD></TR></TBODY></TABLE>"),"[/quote]",$Text);
 // $Text=preg_replace("//<TABLE bgColor=#eeffff border=1 borderColorDark=white  borderColorLight=#777777 cellSpacing=0 height=80 width=600/>/<TBODY/>/</TR/>/<TD vAlign=top/>/<FONT color=#999999/>/<P/>(.+?)/<//P/>/<//FONT/>/<//TD>/<//TR/>/<//TBODY/>/<//TABLE/>/is","[quote]//1[/quote]", $Text);
  //----------------- 对常见的字体,颜色等属性进行反编 -----------------
  $Text=preg_replace("//<h1/>(.+?)/<//h1/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h2/>(.+?)/<//h2/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h3/>(.+?)/<//h3/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h4/>(.+?)/<//h4/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h5/>(.+?)/<//h5/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h6/>(.+?)/<//h6/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<h7/>(.+?)/<//h7/>/is","[h1]//1[/h1]",$Text);
  $Text=preg_replace("//<font color=(.+?)/>(.+?)/<//font/>/is","[color=//1]//2[/color]",$Text);
  $Text=preg_replace("//<font size=(.+?)/>(.+?)/<//font/>/is","[size=//1]//2[/size]",$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("//<i/>(.+?)/<//i/>/is","[i]//1[/i]",$Text);
  $Text=preg_replace("//<b/>(.+?)/<//b/>/is","[b]//1[/b]",$Text);
  $Text=preg_replace("//<u/>(.+?)/<//u/>/is","[u]//1[/u]",$Text);
  //-------------------  反编表情代码 ----------------------------
  $Text=preg_replace("//<img src=images//icons//1.gif border=0 hspace=0 vspace=0/>/is","[:1]",$Text);
  $Text=preg_replace("//<img src=images//icons//2.gif border=0 hspace=0 vspace=0/>/is","[:2]",$Text);
  $Text=preg_replace("//<img src=images//icons//3.gif border=0 hspace=0 vspace=0/>/is","[:3]",$Text);
  $Text=preg_replace("//<img src=images//icons//4.gif border=0 hspace=0 vspace=0/>/is","[:4]",$Text);
  $Text=preg_replace("//<img src=images//icons//5.gif border=0 hspace=0 vspace=0/>/is","[:5]",$Text);
  $Text=preg_replace("//<img src=images//icons//6.gif border=0 hspace=0 vspace=0/>/is","[:6]",$Text);
  $Text=preg_replace("//<img src=images//icons//7.gif border=0 hspace=0 vspace=0/>/is","[:7]",$Text);
  $Text=preg_replace("//<img src=images//icons//8.gif border=0 hspace=0 vspace=0/>/is","[:8]",$Text);
  $Text=preg_replace("//<img src=images//icons//9.gif border=0 hspace=0 vspace=0/>/is","[:9]",$Text);
  $Text=preg_replace("//<img src=images//icons//10.gif border=0 hspace=0 vspace=0/>/is","[:10]",$Text);
  $Text=preg_replace("//<img src=images//icons//11.gif border=0 hspace=0 vspace=0/>/is","[:11]",$Text);
  $Text=preg_replace("//<img src=images//icons//12.gif border=0 hspace=0 vspace=0/>/is","[:12]",$Text);
  $Text=preg_replace("//<img src=images//icons//13.gif border=0 hspace=0 vspace=0/>/is","[:13]",$Text);
  $Text=preg_replace("//<img src=images//icons//14.gif border=0 hspace=0 vspace=0/>/is","[:14]",$Text);
  $Text=preg_replace("//<img src=images//icons//15.gif border=0 hspace=0 vspace=0/>/is","[:15]",$Text);
  $Text=preg_replace("//<img src=images//icons//16.gif border=0 hspace=0 vspace=0/>/is","[:16]",$Text);
  $Text=preg_replace("//<img src=images//icons//17.gif border=0 hspace=0 vspace=0/>/is","[:17]",$Text);
  $Text=preg_replace("//<img src=images//icons//18.gif border=0 hspace=0 vspace=0/>/is","[:18]",$Text);
  $Text=preg_replace("//<img src=images//icons//19.gif border=0 hspace=0 vspace=0/>/is","[:19]",$Text);
  $Text=preg_replace("//<img src=images//icons//20.gif border=0 hspace=0 vspace=0/>/is","[:20]",$Text);
  $Text=preg_replace("//<img src=images//icons//21.gif border=0 hspace=0 vspace=0/>/is","[:21]",$Text);
  $Text=preg_replace("//<img src=images//icons//22.gif border=0 hspace=0 vspace=0/>/is","[:22]",$Text);
  $Text=preg_replace("//<img src=images//icons//23.gif border=0 hspace=0 vspace=0/>/is","[:23]",$Text);
  $Text=preg_replace("//<img src=images//icons//24.gif border=0 hspace=0 vspace=0/>/is","[:24]",$Text);
  $Text=preg_replace("//<img src=images//icons//25.gif border=0 hspace=0 vspace=0/>/is","[:25]",$Text);
  $Text=preg_replace("//<img src=images//icons//26.gif border=0 hspace=0 vspace=0/>/is","[:26]",$Text);
  $Text=preg_replace("//<img src=images//icons//27.gif border=0 hspace=0 vspace=0/>/is","[:27]",$Text);
  $Text=preg_replace("//<img src=images//icons//28.gif border=0 hspace=0 vspace=0/>/is","[:28]",$Text);
  $Text=preg_replace("//<img src=images//icons//29.gif border=0 hspace=0 vspace=0/>/is","[:29]",$Text);
  $Text=preg_replace("//<img src=images//icons//30.gif border=0 hspace=0 vspace=0/>/is","[:30]",$Text);  //-----------------  END --------------------------------------
  //--------------- 反处理 FLASH 程序----------------------------
  $Text=preg_replace("//<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http:////download.macromedia.com//pub//shockwave//cabs//flash//swflash.cab#version=6,0,29,0 width=500 height=400/>/<param name=movie value=(.+?)/>/<param name=quality value=high/>/<embed src=(.+?) quality=high pluginspage=http:////www.macromedia.com//go//getflashplayer type=application//x-shockwave-flash width=500 height=400/>/<//embed/>/<//object/>/is","[flash]//1[/flash]",$Text);
  //--------------  反处理 real 程序----------------------------
  $Text=preg_replace("//<object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA            height=285 id=RAOCX name=rmplay width=356/>/<param name=SRC value=(.+?)/>/<param name=CONSOLE value=Clip1/>  /<param name=CONTROLS value=imagewindow/>/<param name=AUTOSTART value=true/>/<embed  src=(.+?)  autostart=true             controls=ImageWindow console=Clip1 pluginspage=http:////www.real.com width=356 height=285/>/<//embed/>/<//object/>/<object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA height=27 id=video1 width=356/>/<param name=_ExtentX value=7276/>    /<param name=_ExtentY value=1058/>/<param name=AUTOSTART value=0/>/<param name=SHUFFLE value=0/>/<param name=PREFETCH value=0/>/<param name=NOLABELS value=0/>/<param name=CONTROLS value=ControlPanel/>/<param name=CONSOLE value=Clip1/>/<param name=LOOP value=0/>/<param name=NUMLOOP value=0/>/<param name=CENTER value=0/>/<param name=MAINTAINASPECT value=0/>/<param name=BACKGROUNDCOLOR value=#ffffff/>/<embed type=audio//x-pn-realaudio-plugin console=Clip1controls=ControlPanel height=27 width=356 autostart=0 _extentx=7276 _extenty=1058 shuffle=0 prefetch=0 nolabels=0 loop=0 numloop=0 center=0 maintainaspect=0 backgroundcolor=#ffffff/>/<//embed/>/<//object/>/is","[real]//1[/real]",$Text);
  //----------------反处理 Media 程序 ---------------------------
  $Text=preg_replace("//<object align=middle class=OBJECT classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 height=320 id=MediaPlayer width=356/>/<param name=ShowStatusBar value=-1/>/<param name=Filename value=(.+?) /<embed type=application//x-oleobject  codebase=http:////activex.microsoft.com//activex//controls//mplayer//en//nsmp2inf.cab#Version=5,1,52,701 flename=mp src=(.+?) width=356 height=320/>/<//embed/>/<//object/>/is","[media]//1[/media]",$Text);
  //-------------  END ------------------------------------------------------------------------------------
  $Text=preg_replace("//<font size=(.+?)/>(.+?)/<//font/>/is","[size=//1]//2[/size]",$Text);
  $Text=preg_replace("//<font color=(.+?)/>(.+?)/<//font/>/is","[color=//1]//2[/color]",$Text);
  $Text=preg_replace("//<a href=mailto:(.+?)/>(.+?)/<//a/>/is","[email]//1[/email]",$Text);
  $Text=preg_replace("//<img src=(.+?)/>/is","[img]//1[/img]",$Text);
  $Text=preg_replace("//<a href=(.+?)/>(.+?)/<//a/>/is","[url=//1]//2[/url]",$Text);
  return $Text;
}
//-------------------  为解决<br>问题写的函数  -----------------------
function managebr($string)
{
 $string=str_replace("","&nbsp;",$string);
    $string=str_replace("/n","<br>",$string);
    $string=str_replace("/n","<br>/n",$string);
 $string=preg_replace("/&lt;br&gt;/is","<br>",$string);
 $string=preg_replace("//</? (.+?)/?/>/is","&lt;?//1?&gt;",$string);
 return $string;
}

function user_guanxian_far($table,$n)
{
 $query = "select id,num,name from $table where fartherid='0' order by num desc";
 $result = mysql_query($query) or die(mysql_error());
 $i = 0;
 $array = array();
 while($arr = mysql_fetch_array($result))
 {
  $array[$i]=$arr;
  $i++;
 }
 for($j=0;$j<count($array);$j++)
 {
     if($n > $array[$j]['num'])
   {
   $renum = $array[$j]['id'];
   break;
   } 
 }
 return $renum;
}
//------------- 取出各版块的版主 -----------------------------
function getbanzhu($table,$ID)
{
 $result=mysql_query("select userid from $table where group_id='administrator' and second_id='$ID'");
    $i = 0;
 $array=array();
 while($arr = @mysql_fetch_array($result))
 {
  $array[$i]=$arr;
  $i++;
 }
 return $array;
}
//----------  当天时间的起始和终止的计算
function getalltime()
{
 //$t1=date("H",time())*3600;
 //$t2=(24-date("H",time())*3600;
 
}

function id_name($where="",$table="",$value=""){
 $sql = "select $value from $table where $where";
 $result = mysql_query($sql) or die(mysql_error());
 $rs = mysql_fetch_row($result);
 return $rs[0];
}
//------------ 返回要查询资料的条数 --------------
function num($sql)
{
   $num=mysql_num_rows(query_select($sql));
   return $num;
}
//----------- 记录系统日志 -------------
function bbs_log($talbe,$path,$command)
{   global $SESSION;
    $homeip=getenv("REMOTE_ADDR");  //获得代理服务器的IP
    $personalip=getenv("HTTP_X_FORWARDED_FOR");//获得本要的绝对IP
 $time=time();
    if($SESSION['userid']=="")
  {
  $username = "<font color=red>匿名者</a>";
  }
 else{
   $username=$SESSION['userid'];
  }
 $sql = "insert into bbs_log (userid,files,biao,command,time,homeip,personalip)";
 $sql.= "values('$username','$path','$talbe','$command','$time','$homeip','$personalip')";
 $res = mysql_query($sql) or die(mysql_error());
    return true;
}
//--------------  限制论坛的主题访问的级别 -----------------------
function view_grade($id)
{
 $sql     =   "select view_grade from forum where id='".$id."'";
 $result  =   mysql_query($sql) or die(mysql_error());
 $arr     =   mysql_fetch_array($result);
 $query   =   mysql_query("select name from grade where fartherid='0' and id='".$arr['view_grade']."'") or die(mysql_error());
    $arr     =   mysql_fetch_array($query);
 //$num     =   mysql_num_rows($query);
 $name    =   $arr['name'];
 return $name;
}
//-------------  限制图片不超过的最大值
function image_w_h($src,$w,$h)
{
 $data=getImageSize($src);
 $width=$data[0];//为图片宽度
 $height=$data[1];//为图片高度
 if($width>$w)
  $image_w=$w;
 if($width<$w)
  $image_w=$width;
 if($height>$h)
  $image_h=$h;
 if($height<$h)
  $image_h=$height;
 $array=array("width"=>$image_w,"height"=>$image_h);
 return $array;
}

/*$array=image_w_h("http://cimg.163.com/lady/0404/13/1081746550.jpg","400","500");
echo $array['width'];
echo "<br>/n".$array['height'];
echo "<br>/n";
echo "<img src=http://cimg.163.com/lady/0404/13/1081746550.jpg width='".$array['width']."' height='".$array['height']."'>";
*/
?>

阅读全文
0 0

相关文章推荐

img
取 消
img