吐水奉献 ——PHP常用函数

类别:编程语言 点击:0 评论:0 推荐:

有些是从别人的程序收集而来,如有侵犯,请多包含,
独乐乐,不如与众乐
<?
//-----------------------------------------//
//chkperm()判断权限(需添加权限列表)
//最后修正于:2001-5-18
//作者: hehe
//返回权限名称
//-----------------------------------------//
function chkperm($perm){
 $permname = "游客";
 if(ereg("user", "$perm"))  {$permname="普通用户";} else{$permname=$permname;}
 if(ereg("member","$perm"))  {$permname="注册会员";} else{$permname=$permname;}
 if(ereg("0author","$perm"))  {$permname="两情相悦版主";}  else{$permname=$permname;}
 if(ereg("1author","$perm"))  {$permname="孤男版主";}  else{$permname=$permname;}
 if(ereg("2author","$perm"))  {$permname="寡女版主";}  else{$permname=$permname;}
 if(ereg("supervisor","$perm")) {$permname="总版主";} else{$permname=$permname;}
 if(ereg("editor","$perm"))  {$permname="管理员";} else{$permname=$permname;}
 if(ereg("admin","$perm"))  {$permname="网管";}  else{$permname=$permname;}
 return $permname;
 }
//-----------------------------------------//
//chkperm()判断权限具体(需添加权限列表)
//最后修正于:2001-5-28
//作者: hehe
//返回权限名称
//-----------------------------------------//
function cando($perm){
 $permname = "游客";
 if(ereg("user", "$perm"))  {$permname="浏览所有页面,查询注册会员";} else{$permname=$permname;}
 if(ereg("member","$perm"))  {$permname="浏览所有页面,查询注册会员,并且在论坛发帖";} else{$permname=$permname;}
 if(ereg("0author","$perm"))  {$permname="删除、修改或推荐两情相悦版的帖子";} else{$permname=$permname;}
 if(ereg("1author","$perm"))  {$permname="删除、修改或推荐孤男版的帖子";} else{$permname=$permname;}
 if(ereg("2author","$perm"))  {$permname="删除、修改或推荐寡女版的帖子";} else{$permname=$permname;}
 if(ereg("supervisor","$perm"))  {$permname="删除、修改或推荐所有版的帖子";} else{$permname=$permname;}
 if(ereg("editor","$perm"))  {$permname="添加、修改或删除会员资料";} else{$permname=$permname;}
 if(ereg("admin","$perm"))  {$permname="呵呵,没什么好说的";} else{$permname=$permname;}
 return $permname;
 }

//-----------------------------------------//
//msubstr()中文字符截取函数(无半个汉字)
//最后修正于:2000-12-19
// $str字符串,$start开始字符,$len结束字符
//-----------------------------------------//
function msubstr($str,$start,$len){
 $strlen=$start+$len;
 for($i=0;$i<$strlen;$i++){
  if(ord(substr($str,$i,1))>0xa0)
   {
   $tmpstr.=substr($str,$i,2);
   $i++;
   }else{
   $tmpstr.=substr($str,$i,1);
   }
  }
  return $tmpstr;
 }

//-----------------------------------------//
//cutlongstr()连续西文字符截断函数(防止撑坏表格)
//最后修正于:2001-2-14
//作者: hehe
//限制西文字符串$str不超过$long
//-----------------------------------------//
function cutlongstr($str,$long){
 $j = 0;
 for($i=0;$i<strlen($str);$i++){
  $now = substr($str,$i,1);
  $asc = ord($now);
  if($asc > 31 && $asc < 127)$j++;
  else $j=0;
  $string .= $now;
  if($j >= $long){
  $string .= "\t";
  $j=0;
  }
 }
 return $string;
}
//-----------------------------------------//
//mywidth()限制图片宽度
//最后修正于:2001-8-21
//作者: hehe
//限制图片$pic宽度小于$width
//-----------------------------------------//
function mywidth($pic,$width) {

$wid=@GetImageSize($pic);
if ($wid[0]>$width){
return $width;
}else{
return $wid[0];
}
}
//-----------------------------------------//
//myheight()限制图片宽度
//最后修正于:2001-8-25
//作者: hehe
//限制图片$pic宽度小于$height
//-----------------------------------------//
function myheight($pic,$height) {

$heig=@GetImageSize($pic);
if ($heig[1]>$height){
return $height;
}else{
return $heig[1];
}
}
//-----------------------------------------//
//str4db()处理字符串
//最后修正于:2001-5-24
//作者: hehe
//处理字符串$string可以正常插入数据库
//-----------------------------------------//
function str4db($string){
$str=str_replace("\&quot","&quot",htmlspecialchars($string));
return $str;
}

