注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

面包会有的

php asp 高端网站开发 微信网站开发 视频会议软硬件

 
 
 

日志

 
 

userfun.php 之二  

2015-01-02 13:36:24|  分类: 帝国cms |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

/***********************************************************
 * 功能:根据分类信息的分类id获取各上级分类id
 * 调用:
 * 详细说明:
************************************************************/
function user_flxxGetAllClassIdFromClassId($n,$ClassId,$Level){
global $empire,$dbtbpre,$class_r;


//$allClassId = array(0,0,0,0,0,0,0);;
$str = "select id,ParentId from {$dbtbpre}t_flxx_class where id=$ClassId";
$pr = $empire->fetch1($str);
if ($pr){
$allClassId = $pr['ParentId'];
}
//user_flxxGetAllClassIdFromClassId($n-1,$pr['id'],$pr['CurLevel']);
return $allClassId;
}


/***********************************************************
 * 功能:test
 * 调用:
 * 详细说明:
************************************************************/
function user_test($id,$str){
global $empire,$dbtbpre,$class_r;

//echo "<script > alert ('user_test');</script>";
//test111();
return $id.$str."xxxxxxxxxxxx";
}

/***********************************************************
 * 功能:根据userid获取用户组
 * 调用:user_getGroupName(2)
 * 详细说明:
************************************************************/
function user_getGroupName($userid){
global $empire,$dbtbpre,$class_r;
$userid = (int)$userid;

$pu = $empire->fetch1("select userid,groupid from {$dbtbpre}enewsmember where userid='$userid' limit 1");
$groupid = (int)$pu['groupid'];
//查询用户组表
$pg = $empire->fetch1("select groupname from {$dbtbpre}enewsmembergroup where groupid='$groupid' limit 1");
$groupname = $pg['groupname'];
return $groupname;
}

/***********************************************************
 * 功能:根据userid获取用户上传的会员真实照片
 * 调用:user_getUserPhoto(2,1)
 * 详细说明:
************************************************************/
function user_getUserPhoto($userid,$typeid){
global $empire,$dbtbpre,$class_r;
$userid = (int)$userid;
$typeid = (int)$typeid;
$pr = $empire->fetch1("select * from {$dbtbpre}t_uploadpicture where userid='$userid' and typeid='$typeid' limit 1");
$fileurl = $pr['fileurl'];
return $fileurl;
}


/***********************************************************
 * 功能:根据userid判断必填项是否填写完整,实名认证的前提条件
 * 调用:
 * 详细说明:资料真实性须人工检查
 * 必填:地区,地址,电话,手机,邮箱,身份证号,身份证正面、反面,真实姓名,会员真实照片
************************************************************/
function user_CheckZhiLiaoComplete($userid){
global $empire,$dbtbpre,$class_r;
return 1;
}


/***********************************************************
 * 功能:样式更换时执行扣点
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_DoStyleFen($fen,$styleId,$userid){
global $empire,$dbtbpre,$class_r;
//AddInfoFen(-1,1);// \e\member\class\user.php中

//获取会员组,普通会员组可能要扣分,高级会员组不扣分
$pr = $empire->fetch1("select * from {$dbtbpre}enewsmember where userid='$userid'");
$groupid = $pr['groupid'];
$userfen = $pr['userfen'];

//获取本样式所需点数
$tr = $empire->fetch1("select id,userfen,groupid from {$dbtbpre}t_c5_style where id='$styleId'");
$groupid = $tr['groupid'];
$mustfen = (int)$tr['userfen'];

// if ($userfen >= $mustfen){
$sqlStr="UPDATE {$dbtbpre}enewsmember SET userfen = (userfen-".$mustfen.") WHERE userid=$userid";
$sql=$empire->query($sqlStr);
// }

//作记录
$iStr = "insert into ";


return 1;
}



/*****************************/

