• <em id="6vhwh"><rt id="6vhwh"></rt></em>

    <style id="6vhwh"></style>

    <style id="6vhwh"></style>
    1. <style id="6vhwh"></style>
        <sub id="6vhwh"><p id="6vhwh"></p></sub>
        <p id="6vhwh"></p>
          1. 国产亚洲欧洲av综合一区二区三区 ,色爱综合另类图片av,亚洲av免费成人在线,久久热在线视频精品视频,成在人线av无码免费,国产精品一区二区久久毛片,亚洲精品成人片在线观看精品字幕 ,久久亚洲精品成人av秋霞

            PHP語言對接中控考勤機實現打卡推送

            更新時間:2023-12-09 21:24:06 閱讀: 評論:0

            2023年12月9日發(作者:教師節材料)

            -

            PHP語言對接中控考勤機實現打卡推送

            PHP語言對接中控考勤機實現打卡推送

            我選的框架是tp5.1

            考勤機型號:中控M880。固件版本:ver 6.5.4(build162)

            制造商:ZKTECO Inc

            mcu ver 27

            push 2.32

            camera ver V2.0,c2

            push文檔獲取:公眾號搜索 霖深時見露 回復 push文檔 獲取

            幾個要點,做這個功能的肯定都有push文檔。第一個路由對應到。 iclock/cdata。構造一個這樣的路由。apache下,可以選擇重寫,也

            可以選擇route改變路由。nginx下重寫一下路由。基本就可以了。下面貼代碼:

            <?php

            namespace appiclockcontroller;

            u thinkController;

            u thinkfacadeRequest;

            u appiclockmodelMechine;

            u appiclockmodelChecklog;

            u thinkfacadeLog;

            u appiclockmodelCmds;

            //u appmobilecontrollerPushcheck;

            class Cdata extends Controller

            {

            public function login()

            {

            //exit;

            $flag = json_encode(Request::param());

            $sn = Request::param('SN');

            file_put_contents('',$_EOL,FILE_APPEND);

            //1.判斷考勤機是否存在

            $res = Mechine::where('sn',$sn)->find();

            if($res)

            {

            //存在,先更新考勤機信息

            Mechine::where('sn',$sn)->update(['update_time'=>time()]);

            if(Request::param('options') == 'all')

            {

            //首次接收考勤機發來的消息

            $return = "GET OPTION FROM : {$sn}";

            $array = [

            'Stamp' => time(),

            'OpStamp' => time(),

            'PhotoStamp' => time(),

            'ErrorDelay' => 30,

            'Delay' => 30,

            'TransFlag' => '',

            'Realtime' => 1,

            'TransInterval'=>0,

            'Encrypt' => 0,

            'ServerVer' => '2.32 '.date('Y-m-d'),

            'ATTLOGStamp' => time(),

            'ATTPHOTOStamp'=>time(),

            ];

            ];

            $unix_time = date_default_timezone_t('GMT');

            header("HTTP/1.0 200 OK");

            header("Content-Type: text/plain");

            header("Date:".$unix_time);

            $string = "";

            foreach ($array as $key => $val)

            $return .= $key .'='.$_EOL;

            return $return;

            }

            el

            {

            if(Request::param('table') == 'ATTLOG')

            {

            //獲取刷卡時間和卡號

            $stamp = json_encode(Request::param('Stamp'));

            // file_put_contents('',$_EOL,FILE_APPEND);

            $text = json_encode(file_get_contents("php://input"));

            file_put_contents('',$_EOL,FILE_APPEND);

            return "ok";

            }

            elif(Request::param('table') == 'OPERLOG')

            {

            $stamp = json_encode(Request::param());

            //file_put_contents('',$_EOL,FILE_APPEND);

            $text = json_encode(file_get_contents("php://input"));

            // file_put_contents('',$_EOL,FILE_APPEND);

            return "ok";

            }

            elif(Request::param('table') == 'ATTPHOTO')

            {

            $text = file_get_contents("php://input");

            file_put_contents('',$text,FILE_APPEND);

            $str2 = substr($text,68);

            $filepath = 'attendance/';

            if(!is_dir($filepath))mkdir($filepath,0777,true);

            $filename=$().'.jpg';

            $tmp = explode('.jpg', $text);

            $pin = explode('-', $tmp[0]);

            $checktimetmp = $pin[0];

            $checktime = explode('=', $checktimetmp);

            $checktime = strtotime($checktime[1]);

            //pin:用戶工號

            $pin = $pin[1];

            if($pin){ //用戶驗證通過

            //sn:設備號

            $sntmp = explode('=', $text);

            $sn = str_replace('size', '', $sntmp[2]);

            $checklog = model('Checklog')->get(['pin'=>$pin,'checktime'=>$checktime,'sn'=>$sn]);

            if($checklog){

            return iconv("UTF-8", "GB2312//IGNORE", 'ok');

            }el{

            file_put_contents($filename,$str2);

            file_put_contents('',$_EOL,FILE_APPEND);

            $info = Cmds::get(function($query) u ($pin){

            $query->where(['pin'=>$pin,'status'=>1])->order('update_time desc')->field('card,student_name');

            });

            $card = $info->card;

            $student_name = $info->student_name;

            $model = new Checklog();

            $rs = $model->save(['pin'=>$pin,'checktime'=>$checktime,'pic'=>$filename,'sn'=>$sn,'card'=>$card,'student_name'=>$student_name]);

            if(!$rs){

            $rs = $model->save(['pin'=>$pin,'checktime'=>$checktime,'pic'=>$filename,'sn'=>$sn,'card'=>$card,'student_name'=>$student_name]);

            }

            //推送考勤信息

            //推送考勤信息

            // $this->ndTempletemsg($model->id);

            $this->https_request(''.config('domain').'/mobile/pushcheck/ndTempletemsg?checkid='.$model->id);

            }

            return iconv("UTF-8", "GB2312//IGNORE", 'ok');

            }

            /*結束*/

            }

            }

            }

            el

            {

            //不存在,寫入考勤機信息

            $data = ['sn' => $sn,'options'=>$flag,'create_time'=>time()];

            Mechine::inrt($data);

            }

            }

            function get_contents() {

            $filename=time().'.png';

            if(file_put_contents($filename,$xmlstr)){

            echo 'success';

            }el{

            echo 'failed';

            }

            }

            //兩個字符串之間的字符串

            public function str_between(){

            $str = 'DATA UPDATE USERINFO PIN=1tName=測試2tPasswd=123456tPri=14tsCard=[1985100]';

            $str1 = 'Name=';

            $str2 = 'tPasswd';

            $start = mb_strpos($str,$str1)+mb_strlen($str1);

            $end = mb_strpos($str,$str2);

            $length = $end-$start;

            dump($length);

            $needle = mb_substr($str,$start,$length,'utf8');

            dump($needle);

            return $needle;

            }

            $xmlstr = file_get_contents('php://input')?file_get_contents('php://input') : gzuncompress($GLOBALS['HTTP_RAW_POST_DATA']);//得到post過來的二進制原

            //發送考勤打卡推送模板消息

            public function ndTempletemsg($checkid){

            // $checkid = input('d'); //考勤打卡id

            $checkinfo = Checklog::get(intval($checkid)); //考勤打卡信息

            if(!$checkinfo)return;

            $card_sn = $checkinfo->card; //卡號

            $ur = model('ur')->get(array('card_sn'=>$card_sn)); //根據卡號查找學生信息

            if(!$ur)return;

            $ur_id = $ur->id;

            $parentinfo = model('wxur')->all(array('ur_id'=>intval($ur_id))); //查詢綁定了該學生的所有家長老師

            $access_token = $this->getWXToken();

            $url = '/cgi-bin/message/template/nd?access_token='.$access_token;

            foreach ($parentinfo as $key=>$value){

            $openid = $value->openid;

            $data = array(

            "tour"=>$openid,

            "template_id"=>"Y44crAtSKT47r8Cd5mnCM844vn7Iw6uVvU2Dq7p2tng",

            'url'=>''.config('domain').'/'.$checkinfo->pic,

            'data'=>array(

            'first'=>array(

            'first'=>array(

            'value'=>'您好,您有一條考勤消息提醒!',

            'color'=>'#41495e'

            ),

            'keyword1'=>array(

            'value'=>$ur['real_name'], //學生姓名

            ),

            'keyword2'=>array(

            'value'=>date('Y-m-d H:i:s',$checkinfo->checktime), //打卡時間

            ),

            'keyword3'=>array(

            'value'=>$checkinfo->status, //考勤狀態

            ),

            'keyword4'=>array(

            'value'=>$checkinfo->card, //接送卡號

            ),

            'keyword5'=>array(

            'value'=>$checkinfo->address, //地點

            ),

            "remark"=>array(

            'value'=>"點擊查看考勤圖片",

            'color'=>'#41495e'

            )

            )

            );

            $result = $this->https_request($url,json_encode($data));

            $result = json_decode($result,true);

            if($result['errcode'] == 0){

            //保存推送通知

            $model = new Checklog();

            $model->save(['pushstate'=>1],['id'=>$checkid]);

            return true;

            }el{

            //推送失敗 TODO

            return fal;

            }

            }

            }

            //獲取微信access_token

            public function getWXToken(){

            // error_reporting(E_ERROR | E_WARNING | E_PARSE);

            // $wxconfig = config('wxconfig');

            // $cache_file = dirname(__FILE__).'/../../../access_';

            // if(file_exists($cache_file)) $info = json_decode(file_get_contents($cache_file),true);

            // if($info['access_token'] && $info['expire_time']>time()){

            // return $info['access_token'];

            // }

            // $url = '/cgi-bin/token?grant_type=client_credential&appid='.$wxconfig['appid'].'&cret='.$wxconfig['appcret'];

            // $result = $this->https_request($url);

            // $data = json_decode($result,true);

            // if($data['access_token']){

            // $arr = array();

            // $arr['access_token'] = $data['access_token'];

            // $arr['expire_time'] = time() + 7000;

            // file_put_contents($cache_file,json_encode($arr));

            // return $data['access_token'];

            // }

            // el return '';

            }

            //https請求(支持GET和POST)

            public function https_request($url, $data = null){

            $curl = curl_init();

            curl_topt($curl, CURLOPT_URL, $url);

            curl_topt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

            curl_topt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);

            if (!empty($data)){ if (!empty($data)){ curl_topt($curl, CURLOPT_POST, 1); curl_topt($curl, CURLOPT_POSTFIELDS, $data); } curl_topt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_clo($curl); return $output; }}<?phpnamespace appiclockcontroller;u thinkController;u thinkfacadeRequest;u appiclockmodelCmds;class Getrequest extends Controller{ public function login(){ $sn = Request::param('SN'); // file_put_contents('',$_EOL,FILE_APPEND);// $check = Cmds::where('id',11)->find(); $check = Cmds::where('c_name','like','%DATA UPDATE USERINFO%')->where('status',0)->order('id asc')->find(); if(!$check)return fal; //轉換卡號,發送命令 $c_name = $this->changecard($check['c_name']); if($check['status'] == '0' && $check['sn'] == $sn) { $unix_time = date_default_timezone_t('GMT'); header("HTTP/1.0 200 OK"); header("Content-Type: text/plain"); header("Date:".$unix_time); $cmd = "C:{$check['c_id']}:{$c_name}".PHP_EOL; Cmds::where('id',$check['id'])->update(['update_time'=>time(),'status'=>1]); //把CMD的命令 $gbkcmd = iconv("UTF-8", "GB2312//IGNORE", $cmd); return $gbkcmd; } } //轉換卡號為16進制后重新組合 public function changecard($c_name){ $card = explode('sCard=',$c_name); $tmpc_name = $card[0]; $card = str_replace('[', '', $card[1]); $card = dechex(str_replace(']', '', $card)); //轉換成16進制 $str1 = substr($card, 0,2); $str2 = substr($card, 4,2); $str3 = substr($card, 2,2); $card = $str2.$str3.$str1; //重新排列后的卡號 $c_name = $tmpc_name.'sCard=['.$card.'0000]'; $c_name = str_replace('t',iconv("UTF-8", "GBK//IGNORE", "t") , $c_name); return $c_name; } public function hello($name = 'ThinkPHP5'){ return 'hello,' . $name; } public function test(){ $check = Cmds::where('c_name','like','%DATA UPDATE USERINFO%')->where('status',0)->order('id asc')->find(); dump($check); }} // "C:10:DATA UPDATE USERINFO cardno=tpin=32tpassword=123tgroup=0tstarttime=0tendtime=0tname=miketsuperauthorize=

            <?php

            namespace appiclockcontroller;

            u thinkController;

            u thinkfacadeRequest;

            class Devicecmd extends Controller

            {

            public function index()

            {

            $text = file_get_contents("php://input");

            if(stristr($text,'Return=0'))

            {

            $text = json_encode($text);

            file_put_contents('', $text . PHP_EOL, FILE_APPEND);

            $unix_time = date_default_timezone_t('GMT');

            header("HTTP/1.1 200 OK");

            header("Content-Type: text/plain");

            header("Date:" . $unix_time);

            // $cmd = "C:1:SHELL CMD_STRING".PHP_EOL;

            // return $cmd;

            return 'OK';

            }

            }

            public function hello($name = 'ThinkPHP5')

            {

            return 'hello,' . $name;

            }

            }

            之后的邏輯可以自己按需求來寫

            -

            PHP語言對接中控考勤機實現打卡推送

            本文發布于:2023-12-09 21:24:06,感謝您對本站的認可!

            本文鏈接:http://www.newhan.cn/zhishi/a/1702128246241129.html

            版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。

            本文word下載地址:PHP語言對接中控考勤機實現打卡推送.doc

            本文 PDF 下載地址:PHP語言對接中控考勤機實現打卡推送.pdf

            標簽:考勤機   推送   考勤   打卡
            留言與評論(共有 0 條評論)
               
            驗證碼:
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實用文體寫作網旗下知識大全大全欄目是一個全百科類寶庫! 優秀范文|法律文書|專利查詢|
            主站蜘蛛池模板: 国产一区二区爽爽爽视频| 免费国产一级 片内射老| 国产精品中文字幕观看| 亚洲国产精品13p| 亚洲国产成人自拍视频网| 最新亚洲人成无码网站欣赏网| 亚洲精品国产老熟女久久| 久久精品成人免费看| 欧美黑吊大战白妞| 少妇爽到爆视频网站免费| 拔萝卜视频播放在线观看免费| 国产福利社区一区二区| 伊伊人成亚洲综合人网7777| 精品国产迷系列在线观看| 91精品国产综合久久精品| 成人久久精品国产亚洲av| 少妇人妻偷人精品免费| 欧美三级欧美成人高清| 人妻中文字幕精品系列| 亚洲av产在线精品亚洲第一站| jizzjizz少妇亚洲水多| 一区二区久久精品66国产精品| 亚洲岛国成人免费av| 人妻另类 专区 欧美 制服| 国产成人精品久久一区二区| 夜色福利站WWW国产在线视频| 亚洲一本大道在线| 亚洲av麻豆aⅴ无码电影| 精品人妻少妇一区二区三区| 色综合天天综合网天天看片| 91麻豆国产精品91久久久| 国产精品日日摸夜夜添夜夜添2021| 国产精品视频久久| 国产激情艳情在线看视频| 欧美激情黑人极品hd| 韩国免费a级毛片久久| 国产精品99久久免费观看 | 日韩精品中文字幕有码| 中文字幕人妻精品在线| 中文字幕久久精品一区二区三区| 男女爽爽无遮挡午夜视频|