//-----------------------------------------//
//str4html()处理字符串
//最后修正于:2001-5-24
//作者: hehe
//处理字符串$string可以显示html代码
//-----------------------------------------//
function str4html($string){
$str=str_replace("[标准空格]"," ",str_replace("[尖括号开始]","<",str_replace("[尖括号结束]",">",$string)));
return $str;
}
//-----------------------------------------//
//str4show()处理字符串
//最后修正于:2001-5-24
//作者: hehe
//处理字符串$string可以正常显示
//-----------------------------------------//
function str4show($string){
$str=str_replace("\n","<br>",str_replace(" ","&nbsp;",$string));
return $str;
}
//-----------------------------------------//
//str2show()处理字符串
//最后修正于:2001-7-26
//作者: hehe
//处理字符串$string可以正常显示(飞鸽传书专用)
//-----------------------------------------//
function str2show($string){
$str=str_replace(" ","&nbsp;",$string);
return $str;
}


function urltail($kind,$value){

global $blockid,$title,$content,$nick,$writer,$pagestart,$rewriter,$id;
 switch ($kind) {
  case "blockid":
  $str="?blockid=".$value."&pagestart=0";
  break;

  case "title":
  $str="?blockid=".$blockid."&pagestart=0";
  break;

  case "$content":
  $str="?blockid=".$blockid."&pagestart=0";
  break;

  case "nick":
  $str="?blockid=".$blockid."&pagestart=0";
  break;

  case "writer":
  $str="?blockid=".$blockid."&pagestart=0";
  break;

  case "pagestart": $str="?blockid=".$blockid."&title=".$title."&content=".$content."&nick=".$nick."&writer=".$writer."&pagestart=".$value."&rewriter=".$rewriter;
  break;

  case "other": $str="?blockid=".$blockid."&title=".$title."&content=".$content."&nick=".$nick."&writer=".$writer."&pagestart=".$pagestart."&rewriter=".$rewriter;
  break;

  default:   $str="?blockid=".$blockid."&title=".$title."&content=".$content."&nick=".$nick."&writer=".$writer."&pagestart=".$pagestart."&rewriter=".$rewriter."&id=".$id;
  break;
 }
return $str;
}

function isselect($type,$value){
 if($type==$value){
  $str= " selected";  
  }
 return $str;
 }
