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}
你好!我在学习php com组件的,按照你的例子我获取到了登录跟数据,跟其他信息,php7版本上的会报类型参数数目不对,改用php5.6版本一切正常使用,但是这些都不是我想要的具体的功能,还望您不吝赐教,注册好需要触发的实时事件 后我该如何处理获得事实数据,
我找到了我想要的触发实时事件了
class EventMask {
function OnAttTransactionEx($EnrollNumber,$IsInValid,$AttState,$VerifyMode,$Year,$Month,$Day,$Hour,$Minute,$Second,$WorkCode){
echo $EnrollNumber.' , '.$IsInValid.' , '.$AttState.' , '.$VerifyMode.' , '.$Year.' , '.$Month.' , '.$Day.' , '.$Hour.' , '.$Minute.' , '.$Second.' , '.$WorkCode.PHP_EOL;
}
}
while($zk->ReadRTLog(1) === True){
$GetRT = $zk->GetRTLog(1);
$coms = new EventMask();
com_event_sink($zk,$coms,"zkemkeeper.ZKEM");
sleep(2);
}
只能触发一个事件就是 OnAttTransactionEx 当验证通过时触发该事件
感谢你的文章对我的帮助!谢谢