/***********************************************************
 * 功能:查询镇网各类广告数
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_getADCount($pid,$typeid,$typeid2){
global $empire,$dbtbpre,$class_r;

switch ($typeid2)
{
case 1:
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=0 order by MyOrder DESC";
break;  
case 2:
if ($ParentId==0){
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=$ParentId order by MyOrder DESC limit 0";
}else
{
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=$ParentId order by MyOrder DESC";
}
break;  
case 3:
if ($ParentId==0){
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=$ParentId order by MyOrder DESC limit 0";
}else
{
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=$ParentId order by MyOrder DESC";
}
break; 
default:
$str = "select id,ClassName from {$dbtbpre}t_flxx_class where ParentId=0 order by MyOrder DESC limit 0";
}


return 1;
}












/************* 问答中心 start ****************************************************/

/***********************************************************
 * 功能:返回问题的分类中文名
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_questionGetClassNameFromClassId($classid1,$classid2,$classid3){
global $empire,$dbtbpre,$class_r;
$classid1 = (int)$classid1;
$classid2 = (int)$classid2;
$classid3 = (int)$classid3;

$questionClassName=array("readme"=>0,"pid1"=>1,"pid2"=>2,"pid3"=>3,"pid4"=>4,"pid5"=>5);
$questionClassName[0]="问题信息分类";

if ($classid1){
$pr = $empire->fetch1("select * from {$dbtbpre}t_question_class where id='$classid1'");
$questionClassName[1]=$pr['ClassName'];
}
if ($classid2){
$pr = $empire->fetch1("select * from {$dbtbpre}t_question_class where id='$classid2'");
$questionClassName[2]=$pr['ClassName'];
}
if ($classid3){
$pr = $empire->fetch1("select * from {$dbtbpre}t_question_class where id='$classid3'");
$questionClassName[3]=$pr['ClassName'];
}

return $questionClassName;
}
/***********************************************************
 * 功能:获取问答中心的分类列表
 * 调用:
 * 详细说明:
************************************************************/
function user_questionClassOption($ParentId,$SelectId,$LevelId){
global $empire,$dbtbpre,$class_r;

switch ($LevelId)
{
case 1:
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=0 order by MyOrder DESC";
break;  
case 2:
if ($ParentId==0){
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=$ParentId order by MyOrder DESC limit 0";
}else
{
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=$ParentId order by MyOrder DESC";
}
break;  
case 3:
if ($ParentId==0){
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=$ParentId order by MyOrder DESC limit 0";
}else
{
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=$ParentId order by MyOrder DESC";
}
break; 
default:
$str = "select id,ClassName from {$dbtbpre}t_question_class where ParentId=0 order by MyOrder DESC limit 0";
}


$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){
if ($tr['id']==$SelectId){
$checkStr = " selected";
}
else
{
$checkStr="";
}
$optionStr .= "<option value=\"".$tr['id']."\"".$checkStr.">".$tr['ClassName']."</option>";
}
return $optionStr;
}


/************* 问答中心 end ******************************************************/





/*********网址 start************************************************************************/
/***********************************************************
 * 功能:返回网址的分类中文名
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_sitesGetClassNameFromClassId($classid1,$classid2,$classid3){
global $empire,$dbtbpre,$class_r;
$classid1 = (int)$classid1;
$classid2 = (int)$classid2;
$classid3 = (int)$classid3;

$sitesClassName=array("readme"=>0,"pid1"=>1,"pid2"=>2,"pid3"=>3,"pid4"=>4,"pid5"=>5);
$sitesClassName[0]="网址分类";

if ($classid1){
$pr = $empire->fetch1("select * from {$dbtbpre}t_sites_class where id='$classid1'");
$sitesClassName[1]=$pr['ClassName'];
}
if ($classid2){
$pr = $empire->fetch1("select * from {$dbtbpre}t_sites_class where id='$classid2'");
$sitesClassName[2]=$pr['ClassName'];
}
if ($classid3){
$pr = $empire->fetch1("select * from {$dbtbpre}t_sites_class where id='$classid3'");
$sitesClassName[3]=$pr['ClassName'];
}

return $sitesClassName;
}

/***********************************************************
 * 功能:返回网址的列表,如6个
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_sitesGetLiFromClassId($classid1,$classid2,$classid3,$pid1,$pid2,$pid3,$pid4,$pid5,$css,$num=6){
global $empire,$dbtbpre,$class_r;
$classid1 = (int)$classid1;
$classid2 = (int)$classid2;
$classid3 = (int)$classid3;

if ($classid1>0){$add .= " and classid1=$classid1";}
if ($classid2>0){$add .= " and classid2=$classid2";}
if ($classid3>0){$add .= " and classid3=$classid3";}

$str="select * from {$dbtbpre}t_sites where id>0 ".$add." order by qistop desc,newstime desc,id desc limit ".$num;
$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){
$outStr .= "<li class='".$css."'>".$tr['title']."</li>";
}

return $outStr;
}






/*********网址 end************************************************************************/