//-----------------------------------------//
//chk4board()比较字符串
//最后修正于:2001-5-24
//作者: hehe
//处理字符串$val1~$val4,返回最大序列号
//-----------------------------------------//
function url4http($urlval){
 if(substr($urlval,0,7)=="http://")return $urlval;
 else return "http://".$urlval;
}
//-----------------------------------------//
//chk4board()比较字符串
//最后修正于:2001-5-24
//作者: hehe
//处理字符串$val1~$val4,返回最大序列号
//-----------------------------------------//
function chk4board($val1,$val2,$val3,$val4){
if($val1>=$val2){
$tmp=$val1;
$num=0;
}else{
$tmp=$val2;
$num=1;
}
if($tmp<$val3){
$tmp=$val3;
$num=2;
}
if($tmp<$val4){
$num=3;
}
return $num;
}
//-----------------------------------------//
//cutbr()处理字符串
//最后修正于:2001-7-26
//作者: hehe
//去除字符串$string首尾空格和回车
//-----------------------------------------//
function cutbr($string){
$string=trim($string);
for(;substr($string,0,2)=="\n";){
$string=substr($string,2);
$string=trim($string);
}
for(;substr($string,-2,2)=="\n";){
$string=substr($string,-2);
$string=trim($string);
}
return $string;
}
//-----------------------------------------//
//getnick()传入
//最后修正于:2001-8-2
//作者: hehe
//返回数据表的列表及表数量
//-----------------------------------------//
function getnick($namerow){
$dbname="ahfdb";
$marrydb=mysql_connect("localhost","root","12345");
mysql_select_db($dbname,$marrydb);
for($i=0;$namerow[$i];$i++){
$strrow[$i]="'".$namerow[$i]."'";
}
$nnamestr=join(",",$strrow);
  $query_mem = "select username,nick_name from member where username in ($nnamestr)";
  $result_mem = mysql_query($query_mem);
  while($row_mem = mysql_fetch_array($result_mem)){
 $nname[strtolower($row_mem[username])] = $row_mem[nick_name];
  }
return $nname;
}
//-----------------------------------------//
//处理字典型数据
//最后修正于:2001-5-24
//作者: hehe
//
//-----------------------------------------//
function gettabname($i){
 switch ($i) {
   case 0: $str="msgtab";  break;
   case 1: $str="jok_msgtab"; break;
   case 2: $str="water_msgtab";  break;
   case 3: $str="board_msgtab"; break;
   case 4: $str = "overdue";     break;
   case 5: $str = "board_master";break;
 }
return $str;
}
function getretabname($i){
 switch ($i) {
   case 0: $str="remsgtab";  break;
   case 1: $str="jok_remsgtab"; break;
   case 2: $str="water_remsgtab";  break;
   case 3: $str="board_remsgtab"; break;
   case 4: $str = "re_overdue";  break;
   case 5: $str = "re_boardmaster";break;
 }
return $str;
}
function getboardname($i){
 switch ($i) {
   case 0: $str="心情驿站"; break;
   case 1: $str="喜剧人生"; break;
   case 2: $str="灌水乐园";  break;
   case 3: $str="站务柬言"; break;
   case 4: $str="都市心语";   break;
   case 5: $str="版主交流";   break;
 }
return $str;
}
function getboardmanage($i){
 switch ($i) {
   case 0: $row[0]="hs_sx_nb"; $row[1]="cgp"; break;
   case 1: $row[0]="bbhts";$row[1]="WUGANG1977";  break;
   case 2: $row[0]="nettrain";$row[1]="Irishi";   break;
   case 3: $row[0]="webmaster";      break;
   case 4: $row[0]="MELY";$row[1]="webmaster";break;
   case 5: $row[0]="webmaster";break;
 }
return $row;
}

//荣誉网友,帖子颜色变化
function getglory(){
 $row[0]="nanyan";$row[1]="dayue";$row[2]="xueqilin";$row[3]="Selly";$row[4]="chenai";$row[5]="kongl";$row[6]="bingbingbing";$row[7]="joyna";$row[8]="LINYINGYIN";$row[9]="snake";$row[10]="shou";$row[11]="cnpagehf";$row[12]="zhangxiao";$row[13]="WHD3533";$row[14]="w_smile";
 return $row;
}

function chickmanage($name,$row){
$pass=0;
for($i=0;$row[$i]!="";$i++){
 if($name==$row[$i])$pass=1;
}
return $pass;
}

function getsex($i){
 switch ($i) {
   case 1:
  $str="男";
  break;
 case 2:
  $str="女";
  break;
 }
return $str;
}
  
