|
|
@@ -942,238 +942,6 @@ class UserController extends BaseController
|
|
|
return $response->getBody()->write(json_encode($rs));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public function ticket($request, $response, $args)
|
|
|
- {
|
|
|
- if ($_ENV['enable_ticket'] != true) {
|
|
|
- exit(0);
|
|
|
- }
|
|
|
- $pageNum = $request->getQueryParams()['page'] ?? 1;
|
|
|
- $tickets = Ticket::where('userid', $this->user->id)->where('rootid', 0)->orderBy('datetime', 'desc')->paginate(15, ['*'], 'page', $pageNum);
|
|
|
- $tickets->setPath('/user/ticket');
|
|
|
-
|
|
|
- if ($request->getParam('json') == 1) {
|
|
|
- $res['ret'] = 1;
|
|
|
- $res['tickets'] = $tickets;
|
|
|
- return $response->getBody()->write(json_encode($res));
|
|
|
- }
|
|
|
-
|
|
|
- return $this->view()->assign('tickets', $tickets)->display('user/ticket.tpl');
|
|
|
- }
|
|
|
-
|
|
|
- public function ticket_create($request, $response, $args)
|
|
|
- {
|
|
|
- return $this->view()->display('user/ticket_create.tpl');
|
|
|
- }
|
|
|
-
|
|
|
- public function ticket_add($request, $response, $args)
|
|
|
- {
|
|
|
- $title = $request->getParam('title');
|
|
|
- $content = $request->getParam('content');
|
|
|
- $markdown = $request->getParam('markdown');
|
|
|
-
|
|
|
- if ($title == '' || $content == '') {
|
|
|
- $res['ret'] = 0;
|
|
|
- $res['msg'] = '非法输入';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- if (strpos($content, 'admin') != false || strpos($content, 'user') != false) {
|
|
|
- $res['ret'] = 0;
|
|
|
- $res['msg'] = '请求中有不当词语';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- $ticket = new Ticket();
|
|
|
- $antiXss = new AntiXSS();
|
|
|
-
|
|
|
- $ticket->title = $antiXss->xss_clean($title);
|
|
|
- $ticket->content = $antiXss->xss_clean($content);
|
|
|
- $ticket->rootid = 0;
|
|
|
- $ticket->userid = $this->user->id;
|
|
|
- $ticket->datetime = time();
|
|
|
- $ticket->save();
|
|
|
-
|
|
|
- if ($_ENV['mail_ticket'] == true && $markdown != '') {
|
|
|
- $adminUser = User::where('is_admin', '=', '1')->get();
|
|
|
- foreach ($adminUser as $user) {
|
|
|
- $user->sendMail(
|
|
|
- $_ENV['appName'] . '-新工单被开启',
|
|
|
- 'news/warn.tpl',
|
|
|
- [
|
|
|
- 'text' => '管理员,有人开启了新的工单,请您及时处理。'
|
|
|
- ]
|
|
|
- []
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ($_ENV['useScFtqq'] == true && $markdown != '') {
|
|
|
- $ScFtqq_SCKEY = $_ENV['ScFtqq_SCKEY'];
|
|
|
- $postdata = http_build_query(
|
|
|
- array(
|
|
|
- 'text' => $_ENV['appName'] . '-新工单被开启',
|
|
|
- 'desp' => $markdown
|
|
|
- )
|
|
|
- );
|
|
|
- $opts = array('http' =>
|
|
|
- array(
|
|
|
- 'method' => 'POST',
|
|
|
- 'header' => 'Content-type: application/x-www-form-urlencoded',
|
|
|
- 'content' => $postdata
|
|
|
- ));
|
|
|
- $context = stream_context_create($opts);
|
|
|
- file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context);
|
|
|
- }
|
|
|
-
|
|
|
- $res['ret'] = 1;
|
|
|
- $res['msg'] = '提交成功';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- public function ticket_update($request, $response, $args)
|
|
|
- {
|
|
|
- $id = $args['id'];
|
|
|
- $content = $request->getParam('content');
|
|
|
- $status = $request->getParam('status');
|
|
|
- $markdown = $request->getParam('markdown');
|
|
|
-
|
|
|
- if ($content == '' || $status == '') {
|
|
|
- $res['ret'] = 0;
|
|
|
- $res['msg'] = '非法输入';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- if (strpos($content, 'admin') != false || strpos($content, 'user') != false) {
|
|
|
- $res['ret'] = 0;
|
|
|
- $res['msg'] = '请求中有不当词语';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- $ticket_main = Ticket::where('id', '=', $id)->where('rootid', '=', 0)->first();
|
|
|
- if ($ticket_main->userid != $this->user->id) {
|
|
|
- $newResponse = $response->withStatus(302)->withHeader('Location', '/user/ticket');
|
|
|
- return $newResponse;
|
|
|
- }
|
|
|
-
|
|
|
- if ($status == 1 && $ticket_main->status != $status) {
|
|
|
- if ($_ENV['mail_ticket'] == true && $markdown != '') {
|
|
|
- $adminUser = User::where('is_admin', '=', '1')->get();
|
|
|
- foreach ($adminUser as $user) {
|
|
|
- $user->sendMail(
|
|
|
- $_ENV['appName'] . '-工单被重新开启',
|
|
|
- 'news/warn.tpl',
|
|
|
- [
|
|
|
- 'text' => '管理员,有人重新开启了<a href="' . $_ENV['baseUrl'] . '/admin/ticket/' . $ticket_main->id . '/view">工单</a>,请您及时处理。'
|
|
|
- ]
|
|
|
- []
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- if ($_ENV['useScFtqq'] == true && $markdown != '') {
|
|
|
- $ScFtqq_SCKEY = $_ENV['ScFtqq_SCKEY'];
|
|
|
- $postdata = http_build_query(
|
|
|
- array(
|
|
|
- 'text' => $_ENV['appName'] . '-工单被重新开启',
|
|
|
- 'desp' => $markdown
|
|
|
- )
|
|
|
- );
|
|
|
- $opts = array('http' =>
|
|
|
- array(
|
|
|
- 'method' => 'POST',
|
|
|
- 'header' => 'Content-type: application/x-www-form-urlencoded',
|
|
|
- 'content' => $postdata
|
|
|
- ));
|
|
|
- $context = stream_context_create($opts);
|
|
|
- file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context);
|
|
|
- $useScFtqq = $_ENV['ScFtqq_SCKEY'];
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ($_ENV['mail_ticket'] == true && $markdown != '') {
|
|
|
- $adminUser = User::where('is_admin', '=', '1')->get();
|
|
|
- foreach ($adminUser as $user) {
|
|
|
- $user->sendMail(
|
|
|
- $_ENV['appName'] . '-工单被回复',
|
|
|
- 'news/warn.tpl',
|
|
|
- [
|
|
|
- 'text' => '管理员,有人回复了<a href="' . $_ENV['baseUrl'] . '/admin/ticket/' . $ticket_main->id . '/view">工单</a>,请您及时处理。'
|
|
|
- ]
|
|
|
- []
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- if ($_ENV['useScFtqq'] == true && $markdown != '') {
|
|
|
- $ScFtqq_SCKEY = $_ENV['ScFtqq_SCKEY'];
|
|
|
- $postdata = http_build_query(
|
|
|
- array(
|
|
|
- 'text' => $_ENV['appName'] . '-工单被回复',
|
|
|
- 'desp' => $markdown
|
|
|
- )
|
|
|
- );
|
|
|
- $opts = array('http' =>
|
|
|
- array(
|
|
|
- 'method' => 'POST',
|
|
|
- 'header' => 'Content-type: application/x-www-form-urlencoded',
|
|
|
- 'content' => $postdata
|
|
|
- ));
|
|
|
- $context = stream_context_create($opts);
|
|
|
- file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $antiXss = new AntiXSS();
|
|
|
-
|
|
|
- $ticket = new Ticket();
|
|
|
- $ticket->title = $antiXss->xss_clean($ticket_main->title);
|
|
|
- $ticket->content = $antiXss->xss_clean($content);
|
|
|
- $ticket->rootid = $ticket_main->id;
|
|
|
- $ticket->userid = $this->user->id;
|
|
|
- $ticket->datetime = time();
|
|
|
- $ticket_main->status = $status;
|
|
|
-
|
|
|
- $ticket_main->save();
|
|
|
- $ticket->save();
|
|
|
-
|
|
|
-
|
|
|
- $res['ret'] = 1;
|
|
|
- $res['msg'] = '提交成功';
|
|
|
- return $this->echoJson($response, $res);
|
|
|
- }
|
|
|
-
|
|
|
- public function ticket_view($request, $response, $args)
|
|
|
- {
|
|
|
- $id = $args['id'];
|
|
|
- $ticket_main = Ticket::where('id', '=', $id)->where('rootid', '=', 0)->first();
|
|
|
-
|
|
|
- if ($ticket_main->userid != $this->user->id) {
|
|
|
- if ($request->getParam('json') == 1) {
|
|
|
- $res['ret'] = 0;
|
|
|
- $res['msg'] = '这不是你的工单!';
|
|
|
- return $response->getBody()->write(json_encode($res));
|
|
|
- }
|
|
|
- $newResponse = $response->withStatus(302)->withHeader('Location', '/user/ticket');
|
|
|
- return $newResponse;
|
|
|
- }
|
|
|
-
|
|
|
- $pageNum = $request->getQueryParams()['page'] ?? 1;
|
|
|
-
|
|
|
-
|
|
|
- $ticketset = Ticket::where('id', $id)->orWhere('rootid', '=', $id)->orderBy('datetime', 'desc')->paginate(5, ['*'], 'page', $pageNum);
|
|
|
- $ticketset->setPath('/user/ticket/' . $id . '/view');
|
|
|
-
|
|
|
- if ($request->getParam('json') == 1) {
|
|
|
- foreach ($ticketset as $set) {
|
|
|
- $set->username = $set->User()->user_name;
|
|
|
- $set->datetime = $set->datetime();
|
|
|
- }
|
|
|
- $res['ret'] = 1;
|
|
|
- $res['tickets'] = $ticketset;
|
|
|
- return $response->getBody()->write(json_encode($res));
|
|
|
- }
|
|
|
-
|
|
|
- return $this->view()->assign('ticketset', $ticketset)->assign('id', $id)->display('user/ticket_view.tpl');
|
|
|
- }
|
|
|
-
|
|
|
public function updateWechat($request, $response, $args)
|
|
|
{
|
|
|
$type = $request->getParam('imtype');
|
|
|
@@ -1665,7 +1433,7 @@ class UserController extends BaseController
|
|
|
$logs = UserSubscribeLog::orderBy('id', 'desc')->where('user_id', $this->user->id)->paginate(15, ['*'], 'page', $pageNum);
|
|
|
$iplocation = new QQWry();
|
|
|
$logs->setPath('/user/subscribe_log');
|
|
|
-
|
|
|
+
|
|
|
if (($request->getParam('json') == 1)) {
|
|
|
$res['ret'] = 1;
|
|
|
$res['logs'] = $logs;
|