[求助]限制用户浏览的问题? |
如果后台发表的信息限制用户的话,前台只有登陆的部门用户才能查看,就这样一个功能,困扰了我近半个月了,求大家帮忙解决~
以下是functions.inc的源代码,如果还需要其他代码,请回复告知~
<?
//验证用户的访问权限
function acl_verify($acl,$user_id)
{
$people=explode(",",$acl);
if(isset($people))
{
for($index=0;$index < count($people);$index++)
{
if(strlen(trim($people[$index]))!=0)
{
if(substr($user_id,0,strlen(trim($people[$index])))==trim($people[$index]))
return "1";
}
}
return "0";
}
else
{
return "0";
}
}
//列出单位信息表中最新的5条信息
function list_news($conn,$unit_id,$user_id,$img_src,$startx,$starty)
{
if(strlen(trim($col_id))=="")
return "***";
if(strlen(trim($unit_id))=="")
return "***";
$result=mysql_query("select * from tb".$unit_id." ORDER BY info_id DESC limit $startx,$starty",$conn);
if ($myrow = mysql_fetch_array($result))
{
do
{
$infoURL="javascript:openwin('show.php?id=".$myrow["info_id"]."&unit_id=$unit_id')";
if(strlen(trim($myrow["file_url"]))!=0)
{
$infoURL=$myrow["file_url"];
}
else
{
$infoURL="javascript:openwin('http://192.168.58.254/show.php?id=".$myrow["info_id"]."&unit_id=$unit_id')";
}
$l_m=intval(date("m",strtotime($myrow["info_date"])));
$l_d=intval(date("d",strtotime($myrow["info_date"])));
$l_date="".$l_m."-".$l_d."";
if(!strlen(trim($myrow["info_acl"]))==0)
{
if(acl_verify($myrow["info_acl"],$user_id))
{
echo "<tr height=20><td><img border=0 src=$img_src><font color=red> [密] </font><a href=$infoURL title='".$myrow["info_subject"]."'>".substr($myrow["info_subject"],22)."</a>$download [".substr(get_usercnname($conn,$myrow["user_id"]),4).$l_date."]"."</td></tr>";
}
else{ echo "<tr height=20><td><img border=0 src=$img_src> <font color=red>[密] </font><font color=green>内部资料请登录后查看! [".substr(get_usercnname($conn,$myrow["user_id"]),4).$l_date."]</font></td></tr>\n";
}
}
else
echo "<tr height=20><td><img border=0 src=$img_src> <a href=$infoURL title='".$myrow["info_subject"]."'>".substr($myrow["info_subject"],0,28)."</a>$download [".substr(get_usercnname($conn,$myrow["user_id"]),4).$l_date."]"."</td></tr>\n";
} while ($myrow = mysql_fetch_array($result));
}
else
{
return "***";
}
}
?> |
|
|