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/bb.cwoyt.com/Application/Admin/Controller/ClassController.class.php
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 赛脑 <2233759493@qq.com> <http://www.sn.com>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use COM\Page;
/**
 * 产品控制器
 * @author 赛脑 <2233759493@qq.com>
 */
class ClassController extends AdminController {


	public $infoadmin = array();

	public function __construct(){
		parent::__construct();  
		
		$perid = M('member')->where('uid = '.UID)->getField('perid');
		
		$infoadmin = M('permissions')->where('perid = '.$perid)->field('product')->find();
		
		if($infoadmin['product']){
			$infoadmin['system'] = explode(',',$infoadmin['product']);
		}
		
		if(!$infoadmin['product']){
			$this->error('参数错误!');
		}
		$this->infoadmin = $infoadmin;
		$nav_type = 'product';
		$nav_type_li = 'class';
		$this->assign('nav_type', $nav_type);
		$this->assign('nav_type_li', $nav_type_li);
		
	}

    /**
     * 产品列表
     * @author 赛脑 <2233759493@qq.com>
     */
    public function index(){
		
		if(UID != 1){
			$infoadmin = $this->peradmin;
			if(!in_array("class",$infoadmin['product'])){
				$this->error('参数错误!');
			}
		}
		
		$count = M('class')->count();
		$page = new Page($count,100);
		$list = M('class')->limit($page->firstRow.','.$page->listRows)->order('sort asc')->select();
		
		$pages = $page->show();
		
        $this->assign('count', $count);
		$this->assign('_list', $list);
		$this->assign('_page', $pages);
		$this->meta_title = '分类管理';
		$this->display();
    }
	
	public function add(){
		
		if(UID != 1){
			$infoadmin = $this->peradmin;
			if(!in_array("class_add",$infoadmin['product'])){
				$this->error('参数错误!');
			}
		}
		if(IS_POST){
			
			$data = array(
				'title' => trim(I('post.title')),
				'sort' => I('post.sort'),
				'status' => I('post.status'),
			);
			if($data['status'] == 'on'){
				$data['status'] = 1;
			}else{
				$data['status'] = 2;
			}
			
			if(I('post.cid')){
				
				if(UID != 1){
					$infoadmin = $this->peradmin;
					if(!in_array("class_update",$infoadmin['product'])){
						$this->error('参数错误!');
					}
				}
				action_log('class_update', 'member', UID, UID);
				M('class')->where('cid = '.I('post.cid'))->save($data);
				$this->success('编辑成功!',U('index'));
			}else{
				if(UID != 1){
					$infoadmin = $this->peradmin;
					if(!in_array("class_add",$infoadmin['product'])){
						$this->error('参数错误!');
					}
				}
				M('class')->add($data);
				action_log('class_add', 'member', UID, UID);
				$this->success('添加成功!',U('index'));
			}
			
		}else{
			
			$cid = I('get.cid');
			$info = M('class')->where('cid = '.$cid)->find();
			$this->assign('info', $info);
			$this->meta_title = '分类管理';
			$this->display();
		}
		
	}
	
	public function sorts(){
		
		if(IS_POST){
			foreach(I('post.sort') as $k=>$v){
				M('class')->where('cid = '.$k)->save(array('sort' => $v));
			}
		}
		$this->success('操作成功!',U('index'));
		
	}
	
	public function del(){
		if(UID != 1){
			$infoadmin = $this->peradmin;
			if(!in_array("class_del",$infoadmin['product'])){
				$this->error('参数错误!');
			}
		}
		$cid = I('get.cid');
		M('class')->where('cid = '.$cid)->delete();
		action_log('class_del', 'member', UID, UID);
		$this->success('删除成功!',U('index'));
	}
	
	public function del_arr(){
		if(IS_POST){
			foreach($_POST['cid'] as $k=>$v){
				M('class')->where('cid = '.$v)->delete();
			}
			action_log('class_del', 'member', UID, UID);
			$this->success('删除成功!');
		}
	}
}