/**
  * 会员模块设置 
  */
 public function setting()
 {
     if (IS_POST) {
         $setting = $_POST['setting'];
         $data['setting'] = serialize($setting);
         $Module = M("Module");
         if ($Module->create()) {
             if ($Module->where(array("module" => "Member"))->save($data) !== false) {
                 import('Cacheapi');
                 $Cache = new Cacheapi();
                 $Cache->member_cache();
                 $this->success("更新成功!", U("Member_setting/setting"));
             } else {
                 $this->error("更新失败!", U("Member_setting/setting"));
             }
         } else {
             $this->error($Module->getError());
         }
     } else {
         $setting = M("Module")->where(array("module" => "Member"))->getField("setting");
         $this->assign("setting", unserialize($setting));
         $this->assign("show_header", false);
         $this->display();
     }
 }
 public function index()
 {
     $db = M("CensorWord");
     if (IS_POST) {
         $delete = $_POST['delete'];
         //敏感词
         $find = $_POST['find'];
         //不良词语类型
         $replacement = $_POST['replacement'];
         //分类
         $type = $_POST['type'];
         //替换内容
         $replacontent = $_POST['replacontent'];
         if (is_array($delete)) {
             foreach ($delete as $id) {
                 $db->where(array("id" => $id))->delete();
                 unset($find[$id], $replacement[$id], $type[$id], $replacontent[$id]);
             }
         }
         if (is_array($find)) {
             foreach ($find as $id => $ti) {
                 $data = array();
                 if ($replacement[$id] == '{REPLACE}') {
                     $data['replacement'] = $replacontent[$id];
                 } else {
                     $data['replacement'] = $replacement[$id];
                 }
                 $data['type'] = $type[$id];
                 $data['find'] = $find[$id];
                 $db->where(array("id" => $id))->data($data)->save();
             }
         }
         //缓存更新
         import('Cacheapi');
         $Cache = new Cacheapi();
         $Cache->censorword_cache();
         $this->success("操作成功!");
     } else {
         $where = array();
         if (isset($_GET['search'])) {
             $type = (int) $this->_get("type");
             if ($type) {
                 $where['type'] = array("EQ", $type);
             }
             $keyword = $this->_get("keyword");
             if ($keyword) {
                 $where['find'] = array("LIKE", "%{$keyword}%");
                 $this->assign("keyword", $keyword);
             }
         }
         $count = $db->where($where)->count();
         $page = $this->page($count, 20);
         $data = $db->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();
         $this->assign("Page", $page->show('Admin'));
         $this->assign("data", $data);
         $this->display();
     }
 }
 /**
  * 初始化模型 
  */
 protected final function initModel()
 {
     if (!F("Model")) {
         D("Model")->model_cache();
     }
     //栏目缓存
     if (!F("Category")) {
         D("Category")->category_cache();
     }
     //20120615 增加
     if (!is_file(RUNTIME_PATH . "content_output.class.php")) {
         import("Cacheapi");
         $Cache = new Cacheapi();
         $Cache->model_content_cache();
     }
     //会员相关必要缓存
     if (!F("Model_Member") || !F("Member_group")) {
         D("Model")->MemberModelCache();
         D("Member_group")->Membergroup_cache();
     }
 }