/*************分类信息 start******************************************************/

/***********************************************************
 * 功能:返回分类信息的分类中文名
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_flxxGetClassNameFromClassId($classid1,$classid2,$classid3){
global $empire,$dbtbpre,$class_r;
$classid1 = (int)$classid1;
$classid2 = (int)$classid2;
$classid3 = (int)$classid3;

$flxxClassName=array("readme"=>0,"pid1"=>1,"pid2"=>2,"pid3"=>3,"pid4"=>4,"pid5"=>5);
$flxxClassName[0]="分类信息分类";

if ($classid1){
$pr = $empire->fetch1("select * from {$dbtbpre}t_flxx_class where id='$classid1'");
$flxxClassName[1]=$pr['ClassName'];
}
if ($classid2){
$pr = $empire->fetch1("select * from {$dbtbpre}t_flxx_class where id='$classid2'");
$flxxClassName[2]=$pr['ClassName'];
}
if ($classid3){
$pr = $empire->fetch1("select * from {$dbtbpre}t_flxx_class where id='$classid3'");
$flxxClassName[3]=$pr['ClassName'];
}

return $flxxClassName;
}

/***********************************************************
 * 功能:返回分类信息右侧广告1
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_flxxGetRightGoodAndTop($classid1,$classid2,$classid3,$num=5,$pid1=0,$pid2=0,$pid3=0,$pid4=0,$pid5=0){
global $empire,$dbtbpre,$class_r;

$num = (int)$num;
if ($num>0){$limitStr = " limit ".$num;}

$TheTime=time();

//统计符合条件的,如果没有,则显示某些特定的
$ewhere = " checked=1 and isgood>0 and starttime< ".$TheTime." and endtime>".$TheTime;
$str="select * from {$dbtbpre}t_flxx_goodtop where id>0 and ".$ewhere." order by istop desc,isgood desc,id desc ".$limitStr;
//统计
$totalquery="select count(*) as total from {$dbtbpre}t_flxx_goodtop where id>0 and ".$ewhere;
$totalnum=$empire->gettotal($totalquery);
if ($totalnum > 0 )
{
$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){
$outStr .= "
<li>
<dl>
<dd><a href=\"/e/\extend/AD/flxx/Show/?ADId=".$tr['id']."\">".$tr['title']."</a></dd>
<dt>".esub($tr['smalltext'],40)."</dt>
</dl>
</li>";
}



}else
{
;
}

//当自推荐不足时,从分类表中查找后台推荐的补足
if ($totalnum < $num ){
$add =  $num-$totalnum;
$str2="select * from {$dbtbpre}ecms_info where id>0 and classid1 = ".$classid1." order by istop desc,isgood desc,id desc limit ".$add;
$sql=$empire->query($str2);
while($tr=$empire->fetch($sql)){
$outStr .= "
<li>
<dl>
<dd><a href=\"".$tr[titleurl]."\" target=_blank>".$tr['title']."</a></dd>
<dt>".esub($tr['smalltext'],40)."</dt>
</dl>
</li>";
}

}
//$outStr .= $str;
echo $outStr;

}


/***********************************************************
 * 功能:返回分类信息右侧广告1
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_flxxGetRightADListFromClassId1($classid1,$classid2,$classid3,$num=5,$pid1=0,$pid2=0,$pid3=0,$pid4=0,$pid5=0){
global $empire,$dbtbpre,$class_r;

$num = (int)$num;
if ($num>0){$limitStr = " limit ".$num;}

$str="select * from {$dbtbpre}t_ad order by id desc ".$limitStr;
$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){
$outStr .= "
<li>
<dl>
<dd><a href=\"/e/\extend/AD/ZhenAD/Show/?ADId=".$tr['id']."\">".$tr['title']."</a></dd>
<dt>".$tr['smalltext']."</dt>
</dl>
</li>";
}


echo $outStr;

}

/***********************************************************
 * 功能:返回分类信息右侧广告2
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_flxxGetRightADListFromClassId2($classid1,$classid2,$classid3,$num=5,$pid1=0,$pid2=0,$pid3=0,$pid4=0,$pid5=0){


global $empire,$dbtbpre,$class_r;

$num = (int)$num;
if ($num>0){$limitStr = " limit ".$num;}

$str="select * from {$dbtbpre}t_ad order by id desc ".$limitStr;
$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){
$outStr .= "
<li>
<dl>
<dd><a href=\"/e/\extend/AD/ZhenAD/Show/?ADId=".$tr['id']."\">".$tr['title']."</a></dd>
<dt>".$tr['smalltext']."</dt>
</dl>
</li>";
}


echo $outStr;
}

/***********************************************************
 * 功能:返回分类信息列表中广告 置顶
 * 调用:
 * 详细说明:
 * 必填:
************************************************************/
function user_flxxGetLeftDownADListFromClassId2($classid1,$classid2,$classid3,$num=5,$pid1=0,$pid2=0,$pid3=0,$pid4=0,$pid5=0,$titleLen=20,$smalltextLen=40){
global $empire,$dbtbpre,$class_r;

$num = (int)$num;
if ($num>0){$limitStr = " limit ".$num;}

$smalltextLen = (int)$smalltextLen;
$classid1 = (int)$classid1;

$TheTime=time();

//统计符合条件的,如果没有,则显示某些特定的
$ewhere = " checked=1 and istop>0 and starttime< ".$TheTime." and endtime>".$TheTime;
$str="select * from {$dbtbpre}t_flxx_goodtop where id>0 and ".$ewhere." order by istop desc,isgood desc,id desc ".$limitStr;
//统计
$totalquery="select count(*) as total from {$dbtbpre}t_flxx_goodtop where id>0 and ".$ewhere;
$totalnum=$empire->gettotal($totalquery);
if ($totalnum > 0 )
{
$sql=$empire->query($str);
while($tr=$empire->fetch($sql)){

$title = esub($tr[title],$titleLen);
if (strlen($title)>$titleLen){$title .="...";}

$smalltext = esub($tr[smalltext],$smalltextLen);
if (strlen($smalltext)>$smalltextLen){$smalltext .="...";}
$outStr .= "
<li>
<div class=\"li_part1\"><span class=\"chk\"><input type=\"checkbox\" name=\"id[]\" value=\"".$tr[newsid]."\" id=\"flxxid1\"></span><a href=\"/e/\extend/AD/flxx/Show/?ADId=".$tr['id']."\" target=\"_blank\">".$title."</a></div>
<div class=\"mainlist_in_left_ad\">".$smalltext."</div>
</li>";
}



}else
{
;
}
//当自推荐不足时,从分类表中查找后台推荐的补足
if ($totalnum < $num ){
$add =  $num-$totalnum;
$str2="select * from {$dbtbpre}ecms_info where id>0 and istop>0 and classid1 = ".$classid1." order by istop desc,isgood desc,id desc limit ".$add;
$sql=$empire->query($str2);
while($tr=$empire->fetch($sql)){
$title = esub($tr[title],$titleLen);
if (strlen($title)>$titleLen){$title .="...";}

$smalltext = esub($tr[smalltext],$smalltextLen);
if (strlen($smalltext)>$smalltextLen){$smalltext .="...";}
$outStr .= "
<li>
<div class=\"li_part1\"><span class=\"chk\"><input type=\"checkbox\" name=\"id[]\" value=\"".$tr[newsid]."\" id=\"flxxid1\"></span><a href=\"/e/\extend/AD/flxx/Show/?ADId=".$tr['id']."\" target=\"_blank\">".$title."</a></div>
<div class=\"mainlist_in_left_ad\">".$smalltext."</div>
</li>";
}

}

//$outStr .= $str2;
echo $outStr;

}
/*************分类信息 end******************************************************/







