Initial commit,修正
This commit is contained in:
Executable
+229
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-06-04 11:06:07
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-11-11 13:11:55
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use vendor\aliyun\dysms\Sms;
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
class AlimsgController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
/*自定义常量*/
|
||||
|
||||
/*默认配置*/
|
||||
$_HI['accessKeyId'] = 'LTAIQrJFtHfqsyOt'; // AccessKeyId
|
||||
$_HI['accessKeySecret'] = 'tvGieI3vNI7Si3imauCB4rJ3OX4AR8'; // AccessKeySecret
|
||||
$_HI['sign'] = '嗨路客';
|
||||
$_HI['tmpl'] = 'SMS_116695055';
|
||||
|
||||
$_HI['reportQueueName'] = 'Alicom-Queue-31737903-SmsReport'; //状态报告接收
|
||||
$_HI['UpQueueName'] = 'Alicom-Queue-31737903-SmsUp'; //上行消息接收
|
||||
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSend()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
|
||||
$_HI['action'] = 'post';
|
||||
//数据取出方法
|
||||
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
|
||||
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$config = array();
|
||||
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : '';
|
||||
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : '';
|
||||
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : '';
|
||||
|
||||
$option = array();
|
||||
|
||||
$_content = isset($dataPost['content']) ? $dataPost['content'] : '';
|
||||
$_content = explode("\r\n",$_content);
|
||||
$content = array();
|
||||
foreach($_content as $c){
|
||||
$_c = explode(',', $c);
|
||||
$k = trim($_c[0]);
|
||||
$v = trim($_c[1]);
|
||||
$content[$k] = $v;
|
||||
}
|
||||
unset($_c);unset($k);unset($v);
|
||||
|
||||
$phone = isset($dataPost['phone']) ? $dataPost['phone'] : '';
|
||||
if($phone){
|
||||
$phone = explode(',', $phone);
|
||||
$phone = array_unique($phone); //去重
|
||||
$phone = array_filter($phone); //去空
|
||||
}
|
||||
|
||||
|
||||
$tmpl = isset($dataPost['tmpl']) ? $dataPost['tmpl'] : '';
|
||||
|
||||
if(isset($_GET['post']) && $_GET['post']==1){
|
||||
$_POST = array('config'=>$config,'option'=>$option,'phone'=>$phone,'content'=>$content,'tmpl'=>$tmpl);
|
||||
Yii::$app->request->setBodyParams($_POST); //重写模拟POST数据
|
||||
// Yii::$app->request->setQueryParams($_POST); //重写模拟GET数据
|
||||
return $this->actionPost($_POST);
|
||||
}
|
||||
|
||||
$sms = new Sms($option,$config);
|
||||
|
||||
$results = array();
|
||||
$msg = "";
|
||||
foreach($phone as $p){
|
||||
$result = $sms->send($p,$tmpl,$content);
|
||||
$results[$p] = $result;
|
||||
if(!$result){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$sms->errors."\r\n";
|
||||
}elseif(is_array($result) && $result['Code'] !='OK'){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$result['Message']."\r\n";
|
||||
}else{
|
||||
$msg .= "【".$p."】发送成功"."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$message = array();
|
||||
$message['title'] = "阿里云短信发送测试";
|
||||
$message['class'] = "success";
|
||||
$message['button'] = array();
|
||||
$message['content'] = "短信发送完毕;接口返回:".$msg;
|
||||
$message['button'][] = array("class"=>"btn btn-success","title"=>"首页","link"=>Url::toRoute('site/index'));
|
||||
$message['button'][] = array("class"=>"btn btn-info","title"=>"接口","link"=>Url::toRoute(['api/index', 'appid' => Yii::$app->user->identity->username]));
|
||||
return $this->render('//layouts/message.php',[
|
||||
'message'=>$message
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionPost()
|
||||
{
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
|
||||
$_HI['action'] = 'post';
|
||||
//数据取出方法
|
||||
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
|
||||
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
|
||||
$params = Yii::$app->params;
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],strlen(json_encode($dataPost))); //增加一次接口入站数据量累计
|
||||
|
||||
$return = array();
|
||||
$results = array();
|
||||
$msg = "";
|
||||
$errorCode = 0;
|
||||
|
||||
if(!isset($dataPost['config']) || !is_array($dataPost['config'])){
|
||||
$errorCode = '45300403';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$config = $dataPost['config'];
|
||||
|
||||
if(isset($dataPost['option'])){
|
||||
if(!is_array($dataPost['option'])){
|
||||
$errorCode = '45300404';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$option = $dataPost['option'];
|
||||
}else{
|
||||
$option = array();
|
||||
}
|
||||
|
||||
if(!isset($dataPost['tmpl']) || !is_string($dataPost['tmpl'])){
|
||||
$errorCode = '45300405';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$tmpl = $dataPost['tmpl'];
|
||||
|
||||
if(!isset($dataPost['phone']) || !is_array($dataPost['phone'])){
|
||||
$errorCode = '45300406';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$phone = $dataPost['phone'];
|
||||
|
||||
if(isset($dataPost['content'])){
|
||||
if(!is_array($dataPost['content'])){
|
||||
$errorCode = '45300407';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
return json_encode($return);
|
||||
}
|
||||
$content = $dataPost['content'];
|
||||
}else{
|
||||
$content = array();
|
||||
}
|
||||
|
||||
$sms = new Sms($option,$config);
|
||||
$error = $sms->errors;
|
||||
if($error){
|
||||
$errorCode = '45300402';
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode).";接口提示:".$sms->errors.";";;
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
$msg = "";
|
||||
$errors = 0;
|
||||
$pn = count($phone);
|
||||
foreach($phone as $p){
|
||||
$result = $sms->send($p,$tmpl,$content);
|
||||
var_dump($result);die();
|
||||
$results[$p] = $result;
|
||||
if(!$result){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$sms->errors.";";
|
||||
$errors += 1;
|
||||
}elseif(is_array($result) && $result['Code'] !='OK'){
|
||||
$msg .= "【".$p."】发送失败,接口提示:".$result['Message'].";";
|
||||
$errors += 1;
|
||||
}else{
|
||||
$msg .= "【".$p."】发送成功".";";
|
||||
}
|
||||
}
|
||||
|
||||
if($errors>0){
|
||||
if($errors == $pn){
|
||||
$errorcode = 45300402;
|
||||
}else{
|
||||
$errorcode = 45300401;
|
||||
}
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode).";".$msg;
|
||||
$return['data'] = $dataPost;
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
$return['sms_left'] = fmFunc_stat_sms_send($username=$_FM['user']['name'],$times=$pn-$errors); //统计短信发送并返回剩余条数
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use common\models\User;
|
||||
use common\models\CAccess;
|
||||
|
||||
require dirname(__FILE__).'/_public/public_demo.php';
|
||||
|
||||
class ApiController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
$identity = Yii::$app->user->identity;
|
||||
if(!$identity){
|
||||
return $this->goHome();
|
||||
}
|
||||
$_FM['user']['name'] = $identity->username;
|
||||
$_FM['user']['uid'] = $identity->id;
|
||||
|
||||
fmFunc_cert_afterLogin();
|
||||
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'test';
|
||||
|
||||
$request = Yii::$app->request;
|
||||
$request->enableCsrfValidation = false;
|
||||
|
||||
// 返回所有参数
|
||||
$params = $request->get();
|
||||
$_FM['params'] = $params;
|
||||
$accesstoken = isset($_FM['params']['accesstoken']) ? $_FM['params']['accesstoken'] : '';
|
||||
//查询用户信息(根据username)
|
||||
$user = CAccess::findOne(['accesstoken' => $accesstoken]);
|
||||
if($user){
|
||||
$user = $user->toArray();
|
||||
}else{
|
||||
$errorCode = 45300001; //未找到用户
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
$_FM['user'] = $user;
|
||||
$_FM['user']['name'] = $_FM['user']['username'];
|
||||
$cert = fmFunc_cert_exist($_FM['user']['name']);
|
||||
$_FM['apiCert'] = $cert;
|
||||
if ($request->isAjax) {
|
||||
/* 该请求是一个 AJAX 请求 */
|
||||
$result = json_encode(1);
|
||||
}
|
||||
if ($request->isGet) {
|
||||
/* 请求方法是 GET */
|
||||
|
||||
}
|
||||
if ($request->isPost) {
|
||||
/* 请求方法是 POST */
|
||||
}
|
||||
if ($request->isPut) {
|
||||
/* 请求方法是 PUT */
|
||||
|
||||
}
|
||||
|
||||
###定义内容类型###
|
||||
//header('Content-Type: text/html; charset=utf-8'); //网页编码
|
||||
//header('Content-Type: text/plain'); //纯文本格式
|
||||
//header('Content-Type: image/jpeg'); //JPG、JPEG
|
||||
//header('Content-Type: application/zip'); // ZIP文件
|
||||
//header('Content-Type: application/pdf'); // PDF文件
|
||||
//header('Content-Type: audio/mpeg'); // 音频文件
|
||||
//header('Content-type: text/css'); //css文件
|
||||
//header('Content-type: text/javascript'); //js文件
|
||||
//header('Content-Type: application/x-shockw**e-flash'); //Flash动画
|
||||
//header('Content-type: application/pdf'); //pdf
|
||||
//header('Content-type: text/xml'); //xml
|
||||
header('Content-type: application/json'); //json
|
||||
$_FM['apiCert']['timeused'] = getMillisecond() - $START_TIME;
|
||||
$_FM['apiCert']['stat'] = fmFunc_stat_get($username=$_FM['user']['username']);
|
||||
$result = json_encode($_FM['apiCert']);
|
||||
die($result);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+287
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
use Yii;
|
||||
use yii\web\IdentityInterface;
|
||||
use yii\helpers\Url;
|
||||
// use yii\imagine\Image;
|
||||
|
||||
class ImageController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
|
||||
//本方法采用GD库支持
|
||||
|
||||
//创建图片
|
||||
$height = isset($_HI['post']['h']) ? abs($_HI['post']['h']) :(isset($_HI['get']['h']) ? abs($_HI['get']['h']) :0);
|
||||
$height = !$height ? 300 : $height;
|
||||
$width = isset($_HI['post']['w']) ? abs($_HI['post']['w']) :(isset($_HI['get']['w']) ? abs($_HI['get']['w']) :0);
|
||||
$width = !$width ? 300 : $width;
|
||||
|
||||
$im = imagecreatetruecolor($width,$height) or die("Cannot Initialize new GD image stream"); //参数为宽度和高度
|
||||
// $im=ImageCreateFromJpg("https://public.hiluker.com/vcms/nopic.jpg"); //使用背景图片创建
|
||||
|
||||
$bc = isset($_HI['post']['bc']) ? ltrim($_HI['post']['bc']) :(isset($_HI['get']['bc']) ? ltrim($_HI['get']['bc']) :'');
|
||||
$bc = !$bc ? 'AFAFAF' : $bc;
|
||||
$fc = isset($_HI['post']['fc']) ? ltrim($_HI['post']['fc']) :(isset($_HI['get']['fc']) ? ltrim($_HI['get']['fc']) :'');
|
||||
$fc = !$fc ? '333333' : $fc;
|
||||
//添加颜色
|
||||
$bc = $this->Hex2RGB('#'.$bc);
|
||||
$fc = $this->Hex2RGB('#'.$fc);
|
||||
|
||||
|
||||
$text_color = imagecolorallocate($im,$fc['r'],$fc['g'],$fc['b']);
|
||||
$background_color = imagecolorallocate($im,$bc['r'],$bc['g'],$bc['b']);
|
||||
$default_color = imagecolorallocate($im,5,5,5);
|
||||
|
||||
//绘制矩形图片
|
||||
imagefilledrectangle($im , 0, 0, $width-1 , $height-1 , $background_color); //填充
|
||||
// imagefilledrectangle($im , 0, 0, $width-1 , $height-1 , $default_color); //填充
|
||||
// imagerectangle($im , 0, 0, $width-1 , $height-1, $text_color); //边框
|
||||
|
||||
//添加文字
|
||||
$text = isset($_HI['post']['text']) ? trim($_HI['post']['text']) :(isset($_HI['get']['text']) ? trim($_HI['get']['text']) :'');
|
||||
$text = !($text) ? '' : html_entity_decode($text);
|
||||
// imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text );
|
||||
// 图片源;字体尺寸,文字方向,0从左至右,90从一至下;x、y,首字符起点位置,左下角坐标;color颜色索引。使用负的颜色索引值具有关闭防锯齿的效果;fontfile字体文件
|
||||
// imagettftext($im,10,0,$width/2,$height/2,$text_color,"/fonts/STHeiti Medium.ttc","☆"); //中心位置标记
|
||||
|
||||
$strlen = mb_strlen($text); //字符数(中文算1个字符)
|
||||
//BUG 180430 只输入一个字时,部分情况报错(中,0,1,`);无字符输入时报错
|
||||
if($strlen==0){
|
||||
imagettftext($im,10,0,$width/2-1,$height/2-1,$default_color,"/fonts/STHeiti Medium.ttc","☆"); //中心位置标记
|
||||
}else{
|
||||
//文字方向
|
||||
$fd = isset($_HI['post']['fd']) ? intval($_HI['post']['fd']) :(isset($_HI['get']['fd']) ? intval($_HI['get']['fd']) : -1);
|
||||
if($fd==-1){
|
||||
if($width<$height){
|
||||
$fd = 270;
|
||||
}else{
|
||||
$fd = 0;
|
||||
}
|
||||
}
|
||||
$dstyle=1; //文本框长度以矩形长为限
|
||||
// $dstyle=2; //文本框长度以矩形宽为限
|
||||
if($dstyle==1){
|
||||
$long = max($width,$height); //长
|
||||
$short = min($width,$height); //短
|
||||
$fd = ($width<$height) ? 270 : $fd;
|
||||
}else{
|
||||
$long = $width;
|
||||
$short = $height; //短
|
||||
}
|
||||
|
||||
//设置文字大小及位置、方向等
|
||||
$size_l = round($long/$strlen,2)-0.01;
|
||||
$size_l = intval($long/$strlen);
|
||||
$size_s = round($short/3,2)-0.01;
|
||||
$size_s = intval($short/3);
|
||||
$size = min($size_l,$size_s); //每个字的框宽限制
|
||||
|
||||
$f_w = imagefontwidth(6);
|
||||
$f_h = imagefontheight(6);
|
||||
|
||||
$fontsize = intval(($size-$f_w)/1.2); //字体大小
|
||||
|
||||
$text_w = $f_w;
|
||||
if($strlen>1){
|
||||
for($i=0;$i<$strlen;$i++){
|
||||
$t = mb_substr($text, $i, 1, 'utf-8');
|
||||
$len = strlen($t);
|
||||
if($len==3){
|
||||
$text_w += $fontsize+$f_w;
|
||||
}elseif($len==2){
|
||||
$text_w += $fontsize*2/3;
|
||||
}elseif($len==1){
|
||||
$text_w += $fontsize*2/3;
|
||||
}
|
||||
}
|
||||
$text_w = $text_w-$f_w;
|
||||
}else{
|
||||
$text_w = $fontsize;
|
||||
}
|
||||
|
||||
$p_l = $long/2 -$text_w/2;
|
||||
$p_l = intval($p_l);
|
||||
$p_s = $short/2+$fontsize/2; //字符串底部-y轴高度
|
||||
$p_s = intval($p_s);
|
||||
|
||||
if($fd==90){
|
||||
//90度时,右下角位置
|
||||
$x = $p_s-$f_h;
|
||||
$y = $p_l+$text_w;
|
||||
}elseif($fd==270){
|
||||
//270度时,左上角位置
|
||||
$x = $short/2-$fontsize/2;
|
||||
$y = $p_l+$f_w;
|
||||
}else{
|
||||
//0度时,左下角位置
|
||||
$x = ($strlen==1) ? $p_l-$f_w : $p_l-$fontsize/2+2*$f_w;
|
||||
$y = $p_s-$f_h;
|
||||
}
|
||||
|
||||
// var_dump('文本:'.$text);var_dump('字数:'.$strlen);var_dump('字框宽度:'.$size);var_dump('字体大小:'.$fontsize);var_dump('字体宽度:'.$f_w);var_dump('字体高度:'.$f_h);var_dump('文本框总宽度:'.$text_w);var_dump('字符X轴位置:'.$x);var_dump('字符Y轴位置:'.$y);var_dump('文字方向:'.$fd);die();
|
||||
imagettftext($im,$fontsize,$fd,$x+1,$y+1,$default_color,"/fonts/Arial Unicode.ttf",$text);
|
||||
imagettftext($im,$fontsize,$fd,$x,$y,$text_color,"/fonts/Arial Unicode.ttf",$text);
|
||||
}
|
||||
|
||||
//生成图片
|
||||
ob_clean();
|
||||
// header("Content-type:image/jpeg;");
|
||||
// imagejpeg($im,null,100);
|
||||
header("Content-type:image/png;");
|
||||
imagepng($im);
|
||||
//在根目录下生成图片文件
|
||||
// imagejpeg($im,"temp2.jpg",100);
|
||||
// imagepng($im,"temp2.png");
|
||||
//释放内存
|
||||
imagedestroy($im);
|
||||
}
|
||||
|
||||
/**
|
||||
* RGB转 十六进制
|
||||
* @param $rgb RGB颜色的字符串 如:rgb(255,255,255);
|
||||
* @return string 十六进制颜色值 如:#FFFFFF
|
||||
*/
|
||||
function RGB2Hex($rgb){
|
||||
$regexp = "/^rgb\(([0-9]{0,3})\,\s*([0-9]{0,3})\,\s*([0-9]{0,3})\)/";
|
||||
$re = preg_match($regexp, $rgb, $match);
|
||||
$re = array_shift($match);
|
||||
$hexColor = "#";
|
||||
$hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$r = null;
|
||||
$c = $match[$i];
|
||||
$hexAr = array();
|
||||
while ($c > 16) {
|
||||
$r = $c % 16;
|
||||
$c = ($c / 16) >> 0;
|
||||
array_push($hexAr, $hex[$r]);
|
||||
}
|
||||
array_push($hexAr, $hex[$c]);
|
||||
$ret = array_reverse($hexAr);
|
||||
$item = implode('', $ret);
|
||||
$item = str_pad($item, 2, '0', STR_PAD_LEFT);
|
||||
$hexColor .= $item;
|
||||
}
|
||||
return $hexColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制 转 RGB
|
||||
*/
|
||||
function Hex2RGB($hexColor) {
|
||||
$color = str_replace('#', '', $hexColor);
|
||||
if (strlen($color) > 3) {
|
||||
$rgb = array(
|
||||
'r' => hexdec(substr($color, 0, 2)),
|
||||
'g' => hexdec(substr($color, 2, 2)),
|
||||
'b' => hexdec(substr($color, 4, 2))
|
||||
);
|
||||
} else {
|
||||
$color = $hexColor;
|
||||
$r = substr($color, 0, 1) . substr($color, 0, 1);
|
||||
$g = substr($color, 1, 1) . substr($color, 1, 1);
|
||||
$b = substr($color, 2, 1) . substr($color, 2, 1);
|
||||
$rgb = array(
|
||||
'r' => hexdec($r),
|
||||
'g' => hexdec($g),
|
||||
'b' => hexdec($b)
|
||||
);
|
||||
}
|
||||
return $rgb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成图片
|
||||
* @param array 参数,包括图片和文字
|
||||
* @param string $filename 生成海报文件名,不传此参数则不生成文件,直接输出图片
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function createPoster($config=array(),$filename=""){
|
||||
//如果要看报什么错,可以先注释调这个header
|
||||
if(empty($filename)) header("content-type: image/png");
|
||||
$imageDefault = array(
|
||||
'left'=>0,
|
||||
'top'=>0,
|
||||
'right'=>0,
|
||||
'bottom'=>0,
|
||||
'width'=>100,
|
||||
'height'=>100,
|
||||
'opacity'=>100
|
||||
);
|
||||
$textDefault = array(
|
||||
'text'=>'',
|
||||
'left'=>0,
|
||||
'top'=>0,
|
||||
'fontSize'=>32, //字号
|
||||
'fontColor'=>'255,255,255', //字体颜色
|
||||
'angle'=>0,
|
||||
);
|
||||
$background = $config['background'];//海报最底层得背景
|
||||
//背景方法
|
||||
$backgroundInfo = getimagesize($background);
|
||||
$backgroundFun = 'imagecreatefrom'.image_type_to_extension($backgroundInfo[2], false);
|
||||
$background = $backgroundFun($background);
|
||||
$backgroundWidth = imagesx($background); //背景宽度
|
||||
$backgroundHeight = imagesy($background); //背景高度
|
||||
$imageRes = imageCreatetruecolor($backgroundWidth,$backgroundHeight);
|
||||
$color = imagecolorallocate($imageRes, 0, 0, 0);
|
||||
imagefill($imageRes, 0, 0, $color);
|
||||
// imageColorTransparent($imageRes, $color); //颜色透明
|
||||
imagecopyresampled($imageRes,$background,0,0,0,0,imagesx($background),imagesy($background),imagesx($background),imagesy($background));
|
||||
//处理了图片
|
||||
if(!empty($config['image'])){
|
||||
foreach ($config['image'] as $key => $val) {
|
||||
$val = array_merge($imageDefault,$val);
|
||||
$info = getimagesize($val['url']);
|
||||
$function = 'imagecreatefrom'.image_type_to_extension($info[2], false);
|
||||
if($val['stream']){ //如果传的是字符串图像流
|
||||
$info = getimagesizefromstring($val['url']);
|
||||
$function = 'imagecreatefromstring';
|
||||
}
|
||||
$res = $function($val['url']);
|
||||
$resWidth = $info[0];
|
||||
$resHeight = $info[1];
|
||||
//建立画板 ,缩放图片至指定尺寸
|
||||
$canvas=imagecreatetruecolor($val['width'], $val['height']);
|
||||
imagefill($canvas, 0, 0, $color);
|
||||
//关键函数,参数(目标资源,源,目标资源的开始坐标x,y, 源资源的开始坐标x,y,目标资源的宽高w,h,源资源的宽高w,h)
|
||||
imagecopyresampled($canvas, $res, 0, 0, 0, 0, $val['width'], $val['height'],$resWidth,$resHeight);
|
||||
$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']) - $val['width']:$val['left'];
|
||||
$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']) - $val['height']:$val['top'];
|
||||
//放置图像
|
||||
imagecopymerge($imageRes,$canvas, $val['left'],$val['top'],$val['right'],$val['bottom'],$val['width'],$val['height'],$val['opacity']);//左,上,右,下,宽度,高度,透明度
|
||||
}
|
||||
}
|
||||
//处理文字
|
||||
if(!empty($config['text'])){
|
||||
foreach ($config['text'] as $key => $val) {
|
||||
$val = array_merge($textDefault,$val);
|
||||
list($R,$G,$B) = explode(',', $val['fontColor']);
|
||||
$fontColor = imagecolorallocate($imageRes, $R, $G, $B);
|
||||
$val['left'] = $val['left']<0?$backgroundWidth- abs($val['left']):$val['left'];
|
||||
$val['top'] = $val['top']<0?$backgroundHeight- abs($val['top']):$val['top'];
|
||||
imagettftext($imageRes,$val['fontSize'],$val['angle'],$val['left'],$val['top'],$fontColor,$val['fontPath'],$val['text']);
|
||||
}
|
||||
}
|
||||
//生成图片
|
||||
if(!empty($filename)){
|
||||
$res = imagejpeg ($imageRes,$filename,90); //保存到本地
|
||||
imagedestroy($imageRes);
|
||||
if(!$res) return false;
|
||||
return $filename;
|
||||
}else{
|
||||
imagejpeg ($imageRes); //在浏览器上显示
|
||||
imagedestroy($imageRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionGet()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'get';
|
||||
//设置数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$data = array();
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataGet);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/get_data.php';
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
//return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'save';
|
||||
//设置数据保存方法
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/save_data.php';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+482
@@ -0,0 +1,482 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class MetadataController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
use Yii;
|
||||
use yii\web\IdentityInterface;
|
||||
use common\models\User;
|
||||
use common\models\LoginForm;
|
||||
//use yii\helpers\Url;
|
||||
|
||||
//use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
class OssController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
}
|
||||
|
||||
/**
|
||||
* Login.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$post = $request->post();
|
||||
|
||||
if(isset($_GET['api']) && $_GET['api']){
|
||||
//API接口请求,模拟登陆
|
||||
|
||||
//查询用户信息(根据username)
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT * FROM c_user WHERE username = :username";
|
||||
$params[':username'] = urldecode($_GET['LoginForm']['username']);
|
||||
$_user = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if(!$_user){
|
||||
$errorCode = 45300001; //未找到用户
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//如果cert证书文件文件存在,则判断;域名、IP不合规时,不允许访问
|
||||
$username = $_GET['LoginForm']['username'];
|
||||
$cert = fmFunc_cert_exist($username);
|
||||
$viaDomain = fmFunc_server_via_domain();
|
||||
$viaIP = fmFunc_server_via_ip();
|
||||
$_FM['viaDomain'] = $viaDomain;
|
||||
$_FM['viaIp'] = $viaIP;
|
||||
$isAvailable = $cert ? fmFunc_cert_beforeLogin($cert,$viaIP,$viaDomain) : true;
|
||||
if(!$isAvailable) {
|
||||
$errorCode = 45300101; //非法访问1(来路IP或域名不在白名单中)
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//安全校验,登陆密码、授权码auth_key
|
||||
$auth_key = $_user['auth_key'];
|
||||
$hash = $_user['password_hash'];
|
||||
$password = urldecode($_GET['LoginForm']['password']);
|
||||
|
||||
$isPwdRight = Yii::$app->getSecurity()->validatePassword($password, $hash);
|
||||
if (!$isPwdRight) {
|
||||
$errorCode = 45300002; //密码错误
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
if($_user['status'] < 10){
|
||||
$errorCode = 45300003; //账号被冻结
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
|
||||
//校验结束
|
||||
// 使用指定用户名获取用户身份实例
|
||||
$identity = User::findOne(['username' => $_GET['LoginForm']['username']]);
|
||||
|
||||
// 登录用户,有效期30d
|
||||
$duration = 3600 * 24 * 30;
|
||||
$_login = Yii::$app->user->login($identity, $duration);
|
||||
if ($_login) {
|
||||
//将用户信息写入全局变量
|
||||
$_FM['user']['name'] = $identity->username;
|
||||
$_FM['user']['uid'] = $identity->id;
|
||||
$result = 0;
|
||||
$result = json_encode($result);
|
||||
|
||||
//执行登陆后的证书创建/更新等工作
|
||||
fmFunc_cert_afterLogin();
|
||||
|
||||
//将token以data结果返回到客户侧
|
||||
$result = array();
|
||||
$result['errorcode'] = 0;
|
||||
$result['data'] = $_FM['token'];
|
||||
$result = json_encode($result);
|
||||
echo $result; //输出结果到前端视图渲染一次,否则客户侧的模拟登陆无法取cookie
|
||||
return; //返回,否则会继续执行最下面的未知报错
|
||||
} else {
|
||||
$errorCode = 45300004; //登陆失败
|
||||
$result = array();
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$errorCode = 4530009999; //未知错误
|
||||
$result['errorcode'] = $errorCode;
|
||||
$result['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$result = json_encode($result);
|
||||
die ($result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+481
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class PageController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 's';
|
||||
$table = 'page';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
public function actionGet()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'get';
|
||||
//设置数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$data = array();
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataGet);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/get_data.php';
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
//return $this->render('index');
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_FM;
|
||||
$_FM['siteRoot'] = Url::base(true);
|
||||
$_FM['siteUrl'] = Url::home(true);
|
||||
$_FM['urlScript'] = Url::home();
|
||||
$_FM['yii']['action'] = 'save';
|
||||
//设置数据保存方法
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = '客户端设置实例';
|
||||
$f_sn_title = '客户端系统设置实例';
|
||||
$o_sn_title = '客户端系统设置集';
|
||||
|
||||
//依次取用,顺序不可更改
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
require dirname(__FILE__).'/_public/save_data.php';
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+391
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-27 22:28:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(演示版,默认针对vcms的fm453_*系列应用)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定客户id\分组id
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 'undefined';
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
|
||||
//继续根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : 'undefined';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : 'undefined';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : 'undefined';
|
||||
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.$group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
}else{
|
||||
$type = 'app';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台用户组
|
||||
|
||||
if($isAppWeb) {
|
||||
$type = 'appweb';
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台核销用户组
|
||||
}
|
||||
}
|
||||
|
||||
//发送反馈消息
|
||||
$message = array();
|
||||
$message = '棒,客户端绑定成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'tips';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
//根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : '';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : '';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : '';
|
||||
|
||||
if($client_type) {
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
}elseif($isAppWeb){
|
||||
$type = 'appweb';
|
||||
}else{
|
||||
$type = 'app';
|
||||
}
|
||||
if($do){
|
||||
if($ac){
|
||||
if($op){
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}else{
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
|
||||
// 以下是调用示例,接口与GatewayWorker环境的接口一致
|
||||
// 接口具体使用方法见《Lib\Gateway类提供的接口》一章
|
||||
// 注意除了不支持sendToCurrentClient和closeCurrentClient方法
|
||||
// 其它方法都支持
|
||||
//Gateway::sendToAll($data);
|
||||
//Gateway::sendToClient($client_id, $data);
|
||||
//Gateway::closeClient($client_id);
|
||||
//Gateway::isOnline($client_id);
|
||||
//Gateway::bindUid($client_id, $uid);
|
||||
//Gateway::isUidOnline($uid);
|
||||
//Gateway::getClientIdByUid($uid);
|
||||
//Gateway::unbindUid($client_id, $uid);
|
||||
//Gateway::sendToUid($uid, $data);
|
||||
//Gateway::joinGroup($client_id, $group);
|
||||
//Gateway::sendToGroup($group, $data);
|
||||
//Gateway::leaveGroup($client_id, $group);
|
||||
//Gateway::getClientCountByGroup($group);
|
||||
//Gateway::getClientSessionsByGroup($group);
|
||||
//Gateway::getAllClientCount();
|
||||
//Gateway::getAllClientSessions();
|
||||
//Gateway::setSession($client_id, $session);
|
||||
//Gateway::updateSession($client_id, $session);
|
||||
//Gateway::getSession($client_id);
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+562
@@ -0,0 +1,562 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-30 10:11:22
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(针对嗨噜应用系统的HOFC嗨骑定向小程序)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushhofcController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定项
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
//常规绑定(绑定到UID,未传入用户详情)
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC-USER';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
if(!$uid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定用户';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$uid = $group_pre.fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户('.$uid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBinduser()
|
||||
{
|
||||
//绑定用户及详情、APPID,同时向数据关联组发送用户信息
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
//绑定到当前用户组,供服务侧同步绑定校验
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip();
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
if(!$uid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定用户';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$uid = $group_pre.'-USER-'.fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户('.$uid.')成功!';
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
|
||||
$group_ids = array();
|
||||
$group_id = '';
|
||||
//绑定小程序ID
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
if(!$appid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定小程序';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
}else{
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定小程序('.$appid.')成功!';
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
}
|
||||
|
||||
//向数据展板推送用户信息
|
||||
$user = isset($dataPost['user']) ? $dataPost['user'] : [];
|
||||
$time = time();
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'content'; //消息反馈类型:alert,confirm,toast,content,reg
|
||||
if(isset($dataPost['new']) && $dataPost['new']==1){
|
||||
$data['type'] = 'reg';
|
||||
}
|
||||
$data['msg'] = '由['.$viaIP.']进入了寻宝应用('.date('H:i').')';
|
||||
$data['status']=1; //消息状态
|
||||
$data['avatar'] = isset($user['face']) ? $user['face'] : '';
|
||||
$data['username'] = $user['nick_name']; //昵称
|
||||
$data['title'] = '系统提示'; //消息标题
|
||||
$data['mid'] = isset($user['user_id']) ? $user['user_id'] : -1; //消息来源会员, -1为公众号本身
|
||||
$data['id'] = md5($time.'_'.$user['user_id']);
|
||||
$data['ctype'] = 0; //消息内容类型(-1,系统消息;-2表情;-3快捷表态;-4 红包;0,默认,文本消息;1图片;3音频; 4视频;)
|
||||
$data['createtime'] = $time;
|
||||
$data = json_encode($data);
|
||||
//推送数据
|
||||
Gateway::sendToGroup($group_ids[$group_id], $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindgroup()
|
||||
{
|
||||
//绑定用户组
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
//绑定到当前用户组,供服务侧同步绑定校验
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
if($group_id){
|
||||
$group_ids[0] = $group_pre.fmFunc_server_hash_id(0);;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[0]); //将用户加入0会员组
|
||||
}
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定用户组成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindteam()
|
||||
{
|
||||
//绑定团队ID,方便同步接收
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$teamid = isset($dataPost['teamid']) ? $dataPost['teamid'] : 0;
|
||||
if(!$teamid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定队伍';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$group_id = 'team_'.$teamid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定队伍('.$teamid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
public function actionBindwxapp()
|
||||
{
|
||||
//绑定小程序ID
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
if(!$appid){
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '未指定小程序';
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_ids[$group_id]); //奖用户加入指定会员组
|
||||
|
||||
//发送反馈消息
|
||||
$message = '棒,客户端绑定小程序('.$appid.')成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'bind';
|
||||
$data['msg'] = $message;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'XCX-HOFC';
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
if($client_type) {
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据并向全部客户端群发
|
||||
*/
|
||||
public function actionSend2all()
|
||||
{
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
global $_FM;
|
||||
global $_HI;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
|
||||
$group_pre = 'XCX-HOFC';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : ' ';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
|
||||
//处理POST数据
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type; //消息反馈类型:alert,confirm,toast,content
|
||||
$data['msg'] = $msg;
|
||||
$data['status']=1; //消息状态
|
||||
$data['avatar'] = isset($dataPost['avatar']) ? $dataPost['avatar'] : '';
|
||||
$data['username'] = '管理员'; //昵称
|
||||
$data['title'] = '系统提示'; //消息标题
|
||||
$data['mid'] = isset($dataPost['mid']) ? $dataPost['mid'] : 1; //消息来源会员, -1为公众号本身
|
||||
$time = time();
|
||||
$data['id'] = isset($dataPost['id']) ? $dataPost['id'] :md5($time.'_'.$data['mid']);
|
||||
$data['ctype'] = isset($dataPost['type']) ? $dataPost['type'] : 0; //消息内容类型(-1,系统消息;-2表情;-3快捷表态;-4 红包;0,默认,文本消息;1图片;3音频; 4视频;)
|
||||
$data['createtime'] = $time;
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
$data = json_encode($data);
|
||||
//向全体推送数据
|
||||
//设定群发群组
|
||||
$appid = isset($dataPost['appid']) ? $dataPost['appid'] : 0;
|
||||
$group_id = 'wxapp_'.$appid;
|
||||
$group_ids[$group_id] = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$count++;
|
||||
Gateway::sendToGroup($group_ids[$group_id], $data);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '消息已发送';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Executable
+513
@@ -0,0 +1,513 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-04-27 22:19:28
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-04-29 17:08:02
|
||||
*/
|
||||
|
||||
/**
|
||||
* 利用workerman制作的推送接口控制器(针对vcms的fm453_*系列应用)
|
||||
|
||||
*/
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
// 引用GateWay Client
|
||||
require(__DIR__ . '/../../vendor/workerman/GatewayClient-3.0.0/Gateway.php');
|
||||
// GatewayClient 3.0.0版本开始要使用命名空间
|
||||
use GatewayClient\Gateway;
|
||||
|
||||
// 设置GatewayWorker服务的Register服务ip和端口
|
||||
Gateway::$registerAddress = '127.0.0.1:4530';
|
||||
|
||||
class PushimmsController extends Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
/**
|
||||
* 绑定客户端与指定客户id\分组id
|
||||
*/
|
||||
public function actionBind()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
header('Access-Control-Allow-Origin:*'); //允许任何网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : 'undefined';
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
|
||||
$group_ids = array();
|
||||
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 'undefined';
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
// client_id与uid绑定
|
||||
Gateway::bindUid($client_id, $uid);
|
||||
|
||||
$group_id = isset($dataPost['groupid']) ? $dataPost['groupid'] : 0;
|
||||
if($group_id){
|
||||
$group_ids[0] = $group_pre.fmFunc_server_hash_id(0);;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
}
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
// 加入某个群组(可调用多次加入多个群组)
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户所在的会员组
|
||||
|
||||
|
||||
//继续根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : 'undefined';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : 'undefined';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : 'undefined';
|
||||
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.$group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
}else{
|
||||
$type = 'app';
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id);
|
||||
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台用户组
|
||||
|
||||
if($isAppWeb) {
|
||||
$type = 'appweb';
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
$group_ids[$group_id] = $group_id;
|
||||
Gateway::joinGroup($client_id, $group_id); //当前用户并入前台核销用户组
|
||||
}
|
||||
}
|
||||
|
||||
//发送反馈消息
|
||||
$message = array();
|
||||
$message = '棒,客户端绑定成功!';
|
||||
|
||||
$data = array();
|
||||
$data['type'] = 'tips';
|
||||
$data['msg'] = $message;
|
||||
$data['groupids'] = $group_ids;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据
|
||||
*/
|
||||
public function actionIn()
|
||||
{
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
// 建立socket连接到内部推送端口
|
||||
$client = stream_socket_client('tcp://127.0.0.1:4530');
|
||||
|
||||
//如果用户已经登陆,uid和群组id存在
|
||||
//TBD 构建uid、group_id的生成方式
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : 0;
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
|
||||
//$client_id 通过前端传入
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : 0;
|
||||
|
||||
// 推送的数据,包含uid字段,表示是给这个uid推送
|
||||
$uid = isset(Yii::$app->user->identity->username) ? Yii::$app->user->identity->username : '0';
|
||||
$data = array('uid'=> $uid, 'msg'=>urlencode('嗯,这个是测试用的'));
|
||||
|
||||
// 发送数据,注意该端口是Text协议的端口,Text协议需要在数据末尾加上换行符
|
||||
fwrite($client, json_encode($data)."\n");
|
||||
|
||||
// 读取推送结果
|
||||
// echo '$client=='.$client;
|
||||
//echo fread($client, 8192);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向客户端推送消息
|
||||
*/
|
||||
public function actionOut()
|
||||
{
|
||||
global $_FM;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
// header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : '7f000001b0f400000010';
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : 0;
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken AND domain = :domain AND expiretime > :expiretime ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
$params[':domain'] = $viaDomain;
|
||||
$params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$client_type = isset($dataPost['client_type']) ? $dataPost['client_type'] : '';
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
$isWeb = ($client_type=='web') ? true : false;
|
||||
$isApp = ($client_type=='app') ? true : false;
|
||||
$isAppWeb = ($client_type=='appweb') ? true : false;
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToAll($data);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
//根据情况发送消息
|
||||
switch($hasToken){
|
||||
case true:
|
||||
//根据当前用户身份生成可准确识别的用户ID
|
||||
$uid = isset($dataPost['uid']) ? $dataPost['uid'] : '';
|
||||
if($uid){
|
||||
$uid = fmFunc_server_hash_id($uid);
|
||||
Gateway::sendToUid($uid, $data);
|
||||
}
|
||||
|
||||
//有证书时,可继续下一步的推送
|
||||
if(!$hasCert){
|
||||
break; //无证书,不再继续
|
||||
}
|
||||
|
||||
//已指派分组时
|
||||
$group_id = isset($dataPost['group']) ? $dataPost['group'] : 0;
|
||||
if($groud_id){
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
break; //执行后结束此次推送
|
||||
}
|
||||
|
||||
//根据创建更多分组
|
||||
$do = isset($dataPost['do']) ? $dataPost['do'] : '';
|
||||
$ac = isset($dataPost['ac']) ? $dataPost['ac'] : '';
|
||||
$op = isset($dataPost['op']) ? $dataPost['op'] : '';
|
||||
|
||||
if($client_type) {
|
||||
if($isWeb) {
|
||||
$type = 'web';
|
||||
}elseif($isAppWeb){
|
||||
$type = 'appweb';
|
||||
}else{
|
||||
$type = 'app';
|
||||
}
|
||||
if($do){
|
||||
if($ac){
|
||||
if($op){
|
||||
$group_id = $type.'_'.$do.'_'.$ac.'_'.$op;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}else{
|
||||
$group_id = $type.'_'.$do.'_'.$ac;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type.'_'.$do;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}else{
|
||||
$group_id = $type;
|
||||
$group_id = $group_pre.fmFunc_server_hash_id($group_id);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case false;
|
||||
//只发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收客户端数据并向全部客户端群发
|
||||
*/
|
||||
public function actionSend2all()
|
||||
{
|
||||
// header('Access-Control-Allow-Origin:https://vcms.hiluker.com'); //允许指定网站通过ajax发送请求
|
||||
header('Access-Control-Allow-Origin:*'); //允许指定网站通过ajax发送请求
|
||||
global $_FM;
|
||||
global $_HI;
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$params = Yii::$app->params;
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$group_pre = 'VCMS-IMMS';
|
||||
|
||||
/*设置REDIS缓存*/
|
||||
//初始化$cache = new \Redis();
|
||||
$cache = new \Redis();
|
||||
$cache->connect($params['redis']['IP'], $params['redis']['PORT']);
|
||||
// 先检查是否存在,然后写入并设置有效时间
|
||||
$key = 'FmWebSorcketCount';
|
||||
$CACHE_PREFIX = 'DACMS';
|
||||
$count = 0;
|
||||
if($cache->exists($CACHE_PREFIX.$key)){
|
||||
// 读取
|
||||
$count = $cache->get($CACHE_PREFIX . $key);
|
||||
//清除
|
||||
$cache->delete($CACHE_PREFIX . $key);
|
||||
}
|
||||
|
||||
$cache->set($CACHE_PREFIX . $key, $count+1);
|
||||
$expire = time()+604800; //一周时间再过期
|
||||
$cache->expire($CACHE_PREFIX . $key, $expire);
|
||||
|
||||
//前台已经建立起长链接,取得了客户端ID号;需要绑定到当前用户,并返回用户uid,供服务侧同步绑定校验
|
||||
$viaDomain = fmFunc_server_via_domain(); //来路域名
|
||||
$viaIP = fmFunc_server_via_ip(); //来路IP
|
||||
$timestamp = isset($_FM['timestamp']) ? $_FM['timestamp'] : time();
|
||||
|
||||
//通过前端GET传入的
|
||||
$client_id = isset($dataGet['client_id']) ? $dataGet['client_id'] : ' ';
|
||||
if(!$client_id){
|
||||
return;
|
||||
}
|
||||
$accessToken = isset($dataGet['accesstoken']) ? $dataGet['accesstoken'] : '';
|
||||
if(!$accessToken){
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'log';
|
||||
$data['msg'] = '未指定accessToken';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
//判断accesstoken有效性
|
||||
/*
|
||||
@有效性规则判断
|
||||
*Yii::$app->user->identity->username,Yii::$app->user->identity->id 当前用户账号及id
|
||||
*domain 域名匹配
|
||||
*expiretime 有效期判断
|
||||
*$_FM['apiCert'] 服务器证书
|
||||
*/
|
||||
$connection = yii::$app->db;
|
||||
$sql = "SELECT `username` FROM c_access WHERE accesstoken = :accesstoken ORDER BY id ASC";
|
||||
$params = array();
|
||||
$params[':accesstoken'] = $accessToken;
|
||||
// $params[':domain'] = $viaDomain;
|
||||
// $params[':expiretime'] = $timestamp;
|
||||
$result = fmFunc_pdo_yii_fetch($connection,$sql, $params);
|
||||
|
||||
$hasToken = false;
|
||||
$hasCert = false;
|
||||
if($result) {
|
||||
$username = $result['username'];
|
||||
$hasToken = true;
|
||||
//加载证书文件,但无用户登陆状态
|
||||
$cert = $username.'.php';
|
||||
if(file_exists($_HI['apiCertPath'].$cert)){
|
||||
$_FM['apiCert'] = array_merge(include($_HI['apiCertPath'].$cert));
|
||||
$hasCert = true;
|
||||
}
|
||||
}else{
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'log';
|
||||
$data['msg'] = '无效的accessToken';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
$_FM['apiCert']['token'] = $accessToken;
|
||||
|
||||
//处理POST数据
|
||||
$msg_type = isset($dataPost['msg_type']) ? $dataPost['msg_type'] : '';
|
||||
if(!$msg_type){
|
||||
$msg_type = isset($dataGet['msg_type']) ? $dataGet['msg_type'] : '';
|
||||
}
|
||||
|
||||
$msg = isset($dataPost['msg']) ? $dataPost['msg'] : '';
|
||||
if(!$msg){
|
||||
$msg = isset($dataGet['msg']) ? $dataGet['msg'] : '';
|
||||
}
|
||||
|
||||
//设定群发群组
|
||||
$group_id = $group_pre.fmFunc_server_hash_id(0);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = $msg_type;
|
||||
// $data['type'] = 'alert';
|
||||
$data['msg'] = $msg;
|
||||
|
||||
if(isset($dataGet['debug'])){
|
||||
//向全体推送数据
|
||||
$data['msg'] = empty($data['msg']) ? '第'.$count.'次测试群发' : $data['msg'];
|
||||
$count++;
|
||||
$data = json_encode($data);
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
return;
|
||||
}
|
||||
$data = json_encode($data);
|
||||
//向全体推送数据
|
||||
$count++;
|
||||
Gateway::sendToGroup($group_id, $data);
|
||||
|
||||
//构造反馈消息
|
||||
$data = array();
|
||||
$data['type'] = 'toast';
|
||||
$data['msg'] = '消息已发送';
|
||||
$data = json_encode($data);
|
||||
//发送给指定客户端
|
||||
Gateway::sendToClient($client_id, $data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Executable
+481
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class RealtyController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'house'; //楼盘数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'room'; //房型数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_FM;
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'house'; //数据,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'room'; //数据,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->realtydb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'realty_basic';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Realty s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Realty f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Realty o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //房产模型实例数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'house'; //楼盘数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'room'; //户型数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+475
@@ -0,0 +1,475 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SearchController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回param列表
|
||||
$sn = $s_sn;
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list=array();
|
||||
$list[]=$record;
|
||||
$record = $list;
|
||||
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
|
||||
$v = $record;
|
||||
}
|
||||
unset($v);
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Metadata s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Metadata f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Metadata o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = $s_sn;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->db;
|
||||
$tablePre = 's';
|
||||
$table = 'metadata';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
require dirname(__FILE__).'/_public/s_sn.php'; //取$s_sn
|
||||
//搜索模型数据每个站点仅需一个,至此,s_sn已经更新
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
$_goods = array(
|
||||
"title" => '产品查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的产品关键词。
|
||||
提示:您可使用 产品名称中的词语作为条件(如,××酒店,芒果等),进行模糊查询匹配;我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '产品'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询产品,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关产品,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_goods',
|
||||
)
|
||||
);
|
||||
|
||||
$_member = array(
|
||||
"title" => '会员查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的会员关键词。
|
||||
提示:您可使用 姓名、籍贯、行业等条件,进行模糊查询匹配;我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '产品'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询会员资料,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关资料,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_member',
|
||||
)
|
||||
);
|
||||
|
||||
$_article = array(
|
||||
"title" => '文章查询',
|
||||
"value" => '',
|
||||
"status" => 1,
|
||||
"deleted" => 0,
|
||||
"params" => array(
|
||||
"timelimit" => 5,
|
||||
"reply" => array(
|
||||
"welcome" => array(
|
||||
"tips" => '请输入您想要查询的文章内容关键词。
|
||||
提示:我们默认最多取符合条件的前9个作为结果,回复给您。',
|
||||
"key" => '文章'
|
||||
),
|
||||
"none" => array(
|
||||
"tips" => '您正在查询文章内容,关键词:{$keywords};
|
||||
查询结果:抱歉,未查询到相关资料,建议您尝试其他关键词。'
|
||||
),
|
||||
),
|
||||
"keywords" => '_article',
|
||||
)
|
||||
);
|
||||
Executable
+481
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use dataModel; //必须添加这一句,以便引入dataModel外部类库
|
||||
|
||||
require dirname(__FILE__).'/_public/public.php';
|
||||
|
||||
class SettingController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
$_HI['action'] = 'index';
|
||||
require dirname(__FILE__).'/SettingController/index.php';
|
||||
}
|
||||
|
||||
public function actionGet()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'get';
|
||||
//数据取出方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
$data['sqls'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Setting s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Setting f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Setting o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,返回self列表\param列表
|
||||
require dirname(__FILE__).'/_public/list_self.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => $v){
|
||||
$s_sn = $v['sn'];
|
||||
$record_self = $v;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$list[$k] = $record;
|
||||
}
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,根据条件返回form表中的数据\param列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_form.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$f_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,根据条件返回order表中的数据\addon列表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['o_sn']) ? intval($data['addons']['o_sn']) : 0;
|
||||
require dirname(__FILE__).'/_public/list_order.php';
|
||||
$list = $result;
|
||||
if($errorCode==0){
|
||||
foreach($list as $k => &$v){
|
||||
$record_form = $v;
|
||||
//取默认参数
|
||||
$o_sn = 0;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $record_form['sn'];
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_form;
|
||||
$record['params'] = $record_param;
|
||||
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $kk){
|
||||
if(isset($record['params'][$kk])) {
|
||||
$record[$kk] = $record['params'][$kk];
|
||||
}
|
||||
}
|
||||
$v = $record;
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
$record = $list;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['total'] = isset($count) ? $count : 1;//总记录数
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'detail';
|
||||
//取单条数据详情
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost);
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型,返回self表与param表数据
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_self.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
$s_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$errorCode = 0;
|
||||
$record_param = $result;
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['title','status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'instance'; //实例,返回form表\param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_form.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$f_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_param.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
unset($record_param['default'][$kk]); //只对在模型中定义的默认参数进行重置
|
||||
}
|
||||
//unset($record_param['default']); //重置全部默认参数
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300304;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'content'; //内容,返回order表\addon表数据
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
$errorCode = 0;
|
||||
if($sn){
|
||||
require dirname(__FILE__).'/_public/get_order.php';
|
||||
$record_self = $result;
|
||||
if($errorCode == 0){
|
||||
//取默认参数
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_default = $result;
|
||||
//取当前表单的指定参数
|
||||
$o_sn = $sn;
|
||||
require dirname(__FILE__).'/_public/get_addon.php';
|
||||
$record_param_private = $result;
|
||||
|
||||
$record_param = array_merge($record_param_default,$record_param_private);
|
||||
|
||||
//读取默认参数并在写入params后重置
|
||||
if(isset($record_param_default['default'])){
|
||||
foreach($record_param_default['default'] as $kk => $vv){
|
||||
if(isset($record_param[$kk]) && is_array($record_param[$kk]) && is_array($vv)){
|
||||
$record_param[$kk] = array_merge($vv,$record_param[$kk]);
|
||||
}elseif(!isset($record_param[$kk])){
|
||||
$record_param[$kk] = $vv;
|
||||
}
|
||||
}
|
||||
unset($record_param['default']);
|
||||
}
|
||||
|
||||
$record = $record_self;
|
||||
$record['params'] = $record_param;
|
||||
//需要重设的字段
|
||||
$reset = ['status','deleted'];
|
||||
foreach($reset as $k){
|
||||
if(isset($record['params'][$k])) {
|
||||
$record[$k] = $record['params'][$k]; //重设标题
|
||||
}
|
||||
}
|
||||
$errorCode = 0;
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300306;
|
||||
$record = $data['addons'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$errorCode = 4530039999;
|
||||
break;
|
||||
}
|
||||
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
global $START_TIME;
|
||||
$_HI['action'] = 'save';
|
||||
|
||||
//数据保存方法
|
||||
$dataGet = $_FM['get']; //GET进来的参数
|
||||
$dataPost = $_FM['post']; //POST进来的参数
|
||||
$data = array();
|
||||
$data['addons'] = array();
|
||||
|
||||
require dirname(__FILE__).'/_public/plat.php';
|
||||
|
||||
$dbmodel =new dataModel;
|
||||
$data = $dbmodel->data_filter($dataPost); //过滤后的可用值
|
||||
$inbytes = strlen(json_encode($data));//长度字节统计
|
||||
fmFunc_stat_times_in($username=$_FM['user']['name'],1); //增加一次接口入站次数累计
|
||||
fmFunc_stat_bytes_in($username=$_FM['user']['name'],$inbytes); //增加一次接口入站数据量累计
|
||||
|
||||
$connection = yii::$app->pagedb;
|
||||
$tablePre = 'hi';
|
||||
$table = 'setting';
|
||||
|
||||
$s_sn = 0;
|
||||
$f_sn = 0;
|
||||
$o_sn = 0;
|
||||
$s_sn_title = Yii::t('frontend','Default Page s_sn_title');
|
||||
$f_sn_title = Yii::t('frontend','Default Page f_sn_title');
|
||||
$o_sn_title = Yii::t('frontend','Default Page o_sn_title');
|
||||
|
||||
$return = array();
|
||||
$errorCode = 0;
|
||||
$return['errorcode'] = $errorCode;
|
||||
$return['msg'] = '已保存';
|
||||
|
||||
switch($ac){
|
||||
case 'model'; //模型数据,保存到self与param表
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
$s_sn = intval($data['addons']['sn']);
|
||||
require dirname(__FILE__).'/_public/update_self.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_self.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/s_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $s_sn;
|
||||
break;
|
||||
|
||||
case 'instance'; //实例数据,保存到form与param表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_form.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_form.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/f_sn.php';
|
||||
}
|
||||
//写param表
|
||||
require dirname(__FILE__).'/_public/save_param.php';
|
||||
//返回模型SN
|
||||
$record = $f_sn;
|
||||
break;
|
||||
|
||||
case 'content'; //内容数据,保存到order与addon表
|
||||
$s_sn = isset($data['addons']['s_sn']) ? intval($data['addons']['s_sn']) : 0;
|
||||
$f_sn = isset($data['addons']['f_sn']) ? intval($data['addons']['f_sn']) : 0;
|
||||
$o_sn = isset($data['addons']['sn']) ? intval($data['addons']['sn']) : 0;
|
||||
if(isset($data['addons']['sn']) && intval($data['addons']['sn'])>0){
|
||||
//传入了非0SN,即是对指定数据进行修改
|
||||
require dirname(__FILE__).'/_public/update_order.php';
|
||||
}elseif(isset($data['addons']['sn']) && intval($data['addons']['sn'])==0){
|
||||
//传入了0SN,即是新建一个数据
|
||||
require dirname(__FILE__).'/_public/new_order.php';
|
||||
}else{
|
||||
//未传入SN时,从服务器取出一个,未取到时自动新建
|
||||
require dirname(__FILE__).'/_public/o_sn.php';
|
||||
}
|
||||
//写addon表
|
||||
require dirname(__FILE__).'/_public/save_addon.php';
|
||||
//返回模型SN
|
||||
$record = $o_sn;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($errorCode>0){
|
||||
$return['msg'] = Yii::t('errorcode',$errorCode);
|
||||
}
|
||||
$return['data'] = isset($record) ? $record : '';
|
||||
$return['timeused'] = getMillisecond() - $START_TIME;
|
||||
$return['bytes'] = strlen(json_encode($return['data']));//长度字节统计
|
||||
fmFunc_stat_times_out($username=$_FM['user']['name'],1); //增加一次接口出站次数累计
|
||||
fmFunc_stat_bytes_out($username=$_FM['user']['name'],$return['bytes']); //增加一次接口出站数据量累计
|
||||
return json_encode($return);
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
global $_GPC;
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
die(json_encode($_FM));
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
global $_FM;
|
||||
var_dump($_FM);
|
||||
return;
|
||||
Executable
+222
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-09 23:05:45
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-09 23:06:05
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidParamException;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\filters\AccessControl;
|
||||
use frontend\models\LoginForm;
|
||||
use frontend\models\PasswordResetRequestForm;
|
||||
use frontend\models\ResetPasswordForm;
|
||||
use frontend\models\SignupForm;
|
||||
use frontend\models\ContactForm;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
*/
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'only' => ['logout', 'signup'],
|
||||
'rules' => [
|
||||
[
|
||||
'actions' => ['signup'],
|
||||
'allow' => true,
|
||||
'roles' => ['?'],
|
||||
],
|
||||
[
|
||||
'actions' => ['logout'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'logout' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'class' => 'yii\web\ErrorAction',
|
||||
],
|
||||
'captcha' => [
|
||||
'class' => 'yii\captcha\CaptchaAction',
|
||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays homepage.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||
return $this->goBack();
|
||||
} else {
|
||||
return $this->render('login', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the current user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::$app->user->logout();
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays contact page.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionContact()
|
||||
{
|
||||
$model = new ContactForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
|
||||
Yii::$app->session->setFlash('success', '已收到您的反馈,我们将尽快响应并联系您。');
|
||||
} else {
|
||||
Yii::$app->session->setFlash('error', '消息发送时系统遇到错误.');
|
||||
}
|
||||
|
||||
return $this->refresh();
|
||||
} else {
|
||||
return $this->render('contact', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays about page.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionAbout()
|
||||
{
|
||||
return $this->render('about');
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs user up.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionSignup()
|
||||
{
|
||||
$model = new SignupForm();
|
||||
if ($model->load(Yii::$app->request->post())) {
|
||||
if ($user = $model->signup()) {
|
||||
if (Yii::$app->getUser()->login($user)) {
|
||||
return $this->goHome();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('signup', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests password reset.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionRequestPasswordReset()
|
||||
{
|
||||
$model = new PasswordResetRequestForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||
if ($model->sendEmail()) {
|
||||
Yii::$app->session->setFlash('success', '发送完毕,请登陆您的邮箱查阅并进行接下来的操作.');
|
||||
|
||||
return $this->goHome();
|
||||
} else {
|
||||
Yii::$app->session->setFlash('error', '抱歉,系统无法向您填写的邮箱发送重置邮件,请检查邮箱地址.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('requestPasswordResetToken', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets password.
|
||||
*
|
||||
* @param string $token
|
||||
* @return mixed
|
||||
* @throws BadRequestHttpException
|
||||
*/
|
||||
public function actionResetPassword($token)
|
||||
{
|
||||
try {
|
||||
$model = new ResetPasswordForm($token);
|
||||
} catch (InvalidParamException $e) {
|
||||
throw new BadRequestHttpException($e->getMessage());
|
||||
}
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
|
||||
Yii::$app->session->setFlash('success', '新密码已保存.');
|
||||
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
return $this->render('resetPassword', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
//取form表sn
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$f_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$f_sn) {
|
||||
$initdata = $dbmodel->data_format($data,$suffix);
|
||||
$initdata['title'] = $f_sn_title;
|
||||
$initdata['value'] = '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$f_sn = $initdata['sn'];
|
||||
}
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
//OK
|
||||
//取addon表数据
|
||||
$suffix = 'addon';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor]=[];
|
||||
$record[$setfor][$title]=[];
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300307;
|
||||
}
|
||||
$result = $record;
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
//取data表数据
|
||||
$suffix = 'data';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300302;
|
||||
}
|
||||
$result = $record;
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
//OK
|
||||
//取form表数据
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','s_sn','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300305;
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
//OK
|
||||
//取order表数据
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','s_sn','f_sn','sn','partnerid','mid','fid','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300306;
|
||||
}
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
//OK
|
||||
//取param表数据
|
||||
$suffix = 'param';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
default: //默认,取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$columns = ['setfor','title','key','value'];
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits = array(), $showorders=array());
|
||||
$record = array();
|
||||
if($result){
|
||||
foreach($result as $_k => $_v){
|
||||
$setfor = $_v['setfor'];
|
||||
$title = $_v['title'];
|
||||
$key = $_v['key'];
|
||||
$value = iunserializer($_v['value']);
|
||||
$str = $setfor.'_'.$title.'_'.$key.'.php';
|
||||
$len = 0-strlen($str);
|
||||
if(!empty($value) && is_string($value) && substr($value,$len)==$str){
|
||||
if(fmFunc_file_checkExist($value,'data/')){
|
||||
$value = fmFunc_file_dataLoad($value);
|
||||
}
|
||||
}
|
||||
$record[$setfor][$title][$key] = $value;
|
||||
|
||||
if($setfor == $title){
|
||||
if($title == $key){
|
||||
$record[$setfor] = $value;
|
||||
}else{
|
||||
$record[$setfor][$key] = $value;
|
||||
}
|
||||
}else{
|
||||
if($title == $key){
|
||||
$record[$setfor][$title] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$errorCode = 45300303;
|
||||
}
|
||||
|
||||
$result = $record;
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self表某站点、sn对应数据
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','sn','title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$result = fmFunc_pdo_yii_get($connection, $tableName, $columns, $condition, $params, $limits = array());
|
||||
if(!$result){
|
||||
$errorCode = 45300304;
|
||||
}
|
||||
Executable
+191
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
//OK
|
||||
//取form数据列表
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('s_sn','platid','uniacid','shopid','partnerid','uid','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
//跨平台搜索条件
|
||||
if(isset($data['searching']['plat']) && $data['searching']['plat']==$platid){
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
}else{
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
//增加搜索条件,取多s_sn查询
|
||||
$issearching = isset($data['searching']) ? true : false;
|
||||
$searching = array();
|
||||
if($issearching){
|
||||
$condition_searching = $condition;
|
||||
$params_searching = $params;
|
||||
//系统自带搜索条件约定(精确匹配)
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`status` = :status";
|
||||
$params_searching[':status'] = intval($data['searching']['status']);
|
||||
}
|
||||
|
||||
if(isset($data['searching']['deleted'])){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`deleted` = :deleted";
|
||||
$params_searching[':deleted'] = intval($data['searching']['deleted']);
|
||||
}
|
||||
//搜索条件filter参数过滤
|
||||
if(isset($data['searching']['filter'])){
|
||||
foreach($data['searching']['filter'] as $_k =>$_v){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`key` = :key";
|
||||
$params_searching[':key'] = $_k;
|
||||
$condition_searching .=" AND ";
|
||||
if(is_array($_v)){
|
||||
$x_condition = "(";
|
||||
$x_i = count($_v);
|
||||
foreach($_v as $xk=>$xv){
|
||||
$x_i--;
|
||||
$x_condition .= "'".serialize($xv)."'";
|
||||
if($x_i>0){
|
||||
$x_condition .= ",";
|
||||
}
|
||||
}
|
||||
$x_condition .=")";
|
||||
$condition_searching .="`value` IN ".$x_condition;
|
||||
}else{
|
||||
$condition_searching .="`value` LIKE :value";
|
||||
$params_searching[':value'] = '%'.serialize($_v).'%';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//客户侧传入的额外搜索条件(模糊可选匹配)
|
||||
if(isset($data['searching']['addons'])){
|
||||
foreach($data['searching']['addons'] as $_k =>$_v){
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`key` = :key";
|
||||
$params_searching[':key'] = $_k;
|
||||
$condition_searching .=" AND ";
|
||||
$condition_searching .="`value` LIKE :value";
|
||||
$params_searching[':value'] = '%'.serialize($_v).'%';
|
||||
|
||||
$temp_tableName = $tablePre.'_'.$table.'_param';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('s_sn'), $condition_searching, $params_searching, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
if($_vv['s_sn'] != $s_sn){
|
||||
$searching[] = $_vv['s_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$temp_tableName = $tablePre.'_'.$table.'_param';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('s_sn'), $condition_searching, $params_searching, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
if($_vv['s_sn'] != $s_sn && !in_array($_vv['s_sn'],$searching)){
|
||||
$searching[] = $_vv['s_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$searching = array_unique($searching);
|
||||
$issearching = (count($searching) == 0) ? false : true;
|
||||
|
||||
//传入了s_sn时,也作为搜索条件
|
||||
if($s_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
}elseif($issearching){
|
||||
$s_sns = '';
|
||||
foreach($searching as $temp_s_sn){
|
||||
$s_sns .= $temp_s_sn.",";
|
||||
}
|
||||
$s_sns .= $s_sns;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` IN (".$s_sns.")";
|
||||
}
|
||||
|
||||
if($issearching){
|
||||
$op = '';
|
||||
}
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = $data['searching']['status'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
//补充搜索条件
|
||||
if(isset($data['searching']['keyword'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` LIKE :keyword";
|
||||
$params[':keyword'] = '%'.$data['searching']['keyword'].'%';
|
||||
}
|
||||
|
||||
//数据分页
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
//数据排序
|
||||
$orders = !empty($data['sqls']['orders']) ? $data['sqls']['orders'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300305;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
//OK
|
||||
//取order数据列表
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('s_sn','f_sn','platid','uniacid','shopid','partnerid','mid','fid','sn','title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
//传入了s_sn时,也作为搜索条件
|
||||
if($s_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
}
|
||||
|
||||
//增加搜索条件,取多f_sn查询
|
||||
$issearching = false;
|
||||
$searching = array();
|
||||
if($issearching){
|
||||
if(isset($data['searching']['addons'])){
|
||||
foreach($data['searching']['addons'] as $_k =>$_v){
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $_k;
|
||||
$condition .=" AND ";
|
||||
$condition .="`value` LIKE :value";
|
||||
$params[':value'] = '%'.$_v.'%';
|
||||
|
||||
$temp_tableName = $tablePre.'_'.$table.'_addon';
|
||||
$result = fmFunc_pdo_yii_getall($connection, $temp_tableName, array('f_sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
if($result){
|
||||
foreach($result as $_kk => $_vv){
|
||||
$searching[] = $_vv['f_sn'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$searching = array_unique($searching);
|
||||
$issearching = (count($searching) == 0) ? false : true;
|
||||
|
||||
//传入了f_sn时,也作为搜索条件
|
||||
if($f_sn>0){
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
}elseif($issearching){
|
||||
$f_sns = '';
|
||||
foreach($searching as $temp_f_sn){
|
||||
$f_sns .= $temp_f_sn.",";
|
||||
}
|
||||
$f_sns .= $f_sns;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` IN (".$f_sns.")";
|
||||
}
|
||||
|
||||
if($issearching){
|
||||
$op = '';
|
||||
}
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
if(isset($data['searching']['status'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = $data['searching']['status'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
//补充搜索条件
|
||||
if(isset($data['searching']['keyword'])){
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` LIKE :keyword";
|
||||
$params[':keyword'] = '%'.$data['searching']['keyword'].'%';
|
||||
}
|
||||
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300306;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self数据列表,只对应到站点即可
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('platid','uniacid','shopid','sn','title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
switch($op)
|
||||
{
|
||||
case 'index': //取未删除、可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 1;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'unused': //取未删除、不可用状态的数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`status` = :status";
|
||||
$params[':status'] = 0;
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
case 'deleted': //取已删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 1;
|
||||
break;
|
||||
|
||||
case 'all': //取未删除数据
|
||||
$condition .=" AND ";
|
||||
$condition .="`deleted` = :deleted";
|
||||
$params[':deleted'] = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$limits = !empty($data['sqls']['limits']) ? $data['sqls']['limits'] : array();
|
||||
|
||||
$result = fmFunc_pdo_yii_getall($connection, $tableName, $columns, $condition, $params, $limits, $orders=array());
|
||||
if(!$result){
|
||||
$errorCode = 45300304;
|
||||
}
|
||||
|
||||
$total = FmFunc_pdo_yii_getall($connection, $tableName, $columns=array('sn'), $condition, $params, $limits=array(), $orders=array());
|
||||
$count = count($total);
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$uid = isset($data['uid']) ? $data['uid'] : 0;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['value'] = isset($initdata['value']) ? $initdata['value'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$f_sn = $initdata['sn'];
|
||||
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['value'] = isset($initdata['value']) ? $initdata['value'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
$initdata['f_sn'] = $f_sn;
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$o_sn = $initdata['sn'];
|
||||
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
//OK
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['keywords'] = isset($initdata['keywords']) ? $initdata['keywords'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = isset($initdata['deleted']) ? $initdata['deleted'] : 0;
|
||||
$initdata['status'] = isset($initdata['status']) ? $initdata['status'] : 1;
|
||||
$initdata['displayorder'] = isset($initdata['displayorder']) ? $initdata['displayorder'] : 0;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
|
||||
$result = fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$s_sn = $initdata['sn'];
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
//取order表sn
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$o_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$o_sn) {
|
||||
$initdata = $dbmodel->data_format($data,$suffix);
|
||||
$initdata['title'] = $o_sn_title;
|
||||
$initdata['value'] = '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
$initdata['s_sn'] = $s_sn;
|
||||
$initdata['f_sn'] = $f_sn;
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$o_sn = $initdata['sn'];
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'index';
|
||||
$op = in_array($op,array('index','deleted','unused')) ? $op : 'index';
|
||||
|
||||
$setfor = isset($dataGet['setfor']) ? $dataGet['setfor'] : 'index';
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
//OK
|
||||
//TBD uniacid的更复杂逻辑处理,以便平台模式切换
|
||||
|
||||
$op = isset($dataGet['op']) ? $dataGet['op'] : 'null';
|
||||
|
||||
$ac = isset($dataGet['ac']) ? $dataGet['ac'] : 'null';
|
||||
|
||||
$siteId = isset($_FM['apiCert']['siteId']) ? $_FM['apiCert']['siteId'] : 0;
|
||||
|
||||
$platid = (isset($dataGet['platid']) && intval($dataGet['platid'])>0) ? intval($dataGet['platid']) : 0;
|
||||
//TBD 进一步校验platid是否合法
|
||||
$platid = (isset($_FM['platid'])) ? $_FM['platid'] : $platid;
|
||||
|
||||
$uniacid = (isset($dataGet['uniacid']) && intval($dataGet['uniacid'])>0) ? intval($dataGet['uniacid']) : 0;
|
||||
//TBD 进一步校验uniacid是否合法
|
||||
$uniacid = (isset($_FM['uniacid'])) ? $_FM['uniacid'] : $uniacid;
|
||||
|
||||
$shopid = (isset($dataGet['shopid']) && intval($dataGet['shopid'])>0) ? intval($dataGet['shopid']) : 0;
|
||||
//TBD 进一步校验shopid是否合法
|
||||
$shopid = (isset($_FM['shopid'])) ? $_FM['shopid'] : $shopid;
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
global $START_TIME;
|
||||
$START_TIME = getMillisecond();
|
||||
//加载变量设置
|
||||
global $_FM;
|
||||
|
||||
//记录请求日志-20170629
|
||||
$dologs = new common\components\DoLogs;
|
||||
$dologs ->record();
|
||||
|
||||
//授权服务器通讯检查,排除前台登陆演示'我的接口'时的判断
|
||||
$errorCode=0;
|
||||
|
||||
if(substr($_GET['r'],-6) !='/index'){
|
||||
$errorCode = fmFunc_cert_checkAuth();
|
||||
}
|
||||
|
||||
if($errorCode!=0){
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}
|
||||
|
||||
//未登陆不返回数据!
|
||||
if(!isset($_FM['user']['name']))
|
||||
{
|
||||
$errorCode = 45300201;
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}elseif (Yii::$app->user->isGuest)
|
||||
{
|
||||
$errorCode = 45300201;
|
||||
die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
}
|
||||
|
||||
//补充添加平台号关联
|
||||
$_FM['platid'] = isset($_GET['platid']) ? intval($_GET['platid']) : 0;
|
||||
if(isset($_FM['apiCert']['platid'])){
|
||||
$_FM['platid'] = $_FM['apiCert']['platid'];
|
||||
}
|
||||
$_FM['uniacid'] = isset($_GET['uniacid']) ? intval($_GET['uniacid']) : 0;
|
||||
if(isset($_FM['apiCert']['uniacid'])){
|
||||
$_FM['uniacid'] = $_FM['apiCert']['uniacid'];
|
||||
}
|
||||
$_FM['shopid'] = isset($_GET['shopid']) ? intval($_GET['shopid']) : 0;
|
||||
if(isset($_FM['apiCert']['shopid'])){
|
||||
$_FM['shopid'] = $_FM['apiCert']['shopid'];
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
global $START_TIME;
|
||||
$START_TIME = getMillisecond();
|
||||
//加载变量设置
|
||||
global $_FM;
|
||||
|
||||
//记录请求日志-20170629
|
||||
$dologs = new common\components\DoLogs;
|
||||
$dologs ->record();
|
||||
|
||||
//授权服务器通讯检查,排除前台登陆演示我的接口时的判断
|
||||
$errorCode=0;
|
||||
|
||||
//未登陆不返回数据!
|
||||
// if(!isset($_FM['user']['name']))
|
||||
// {
|
||||
// $errorCode = 45300201;
|
||||
// die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
// }elseif (Yii::$app->user->isGuest)
|
||||
// {
|
||||
// $errorCode = 45300201;
|
||||
// die (json_encode(array('errorcode'=>$errorCode,'msg'=>Yii::t('errorcode',$errorCode))));
|
||||
// }
|
||||
|
||||
//补充添加平台号关联
|
||||
$_FM['platid'] = isset($_GET['platid']) ? intval($_GET['platid']) : 0;
|
||||
if(isset($_FM['apiCert']['platid'])){
|
||||
$_FM['platid'] = $_FM['apiCert']['platid'];
|
||||
}
|
||||
$_FM['uniacid'] = isset($_GET['uniacid']) ? intval($_GET['uniacid']) : 0;
|
||||
if(isset($_FM['apiCert']['uniacid'])){
|
||||
$_FM['uniacid'] = $_FM['apiCert']['uniacid'];
|
||||
}
|
||||
$_FM['shopid'] = isset($_GET['shopid']) ? intval($_GET['shopid']) : 0;
|
||||
if(isset($_FM['apiCert']['shopid'])){
|
||||
$_FM['shopid'] = $_FM['apiCert']['shopid'];
|
||||
}
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
//OK
|
||||
//取self表sn,SELF对应到客户端站点系统级——每个站点均支持多个主模型存在
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$column = "sn";
|
||||
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$s_sn = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
if(!$s_sn) {
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$initdata['title'] = isset($initdata['title']) ? $initdata['title'] : $s_sn_title;
|
||||
$initdata['keywords'] = isset($initdata['keywords']) ? $initdata['keywords'] : '';
|
||||
$initdata['createtime'] = $_FM['timestamp'];
|
||||
$initdata['updatetime'] = $_FM['timestamp'];
|
||||
$initdata['deleted'] = 0;
|
||||
$initdata['status'] = 1;
|
||||
$initdata['sn'] = getMillisecond()*10;
|
||||
$initdata['sn'] = intval($initdata['sn']);
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $initdata);
|
||||
$s_sn = $initdata['sn'];
|
||||
}
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置addon表数据
|
||||
$suffix = 'addon';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$o_sn.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['o_sn'] = $o_sn;
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['mid'] = $mid;
|
||||
$record['fid'] = $fid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置data表数据
|
||||
$suffix = 'data';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$mid = isset($data['mid']) ? $data['mid'] : 0;
|
||||
$fid = isset($data['fid']) ? $data['fid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`o_sn` = :o_sn";
|
||||
$params[':o_sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$o_sn.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['o_sn'] = $o_sn;
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['mid'] = $mid;
|
||||
$record['fid'] = $fid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
//OK
|
||||
//设置param表数据
|
||||
$suffix = 'param';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$partnerid = isset($data['partnerid']) ? $data['partnerid'] : 0;
|
||||
$settingData = $dbmodel->data_format($data['addons'],$suffix);
|
||||
|
||||
$column = "id";
|
||||
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
$condition .=" AND ";
|
||||
$condition .="`platid` = :platid";
|
||||
$params[':platid'] = $platid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`uniacid` = :uniacid";
|
||||
$params[':uniacid'] = $uniacid;
|
||||
$condition .=" AND ";
|
||||
$condition .="`shopid` = :shopid";
|
||||
$params[':shopid'] = $shopid;
|
||||
|
||||
$i = 0;
|
||||
$temp = array();
|
||||
$temp['keys']=array();
|
||||
$temp['titles']=array();
|
||||
$temp_condition = $condition;
|
||||
foreach($settingData as $v_k => $value){
|
||||
$i++;
|
||||
$record = array();
|
||||
$_temp_condition = '';
|
||||
$condition = '';
|
||||
$condition .=" AND ";
|
||||
$condition .="`setfor` = :setfor";
|
||||
$params[':setfor'] = $value['setfor'];
|
||||
if(!isset($temp['keys'][$value['setfor']])) {
|
||||
$temp['keys'][$value['setfor']] = [];
|
||||
}
|
||||
if(!isset($temp['titles'][$value['setfor']])) {
|
||||
$temp['titles'][$value['setfor']] = [];
|
||||
}
|
||||
//170702补充——增强修复参数title键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['title'])){
|
||||
$_temp_titles = $temp['titles'][$value['setfor']];
|
||||
if(count($_temp_titles)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['titles'][$value['setfor']],$value['title']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`title` = :title";
|
||||
$params[':title'] = $value['title'];
|
||||
|
||||
if(!isset($temp['keys'][$value['setfor']][$value['title']])) {
|
||||
$temp['keys'][$value['setfor']][$value['title']] = [];
|
||||
}
|
||||
//170419补充——针对参数key键为数字的情况(判定其父级数组需完全被该次所传入之的参数数组替代),因为要删除掉无关键(设置deleted为1)
|
||||
//170501补充——增强修复参数key键为数字时的保存命令
|
||||
|
||||
if(is_numeric($value['key'])){
|
||||
$_temp_keys = $temp['keys'][$value['setfor']][$value['title']];
|
||||
if(count($_temp_keys)==0){
|
||||
$record['deleted'] = 1;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
$_temp_condition = $temp_condition.$condition;
|
||||
unset($params[':key']);
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $record, $_temp_condition, $params);
|
||||
}
|
||||
array_push($temp['keys'][$value['setfor']][$value['title']],$value['key']);
|
||||
}
|
||||
|
||||
$condition .=" AND ";
|
||||
$condition .="`key` = :key";
|
||||
$params[':key'] = $value['key'];
|
||||
$condition = $temp_condition.$condition;
|
||||
|
||||
$id = fmFunc_pdo_yii_fetchcolumn($connection, $tableName, $column, $condition, $params);
|
||||
$record['value'] = $value['value'];
|
||||
//170722 补充-value键值超过mysql的text最大长度65535时,改为使用文件存储的方式
|
||||
if(isset($value['value']{65535})){
|
||||
$filename = $siteId.'/'.$uniacid.'/'.$platid.'_'.$shopid.'_'.$f_sn.'_'.$s_sn.'_'.$suffix.'_'.$value['setfor'].'_'.$value['title'].'_'.$value['key'];
|
||||
fmFunc_file_dataWrite($filename,$value['value'],$uri=null,$origin_cache_key=null);
|
||||
$record['value'] = $filename.'.php';
|
||||
}
|
||||
|
||||
if($id){
|
||||
$record['deleted'] = 0;
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
fmFunc_pdo_yii_update($connection, $tableName, $record, $condition, $params);
|
||||
}else{
|
||||
$record['setfor'] = $value['setfor'];
|
||||
$record['title'] = $value['title'];
|
||||
$record['key'] = $value['key'];
|
||||
$record['f_sn'] = $f_sn;
|
||||
$record['s_sn'] = $s_sn;
|
||||
$record['sn'] = getMillisecond()*10;
|
||||
$record['sn'] = intval($record['sn']);
|
||||
$record['siteid'] = $siteId;
|
||||
$record['platid'] = $platid;
|
||||
$record['uniacid'] = $uniacid;
|
||||
$record['shopid'] = $shopid;
|
||||
$record['partnerid'] = $partnerid;
|
||||
$record['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
|
||||
$record['status'] = isset($data['status']) ? $data['status'] : 1;
|
||||
$record['statuscode'] = isset($data['statuscode']) ? $data['statuscode'] : 64;
|
||||
$record['deleted'] = 0;
|
||||
$record['createtime'] = $_FM['timestamp'];
|
||||
$record['updatetime'] = $_FM['timestamp'];
|
||||
|
||||
fmFunc_pdo_yii_insert($connection, $tableName, $record);
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
//OK
|
||||
//更新form表
|
||||
$suffix = 'form';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对form表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
//更新order表
|
||||
$suffix = 'order';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','value','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $o_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`f_sn` = :f_sn";
|
||||
$params[':f_sn'] = $f_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`s_sn` = :s_sn";
|
||||
$params[':s_sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对order表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
//OK
|
||||
//更新self表
|
||||
$suffix = 'self';
|
||||
$tableName = $tablePre.'_'.$table.'_'.$suffix;
|
||||
$condition = "";
|
||||
$params = array();
|
||||
|
||||
$columns = array('title','keywords','displayorder','status','deleted');
|
||||
|
||||
$condition .="`sn` = :sn";
|
||||
$params[':sn'] = $s_sn;
|
||||
$condition .=" AND ";
|
||||
$condition .="`siteid` = :siteid";
|
||||
$params[':siteid'] = $siteId;
|
||||
|
||||
$initdata = $dbmodel->data_format($data['addons'],$suffix);
|
||||
$updateData = array();
|
||||
foreach($columns as $col){
|
||||
if(isset($initdata[$col])){
|
||||
$updateData[$col] = $initdata[$col];
|
||||
}elseif(isset($data[$col])){
|
||||
$updateData[$col] = $data[$col];
|
||||
}
|
||||
}
|
||||
|
||||
//根据传参op进行数据微调
|
||||
switch($op) {
|
||||
case 'param':
|
||||
//指定为param操作时,不对self表进行写操作
|
||||
$unset = ['title','keywords','displayorder','status','deleted'];
|
||||
$updateData = array();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($updateData)){
|
||||
$updateData['updatetime'] = $_FM['timestamp'];
|
||||
$result = fmFunc_pdo_yii_update($connection, $tableName, $updateData, $condition, $params);
|
||||
}else{
|
||||
$result = false;
|
||||
}
|
||||
Reference in New Issue
Block a user