49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\home\controller;
|
|
|
|
use api\Httpcurl;
|
|
use think\facade\Cookie;
|
|
use think\facade\Db;
|
|
use think\facade\View;
|
|
|
|
class Contact extends Base
|
|
{
|
|
public function index()
|
|
{
|
|
if (Cookie::get('think_var') == 'en-us') {
|
|
View::assign('reason', CONTACT_REASON_EN);
|
|
} else {
|
|
View::assign('reason', CONTACT_REASON);
|
|
}
|
|
return View::fetch();
|
|
}
|
|
public function do_apply()
|
|
{
|
|
if(!captcha_check($_REQUEST['yzm'])){
|
|
return $this->error(lang('contact.yzm_error'));
|
|
}
|
|
if ($_REQUEST['email'] !== $_REQUEST['re_email']) {
|
|
return $this->error(lang('contact.email_error'));
|
|
}
|
|
unset($_REQUEST['re_email']);
|
|
unset($_REQUEST['s']);
|
|
unset($_REQUEST['yzm']);
|
|
$_REQUEST['reg_time'] = date('Y-m-d H:i:s');
|
|
$_REQUEST['source'] = MODEL;
|
|
$_REQUEST['model'] = CONTACT_MODEL;
|
|
$_REQUEST['lang'] = Cookie::get('think_var');
|
|
$_REQUEST['token'] = md5(CONTACT_MODEL);
|
|
try {
|
|
$order_res = Httpcurl::request(config('app.CREATE_CONTACT_URL'), 'post', $_REQUEST);
|
|
$order = json_decode($order_res[0], true);
|
|
if (!$order['code']) {
|
|
return $this->error($order['msg']);
|
|
}
|
|
return $this->success(lang('controller.success'));
|
|
} catch (\Exception $e) {
|
|
return $this->error(lang('controller.fail'));
|
|
}
|
|
}
|
|
|
|
} |