thinkphp 3.2 代码如下:
public function view($ip,$port)
{
$zk = new \COM("zkemkeeper.ZKEM.1") or die("Unable to instanciate ZK");
if ($zk->Connect_Net($ip,$port)==false)
{
header("Content-Type:text/html;charset=UTF-8");
echo "设备连接失败!";
return;
}
else
{
$year=0;
$month=0;
$day=0;
$hour=0;
$minter=0;
$second=0;
$zk->GetDeviceTime(1,$year,$month,$day,$hour,$minter,$second);
$dtime="设备时间:{$year}-{$month}-{$day} {$hour}:{$minter}:{$second}";
$SerialNumber="";
$zk->GetSerialNumber(1,$SerialNumber);
$idwErrorCode="";
$bRead = $zk->ReadAllUserID(1);
If( $bRead == False )
{
$zk->GetLastError($idwErrorCode);
echo "人员信息下载失败,ErrorCode={$idwErrorCode}";
$zk->Disconnect();
Return;
}
$dwEnrollNumber='';
$dwName='';
$dwPassword='';
$dwPrivilege=1;
$dwEnabled=true;
$i=0;
$data=array();
$bUser = $zk->SSR_GetAllUserInfo(1,$dwEnrollNumber,$dwName,$dwPassword,$dwPrivilege,$dwEnabled);
While ($bUser == True)
{
$name=$text=iconv("GB2312","UTF-8",$dwName);
$data[$i]['workcode']=$dwEnrollNumber;
$data[$i]['name']=$name;
$data[$i]['password']=$dwPassword;
If ($dwPrivilege == 3)
{
$data[$i]['privilege']="管理员";
}
Else
{
$data[$i]['privilege']="普通用户";
}
$i++;
$bUser = $zk->SSR_GetAllUserInfo(1, $dwEnrollNumber, $dwName, $dwPassword, $dwPrivilege, $dwEnabled);
}
$zk->Disconnect();
}
$rst = array();
foreach ($data as $rowdata)
{
$rst[] = $rowdata['workcode'];
}
array_multisort($rst, SORT_ASC, $data);
$date=date("Y年m月d日",time());
$this->assign("date",$date);
$this->assign('dtime',$dtime);
$this->assign('serial',$SerialNumber);
$this->assign('list',$data);
$this->display();
}
模板文件:
{$dtime}
序列号:{$serial}
签到号
用户名
密码
权限
{$vo.workcode}
{$vo.name}
{$vo.password}
{$vo.privilege}