<?php namespace controllers; use Engine\X; use Engine\Gvar; use Engine\Route; /** * 添加脏词 */ Route::get('add', function () { X::render('audit/dirtyword_add'); }); Route::post('add', function () { $post = X::request()->post(['dirtyword' => '']); //添加脏词 X::module('dirtyword')->add(['words' => $post->dirtyword, 'company_id' => Gvar::audit('company_id')]); X::redirect("/audit/dirtyword/add"); }); Route::get('delete', function () { $get = X::request()->get(['id' => '']); //添加脏词 X::module('dirtyword')->del($get->id); echo "success"; });
<?php use Engine\X; use Engine\Gvar; X::map('csrf', function () { echo "~~~~~~~~~~csrf~~~~~~~~~~~~~~"; }); //关闭csrf X::setEnv('csrf', false); //初始化session X::register('session', function () { $session = new libraries\session(); $session->start(); return $session; }); if (!X::session()->get('company_id') && X::getEnv('action') != 'signin' && X::getEnv('controller') != 'audit/index') { X::redirect('/audit/signin'); } // Gvar::set(['company_id' => X::session()->get('company_id'), 'company_name' => X::session()->get('company_name'), 'account' => X::session()->get('account')], 'audit');
/** * 查找 */ Route::get('search', function () { $get = X::request()->get(['search' => '']); $dw = X::module('dirtyword')->search($get->search); X::render('audit/index', ['dirtyword' => $dw]); }); /** * 登录 */ Route::get('signin', function () { X::render('audit/login'); }); Route::post('signin', function () { $post = X::request()->post(['account' => '', 'password' => '']); if (!$post->account || !$post->password) { X::redirect('/audit/signin'); } if ($company = X::module('company')->signin($post->account, $post->password)) { X::redirect('/audit'); } else { X::redirect('www.baidu.com'); } }); /** * 脏词管理 */ Route::get('dirtyword', function () { X::render('audit/dirtyword'); });