Ejemplo n.º 1
0
 public static function check_badword($data)
 {
     $checkword = Badword::where('status', 1)->get();
     //获取审核词语列表
     foreach ($checkword as $li) {
         if ($li->type == 3) {
             $pattern = "/{$li->badword}/i";
             $replacement = $li->replace;
             $newcontent = preg_replace($pattern, $replacement, $data['content']);
             if ($newcontent != $data['content']) {
                 $data['content'] = $newcontent;
             }
         } else {
             if (stripos($data['content'], $li->badword) !== false) {
                 if ($li->type == 1) {
                     return false;
                 } else {
                     if ($li->type == 2) {
                         $data['status'] = 0;
                     }
                 }
             }
         }
         $curr = Badword::find($li->id);
         $curr->count = $curr->count + 1;
         $curr->save();
     }
     return $data;
 }
 public function status($do)
 {
     $data['do'] = $do;
     $data['ids'] = Input::get('ids');
     $rules = array('do' => 'required|integer', 'ids' => 'required|array');
     $valid = Validator::make($data, $rules);
     if ($valid->fails()) {
         return Redirect::to('msg')->withInput()->with('jump_sec', 3)->withErrors($valid);
     } else {
         foreach ($data['ids'] as $val) {
             $p = Badword::find($val);
             $p->status = $do;
             $p->save();
         }
         return Redirect::to('msg')->withInput()->with('jump_sec', 3)->with('jump_url', URL::to('admin/badword_list'))->with('message', "修改成功!");
     }
 }
Ejemplo n.º 3
0
 /**
  * 留言内容的过滤
  * @param $contents
  * @return mixed
  * @throws CommentApiException
  */
 protected function filterContent($contents)
 {
     $filterData = Badword::check_badword(array("content" => $contents));
     if ($filterData === false) {
         throw new CommentApiException($contents . "被禁止提交~!");
     }
     return $filterData["content"];
 }
Ejemplo n.º 4
0
 Route::get('/comment_edit/{id}', function ($id) {
     $p = Comment::find($id);
     //        dd($p);
     return View::make('admin/comment_edit')->with('p', $p);
 });
 Route::post('/comment_edit', "CommentController@edit");
 Route::post('/comment_status/{do}', "CommentController@status");
 Route::get('/badword_add', function () {
     return View::make('admin.badword_add');
 });
 Route::post('/badword_add', "BadwordController@add");
 Route::any('/badword_list', "BadwordController@index");
 Route::get('/badword_delete/{id}', "BadwordController@delete");
 Route::post('/badword_delete', "BadwordController@delete");
 Route::get('/badword_edit/{id}', function ($id) {
     $p = Badword::find($id);
     return View::make('admin/badword_edit')->with('p', $p);
 });
 Route::post('/badword_edit', "BadwordController@edit");
 Route::post('/badword_status/{do}', "BadwordController@status");
 //超管页面
 Route::group(['middleware' => 'super'], function () {
     Route::get('/user_add', function () {
         return View::make('admin.user_add');
     });
     Route::post('/user_add', "UserController@add");
     Route::any('/user_list', "UserController@index");
     Route::get('/user_delete/{id}', "UserController@delete");
     Route::post('/user_delete', "UserController@delete");
     Route::get('/user_edit/{id}', function ($id) {
         $u = User::find($id);
Ejemplo n.º 5
0
 /**
  * 保存数据
  * @return array|\Illuminate\Http\JsonResponse
  */
 protected function _save_data_process()
 {
     $save_data = array();
     $save_data['fid'] = Input::get('fid');
     $save_data['user_id'] = Input::get('user_id');
     $save_data['nickname'] = Input::get('nickname');
     $save_data['content'] = Input::get('content');
     $save_data['ip'] = Input::get('ip');
     $save_data['project_id'] = $this->project_id;
     $save_data['page_id'] = $this->page_id;
     if ($this->project_config['checkout'] == 1) {
         $save_data['status'] = 0;
     } else {
         $save_data['status'] = 1;
     }
     if (!empty(Input::get('star'))) {
         $save_data['star'] = Input::get('star');
     }
     if (!empty(Input::get('top'))) {
         $save_data['top'] = Input::get('top');
     }
     $validator = Validator::make($save_data, array('fid' => 'required|integer', 'user_id' => 'required|integer', 'nickname' => 'required', 'content' => 'required', 'ip' => 'required|ip', 'star' => 'sometimes|required', 'top' => 'sometimes|required|integer'));
     if ($validator->fails()) {
         $failed = $validator->failed();
         if (array_key_exists('fid', $failed)) {
             $return_arr['status'] = -10;
         } else {
             if (array_key_exists('user_id', $failed)) {
                 $return_arr['status'] = -11;
             } else {
                 if (array_key_exists('nickname', $failed)) {
                     $return_arr['status'] = -12;
                 } else {
                     if (array_key_exists('content', $failed)) {
                         $return_arr['status'] = -13;
                     } else {
                         if (array_key_exists('star', $failed)) {
                             $return_arr['status'] = -14;
                         } else {
                             if (array_key_exists('top', $failed)) {
                                 $return_arr['status'] = -15;
                             } else {
                                 if (array_key_exists('ip', $failed)) {
                                     $return_arr['status'] = -16;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return $this->_return_json($return_arr);
     } else {
         $blackcheck = $this->_check_blacklist($save_data['user_id'], $save_data['ip']);
         if ($blackcheck !== false) {
             return $this->_return_json($blackcheck);
         }
         $filter_data = Badword::check_badword($save_data);
         if ($filter_data === false) {
             $return_arr['status'] = -20;
             return $this->_return_json($return_arr);
         } else {
             $save_data = $filter_data;
         }
         $fid_arr = Comment::find($save_data['fid']);
         if ($fid_arr) {
             $tmp = '';
             $save_data['level'] = $fid_arr->level + 1;
             if ($fid_arr->path != '') {
                 $tmp = ',';
             }
             $save_data['path'] = $fid_arr->path . $tmp . $fid_arr->id;
         } else {
             $save_data['level'] = 1;
             $save_data['path'] = '';
         }
         return $save_data;
     }
 }