function getflok($i){
 switch ($i) {
  case 1: $str="汉族"; break;
  case 2: $str="蒙古族"; break;
  case 3: $str="回族"; break;
  case 4: $str="藏族"; break;
  case 5: $str="维吾尔族"; break;
  case 6: $str="苗族"; break;
  case 7: $str="彝族"; break;
  case 8: $str="壮族"; break;
  case 9: $str="布依族"; break;
  case 10: $str="朝鲜族"; break;
  case 11: $str="满族"; break;
  case 12: $str="侗族"; break;
  case 13: $str="瑶族"; break;
  case 14: $str="白族"; break;
  case 15: $str="土家族"; break;
  case 16: $str="哈尼族"; break;
  case 17: $str="哈萨克族"; break;
  case 18: $str="傣族"; break;
  case 19: $str="黎族"; break;
  case 20: $str="傈僳族"; break;
  case 21: $str="佤族"; break;
  case 22: $str="畲族"; break;
  case 23: $str="高山族"; break;
  case 24: $str="拉祜族"; break;
  case 25: $str="水族"; break;
  case 26: $str="东乡族"; break;
  case 27: $str="纳西族"; break;
  case 28: $str="景颇族"; break;
  case 29: $str="柯尔克孜族"; break;
  case 30: $str="土族"; break;
  case 31: $str="达斡尔族"; break;
  case 32: $str="仫佬族"; break;
  case 33: $str="羌族"; break;
  case 34: $str="布朗族"; break;
  case 35: $str="撒拉族"; break;
  case 36: $str="毛南族"; break;
  case 37: $str="仡佬族"; break;
  case 38: $str="锡伯族"; break;
  case 39: $str="阿昌族"; break;
  case 40: $str="普米族"; break;
  case 41: $str="塔吉克族"; break;
  case 42: $str="怒族"; break;
  case 43: $str="乌孜别克族"; break;
  case 44: $str="俄罗斯族"; break;
  case 45: $str="鄂温克族"; break;
  case 46: $str="德昂族"; break;
  case 47: $str="保安族"; break;
  case 48: $str="裕固族"; break;
  case 49: $str="京族"; break;
  case 50: $str="塔塔尔族"; break;
  case 51: $str="独龙族"; break;
  case 52: $str="鄂伦春族"; break;
  case 53: $str="赫哲族"; break;
  case 54: $str="门巴族"; break;
  case 55: $str="珞巴族"; break;
  case 56: $str="基诺族"; break;
  case 97: $str="其他"; break;
  case 98: $str="外国血统中国籍人士"; break;
  default: $str="未填";break;
 }
return $str;
}

function getblood($i){
 switch ($i) {
  case 0: $str="O型"; break;
  case 1: $str="A型"; break;
  case 2: $str="B型"; break;
  case 3: $str="AB型"; break;
  case 9: $str="其它"; break;
 }
return $str;
}

function getzz($i){
 switch ($i) {
  case 1: $str="中共党员"; break;
  case 2: $str="预备党员"; break;
  case 3: $str="共青团员"; break;
  case 4: $str="民革会员"; break;
  case 5: $str="民盟盟员"; break;
  case 6: $str="民建会员"; break;
  case 7: $str="民进会员"; break;
  case 8: $str="农工党党员"; break;
  case 9: $str="致公党党员"; break;
  case 10: $str="九三学社社员"; break;
  case 11: $str="台盟盟员"; break;
  case 12: $str="无党派人士"; break;
  case 13: $str="群众"; break;
  case 15: $str="工商"; break;
  case 99: $str="其他党派"; break;
 }
return $str;
}    

function getedu_level($edu_level)
{
  switch ($edu_level) {
    case 1: $retval = "高中";
            break ;
    case 2: $retval = "中专";
            break ;              
    case 3: $retval = "大专";
            break ;
    case 4: $retval = "本科";              
            break ;                             
    case 5: $retval = "硕士";              
            break ;                             
    case 6: $retval = "博士";              
            break ;                             
    case 7: $retval = "其它";              
            break ;    
    case 8: $retval = "请选择";              
            break ;                                       
   }
   return $retval;
}             

