101 lines
4.3 KiB
PHP
101 lines
4.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\index\controller;
|
||
|
|
|
||
|
|
use app\common\controller\Frontend;
|
||
|
|
|
||
|
|
class Index extends Frontend
|
||
|
|
{
|
||
|
|
|
||
|
|
protected $noNeedLogin = '*';
|
||
|
|
protected $noNeedRight = '*';
|
||
|
|
protected $layout = '';
|
||
|
|
private $iv = 'XAkVMV0l4Dk4tsqs';// iv的长度要根据加密方式和模式来定,aes-128-cbc偏移量的是16位
|
||
|
|
|
||
|
|
private $key = 'VlHFhskOPV1vrYTo12';
|
||
|
|
|
||
|
|
public function mb_str_splits($string, $split_length = 1, $encoding = 'UTF-8') {
|
||
|
|
$result = [];
|
||
|
|
$length = mb_strlen($string, $encoding);
|
||
|
|
for ($i = 0; $i < $length; $i += $split_length) {
|
||
|
|
$result[] = mb_substr($string, $i, $split_length, $encoding);
|
||
|
|
}
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
//模拟AI回复文本输出
|
||
|
|
public function outText($message)
|
||
|
|
{
|
||
|
|
if (ob_get_level() > 0) {
|
||
|
|
ob_end_clean();
|
||
|
|
}
|
||
|
|
header('Content-Type: text/event-stream');
|
||
|
|
header('Cache-Control: no-cache');
|
||
|
|
header('Connection: keep-alive');
|
||
|
|
header('X-Accel-Buffering: no');
|
||
|
|
// 确保没有输出缓冲区阻止我们立即发送内容
|
||
|
|
while (ob_get_level() > 0) {
|
||
|
|
ob_end_flush();
|
||
|
|
}
|
||
|
|
ob_start();
|
||
|
|
// 要显示的消息
|
||
|
|
$msg = $this->mb_str_splits($message);
|
||
|
|
foreach ($msg as $char) {
|
||
|
|
|
||
|
|
$data = ['choices' =>[['delta' =>['content' => $char]]]];
|
||
|
|
echo 'data: ' . json_encode($data, JSON_UNESCAPED_UNICODE). PHP_EOL;
|
||
|
|
ob_flush();
|
||
|
|
flush();
|
||
|
|
usleep(25000);
|
||
|
|
}
|
||
|
|
echo '[回答完毕]';
|
||
|
|
ob_flush();
|
||
|
|
flush();
|
||
|
|
ob_end_flush();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
|
||
|
|
// //获取园区坐标
|
||
|
|
// $perimeter = (new Perimeter)->select();
|
||
|
|
//
|
||
|
|
// $str = '107.024924,29.817815;107.033335,29.822283;107.03591,29.823028;107.037455,29.825113;107.041918,29.826304;107.041918,29.829283;107.044836,29.830325;107.04621,29.827793;107.051531,29.825411;107.055651,29.821985;107.058226,29.820347;107.057539,29.817666;107.054793,29.816177;107.042605,29.810219;107.037798,29.805453;107.035567,29.800388;107.035223,29.796962;107.025954,29.788024;107.02561,29.784448;107.025439,29.783405;107.020975,29.781021;107.022349,29.779681;107.015311,29.77685;107.019259,29.771039;107.020804,29.769549;107.026125,29.774913;107.030417,29.779979;107.035738,29.786534;107.044493,29.798154;107.051188,29.805453;107.056509,29.809028;107.062174,29.8059;107.068011,29.802474;107.069384,29.80158;107.057711,29.786981;107.048785,29.775807;107.039515,29.766866;107.030588,29.759267;107.028872,29.75882;107.022349,29.763141;107.015654,29.770741;107.011706,29.77685;107.001234,29.774168;106.995055,29.773274;106.988703,29.783852;106.982695,29.786832;106.97497,29.788322;106.970679,29.786832;106.967074,29.786832;106.96364,29.79145;106.963812,29.794877;106.969134,29.802325;106.97291,29.805751;106.972395,29.813198;106.967245,29.81722;106.962954,29.820943;106.965872,29.827645;106.968619,29.832112;106.973082,29.839557;106.97909,29.848342;106.984583,29.855638;106.985785,29.856829;106.996599,29.85266;107.001234,29.861593;107.003638,29.864868;107.012736,29.864272;107.0184,29.862337;107.014109,29.850725;107.011362,29.845662;107.010847,29.842089;107.012736,29.837026;107.017199,29.830623;107.017371,29.830325;107.019945,29.829878;107.021319,29.826453;107.02355,29.821092;107.024752,29.818113';
|
||
|
|
// $arr = explode(';', $str);
|
||
|
|
// $lat_str = [];
|
||
|
|
// foreach ($arr as $key => $value) {
|
||
|
|
// $lat_lag = explode(',', $value);
|
||
|
|
// $lat_str [] = [
|
||
|
|
// 'lat' => $lat_lag[1],
|
||
|
|
// 'lon' => $lat_lag[0],
|
||
|
|
// ];
|
||
|
|
// }
|
||
|
|
// print_r(json_encode($lat_str));
|
||
|
|
// die();
|
||
|
|
|
||
|
|
// 手机号 密码 加密
|
||
|
|
// 单独加一个(对应)字段来存储验证 现在手机号和之前保存手机号
|
||
|
|
// return $this->view->fetch('datav/index');
|
||
|
|
// return $this->view->fetch();
|
||
|
|
return $this->view->fetch('jingmen/index');
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public function h5()
|
||
|
|
{
|
||
|
|
return $this->view->fetch('/index/h5');
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public function encrypt($input)
|
||
|
|
{
|
||
|
|
return base64_encode(openssl_encrypt($input, 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function decrypt($input)
|
||
|
|
{
|
||
|
|
return openssl_decrypt(base64_decode($input), 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|