<?php
/**
  * @method 图像识别
  * @author soul
  * @copyright 2016/3/31
  */
class MainOcr
{
	/**
	  * @method 飞浆OCR
	  * @param  $image     string  [必填] 图片内容base64
	  * @param  $ocrCfg     array  [选填] ['type'=>'', 'rotate'=>0, 'timeout'=>5]
											type--空(默认)只返回文本  all:返回位置信息
											rotate--旋转角度 默认不旋转 0~360
											timeout--超时时间  默认5秒
											style--识别类型  cn en vin
	  * @author soul
	  * @copyright 2022/12/12
	  * @return
			{"status":false,"data":["中国","浙江豪情汽车制造有限公司","制造","LB37742Z8NB005901","品牌：吉利","整车型号：HQ6453D24","发动机型号：JLE-4G18TDC","乘坐人数：5","发动机最大净功率：135kW","发动机排量：1799mL","最大允许总质量：2065kg","制造年月：2022年1月"],"code":0}
			all:{"status":false,"data":[{"text":"中国","match":0.8273949,"pos":[[139,501],[204,501],[204,536],[139,536]]},{"text":"浙江豪情汽车制造有限公司","match":0.9060057,"pos":[[223,502],[611,500],[611,531],[223,533]]},{"text":"制造","match":0.9990343,"pos":[[636,498],[711,498],[711,537],[636,537]]},{"text":"LB37742Z8NB005901","match":0.8950925,"pos":[[241,543],[596,543],[596,574],[241,574]]},{"text":"品牌：吉利","match":0.97945106,"pos":[[132,610],[300,610],[300,648],[132,648]]},{"text":"整车型号：HQ6453D24","match":0.91018957,"pos":[[419,618],[628,618],[628,646],[419,646]]},{"text":"发动机型号：JLE-4G18TDC","match":0.9535794,"pos":[[141,657],[362,657],[362,685],[141,685]]},{"text":"乘坐人数：5","match":0.90769553,"pos":[[416,660],[536,660],[536,688],[416,688]]},{"text":"发动机最大净功率：135kW","match":0.9529975,"pos":[[142,695],[387,699],[387,727],[142,723]]},{"text":"发动机排量：1799mL","match":0.93510383,"pos":[[416,696],[619,701],[618,730],[415,725]]},{"text":"最大允许总质量：2065kg","match":0.98247397,"pos":[[143,734],[380,738],[380,766],[143,762]]},{"text":"制造年月：2022年1月","match":0.95226,"pos":[[419,736],[621,739],[621,770],[419,767]]}],"code":0}
	  */
	public function paddleOcr($image, $ocrCfg = [])
	{
		$wordArr = [];
		if(empty($ocrCfg['type'])) $ocrCfg['type'] = '';
		if(empty($ocrCfg['rotate'])) $ocrCfg['rotate'] = 0;
		if(empty($ocrCfg['timeout'])) $ocrCfg['timeout'] = 5;
		if(empty($ocrCfg['style'])) $ocrCfg['style'] = 'cn';
		
		if(empty(mvc::$cfg['OCR']['paddleOcr']['url_'.$ocrCfg['style']]))
			return LibFc::ReturnData(false, '识别类型'.$ocrCfg['style'].'尚未配置');
		$url = mvc::$cfg['OCR']['paddleOcr']['url_'.$ocrCfg['style']];
		$LibHttp = new LibHttp();
		$LibHttp->timeout = $ocrCfg['timeout'];
		if($ocrCfg['rotate'] > 0){
			//本地服务器直接转图
			$OthImg = new OthImg(100);
			$tempFile = mvc::$cfg['PATH_CACHE'].md5($image).'_'.$ocrCfg['rotate'].'.jpg';
			file_put_contents($tempFile, base64_decode($image));
			$OthImg->rotate($tempFile, $tempFile, $ocrCfg['rotate'], '#ffffff');
			$image = base64_encode(file_get_contents($tempFile));
			@unlink($tempFile);
		}
		if(strlen($image) < 300) return LibFc::ReturnData(true, $wordArr);
		$LibHttp->httpheader = ['Content-Type:application/json'];
		$html = $LibHttp->fetch($url, json_encode(["image"=>$image]));
		$data = json_decode($html, true);
		if(is_array($data['data']) && $data['status']){
			if($ocrCfg['type'] == 'all'){
				$wordArr = $data['data'];
			}else{
				$wordArr = array_column($data['data'], 'text');
			}
			return LibFc::ReturnData(true, $wordArr);
		}else if(stripos($html, 'image file')){
			return LibFc::ReturnData(true, $wordArr);
		}else{
			return LibFc::ReturnData(false, 'Ocr'.$html);
		}
	}