/***********************************************************
 * 功能:获取某类全部广告
 * 调用:
 * 模板:
 * 配套文件:
 * 详细说明:
************************************************************/
function user_getADComm($pid,$typeid,$tpid,$pos){
global $empire,$dbtbpre,$class_r;

switch ($tpid)
{
case 1:
$pAdd = "pid1='$pid'";
break;  
case 2:
$pAdd = "pid2='$pid'";
break;  
case 3:
$pAdd = "pid3='$pid'";
$t = "";
break;  
case 4:
$pAdd = "pid4='$pid'";
break;  
case 5:
$pAdd = "pid5='$pid'";
break;  
default:
$pAdd = "pid1='$pid'";
}
$start = $pos-1;
$end = $pos;
$qStr = "select id,fileurl,title from {$dbtbpre}t_ad where ".$pAdd." and typeid=$typeid and tpid=$tpid and checked=1 order by myorder desc, id desc limit $start,1";

$tr=$empire->fetch1( $qStr );
$mid = (int)$tr['id'];
$fileurl=$tr[fileurl];
$title=$tr[title];
switch ($typeid)
{
case 1:
$w = 343;$h=200;
break;  
case 2:
$w = 170;$h=100;
break;  
case 3:
$w = 228;$h=80;
$t = "<br>".$tr[title];
break;  
case 4:
$w = 1012;$h=100;
break;  
case 5:
$w = 0;$h=0;
break;  
default:
$w = 343;$h=200;
}


//return $qStr;
if ($mid>0){
$str = "<a href='/e/extend/AD/ZhenAD/Go/?ADId=".$mid."' target='_blank'><img src='".$fileurl."' border=0 width='".$w."' height='".$h."' >".$t."</a>";
}else{
switch ($typeid)
{
case 1:
$str1= "select * from {$dbtbpre}enewsad where classid=3 order by adid desc limit $start,1";
break;  
case 2:
$str1= "select * from {$dbtbpre}enewsad where classid=4 order by adid desc limit $start,1";
break;  
case 3:
$str1= "select * from {$dbtbpre}enewsad where classid=2 order by adid desc limit $start,1";
break;  
case 4:
$str1= "select * from {$dbtbpre}enewsad where classid=5 order by adid desc limit $start,1";
break;
default:
;
}
$tr=$empire->fetch1($str1);

$fileurl=$tr['picurl'];//"/skin/default/images/ad1.jpg";
if ($typeid==3){$t=$tr['alt'];}
$url=$tr['url'];
$str = "<a href='".$url."' target='_blank'><img src='".$fileurl."' border=0 width='".$w."' height='".$h."' ><br>".$t."</a>";
}

return $str; 
}










