Beispiel #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 index()
 {
     $search['text'] = Input::get('search_text');
     $search['type'] = Input::get('search_type');
     if ($search['type'] == 'type') {
         $list = Badword::where('type', $search['text'])->orderBy('id', 'desc')->paginate(15);
     } else {
         if ($search['type'] == 'badword') {
             $list = Badword::where('badword', 'like', "%{$search['text']}%")->orderBy('id', 'desc')->paginate(15);
         } else {
             $list = Badword::orderBy('id', 'desc')->paginate(15);
         }
     }
     return View::make('admin.badword_list')->withlist($list)->withsearch($search);
 }