function getlocation($location)
{
  switch ($location) {
    case 1: $retval = "安徽省";
            break ;
    case 2: $retval = "北京市";
            break ;              
    case 3: $retval = "上海市";
            break ;
    case 4: $retval = "天津市";
            break ;                             
    case 5: $retval = "重庆市";
            break ;                             
    case 6: $retval = "河北省";              
            break ;                             
    case 7: $retval = "山西省";        
            break ;
    case 8: $retval = "内蒙古";
            break ;
    case 9: $retval = "辽宁省";              
            break ;
    case 10: $retval = "吉林省";              
            break ;
    case 11: $retval = "黑龙江省";              
            break ;
    case 12: $retval = "江苏省";              
            break ;
    case 13: $retval = "浙江省";              
            break ;
    case 15: $retval = "福建省";
            break ;
    case 16: $retval = "江西省";              
            break ;
    case 17: $retval = "山东省";              
            break ;
    case 18: $retval = "河南省";              
            break ;
    case 19: $retval = "湖北省";              
            break ;
    case 20: $retval = "湖南省";              
            break ;
    case 21: $retval = "广西省";              
            break ;
    case 22: $retval = "四川省";              
            break ;
    case 23: $retval = "贵州省";              
            break ;
    case 24: $retval = "云南省";              
            break ;
    case 25: $retval = "西藏自治区";              
            break ;
    case 26: $retval = "陕西省";              
            break ;
    case 27: $retval = "甘肃省";
            break ;
    case 28: $retval = "青海省";
            break ;
    case 29: $retval = "宁夏";
            break ;
    case 30: $retval = "新疆";
            break ;
    case 31: $retval = "香港";
            break ;
    case 32: $retval = "台湾省";
            break ;
    case 33: $retval = "澳门";
            break ;
    case 34: $retval = "海南省";
            break ;
    case 35: $retval = "广东省";
            break ;
    case 36: $retval = "国外";
            break ;
    case 37: $retval = "其它";
            break ;
    case 38: $retval = "请选择";
            break ;
  }             
  return $retval;
}

function getmoney($i){
 switch ($i) {
  case 1: $str="富裕 "; break;
  case 2: $str="良好"; break;
  case 3: $str="一般"; break;
  case 4: $str="尚可"; break;
  case 5: $str="贫困"; break;
  case 9: $str="不稳定"; break;
      }
return $str;
}  

function getjobkind($i){
 switch ($i) {
  case 1: $str="计算机"; break;
  case 2: $str="家电电子"; break;
  case 3: $str="邮电通信"; break;
  case 4: $str="房地产业"; break;
  case 5: $str="宣传媒体"; break;
  case 6: $str="科研院所"; break;
  case 7: $str="医药卫生"; break;
  case 8: $str="党政机关"; break;
  case 9: $str="公安司法"; break;
  case 10: $str="部队消防"; break;
  case 11: $str="文化教育"; break;
  case 12: $str="商业贸易"; break;
  case 13: $str="能源电力"; break;
  case 14: $str="机械制造"; break;
  case 15: $str="服务行业"; break;
  case 16: $str="金融证券保险"; break;
  case 17: $str="旅游娱乐"; break;
  case 18: $str="体育运动"; break;
  case 19: $str="民航海运"; break;
  case 20: $str="铁路公路"; break;
  case 21: $str="冶金石化"; break;
  case 22: $str="化工纺织"; break;
  case 23: $str="农林渔牧"; break;
  case 99: $str="其他行业"; break;
      }
return $str;
}  

