弃用
This commit is contained in:
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
class txcloud_renlianClassModel extends txcloudModel
|
||||
{
|
||||
|
||||
public function inittxCloud()
|
||||
{
|
||||
$this->settable('wxtx_renlian');
|
||||
$this->groupid = $this->option->getval('txcloud_rlroupid');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 人脸检测
|
||||
*/
|
||||
public function DetectFace($url)
|
||||
{
|
||||
$chul = $this->DetectFaceInit($url);
|
||||
$barr = $this->send('DetectFace', $chul[0], $chul[1]);
|
||||
return $barr;
|
||||
}
|
||||
private function DetectFaceInit($url)
|
||||
{
|
||||
$chul = $chul1 = array();
|
||||
if(substr($url,0,4)=='http'){
|
||||
$chul['Url'] = $url;
|
||||
}else{
|
||||
$chul['Image'] = base64_encode(file_get_contents($url));
|
||||
$chul1['Image'] = $chul['Image'];
|
||||
}
|
||||
return array($chul, $chul1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取
|
||||
*/
|
||||
public function GetPersonList()
|
||||
{
|
||||
$barr = $this->send('GetPersonList', array(
|
||||
'GroupId' => $this->groupid,
|
||||
'Limit' => 1000
|
||||
));
|
||||
if($barr['success']){
|
||||
$data = $barr['data'];
|
||||
$PersonInfos = $data['PersonInfos'];
|
||||
$ids = '0';
|
||||
$ren = 0;
|
||||
foreach($PersonInfos as $k=>$rs){
|
||||
$ren++;
|
||||
$PersonId = $rs['PersonId'];
|
||||
$where = "`personid`='$PersonId'";
|
||||
$id1 = (int)$this->getmou('id', $where);
|
||||
if($id1==0)$where='';
|
||||
$this->record(array(
|
||||
'personid' => $PersonId,
|
||||
'personname' => $rs['PersonName'],
|
||||
'gender' => $rs['Gender'],
|
||||
'faceids' => join(',', $rs['FaceIds'])
|
||||
), $where);
|
||||
if($id1==0)$id1 = $this->db->insert_id();
|
||||
$ids .= ','.$id1.'';
|
||||
}
|
||||
$this->delete("`id` not in($ids)");
|
||||
return returnsuccess('共获取到'.$ren.'人');
|
||||
}
|
||||
return $barr;
|
||||
}
|
||||
|
||||
public function GetGroupList()
|
||||
{
|
||||
$barr = $this->send('GetGroupList');
|
||||
return $barr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除人脸用户
|
||||
*/
|
||||
public function deleteRenlian($id)
|
||||
{
|
||||
$rs = $this->getone("`id`='$id'");
|
||||
if(!$rs)return returnerror('不存在');
|
||||
|
||||
$barr = $this->send('DeletePerson', array(
|
||||
'PersonId' => $rs['personid']
|
||||
));
|
||||
if($barr['success']){
|
||||
$this->delete($id);
|
||||
}
|
||||
return $barr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建人脸用户
|
||||
*/
|
||||
public function createUser($arr)
|
||||
{
|
||||
$id = $arr['id'];
|
||||
$uid = $arr['uid'];
|
||||
$personname = $arr['personname'];
|
||||
$imgurl = $arr['imgurl'];
|
||||
if($this->rows("`uid`='$uid' and `id`<>'$id'")>0)return returnerror('该用户已经创建过了');
|
||||
$urs = m('admin')->getone("`id`='$uid' and `status`=1");
|
||||
if(!$urs)return returnerror('该用户不存在/停用了,请到用户管理查看');
|
||||
|
||||
if($id==0 && isempt($imgurl))return returnerror('请选择人脸图片地址');
|
||||
if(!isempt($imgurl) && substr($imgurl,0,4)!='http'){
|
||||
if(!file_exists($imgurl))return returnerror('人脸图片不存在');
|
||||
list($width, $height) = getimagesize($imgurl);
|
||||
if($width< 60 || $height<60)return returnerror('人脸图片像素至少60x60,当前:'.$width.'x'.$height.'');
|
||||
$size = filesize($imgurl);
|
||||
if($size>1*1024*1024)return returnerror('人脸图片不能大于1M');
|
||||
}
|
||||
|
||||
//检测人脸是否可以
|
||||
$barr = $this->DetectFace($imgurl);
|
||||
if(!$barr['success'])return $barr;
|
||||
|
||||
|
||||
if($id==0){
|
||||
$can = $this->DetectFaceInit($imgurl);
|
||||
$params = $can[0];
|
||||
$params['GroupId'] = $this->groupid;
|
||||
$params['PersonName'] = $personname;//姓名
|
||||
$params['PersonId'] = 'xinhu'.$urs['user'].'';
|
||||
$params['Gender'] = $urs['sex']=='男' ? '1': '2';
|
||||
|
||||
//接口创建
|
||||
$barr = $this->send('CreatePerson',$params, $can[1]);
|
||||
if(!$barr)return $barr;
|
||||
|
||||
|
||||
$id = $this->insert(array(
|
||||
'personname'=> $personname,
|
||||
'personid' => $params['PersonId'],
|
||||
'gender' => $params['Gender'],
|
||||
'uid' => $uid,
|
||||
'imgurl' => $imgurl,
|
||||
'faceids' => $barr['data']['FaceId'],
|
||||
));
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
|
||||
return returnsuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人脸搜索,用刷脸登录
|
||||
*/
|
||||
public function SearchFaces()
|
||||
{
|
||||
$can = $this->DetectFaceInit('images/wo.png');
|
||||
$params = $can[0];
|
||||
$params['GroupIds.0'] = $this->groupid;
|
||||
$barr = $this->send('SearchFaces', $params, $can[1]);
|
||||
|
||||
return $barr;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
class txcloudModel extends Model
|
||||
{
|
||||
private $SecretId = '';
|
||||
private $SecretKey = '';
|
||||
|
||||
//api地址[这个是人脸识别上的]
|
||||
public $apiurl = 'iai.tencentcloudapi.com';
|
||||
|
||||
public function inittxCloud(){}
|
||||
|
||||
public function initModel()
|
||||
{
|
||||
$this->option = m('option');
|
||||
$this->SecretId = $this->rock->jm->uncrypt($this->option->getval('txcloud_secretid'));
|
||||
$this->SecretKey = $this->rock->jm->uncrypt($this->option->getval('txcloud_secretkey'));
|
||||
$this->inittxCloud();
|
||||
}
|
||||
|
||||
//创建签名和参数
|
||||
private function createAuth($can = array())
|
||||
{
|
||||
$barr['Action'] = '';
|
||||
$barr['Region'] = ''; //地区
|
||||
$barr['SecretId'] = $this->SecretId;
|
||||
$barr['Timestamp'] = time();
|
||||
$barr['Nonce'] = rand(10000,99999);
|
||||
$barr['Version'] = '2018-03-01';
|
||||
foreach($can as $k=>$v)$barr[$k] = $v;
|
||||
|
||||
ksort($barr);
|
||||
$str = '';
|
||||
foreach($barr as $k=>$v)$str.='&'.$k.'='.$v.'';
|
||||
$str = substr($str, 1);
|
||||
$srcStr = 'POST'.$this->apiurl.'/?'.$str.'';
|
||||
|
||||
$signStr = base64_encode(hash_hmac('sha1', $srcStr, $this->SecretKey, true));
|
||||
|
||||
$barr['Signature'] = urlencode($signStr);
|
||||
return $barr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送请求 $Action方法,其他参数
|
||||
*/
|
||||
public function send($Action, $can = array(), $njcan=array())
|
||||
{
|
||||
if(isempt($this->SecretId) || isempt($this->SecretKey))return returnerror('没有完整配置腾讯云api密钥');
|
||||
|
||||
$can['Action'] = $Action;
|
||||
$params = $this->createAuth($can);
|
||||
$url = 'https://'.$this->apiurl.'';
|
||||
|
||||
foreach($njcan as $k=>$v)$params[$k]= urlencode($v);
|
||||
|
||||
$result = c('curl')->postjson($url, $params);
|
||||
|
||||
if(isempt($result))return returnerror('无法访问接口');
|
||||
$barr = json_decode($result, true);
|
||||
if(!isset($barr['Response']))return returnerror('返回出错'.$result.'');
|
||||
|
||||
$Response = $barr['Response'];
|
||||
if(isset($Response['Error'])){
|
||||
$error = $Response['Error'];
|
||||
return returnerror('error:'.$error['Message'].','.$error['Code'].'');
|
||||
}
|
||||
|
||||
return returnsuccess($Response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
|
||||
var c={
|
||||
init:function(){
|
||||
$.get(js.getajaxurl('getset','{mode}','{dir}'), function(s){
|
||||
var a=js.decode(s);
|
||||
get('txcloud_secretid_{rand}').value=a.secretid;
|
||||
get('txcloud_secretkey_{rand}').value=a.secretkey;
|
||||
get('txcloud_rlroupid_{rand}').value=a.rlroupid;
|
||||
});
|
||||
},
|
||||
save:function(o){
|
||||
var d={};
|
||||
d.secretid = get('txcloud_secretid_{rand}').value;
|
||||
d.secretkey = get('txcloud_secretkey_{rand}').value;
|
||||
d.rlroupid = get('txcloud_rlroupid_{rand}').value;
|
||||
js.msg('wait','保存中...');
|
||||
js.ajax(js.getajaxurl('setsave','{mode}','{dir}'), d, function(s){
|
||||
js.msg('success','保存成功');
|
||||
},'post');
|
||||
}
|
||||
};
|
||||
js.initbtn(c);
|
||||
c.init();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<div align="left">
|
||||
<div style="padding:10px;">
|
||||
|
||||
|
||||
|
||||
<table cellspacing="0" width="650" border="0" cellpadding="0">
|
||||
|
||||
<tr>
|
||||
<td align="right"><font color=red>*</font> API密钥SecretId:</td>
|
||||
<td class="tdinput"><input id="txcloud_secretid_{rand}" onblur="this.value=strreplace(this.value)" class="form-control"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right"><font color=red>*</font> API密钥SecretKey:</td>
|
||||
<td class="tdinput"><input id="txcloud_secretkey_{rand}" onblur="this.value=strreplace(this.value)" class="form-control">
|
||||
<font id="showddd_{rand}" color="#888888">请到<a href="https://console.cloud.tencent.com/cam/capi" target="_blank">[腾讯云管理后台]</a>下获取。</font>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><div class="inputtitle">产品应用设置</div></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">使用人脸人员库ID:</td>
|
||||
<td class="tdinput"><input onblur="this.value=strreplace(this.value)" id="txcloud_rlroupid_{rand}" class="form-control"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td align="right"></td>
|
||||
<td style="padding:15px 0px" colspan="3" align="left"><button click="save" class="btn btn-success" type="button"><i class="icon-save"></i> 保存</button>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
|
||||
var c = {
|
||||
|
||||
};
|
||||
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div id="view_{rand}"><h1>文件上传到腾讯云的对象存储中</h1><br>查看这个<a target="_blank" href="<?=URLY?>view_txcos.html">帮助</a>去配置。</div>
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
var a = $('#view_{rand}').bootstable({
|
||||
tablename:'wxtx_renlian',celleditor:true,fanye:true,statuschange:true,
|
||||
url:publicstore('{mode}','{dir}'),storebeforeaction:'beforeuserdshow',storeafteraction:'aftereuserdshow',
|
||||
columns:[{
|
||||
text:'姓名',dataIndex:'personname',sortable:true
|
||||
},{
|
||||
text:'人员库ID',dataIndex:'personid'
|
||||
},{
|
||||
text:'人脸图片数',dataIndex:'imgshu'
|
||||
},{
|
||||
text:'启用',dataIndex:'status',type:'checkbox',editor:true,sortable:true
|
||||
},{
|
||||
text:'关联OA用户ID',dataIndex:'uid',editor:true,type:'number'
|
||||
},{
|
||||
text:'关联OA用户姓名',dataIndex:'name'
|
||||
},{
|
||||
text:'关联OA用户部门',dataIndex:'deptallname'
|
||||
}],
|
||||
itemclick:function(){
|
||||
get('delbtn{rand}').disabled=false;
|
||||
},
|
||||
beforeload:function(){
|
||||
get('delbtn{rand}').disabled=true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var c = {
|
||||
search:function(){
|
||||
var s=get('key_{rand}').value;
|
||||
a.setparams({key:s},true);
|
||||
},
|
||||
getlist:function(){
|
||||
js.msg('wait','获取中...');
|
||||
js.ajax(js.getajaxurl('reloaduser','{mode}', '{dir}'),{}, function(d){
|
||||
if(d.success){
|
||||
js.msg('success', d.data);
|
||||
a.reload();
|
||||
}else{
|
||||
js.msg('msg', d.msg);
|
||||
}
|
||||
},'get,json');
|
||||
},
|
||||
delaluser:function(){
|
||||
a.del({url:js.getajaxurl('delrenlian','{mode}','{dir}')});
|
||||
},
|
||||
adduser:function(){
|
||||
var h = $.bootsform({
|
||||
title:'用户人脸',height:400,width:500,
|
||||
tablename:'wxtx_renlian',isedit:0,
|
||||
url:js.getajaxurl('createurenlian','{mode}','{dir}'),
|
||||
submitfields:'uid,personname',
|
||||
items:[{
|
||||
name:'uid',type:'hidden'
|
||||
},{
|
||||
labelText:'对应用户',type:'changeuser',changeuser:{
|
||||
type:'user',idname:'uid',title:'选择uid'
|
||||
},name:'personname',clearbool:true,required:true
|
||||
},{
|
||||
labelText:'人脸图片地址',name:'imgurl',blankText:'系统目录下图片,不能超过1M,60x60像素以上'
|
||||
}],
|
||||
success:function(){
|
||||
a.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="padding-right:10px"><button class="btn btn-primary" click="adduser" type="button"><i class="icon-plus"></i> 创建人员</button></td>
|
||||
<td style="padding-right:10px"><button class="btn btn-default" click="getlist" type="button">获取人脸用户库上人员</button></td>
|
||||
<td>
|
||||
<div class="input-group" style="width:250px;">
|
||||
<input class="form-control" id="key_{rand}" placeholder="姓名/关联用户部门">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" click="search" type="button"><i class="icon-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td width="90%" style="padding-left:10px">
|
||||
|
||||
</td>
|
||||
<td align="right" nowrap>
|
||||
<button class="btn btn-danger" disabled id="delbtn{rand}" click="delaluser" type="button">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="blank10"></div>
|
||||
<div id="view_{rand}"></div>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
class txcloudClassAction extends Action
|
||||
{
|
||||
|
||||
|
||||
public function setsaveAjax()
|
||||
{
|
||||
$secretid = $this->post('secretid');
|
||||
$secretkey = $this->post('secretkey');
|
||||
if(!contain($secretid,'****'))
|
||||
$this->option->setval('txcloud_secretid@-6', $this->jm->encrypt($secretid));
|
||||
if(!contain($secretkey,'****'))
|
||||
$this->option->setval('txcloud_secretkey@-6', $this->jm->encrypt($secretkey));
|
||||
|
||||
$this->option->setval('txcloud_rlroupid@-6', $this->post('rlroupid'));
|
||||
$this->backmsg();
|
||||
}
|
||||
|
||||
public function getsetAjax()
|
||||
{
|
||||
$arr= array();
|
||||
$arr['secretid'] = $this->option->getval('txcloud_secretid');
|
||||
$arr['secretkey'] = $this->option->getval('txcloud_secretkey');
|
||||
$arr['rlroupid'] = $this->option->getval('txcloud_rlroupid');
|
||||
if(!isempt($arr['secretid'])){
|
||||
$secretid = $this->jm->uncrypt($arr['secretid']);
|
||||
$arr['secretid'] = substr($secretid,0,5).'******'.substr($secretid,-5);
|
||||
}
|
||||
if(!isempt($arr['secretkey'])){
|
||||
$secretkey = $this->jm->uncrypt($arr['secretkey']);
|
||||
$arr['secretkey'] = substr($secretkey,0,5).'******'.substr($secretkey,-5);
|
||||
}
|
||||
echo json_encode($arr);
|
||||
}
|
||||
|
||||
//获取
|
||||
public function reloaduserAjax()
|
||||
{
|
||||
return m('txcloud:renlian')->GetPersonList();
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delrenlianAjax()
|
||||
{
|
||||
return m('txcloud:renlian')->deleteRenlian((int)$this->post('id','0'));
|
||||
}
|
||||
|
||||
public function beforeuserdshow($table)
|
||||
{
|
||||
$where = '';
|
||||
$key = $this->post('key');
|
||||
if(!isempt($key))$where=" and (a.`personname` like '%$key%' or b.`deptallname` like '%$key%')";
|
||||
return array(
|
||||
'where' => $where,
|
||||
'fields'=> 'a.*,b.name,b.deptallname',
|
||||
'table' => '`[Q]'.$table.'` a left join `[Q]admin` b on a.uid=b.id'
|
||||
);
|
||||
}
|
||||
public function aftereuserdshow($table, $rows)
|
||||
{
|
||||
foreach($rows as $k=>$rs){
|
||||
if($rs['uid']>0 && $rs['personname']!=$rs['name']){
|
||||
$rows[$k]['name'].='<font color=red>,关联的姓名不一样</font>';
|
||||
}
|
||||
if(!isempt($rs['faceids']))$rows[$k]['imgshu'] = count(explode(',', $rs['faceids']));
|
||||
}
|
||||
return array(
|
||||
'rows' => $rows
|
||||
);
|
||||
}
|
||||
//创建用户
|
||||
public function createurenlianAjax()
|
||||
{
|
||||
return m('txcloud:renlian')->createUser(array(
|
||||
'id' => (int)$this->post('id'),
|
||||
'uid' => (int)$this->post('uid'),
|
||||
'personname' => $this->post('personname'),
|
||||
'imgurl' => $this->post('imgurl'),
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user