	/**
	  * @method 获取图片的角度
	  * @param  $image     string  [必填] 图片内容base64
	  * @author soul
	  * @copyright 2024/8/16
	  * @return
	  */
	public function getAngle($image)
	{
		$LibHttp = new LibHttp();
		$LibHttp->timeout = 3;
		$LibHttp->httpheader = ['Content-Type:application/json'];
		$html = $LibHttp->fetch(mvc::$cfg['OCR']['angle']['url'], json_encode(["image"=>$image]));
		$data = json_decode($html, true);
		if(is_array($data) && $data['status']){
			if(isset($data['data'][0]['angle'])){
				return LibFc::ReturnData(true, $data['data'][0]['angle']);
			}else{
				return LibFc::ReturnData(false, '角度识别失败');
			}
		}else{
			return LibFc::ReturnData(false, 'Angle'.$html);
		}
	}


	/**
	  * @method 获取vin图片的类别
	  * @param  $image     string  [必填] 图片内容base64
	  * @author soul
	  * @copyright 2024/8/16
	  * @return 
		"mp"=>'铭牌',
		"xsz"=>"行驶证",
		"vin"=>'仅VIN',
		"cp"=>'车牌',
		"hgz"=>'合格证',
		"djzs"=>'登记证书',
		"fp"=>'发票',
		"tool"=>'应用工具',
		"oth"=>'其它',
	  */
	public function vinCls($image)
	{
		$LibHttp = new LibHttp();
		$LibHttp->timeout = 3;
		$LibHttp->httpheader = ['Content-Type:application/json'];
		$html = $LibHttp->fetch(mvc::$cfg['OCR']['clsvin']['url'], json_encode(["image"=>$image]));
		$data = json_decode($html, true);
		if(is_array($data) && $data['status']){
			if(isset($data['data'][0]['label'])){
				return LibFc::ReturnData(true, $data['data'][0]['label']);
			}else{
				return LibFc::ReturnData(false, '角度识别失败');
			}
		}else{
			return LibFc::ReturnData(false, 'vinCls'.$html);
		}
	}


	/**
	  * @method 获取VIN信息区域
	  * @param  $image     string  [必填] 图片内容base64
	  * @author soul
	  * @copyright 2024/8/16
	  * @return
	  */
	public function getVinInfoArea($image)
	{
		$LibHttp = new LibHttp();
		$LibHttp->timeout = 3;
		$LibHttp->httpheader = ['Content-Type:application/json'];
		$html = $LibHttp->fetch(mvc::$cfg['OCR']['area']['url'], json_encode(["image"=>$image]));
		$data = json_decode($html, true);
		if(is_array($data) && $data['status']){
			if(isset($data['data'][0]) && $data['data'][0]['label']  == 'area'){
				return LibFc::ReturnData(true, $data['data'][0]);
			}else{
				return LibFc::ReturnData(true, []);
			}
		}else{
			return LibFc::ReturnData(false, 'VinInfoArea'.$html);
		}
	}


	/**
	  * @method 通用文字识别
	  * @param  image              string  图片内容base64   image || url 二选一
	  * @param  url                string  图片URL
	  * @author soul
	  * @copyright 2017/8/16
	  * @return
	  */
	public function general($imageData, $imageUrl = '', $style = 1)
	{
		$arr = [];
		//兼容旧模式
		if(is_array($imageData) && !empty($imageData['data']))
		{
			$imageData = $imageData['data'];
		}
		else if(!empty($imageUrl))
		{
			$imageData = base64_encode(file_get_contents($imageUrl));
		}
		if(!empty($imageData))
		{
			$ocrRes = $this->paddleOcr($imageData);
			$arr = $ocrRes['data'];
			/*$ocrRes = $this->baiduOcr($imageData, $style);
			$arr = $ocrRes['data']['words'];*/
		}
		return LibFc::ReturnData(true, $arr);
	}
	
