www_fpvone_cn/application/index/controller/Index.php

215 lines
7.1 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use addons\third\library\Wechat;
use app\admin\model\Userwechat;
use think\Session;
use think\Config;
use app\admin\model\Renzheng;
use think\Response;
use app\admin\model\shopro\Vip as VipModel;
use app\admin\model\shopro\user\User;
use app\admin\model\shopro\Category as CategoryModel;
use app\admin\model\MatchRanking;
use app\admin\model\shopro\order\OrderItem;
use app\admin\model\shopro\goods\Goods;
use AlibabaCloud\SDK\Sample\Sample;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function inter_sms(){
require_once dirname(dirname(dirname(__DIR__))).'/vendor/alisms/autoload.php';
$arr = array(1,2,3,4);
$Sample = new Sample();
$res = $Sample::main($arr);
return $res;
}
public function abt(){
// @$abv = new abv();
// echo dirname(dirname(__FILE__));
@fopen('/www/wwwroot/www.fpvone.cn/public/imgs/auto_login_ali.png');
}
public function uuu(){
exit;
$res = $this->qsq(1);
// var_dump($res);exit;
$arr = ['203.11','12.68','95.55'];
$maxString = min($arr);
// var_dump($maxString);exit;
$url = 'https://www.fpvone.cn/api/sms/send';
// POST数据
$data = array('mobile' => '13626832346', 'event' => 'notice_diyform');
// 初始化cURL会话
$ch = curl_init($url);
// 设置cURL选项
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回结果而不是输出
curl_setopt($ch, CURLOPT_POST, true); // 发送POST请求
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); // POST数据
// 执行cURL会话
$response = curl_exec($ch);
// 关闭cURL会话
curl_close($ch);
// 打印结果
// echo $response;exit;
// exit;
$OrderItem = new OrderItem();
$Goods = new Goods();
$res = $Goods->where('id',183)->find();
// $res = $OrderItem->where('id',916)->find();
$arr = explode(",", $res['category_ids']);
var_dump($arr);exit;
$virtualfiled = json_decode($res['virtualfiled']);
foreach ($virtualfiled as $val){
var_dump($val);exit;
}
var_dump($oldarr);exit;
}
public function bcd(){
$CategoryModel = new CategoryModel();
$category_ids = 377;
$cate_res = $CategoryModel->where('id',$category_ids)->find();
var_dump($cate_res['vip_discount']);exit;
$vip = new VipModel();
$config_vip = sheep_config('shop.vip');
$order['user_id'] = 1044;
$order['createtime'] = 1729042450;
$user = User::where('id', $order['user_id'])->find();
$vip_res = $vip->where('uid',$order['user_id'])->find();
if(empty($vip_res)){
$data = [
'uid' => $order['user_id'],
'nickname' => $user->nickname,
'starttime' => strtotime($order['createtime']),
'endtime' => strtotime($order['createtime']) + ($config_vip['vip_range'])*24*3600,
];
$res = $vip->create($data);
}else{
$data = [
'endtime' => $vip_res['endtime'] + ($config_vip['vip_range'])*24*3600,
];
$res = $vip->update($data,['uid'=>$order['user_id']]);
}
var_dump($res);exit;
$url = 'http://www.baidu.com';
$headers = [
'Location' => $url,
'Other-Token' => 'tsdfsdfsdf',
// 可以继续添加其他需要设置的HTTP头信息
];
return redirect($url, [], 301)->header($headers);
}
public function abc($token = 'abc'){
// var_dump(123);exit;
// $url = 'https://timer.fpvone.cn/timer/#/game';
// $response = Response::create($url, 'redirect');
// // 设置请求头
// $response->header([
// 'Location' => $url,
// 'Other-Token' => $token // 可以设置其他需要的请求头
// ]);
// // 发送响应并终止脚本执行
// $response->send();
// exit;
$this->request->header('asdfsdf:ckjxvhkxjc');
// header('abcd:adfsdfsd');
// $returnURL = 'https://www.baidu.com';
// header('location:'.$returnURL);exit;
$token = '34670c8a-d006-4e22-ac10-cb1f6e38b328';
$config = [
'hashalgo' => 'ripemd160',
'key' => 'nRU6uwTVHyD3i8AMch4Qf79tjOdYCPzX'
];
$res = hash_hmac($config['hashalgo'], $token, $config['key']);
var_dump($res);exit;;
// file_put_contents("test.txt",'aaa');
}
public function index()
{
$url = 'https://ydool2017.oss-cn-shanghai.aliyuncs.com/%E6%AF%94%E7%BF%BC%E9%A3%9E%E8%A1%8C%E7%BD%91/uploads/20240311/06335f00b870cbc5650193c7cdff2301.jpg';
$headers = get_headers($url);
// var_dump($headers);exit;
// 如果无法获取响应头或者响应头第0位不是HTTP/1.1 200 OK则认为链接无效
if (!is_array($headers) || strpos($headers[0], '200 OK') === false) {
// var_dump(123);exit;
return false;
}
return $this->view->fetch();
}
public function wechatlogin(){
$code = $this->request->param("code");
$match_id = $this->request->param("match_id");
// var_dump($match_id);exit;
$wechat = new Wechat();
$access_token = $wechat->getAccessTokens($code);
$userinfo = $wechat->getUserInfos($access_token);
// var_dump($userinfo);exit;
$userwechat = new Userwechat();
$res = $userwechat->where('openid','=',$userinfo['openid'])->find();
// var_dump($res->toArray());exit;
//数据库为空
if(empty($res)){
$userwechat->data([
'openid'=> $userinfo['openid'],
'wechat_name' => $userinfo['nickname'],
'wechat_avatar' => $userinfo['headimgurl']
]);
$userwechat->save();
}else{
$res = $res->toArray();
$userwechat->save([
'wechat_name' => $userinfo['nickname'],
'wechat_avatar' => $userinfo['headimgurl']
],['openid' => $userinfo['openid']]);
}
Session::set('userinfo', $userinfo);
header('location:https://www.fpvone.cn/wurenjijingsusaicheng/'.$match_id);
// var_dump($res);
}
public function test(){
$str = '金老板';
$strlen = mb_strlen($str,'UTF8');
if($strlen == 2){
$real_name=mb_substr($str,0,1,'UTF8').'*';
}
if($strlen > 2){
$tmp_str=mb_substr($str,0,$strlen-2,'UTF8').'*';
$real_name=$tmp_str.mb_substr($str,-1,1,'UTF8');
}
var_dump($real_name);exit;
}
//获取插件配置信息
public function getconfig(){
$config = get_addon_config('third');
// $config = Config::get('third.wechat');
// print_r($config['wechat']);exit;
}
}