Пример #1
0
 /**
  * 设置
  *
  */
 public function setting()
 {
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_POST)) {
             die('hack attemp.');
         }
         $captcha = 0;
         $captcha = empty($_POST['captcha_register']) ? $captcha : $captcha | CAPTCHA_REGISTER;
         $captcha = empty($_POST['captcha_login']) ? $captcha : $captcha | CAPTCHA_LOGIN;
         $captcha = empty($_POST['captcha_comment']) ? $captcha : $captcha | CAPTCHA_COMMENT;
         $captcha = empty($_POST['captcha_tag']) ? $captcha : $captcha | CAPTCHA_TAG;
         $captcha = empty($_POST['captcha_admin']) ? $captcha : $captcha | CAPTCHA_ADMIN;
         $captcha = empty($_POST['captcha_login_fail']) ? $captcha : $captcha | CAPTCHA_LOGIN_FAIL;
         $captcha = empty($_POST['captcha_message']) ? $captcha : $captcha | CAPTCHA_MESSAGE;
         $captcha_width = empty($_POST['captcha_width']) ? 100 : intval($_POST['captcha_width']);
         $captcha_height = empty($_POST['captcha_height']) ? 30 : intval($_POST['captcha_height']);
         $m = M('site_config');
         $m->where('code="captcha"')->save(array('value' => $captcha));
         $m->where('code="captcha_width"')->save(array('value' => $captcha_width));
         $m->where('code="captcha_height"')->save(array('value' => $captcha_height));
         clear_all_caches();
         $this->success('编辑成功');
     }
     $res = M('site_config')->where('code="captcha"')->find();
     $captcha = $res['value'];
     $captcha_check = array();
     if ($captcha & CAPTCHA_REGISTER) {
         $captcha_check['register'] = 'checked="checked"';
     }
     if ($captcha & CAPTCHA_LOGIN) {
         $captcha_check['login'] = '******';
     }
     if ($captcha & CAPTCHA_COMMENT) {
         $captcha_check['comment'] = 'checked="checked"';
     }
     if ($captcha & CAPTCHA_ADMIN) {
         $captcha_check['admin'] = 'checked="checked"';
     }
     if ($captcha & CAPTCHA_MESSAGE) {
         $captcha_check['message'] = 'checked="checked"';
     }
     if ($captcha & CAPTCHA_LOGIN_FAIL) {
         $captcha_check['login_fail_yes'] = 'checked="checked"';
     } else {
         $captcha_check['login_fail_no'] = 'checked="checked"';
     }
     $this->assign('captcha', $captcha_check);
     $res = M('site_config')->where('code="captcha_width"')->find();
     $this->assign('captcha_width', $res['value']);
     $res = M('site_config')->where('code="captcha_height"')->find();
     $this->assign('captcha_height', $res['value']);
     $this->assign('ur_href', '验证码管理 > 验证码设置');
     $this->assign('_hash_', buildFormToken());
     $this->display();
 }
Пример #2
0
 /**
  * 清除缓存
  *
  */
 public function clear()
 {
     if ($this->isPost() && $this->isAjax()) {
         if (C('TOKEN_ON') && !checkFormToken($_POST)) {
             die('hack attemp.');
         }
         set_time_limit(0);
         //清空数据缓存
         clear_all_caches();
         $this->ajaxReturn('', buildFormToken(), 1);
     }
     $this->assign('_hash_', buildFormToken());
     $this->assign('ur_href', '清除系统缓存');
     $this->display();
 }
Пример #3
0
 public function toggleStatus()
 {
     $action = '';
     if (empty($_REQUEST['model'])) {
         $action = strtolower(trim($_REQUEST['field']));
     } else {
         $action = $_REQUEST['model'] . '_' . strtolower(trim($_REQUEST['field']));
     }
     if (!AdminPriv::checkPrive(MODULE_NAME, $action)) {
         $this->ajaxReturn('', '您没有权限进行此操作', 0);
     }
     $id = intval($_REQUEST['id']);
     if ($id == 0) {
         exit;
     }
     $val = intval($_REQUEST['val']) == 0 ? 1 : 0;
     $field = trim($_REQUEST['field']);
     if (empty($field)) {
         exit;
     }
     $name = $_REQUEST['model'] ? $_REQUEST['model'] : $this->getActionName();
     if (empty($name)) {
         exit;
     }
     $model = D($name);
     if (!$model instanceof Model) {
         $model = M($name);
         if (!$model instanceof Model) {
             exit;
         }
     }
     $pk = $_REQUEST['pk'] ? $_REQUEST['pk'] : $model->getPk();
     if (false !== $model->where($pk . ' = ' . $id)->setField($field, $val)) {
         //清空数据缓存
         clear_all_caches();
         $this->ajaxReturn('', $val, 1);
     } else {
         $this->ajaxReturn('', '操作失败', 0);
     }
 }