/*
 * 联系方式
 * 
 * 
 * 
*/
function user_memberlxfs($superuserid,$typeid=5){
global $empire,$dbtbpre,$class_r;
$qStr = "select a.email, c.truename,c.oicq,phone,c.mobile from {$dbtbpre}enewsmember a, {$dbtbpre}enewsmemberadd c where a.userid = c.userid group by(a.userid) and a.userid = ".$superuserid;
//$qStr =  "select * from {$dbtbpre}enewsmemberadd where userid='".$superuserid."' limit 1";
$rrr = $empire->fetch1( $qStr );

$truename = $rrr[truename];//真实姓名
$oicq = $rrr[oicq];
$email = $email[email];
$phone = $rrr[phone];
$mobile = $rrr[mobile];


switch ($typeid)
{
case 1:
$str1= "网络省长";
break;  
case 2:
$str1= "网络市长";
break;  
case 3:
$str1= "网络县长";
break;  
case 4:
$str1= "网络镇长";
break;
case 5:
$str1= "网络村长";
break;
default:
;
}




if (!empty($truename)){
$outStr .= "<li>".$str1.":$truename</li>";
}
if (!empty($phone)){
//$outStr .= "<li>电话:$phone</li>";
}
if (!empty($mobile)){
$outStr .= "<li>联系手机:$mobile </li>";
}

if (!empty($oicq)){
$outStr .= "<li>&nbsp;&nbsp;QQ号码:".$oicq."&nbsp;<a href=\"tencent://message/?uin=".$oicq."&Site=村镇网&Menu=yes\"><img border=0 src=\"/images/qq.jpg\" alt=\"QQ在线咨询\"></a></li>";
//$outStr .= "<li>QQ:".$oicq."&nbsp;<a target=_parent href=\"tencent://message/?Menu=yes&uin=".$oicq."&Site=村镇网&Service=200&sigT=2a0e37386280486ada2b5d5e69ee49186ccae1257fd9e1c9598af1f0b9c916067002a57aaaec8c8d\"><img border=0 src=\"/images/qq.jpg\" alt=\"QQ在线咨询\"></a>";
}
if (!empty($mobile)){
$outStr .= "<li>本镇广告发布请联系网络镇长</li>";
}

return $outStr;


}