function getlevel($i){
 switch ($i) {        
  case 0: $str="无"; break;
  case 1: $str="副教授"; break;
  case 2: $str="副研究员"; break;
  case 3: $str="高级工程师"; break;
  case 4: $str="高级会计师"; break;
  case 5: $str="高级讲师"; break;
  case 6: $str="高级经济师"; break;
  case 7: $str="高级实验师"; break;
  case 8: $str="高级统计师"; break;
  case 9: $str="高级行政师"; break;
  case 10: $str="高级政工师"; break;
  case 11: $str="工程师"; break;
  case 12: $str="会计师"; break;
  case 13: $str="会计员"; break;
  case 14: $str="技术员"; break;
  case 15: $str="讲师"; break;
  case 16: $str="教授"; break;
  case 17: $str="教员"; break;
  case 18: $str="经济师"; break;
  case 19: $str="经济员"; break;
  case 20: $str="其它高职师"; break;
  case 21: $str="其它员级"; break;
  case 22: $str="其它中职师"; break;
  case 23: $str="其它助级师"; break;
  case 24: $str="实验师"; break;
  case 25: $str="实验员"; break;
  case 26: $str="统计师"; break;
  case 27: $str="统计员"; break;
  case 28: $str="行政员"; break;
  case 29: $str="研究员"; break;
  case 30: $str="医务高级师"; break;
  case 31: $str="医务员级"; break;
  case 32: $str="医务中级师"; break;
  case 33: $str="医务助级师"; break;
  case 34: $str="政工师"; break;
  case 35: $str="政工员"; break;
  case 36: $str="中级行政师"; break;
  case 37: $str="助级行政师"; break;
  case 38: $str="助理工程师"; break;
  case 39: $str="助理会计师"; break;
  case 40: $str="助理讲师"; break;
  case 41: $str="助理经济师"; break;
  case 42: $str="助理实验师"; break;
  case 43: $str="助理统计师"; break;
  case 44: $str="助理政工师"; break;
  case 45: $str="主任高级工程师"; break;
  case 46: $str="成绩优异高工"; break;
       }
return $str;
}  

function getsalary($i){
 switch ($i) {
  case 0: $str="500元以下"; break;
  case 1: $str="500~1000元"; break;
  case 2: $str="1000~1500元"; break;
  case 3: $str="1500~2000元"; break;
  case 4: $str="2000~3000元"; break;
  case 5: $str="3000~5000元"; break;
  case 9: $str="5000~10000元"; break;
  case 10: $str="10000元以上"; break;
 }
return $str;
}  

function gethouse($house)
{
  switch ($house) {
    case 1: $retval = "有自己的房子";
            break;
    case 2: $retval = "住单位的房子";
            break ;
    case 3: $retval = "与父母同住";
            break ;              
    case 4: $retval = "结婚时可买房";
            break ;
    case 5: $retval = "暂时租房";              
            break ;                             
    case 6: $retval = "其它";              
            break ;
    case 7: $retval = "请选择";              
            break ;                           
  }              
  return $retval;
}  

function gethealth($i){
 switch ($i) {
  case 1: $str="健康或良好"; break;
  case 2: $str="一般或较弱"; break;
  case 3: $str="有慢性病"; break;
  case 31: $str="心血管病"; break;
  case 32: $str="脑血管病"; break;
  case 33: $str="慢性呼吸系统病"; break;
  case 34: $str="慢性消化系统病"; break;
  case 35: $str="慢性肾炎"; break;
  case 36: $str="结核病"; break;
  case 37: $str="糖尿病"; break;
  case 38: $str="神经或精神疾病"; break;
  case 39: $str="其他慢性病"; break;
  case 4: $str="有生理缺陷"; break;
  case 41: $str="聋哑"; break;
  case 42: $str="盲人"; break;
  case 43: $str="高度近视"; break;
  case 49: $str="其他缺陷"; break;
  case 5: $str="残废"; break;
  case 51: $str="特等残废"; break;
  case 52: $str="一等残废"; break;
  case 53: $str="二等甲级残废 "; break;
  case 54: $str="二等乙级残废"; break;
  case 55: $str="三等甲级残废"; break;
  case 56: $str="三等乙级残废"; break;
  case 59: $str="其他残废"; break;
  case 99: $str="其他"; break;
 }
return $str;
}  