	/**
	  * @method VIN识别
	  * @param  image              string  图片内容base64   base64_encode(file_get_contents('D:\www\ocr/ocr.jpg'))
	  * @param  oths             ['site'=>'yt', 'issmall'=>0, 'nocoll'=>false] site(wt:文通   yt:译图 默认) issmall(是否为裁剪后的图 1|0 默认0)  nocoll:不收集 默认收集
	  * @author soul
	  * @copyright 2017/8/16
	  * @return
			成功：['status'=>true, 'data'=>vin]
			失败：['status'=>false, 'data'=>'xxx', 'code'=>'xxx']
	  */
	public function vin($imageData, $oths = ['site'=>'yt', 'issmall'=>0], $run = 0)
	{
		$vin = '';
		if(!empty($imageData))
		{
			if($oths['site'] == 'wt')
			{
				$url = mvc::$cfg['HOST']['vinocr'];
				$jsonStr = '{"username":"test","paramdata":"'.$imageData.'==##2007==##==##NULL","signdata":"NULL","imgtype":"jpg"}';
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_URL, $url);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				curl_setopt($ch, CURLOPT_HTTPHEADER, array(
						'Content-Type: text/plain;charset=UTF-8',
						'Content-Length: ' . strlen($jsonStr)
					)
				);
				$html = curl_exec($ch);
				curl_close($ch);
				if(preg_match('/\[CDATA\[([0-9a-zA-Z]{17})\]\]/', $html, $mat))
				{
					$vin = LibFc::FormatVin($mat[1]);
				}
			}
			else
			{
				$oths['site'] = 'yt';
				$url = mvc::$cfg['HOST']['vinocrYt'];
				$post = [
					'filedata'=>$imageData,
					'pid'=>1,
					'image_base'=>false
				];
				$post = http_build_query($post);
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_URL, $url);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
				$html = curl_exec($ch);
				curl_close($ch);
				$data = json_decode($html, true);
				
				if(is_array($data['PageInfo']) && !empty($data['PageInfo'][0]['Result'][0]['VIN'])){
					$vin = LibFc::FormatVin($data['PageInfo'][0]['Result'][0]['VIN']);
					if(strlen($vin) != 17) $vin = '';
				}else{
					$run++;
					$maxrun = stripos($html, '服务异常')? 5: 3;
					if($run < $maxrun){
						return $this->vin($imageData, $oths, $run);
					}
				}
			}
			if(!empty($vin) && empty($oths['issmall']) && empty($oths['nocoll']))
			{
				$ok = true;
				if(in_array(substr($vin, 0, 1), ['L', 'H']))
				{
					$check = LibFc::VinCheckCode($vin);
					if(!$check['ok']) $ok = false;
				}
				if($ok)
				{
					$YpwVin = new YpwVin();
					$YpwVin->collOcrVinImg($vin, $imageData, ['vinocr'=>$oths['site']]);
				}
			}	
		}
		return LibFc::ReturnData(true, $vin);
	}

	

	
	/**
	*$style = 2  高精度
	*/
	public function baiduOcr($imageData, $style = 1, $ocrkey=null)
	{
		require_once mvc::$cfg['AUTOLOAD']['Main']['path'].'lib/AipOcr.php';
		$returnArr = ['html'=>'', 'words'=>[]];
		if(empty($ocrkey) && $style == 1 && !empty(mvc::$cfg['OCR']['baidu_general']))
			$ocrkey = 'baidu_general';
		if(empty($ocrkey))
		{
			$APP_ID = mvc::$cfg['OCR']['baidu']['APP_ID'];
			$API_KEY = mvc::$cfg['OCR']['baidu']['API_KEY'];
			$SECRET_KEY = mvc::$cfg['OCR']['baidu']['SECRET_KEY'];
		}
		else
		{
			$APP_ID = mvc::$cfg['OCR'][$ocrkey]['baidu']['APP_ID'];
			$API_KEY = mvc::$cfg['OCR'][$ocrkey]['baidu']['API_KEY'];
			$SECRET_KEY = mvc::$cfg['OCR'][$ocrkey]['baidu']['SECRET_KEY'];
		}
		if($style == 2)
		{
			$YpwBase = new YpwBase();
			$date = date('Ymd');
			$hasres = $YpwBase->get('zz_ocr_tj', ['zot_count'], sprintf(" and zot_by='baidu' and zot_date=%d and zot_account='%s' limit 1", $date, $APP_ID), true);
			if(!empty($hasres['data']))
			{
				if($hasres['zot_count'] >= 500)
					return LibFc::ReturnData(true, $returnArr);
				$YpwBase->set('zz_ocr_tj', ['zot_count'=>'#@zot_count+1'], sprintf(" and zot_by='baidu' and zot_date=%d and zot_account='%s'", $date, $APP_ID));
			}
			else
			{
				$YpwBase->add('zz_ocr_tj', ['zot_account'=>$APP_ID, 'zot_count'=>1, 'zot_by'=>'baidu', 'zot_date'=> $date]);
			}
			$aipOcr = new AipOcr($APP_ID, $API_KEY, $SECRET_KEY);
			$res = $aipOcr->basicAccurate(base64_decode($imageData));
		}
		else
		{
			$aipOcr = new AipOcr($APP_ID, $API_KEY, $SECRET_KEY);
			$res = $aipOcr->basicGeneral(base64_decode($imageData));
		}

		$returnArr['html'] = json_encode($res);
		if(!empty($res['words_result']))
		{
			foreach($res['words_result'] as $v)
			{
				$returnArr['words'][] = $v['words'];
			}
		}
		return LibFc::ReturnData(true, $returnArr);
	}


	public function aliOcr($imageData)
	{
		$host = "http://tysbgpu.market.alicloudapi.com";
		$path = "/api/predict/ocr_general";
		$method = "POST";
		$headers = array();
		array_push($headers, "Authorization:APPCODE " . mvc::$cfg['OCR']['ali']['AppCode']);
		array_push($headers, "Content-Type".":"."application/json; charset=UTF-8");
		$bodys = "{\"image\":\"{$imageData}\", \"configure\":\"{ \\\"min_size\\\" : 16,\\\"output_prob\\\" : true }\"}";
		$url = $host . $path;
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($curl, CURLOPT_FAILONERROR, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
		$html = curl_exec($curl);
			
		/*$html = <<<EOT
				{"request_id":"20171209171015_31500f2a7c745c3288b01b045cf18499","ret":[{"prob":0.99653244018554688,"rect":{"angle":-90,"height":547.9998779296875,"left":590.49993896484375,"top":1,"width":46.999992370605469},"word":"1华人民共和国机动车行驶证"},{"prob":0.97597038745880127,"rect":{"angle":-90,"height":598,"left":592.5,"top":1,"width":29},"word":"Vchicle License of the People's Republic of China"},{"prob":0.96769171953201294,"rect":{"angle":0,"height":24.999996185302734,"left":176,"top":176,"width":112.99998474121094},"word":"号牌号码"},{"prob":0.93704187870025635,"rect":{"angle":0,"height":34.999992370605469,"left":290,"top":171,"width":173.99996948242188},"word":"粤AF51K8"},{"prob":0.93451964855194092,"rect":{"angle":-90,"height":108,"left":590.5,"top":137.5,"width":27},"word":"车辆类型"},{"prob":0.92800688743591309,"rect":{"angle":-90,"height":144,"left":764,"top":121,"width":40},"word":"型轿车"},{"prob":0.92212378978729248,"rect":{"angle":-90,"height":90,"left":216,"top":169,"width":18},"word":"Plate No."},{"prob":0.91793966293334961,"rect":{"angle":-90,"height":114,"left":590.5,"top":161.5,"width":23},"word":"Vehicle Type"},{"prob":0.90497171878814697,"rect":{"angle":0,"height":36.999992370605469,"left":174.00001525878906,"top":247,"width":245.99996948242188},"word":"所有人齐新貌"},{"prob":0.90324199199676514,"rect":{"angle":-90,"height":62,"left":199.5,"top":258.5,"width":17},"word":"Ownel"},{"prob":0.89728450775146484,"rect":{"angle":0,"height":42,"left":285,"top":319,"width":397},"word":"广东省广州市白云区"},{"prob":0.89592772722244263,"rect":{"angle":-90,"height":80,"left":204,"top":326,"width":20},"word":"Address"},{"prob":0.89589804410934448,"rect":{"angle":-90,"height":121,"left":333.5,"top":352.5,"width":36},"word":"非营运"},{"prob":0.88539952039718628,"rect":{"angle":-90,"height":426,"left":707,"top":204,"width":40},"word":"型号丰田牌GTM718CHEV"},{"prob":0.88193130493164062,"rect":{"angle":0,"height":18.999996185302734,"left":479,"top":432,"width":63.999992370605469},"word":"Model"},{"prob":0.87985867261886597,"rect":{"angle":-90,"height":160,"left":452.5,"top":410.5,"width":31},"word":"车辆识别代号"},{"prob":0.86077326536178589,"rect":{"angle":-90,"height":358,"left":743.5,"top":312.5,"width":39},"word":"LVGBY80E8GG020152"},{"prob":0.85261762142181396,"rect":{"angle":0,"height":52,"left":172,"top":471,"width":200},"word":"广东省广州"},{"prob":0.84021192789077759,"rect":{"angle":-90,"height":132,"left":438.5,"top":498.5,"width":29},"word":"发动机号码"},{"prob":0.83605575561523438,"rect":{"angle":0,"height":39,"left":553,"top":548,"width":147},"word":"9125857"},{"prob":0.83428102731704712,"rect":{"angle":-88.7939453125,"height":191.96800231933594,"left":241.68899536132812,"top":472.300537109375,"width":49.652156829833984},"word":"市公安局交"},{"prob":0.8298075795173645,"rect":{"angle":-90,"height":110,"left":428,"top":539,"width":26},"word":"Engine No."},{"prob":0.81826317310333252,"rect":{"angle":0,"height":54,"left":161,"top":612,"width":200},"word":"通警察支队"},{"prob":0.8139156699180603,"rect":{"angle":-90,"height":111,"left":423.5,"top":585.5,"width":28},"word":"注册日期"},{"prob":0.79895645380020142,"rect":{"angle":0,"height":43,"left":496,"top":626,"width":221},"word":"2016-69-07"},{"prob":0.79865550994873047,"rect":{"angle":-90,"height":108,"left":970.5,"top":600.5,"width":43},"word":"09-07"},{"prob":0.75275617837905884,"rect":{"angle":0,"height":21.999996185302734,"left":375,"top":658,"width":109.99998474121094},"word":"RegisterDate"},{"prob":0.73763513565063477,"rect":{"angle":0,"height":20,"left":724,"top":666,"width":102},"word":"Issue Date"}],"success":true}
EOT;*/
		$returnArr['html'] = json_encode($html);
		$htmlArr = json_decode($html, true);
		if(is_array($htmlArr) && !empty($htmlArr['ret']))
		{
			foreach($htmlArr['ret'] as $v)
			{
				$returnArr['words'][] = $v['word'];
			}
		}
		return LibFc::ReturnData(true, $returnArr);
	}


	public function tengXunOcr($imageData)
	{
		require_once mvc::$cfg['AUTOLOAD']['Main']['path'].'lib/tengxun/autoload.php';
		$appid = mvc::$cfg['OCR']['tengxun']['appid'];
		$secretId = mvc::$cfg['OCR']['tengxun']['secretId'];
		$secretKey = mvc::$cfg['OCR']['tengxun']['secretKey'];
		$bucket = mvc::$cfg['OCR']['tengxun']['bucket'];

		$client = new QcloudImage\CIClient($appid, $secretId, $secretKey, $bucket);
		$client->setTimeout(30);
		$html = $client->generalDetect(array('buffer'=>$imageData));
		/*$html = <<<EOT
{"code":0,"message":"OK","data":{"session_id":"1255628073388539375","items":[{"itemcoord":{"x":116,"y":115,"width":1419,"height":158},"itemstring":"LFV3A23COH3131833","words":[{"character":"L","confidence":0.99873834848404},{"character":"F","confidence":0.99993014335632},{"character":"V","confidence":0.99781930446625},{"character":"3","confidence":0.99772971868515},{"character":"A","confidence":0.97299259901047},{"character":"2","confidence":0.99998688697815},{"character":"3","confidence":0.99999916553497},{"character":"C","confidence":0.99831187725067},{"character":"O","confidence":0.55792218446732},{"character":"H","confidence":0.99984776973724},{"character":"3","confidence":0.9999988079071},{"character":"1","confidence":0.99977725744247},{"character":"3","confidence":0.99999845027924},{"character":"1","confidence":0.99999356269836},{"character":"8","confidence":0.9999395608902},{"character":"3","confidence":0.99999678134918},{"character":"3","confidence":0.99998414516449}]}]},"http_code":200}
EOT;*/
		$returnArr['html'] = $html;
		$htmlArr = json_decode($html, true);
		if(is_array($htmlArr) && !empty($htmlArr['data']['items']))
		{
			foreach($htmlArr['data']['items'] as $v)
			{
				$returnArr['words'][] = $v['itemstring'];
			}
		}
		return LibFc::ReturnData(true, $returnArr);
	}

	
	/**
	  * @method 车牌/行驶证/铭牌、车架号识别
	  * @param  $type           string [必填] numplate:车牌 driving:行驶证  vin:车架号
	  * @param  $image          string [image、url二选一] base64_encode(file_get_contents('D:\www\ocr/ocr.jpg'))
	  * @param  $url            string [image、url二选一] 图片URL
	  * @author soul
	  * @copyright 2023/9/23
	  * @return 
		numplate:{"status":true,"data":{"color":"blue","numplate":"京NAV888"},"code":0,"runtime":418}
		driving:{"status":true,"data":{"numplate":"京AA5599","vin":"HHGHH555778802669","addr":"北京市石景山区","gxb":"讴歌牌GHA7150JAD5B","vtype":"小型轿车","owner":"王京","usetype":"非营运","engnum":"112244"},"code":0,"runtime":1082}
		vin:{"status":true,"data":{"vin":"HHGHH555778802669"},"code":0,"runtime":2268}
	  */
	public function vehicle($type, $image = '', $url = '')
	{
		require_once mvc::$cfg['AUTOLOAD']['Main']['path'].'lib/AipOcr.php';
		$arr = [];
		$cfg = mvc::$cfg['OCR']['baidu_vehicle'];
		if(empty($image) && !empty($url)){
			$LibHttp = new LibHttp();
			$image = base64_encode($LibHttp->fetch($url));
		}
		if(!empty($image)){
			$aipOcr = new AipOcr($cfg['APP_ID'], $cfg['API_KEY'], $cfg['SECRET_KEY']);
			$fileds = [];
			if($type == 'numplate'){
				$fileds = ['color'=>'color', 'number'=>'numplate'];
				$ocrRes = $aipOcr->licensePlate(base64_decode($image));
			}else if($type == 'driving'){
				$fileds = ['号牌号码'=>'numplate', '车辆识别代号'=>'vin', '住址'=>'addr', '品牌型号'=>'gxb', '车辆类型'=>'vtype', '所有人'=>'owner', '使用性质'=>'usetype', '发动机号码'=>'engnum'];
				$ocrRes = $aipOcr->vehicleLicense(base64_decode($image));
			}

			foreach($fileds as $oldf=>$newf)
			{
				if(isset($ocrRes['words_result'][$oldf])){
					$val = $ocrRes['words_result'][$oldf];
					if(is_array($val) && isset($val['words'])) $val = $val['words'];
					$arr[$newf] = $val;
				} 
			}

			$res = $this->vin($image);
			if(!empty($res['data'])) $arr['vin'] = $res['data'];
		}
		return LibFc::ReturnData(true, $arr);
	}
}