/*
 * 当审核、取消审核某个信息时,要刷新某个其它表中相关的信息
 * typeid==0,是审核,typeid==1,是取消审核
 * hinfofun.php的CopyNews_all和NoCheckNews_all中调用过
 * 删除时不能用本函数刷新,因为内部要查询表
*/
function user_guanliando($classid1,$id,$typeid=0){
global $empire,$dbtbpre,$class_r;
$classid1 = (int)$classid1;
$id = (int)$id;

if ($classid1==10){/* 处理答案时更新问题页 */
if ($typeid==0){
$str = "select id,questionId from {$dbtbpre}ecms_answer where id = ".$id;
}elseif($typeid==1)
{
$str = "select id,questionId from {$dbtbpre}ecms_answer_check where id = ".$id;
}
$pr = $empire->fetch1($str);
if ($pr['questionId']){
//刷新
$questionId = $pr['questionId'];
$str_1 = "select * from {$dbtbpre}ecms_question where id='$questionId' limit 1";
$tr = $empire->fetch1($str_1);

echo "刷新".$questionId;
GetHtml(9,$tr[id],$tr,1,0);//刷新对应的问题页面
}
}

}





function user_loginForm($fromUrl){
//$strLoginForm = "user_loginForm";
echo "<script>location.href='/e/extend/user/userLoginForm.php?ecmsfrom=".$fromUrl."'</script>";
//return $strLoginForm;
}

/***********************************************************
 * Utf-8、gb2312都支持的汉字截取函数
 * cut_str(字符串, 截取长度, 开始长度, 编码);
 * 编码默认为 utf-8
 * 开始长度默认为 0
 * $str = "abcd需要截取的字符串";
 * echo cut_str($str,8,0,'gb2312');
************************************************************/

function cut_str($string, $sublen, $start = 0, $code = 'UTF-8',$showdot=0)
{
    if($code == 'UTF-8')
    {
        $pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
        preg_match_all($pa, $string, $t_string);

        if(count($t_string[0]) - $start > $sublen){ 
if ($showdot){
return join('', array_slice($t_string[0], $start, $sublen))."...";
}else{
return join('', array_slice($t_string[0], $start, $sublen));//."...";
}
}
        return join('', array_slice($t_string[0], $start, $sublen));
    }
    else
    {
        $start = $start*2;
        $sublen = $sublen*2;
        $strlen = strlen($string);
        $tmpstr = '';

        for($i=0; $i< $strlen; $i++)
        {
            if($i>=$start && $i< ($start+$sublen))
            {
                if(ord(substr($string, $i, 1))>129)
                {
                    $tmpstr.= substr($string, $i, 2);
                }
                else
                {
                    $tmpstr.= substr($string, $i, 1);
                }
            }
            if(ord(substr($string, $i, 1))>129) $i++;
        }
        if ($showdot){
if(strlen($tmpstr)< $strlen ) $tmpstr.= "...";
}
        return $tmpstr;
    }
}

