LimitNameAction.class.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class LimitNameAction extends CommonAction{
  10. //检查模块开关是否开启
  11. public function check_Module(){
  12. $m_config = load_auto_cache("m_config");
  13. if($m_config['name_limit']==0){
  14. $this->redirect('APP_ROOT+'.get_manage_url_name().'?m=Conf&a=mobile&');
  15. }
  16. }
  17. //昵称限制
  18. public function index(){
  19. $this->check_Module();
  20. if (trim($_REQUEST['name'])) {
  21. $where = ' name like \'%' . trim($_REQUEST['name']) . '%\'';
  22. }
  23. $model = M('limit_name');
  24. $count = $model->where($where)->count();
  25. $p = new Page($count);
  26. $page = $p->show();
  27. $vo = $model->where($where)->limit($p->firstRow.','.$p->listRows)->select();
  28. $this->assign("page", $page);
  29. $this->assign("list", $vo);
  30. $this->display ();
  31. }
  32. //添加页面显示
  33. public function add()
  34. {
  35. $this->display();
  36. }
  37. //添加方法
  38. public function insert()
  39. {
  40. $this->check_Module();
  41. B('FilterString');
  42. $data = M(MODULE_NAME)->create();
  43. //开始验证有效性
  44. $this->assign("jumpUrl", u(MODULE_NAME . "/add"));
  45. if (!check_empty($data['name'])) {
  46. $this->error("请输入昵称");
  47. }
  48. $condition['name'] = $data['name'];
  49. $count = M(MODULE_NAME)->where($condition)->count();
  50. if ($count > 0){
  51. $this->error("该昵称已存在");
  52. }
  53. // 更新数据
  54. $log_info = $data['name'];
  55. $list = M(MODULE_NAME)->add($data);
  56. if ($list!==false) {
  57. //成功提示
  58. save_log($log_info . L("INSERT_SUCCESS"), 1);
  59. $this->success(L("INSERT_SUCCESS"));
  60. } else {
  61. //错误提示
  62. save_log($log_info . L("INSERT_FAILED"), 0);
  63. $this->error(L("INSERT_FAILED"));
  64. }
  65. }
  66. //彻底删除指定记录
  67. public function foreverdelete() {
  68. $this->check_Module();
  69. //彻底删除指定记录
  70. $ajax = intval($_REQUEST['ajax']);
  71. $id = intval($_REQUEST ['id']);
  72. if (isset ( $id )) {
  73. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  74. $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  75. foreach($rel_data as $data)
  76. {
  77. $info[] = $data['name'];
  78. }
  79. if($info) $info = implode(",",$info);
  80. $list = M(MODULE_NAME)->where ( $condition )->delete();
  81. //删除相关预览图
  82. // foreach($rel_data as $data)
  83. // {
  84. // @unlink(get_real_path().$data['preview']);
  85. // }
  86. if ($list!==false) {
  87. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  88. clear_auto_cache("get_help_cache");
  89. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  90. } else {
  91. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  92. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  93. }
  94. } else {
  95. $this->error (l("INVALID_OPERATION"),$ajax);
  96. }
  97. }
  98. }
  99. ?>