function getmarriage($marriage)
{
  switch ($marriage) {
    case 1: $retval = "未婚";
            break ;
    case 2: $retval = "已婚";
            break ;              
    case 3: $retval = "离异有小孩";
            break ;
    case 4: $retval = "离异无负担";              
            break ;
    case 5: $retval = "有缘就行";              
            break ;                             
  }
  return $retval;
}

function getstar($day){
  if($day>320&&$day<420){
return "牡羊座";
}elseif($day>419&&$day<521){
return "金牛座";
}elseif($day>520&&$day<621){
return "双子座";
}elseif($day>620&&$day<723){
return "巨蟹座";
}elseif($day>722&&$day<823){
return "狮子座";
}elseif($day>822&&$day<923){
return "处女座";
}elseif($day>922&&$day<1122){
return "天秤座";
}elseif($day>1022&&$day<1122){
return "天蝎座";
}elseif($day>1121&&$day<1222){
return "射手座";
}elseif($day>1221||$day<120){
return "摩羯座";
}elseif($day>119&&$day<219){
return "水瓶座";
}elseif($day>218&&$day<321){
return "双鱼座";
}

}

function getagree($i){
 switch ($i) {
  case 0: $str="发布"; break;
  case 1: $str="不发布"; break;
 }
return $str;
}  

//各级别名称
function getscore($score){
 //echo $score;
 if($score>=150000){
  $name_char = "<img src=../image/start/taiy.gif>";
 }
 elseif(($score<150000)&&($score>=120000)){
  $name_char = "<img src=../image/start/shui.gif>";
 }
 elseif(($score<120000)&&($score>=90000)){
  $name_char = "<img src=../image/start/jin.gif>";
 }
 elseif(($score<90000)&&($score>=60000)){
  $name_char = "<img src=../image/start/po.gif>";
 }
 elseif(($score<60000)&&($score>=50000)){
  $name_char = "<img src=../image/start/huo.gif>";
 }
 elseif(($score<50000)&&($score>=40000)){
  $name_char = "<img src=../image/start/mu.gif>";
 }
 elseif(($score<40000)&&($score>=30000)){
  $name_char = "<img src=../image/start/tu.gif>";
 }
 elseif(($score<30000)&&($score>=20000)){
  $name_char = "<img src=../image/start/tian.gif>";
 }
 elseif(($score<20000)&&($score>=10000)){
  $name_char = "<img src=../image/start/hai.gif>";
 }
 elseif(($score<10000)&&($score>=3000)){
  $name_char = "<img src=../image/start/min.gif>";
 }
 return $name_char;
}

function get_bbsname($username){
 $str = "select prems,blockid from prem where username='$username'";
 $res = mysql_query($str);
 $row = mysql_fetch_array($res);
 if($row[prems]<5){
  $b_name = $row[blockid];
 }
 else{
  $b_name = 10;
 }
 return $b_name;
}

function get_jh($username){
 $str = "select username from newarticle where username='$username'";
// echo $str;
 $res = mysql_query($str);
 $num = mysql_num_rows($res);
 if($num>=20){
  $pass = "1";
 }
 else{
  $pass = "0";
 }
 //echo $num;
return $pass;
}
//根据分数判断
function get_score($username){
 $str = "select score from member where username='$username'";
 
 $res = mysql_query($str);
 $fen = mysql_fetch_row($res);
 if($fen[0]>=50000){
  $pass1 = "1";
 }
 else{
  $pass1 = "0";
   }
 return $pass1;
}

//贴子过滤
function leach($char){
 $str = "select * from leach";
 $res = mysql_query($str);
 while($row=mysql_fetch_array($res)){
  //$leach = ereg("jzm",$char);
  if(ereg($row[keyword],$char)){
   $leach = "0";
   break;
  }
  else{
   $leach = "1";
  }
 }
 return $leach;
}
//看来CSDN也有用到过滤功能,我的JZM加上汉语就不行,不知他的算法是否和$leach一样,如有知道的,请帖出来看看。
?>

本文地址:http://com.8s8s.com/it/it25501.htm