/***********************************************************
 * 功能:检测用户是否登陆,未登陆的话显示登陆表单,jquery版 
 * 调用:
 * 模板:
 * 配套文件:<script type="text/javascript" src="/js/user/userLoginJquery.js"></script>
 * 详细说明:
************************************************************/
function user_jqueryLoginForm(){
$myuserid = (int)getcvar('mluserid');//get cookie
$myusername = RepPostVar(getcvar('mlusername'));
$userid = $myuserid;
$username = $myusername;
if (!$userid || !$username){
$strJqueryLoginForm .= "<form method=\"POST\" action=\"--WEBBOT-SELF--\">";
$strJqueryLoginForm .= "<div id=\"loginmsg\" class=\"msgAreaUserLogin\" >";
$strJqueryLoginForm .= "<input type=\"text\" name=\"username\" id=\"uname\" size=\"8\">&nbsp;";
$strJqueryLoginForm .= "密码:";
$strJqueryLoginForm .= "<input type=\"password\" name=\"password\" id=\"upwd\" size=\"8\">";
$strJqueryLoginForm .= "<input type=\"button\" value=\"登陆\" name=\"loginJquery\" id=\"btnLoginJquery\" >";
$strJqueryLoginForm .= "<input type=\"button\" value=\"注册\" name=\"loginJquery\" id=\"btnRegJquery\" >";
$strJqueryLoginForm .= "</div>";
$strJqueryLoginForm .= "<div class=\"msgArealoginMsg\" id=\"userloginMsg\" >...</div>";
$strJqueryLoginForm .= "</form>";

echo $strJqueryLoginForm;
}else{
return 1;
}


}

















/***********************************************************
 * 功能:取用户头像 
 * 调用:
 * 模板:
 * 配套文件:
 * 详细说明:
************************************************************/
function getUserPic($userid){
global $empire,$dbtbpre,$class_r;


$addr=$empire->fetch1("select * from {$dbtbpre}enewsmemberadd where userid='".$userid."' limit 1");
//头像
$userpic=$addr['userpic']?$addr['userpic']:$public_r[newsurl].'e/data/images/nouserpic.gif';
return $userpic;
}


/***********************************************************
 * 功能:检测实名认证必填项未完成个数,全完成的话返回0 
 *       只用于后台检测,前台要考虑并非所有的人都处在村级
 * 调用:user_CheckShiMingRenZhengMust($userid,5,0)
 user_CheckShiMingRenZhengMust($userid,4,0) //四级地区必选,关键联系方式必填
 user_CheckShiMingRenZhengMust($userid,5,1) //五级地区必选,所有联系方式等必填
 * 模板:
 * 配套文件:
 * 详细说明:
************************************************************/
function user_CheckShiMingRenZhengMust($userid,$typeid=5,$all=0){
global $empire,$dbtbpre,$class_r;
$errNum=0;//未填项的数目
$sqlstr = "select a.*, c.* from {$dbtbpre}enewsmember a, {$dbtbpre}enewsmemberadd c where a.userid='".$userid."' and a.userid = c.userid group by(a.userid)";
$rr=$empire->fetch1($sqlstr);

//地区设置
if ($typeid==5){
if ($rr[pid1]==0){$errNum +=1;}
if ($rr[pid2]==0){$errNum +=1;}
if ($rr[pid3]==0){$errNum +=1;}
if ($rr[pid4]==0){$errNum +=1;}
if ($rr[pid5]==0){$errNum +=1;}
}
else if ($typeid==4){
if ($rr[pid1]==0){$errNum +=1;}
if ($rr[pid2]==0){$errNum +=1;}
if ($rr[pid3]==0){$errNum +=1;}
if ($rr[pid4]==0){$errNum +=1;}
}
else if ($typeid==3){
if ($rr[pid1]==0){$errNum +=1;}
if ($rr[pid2]==0){$errNum +=1;}
if ($rr[pid3]==0){$errNum +=1;}
}
else if ($typeid==2){
if ($rr[pid1]==0){$errNum +=1;}
if ($rr[pid2]==0){$errNum +=1;}
}
else if ($typeid==1){
if ($rr[pid1]==0){$errNum +=1;}
}

//姓名为空
if (empty($rr[truename])){
$errNum +=1;
}

//电话
if (empty($rr[phone])){
$errNum +=1;
}

//手机
if (empty($rr[mobile])){
$errNum +=1;
}


//身份证号
if (empty($rr[code])){
$errNum +=1;
}

//身份证扫描件正面
if (empty($rr[sfzPhoto1])){
$errNum +=1;
}

//身份证扫描件背面
if (empty($rr[sfzPhoto2])){
$errNum +=1;
}

//
if ($all>0){
if (empty($rr[userPhoto])){$errNum +=1;}//生活照
if (empty($rr[address])){$errNum +=1;}//地址
if (empty($rr[oicq])){$errNum +=1;}//qq
}

return $errNum;

}


