128 lines
5.0 KiB
PHP
Executable File
128 lines
5.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\usmobile\controller;
|
|
|
|
use think\Lang;
|
|
use think\Loader;
|
|
use think\Config;
|
|
use think\TransDb;
|
|
class Index extends BaseController {
|
|
|
|
public function index() {
|
|
|
|
// 如果是手机端进官网
|
|
if (isMobile()) {
|
|
if ($_SERVER['HTTP_HOST']=="www.orico.com.cn" || $_SERVER['HTTP_HOST']=="orico.com.cn") {
|
|
return $this->redirect("https://www.orico.com.cn/mobile");
|
|
}
|
|
}
|
|
else{
|
|
return $this->redirect("https://www.orico.cc/us");
|
|
}
|
|
|
|
$lebel_list = getDifferentProduct("recommend",12);
|
|
$this->assign('recomment_items',$lebel_list);
|
|
|
|
|
|
|
|
$blog_list = getArticleList();
|
|
$this->assign('blog_items',$blog_list);
|
|
|
|
$faqData = getFaqList();
|
|
$this->assign('faqData',$faqData);
|
|
|
|
return $this->fetch('/index');
|
|
}
|
|
public function info(){
|
|
echo "\nstart: ".date("Y-m-d H:i:s")."\n";
|
|
$TransDb = new TransDb();
|
|
$TransDb->selectAllStruct("ProductCategory");
|
|
//$getDb = $TransDb->getkv();
|
|
echo "\nend :".date("Y-m-d H:i:s")."\n";
|
|
|
|
dump($TransDb);
|
|
// phpinfo();
|
|
}
|
|
public function feedback() {
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->post();
|
|
if (empty($data) || !is_array($data)) {
|
|
return $this->error('未知错误');
|
|
}
|
|
$this->verify_check($data['authcode'], 'yanzhengma') || $this->error('验证码不正确');
|
|
$validaterule = [
|
|
'name' => 'require',
|
|
'subject' => 'require',
|
|
'contact' => 'require',
|
|
'content' => 'require',
|
|
];
|
|
$validatemsg = [
|
|
'name.require' => '名称不能为空',
|
|
'subject.require' => '主题不能为空',
|
|
'contact.require' => '联系方式不能为空',
|
|
'content.require' => '内容不能为空',
|
|
];
|
|
if (empty($data['way'])) {
|
|
return $this->error('请选择正确的联系方式');
|
|
} else {
|
|
if ($data['way'] == 'E-mail') {
|
|
$validaterule['contact'] = 'email';
|
|
$validatemsg['contact.email'] = '联系方式格式不正确';
|
|
}
|
|
if ($data['way'] == 'tel') {
|
|
$validaterule['contact'] = ['regex' => '^1[345789]\d{9}$|^([0-9]{3,4}-?)?[0-9]{7,8}$'];
|
|
$validatemsg['contact.regex'] = '联系方式格式不正确';
|
|
}
|
|
}
|
|
$valid_result = $this->validate($data, $validaterule, $validatemsg);
|
|
if (true !== $valid_result) {
|
|
// 验证失败 输出错误信息
|
|
return $this->error($valid_result);
|
|
}
|
|
|
|
$referer = isset($data['refer']) ? $data['refer'] : 'https://www.baidu.com?wd=9558s';
|
|
$url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
|
|
|
|
$searchFeed = getKeywords($referer);
|
|
$channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : '';
|
|
$keyword = isset($searchFeed['search']) ? $searchFeed['search'] : '';
|
|
|
|
$fed = visitLog();
|
|
|
|
$set = [
|
|
'feedback_type' => isset($data['feedback_type']) ? $data['feedback_type'] : '',
|
|
'name' => isset($data['name']) ? $data['name'] : 'Name',
|
|
'subject' => isset($data['subject']) ? $data['subject'] : '',
|
|
'content' => isset($data['content']) ? $data['content'] : '',
|
|
'way' => isset($data['way']) ? $data['way'] : '',
|
|
'contact' => isset($data['contact']) ? $data['contact'] : '',
|
|
'addtime' => date('Y-m-d H:i:s'),
|
|
|
|
'order_id' => isset($data['order_id']) ? $data['order_id'] : '',
|
|
'country' => isset($data['country']) ? $data['country'] : '',
|
|
'channel' => isset($data['channel']) ? $data['channel'] : '',
|
|
|
|
|
|
'refer' => $referer,
|
|
'url' => $url,
|
|
'channels' => $channel,
|
|
'keyword' => $keyword,
|
|
'ip' => $fed['ip'],
|
|
'state' => $fed['country'],
|
|
'province' => $fed['province'],
|
|
'city' => $fed['city'],
|
|
'drvice' => $fed['drive'],
|
|
'user_agent' => $fed['system']." ".$fed['brower'],
|
|
];
|
|
$model = Loader::model('Msgform')->insertRow($set);
|
|
if ($model && $model->getData('id')) {
|
|
return $this->success('成功!成功!等待管理员查看', url('/'));
|
|
} else {
|
|
return $this->error('操作失败');
|
|
}
|
|
}
|
|
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
|
|
}
|
|
|
|
}
|