HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.fpngv.com/application/member/controller/Group.php
<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 御宅男 <530765310@qq.com>
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | 会员组管理
// +----------------------------------------------------------------------
namespace app\member\controller;

use app\common\controller\Adminbase;
use app\member\model\Member as Member_Model;
use app\member\model\MemberGroup as Member_Group;

class Group extends Adminbase
{
    //初始化
    protected function initialize()
    {
        parent::initialize();
        $this->Member_Group = new Member_Group;
        $this->Member_Model = new Member_Model;
    }

    /**
     * 会员组列表
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            $_list = $this->Member_Group->order(["listorder" => "ASC", "id" => "DESC"])->select();
            foreach ($_list as $k => $v) {
                //统计会员总数
                $_list[$k]['_count'] = $this->Member_Model->where(["groupid" => $v['id']])->count('id');
            }
            $result = array("code" => 0, "data" => $_list);
            return json($result);
        }
        return $this->fetch();
    }

    /**
     * 会员组添加
     */
    public function add()
    {
        if ($this->request->isPost()) {
            $data = $this->request->post();
            $result = $this->validate($data, 'Group');
            if (true !== $result) {
                return $this->error($result);
            }
            if ($this->Member_Group->groupAdd($data)) {
                //更新缓存
                $this->Member_Group->Membergroup_cache();
                $this->success("添加成功!", url("group/index"));
            } else {
                $this->error("添加失败!");
            }

        } else {
            return $this->fetch();
        }
    }

    /**
     * 会员组编辑
     */
    public function edit()
    {
        if ($this->request->isPost()) {
            $data = $this->request->post();
            $result = $this->validate($data, 'Group');
            if (true !== $result) {
                return $this->error($result);
            }
            if ($this->Member_Group->groupEdit($data)) {
                //更新缓存
                $this->Member_Group->Membergroup_cache();
                $this->success("修改成功!", url("group/index"));
            } else {
                $this->error("修改失败!");
            }

        } else {
            $groupid = $this->request->param('id/d', 0);
            $data = $this->Member_Group->where(["id" => $groupid])->find();
            if (empty($data)) {
                $this->error("该会员组不存在!", url("Group/index"));
            }
            $this->assign("data", $data);
            //$this->assign('expand', unserialize($data['expand']));
            return $this->fetch();
        }

    }

    /**
     * 会员组删除
     */
    public function del()
    {
        $groupid = $this->request->param('id/d', 0);
        if (empty($groupid)) {
            $this->error("没有指定需要删除的会员组别!");
        }
        if ($this->Member_Group->groupDelete($groupid)) {
            //更新缓存
            $this->Member_Group->Membergroup_cache();
            $this->success("删除成功!", url("group/index"));
        } else {
            $this->error($this->Member_Group->getError());
        }
    }

}