/******后台专用函数******************************8888*/
/***********************************************************
 * 功能:
 *       
 * 调用:user_admin_Check1($logininid,$loginin,$loginlevel,20,'1,2,3,4,5','/e/admin/extend/flxx/list_flxx_class.php',2);//用户组1,2,3,4,5可管理
 user_admin_Check1($logininid,$loginin,$loginlevel,20,'1,2,3,4,5','/e/admin/extend/flxx/list_flxx_class.php',3);//用户1,2,3,4,5可管理
 user_admin_Check1($logininid,$loginin,$loginlevel,20,'','(-1)',1);//1用户组可管理

 * 模板:
 * 配套文件:
 * 详细说明:$typeid=1,指定用户组可管理
 $typeid=2,指定的某几个用户组可管理
 $typeid=3,指定的某几个用户可管理
************************************************************/
function user_admin_Check1($userid=0,$username='',$userlevel=0,$mustUserLevel=1,$str=''/*逗号分隔的用户id或用户组id*/,$fromurl='',$typeid=0){
global $empire,$dbtbpre,$class_r;
if (empty($fromurl)){$fromurl="/e/admin/main.php";}
if ($typeid==0){$typeid=1;}

switch ($typeid)
{
case 1://mustLoginLevel用户组可管理本栏目
if ($userlevel!=$mustUserLevel){
printerror2("无权限管理",$fromurl,1);
}
break;  
case 2://,分隔的用户组可管理:1,2,3,4,5
if (!empty($str)){
if ( substr($str,0,1) == "," ){ //去左, 
$str = substr($str, 1, strlen($str)-1);//
}
if ( substr($str,-1,1) == "," ){ //去右, 
$str = substr($str,  0, strlen($str)-1);//
}
$ar = explode(",",$str);//放入数组

if (!in_array($userlevel, $ar)){/* 是否在 数组[1,2,3,4,5]中*/
printerror2("无权限管理",$fromurl,1);
}
}else{
printerror2("无权限管理",$fromurl,1);
}

break;  
case 3://,分隔的用户id可管理,在"1,2,3,4"中的用户可管理
if (!empty($str)){
if ( substr($str,0,1) == "," ){ //去左 | 
$str = substr($str, 1, strlen($str)-1);//
}

if ( substr($str,-1,1) == "," ){ //去右 | 
$str = substr($str,  0, strlen($str)-1);//
}
$ar = explode(",",$str);//放入数组

if (!in_array($userid, $ar)){/* 是否在 数组[1,2,3,4,5]中*/
printerror2("不在数组中,无权限管理",$fromurl,1);
}
}else{
printerror2("不在数组中,无权限管理",$fromurl,1);
}
break;  
case 4:
break;
case 5:
break;
default:
;
}



}
  评论这张
 
阅读(251)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017