80 lines
3.1 KiB
PHP
Executable File
80 lines
3.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\th\controller;
|
|
|
|
use think\Lang;
|
|
use think\Loader;
|
|
use think\Config;
|
|
use think\TransDb;
|
|
class Index extends BaseController {
|
|
|
|
public function index() {
|
|
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'], 'authcode') || $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);
|
|
}
|
|
$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'),
|
|
];
|
|
$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, '未知错误');
|
|
}
|
|
|
|
}
|