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/bs.kntsleep.com/system/admin/group/group.class.php
<?php
/*
 * Copyright (c) Huyin Information Technology Co., Ltd. All Rights Reserved.
 * BOSSCMS Content Management System (https://www.bosscms.net/)
 */
defined('IS_OK') or exit('Access Forbidden');

into::basic_class('admin');

class group extends admin
{
	public function init()
	{
		global $G;
		$G['cover'] = $this->cover('group');
		$data = $this->glist(1);
		echo $this->theme('group/group', $data);
	}

	public function glist($where)
	{
		global $G;
		if($where){
			if(!$G['get']['column']){
				$G['body_class'] = 'iframe-content';
				$G['navsub'] = into::load_class('admin','items','content','new')->navsub();
			}
			
			$type = arrExist($G,'get|type');
			$items = arrExist($G,'get|items');
			if(!$type && $res=mysql::select_one('type','items',"id='{$items}'")){
				$type = $res['type'];
			}
			if($type && !preg_match('/^(2|3|4|5)\d?$/',$type)){
				alert('栏目类型错误');
			}
			if(is_numeric($G['get']['manager']) && $mid=mysql::select_one('id,level','manager',"id='{$G['get']['manager']}' AND (level>{$G['manager']['level']} OR id='{$G['manager']['id']}')")){
				if($mid['level']==1){
					$where = "FIND_IN_SET(issuer,'{$mid['id']},0') AND {$where}";
				}else{
					$where = "issuer='{$mid['id']}' AND {$where}";
				}
			}
			if($keyword = trim($G['get']['keyword'])){
				if(is_numeric($keyword)){
					$where = "id='{$keyword}' AND {$where}";
				}else if(!$mid && $res=mysql::select_one('id,level','manager',"(alias='{$keyword}' OR username='{$keyword}') AND (level>{$G['manager']['level']} OR id='{$G['manager']['id']}')")){
					if($res['level']==1){
						$where = "FIND_IN_SET(issuer,'{$res['id']},0') AND {$where}";
					}else{
						$where = "issuer='{$res['id']}' AND {$where}";
					}
				}else if($res=mysql::select_one('id','member',"username='{$keyword}'")){
					$where = "issuer='-{$res['id']}' AND {$where}";
				}else{
					$where = "name LIKE '%{$keyword}%' AND {$where}";
				}
			}
			$man = mysql::select_all('id,alias,username','manager',"level>{$G['manager']['level']} OR id='{$G['manager']['id']}'");
			foreach($man as $v){
				$G['man'][$v['id']] = $v['alias']?$v['alias']:$v['username'];
			}
			if(!$this->allow('read')){
				if($man){
					$where = "(issuer<0 OR FIND_IN_SET(issuer,'{$G['manager']['id']},".implode(',',arrOption($man,'id','id'))."')) AND {$where}";
				}else{
					$where = "(issuer<0 OR issuer='{$G['manager']['id']}') AND {$where}";
				}
			}
			switch($G['get']['order']){
				case 1:
					$order = 'top DESC, sort DESC, id DESC';
					break;
				case 2:
					$order = 'notice DESC, id DESC';
					break;
				default:
					$order = 'mtime DESC, id DESC';
					break;
			}
			if($attr = $G['get']['attr']){
				if($attr == 'c'){
					$wor = 'recommend=1 OR';
				}
				$where = "({$wor} FIND_IN_SET('{$attr}',recommend)) AND {$where}";
			}
			$rows = $G['rows'] = $this->rows(20);
			if($type){
				$data = page::group_pages($items, $type, $rows, null, null, null, 'pages', "*", $where, $order);
			}else{
				$data = page::group_all($rows, null, null, null, 'pages', "*", $where, $order);
			}
			foreach($data['list'] as $k=>$v){
				if($v['issuer']>0){
					$data['list'][$k]['user'] = $G['man'][$v['issuer']];
				}else if($v['issuer']<0){
					$data['list'][$k]['user'] = arrExist(mysql::select_one('username','member',"id='".abs($v['issuer'])."'"),'username');
				}else{
					$data['list'][$k]['user'] = $G['man'][1];
				}
			}

			$G['grade'] = $this->grade();
			$G['attribute'] = $this->attribute;
			$data['id'] = $items;
			$data['keyword'] = $keyword;
			$G['subarr'] = page::items_option(0,false,array(),false,'^(2|3|4|5)\d?$');
			$G['models'] = arrOption(mysql::select_all('id,type','items',"FIND_IN_SET(id,'".implode(',',array_keys($G['subarr']))."')"),'id','type');
			$G['get']['type'] = $type;
			if(isset($G['config']['attrflag'])){
				$G['attrflag'] = json::decode($G['config']['attrflag']);
			}else{
				into::basic_json('attrflag');
			}
			return $data;
		}
	}
	
	public function modify()
	{
		global $G;
		$this->cover('group','M');
		if(isset($G['post']['id'])){
			$error=array();
			foreach($G['post']['id'] as $typeid){
				if(isset($G['post']['sort'.$typeid])){
					list($type,$id) = explode('_',$typeid);
					$table = array_search($type,$G['pass']['type']);
					if(!is_numeric(mysql::update(array('sort'=>$G['post']['sort'.$typeid]),$table,"id='{$id}'"))){
						$error[]=$id;
					}
				}
			}
			if($error){
				alert('ID为'.implode(',',$error).'修改失败');
			}else{
				alert('修改成功', $_SERVER['HTTP_REFERER']);
			}
		}else{
			alert('没有提交信息');
		}
	}

	public function examine()
	{
		global $G;
		$this->cover('group','M');
		if(isset($G['post']['id']) && $this->allow()){
			$error=array();
			foreach($G['post']['id'] as $typeid){
				list($type,$id) = explode('_',$typeid);
				$table = array_search($type,$G['pass']['type']);
				if(!is_numeric(mysql::update(array('weight'=>0),$table,"id='{$id}' AND weight=-1"))){
					$error[]=$id;
				}
			}
			if($error){
				alert('ID为'.implode(',',$error).'审核失败');
			}else{
				$this->sitemap();
				alert('审核成功', $_SERVER['HTTP_REFERER']);
			}
		}else{
			alert('没有提交信息');
		}
	}

	public function refuse()
	{
		global $G;
		$this->cover('group','M');
		if(isset($G['post']['id']) && $this->allow()){
			$error=array();
			foreach($G['post']['id'] as $typeid){
				list($type,$id) = explode('_',$typeid);
				$table = array_search($type,$G['pass']['type']);
				if($G['config']['group_recycle']){
					if(!is_numeric(mysql::update(array('recycle'=>1),$table,"id='{$id}' AND weight=-1"))){
						$error[]=$id;
					}
				}else{
					if(is_numeric(mysql::delete($table,"id='{$id}' AND weight=-1"))){
						mysql::delete($table.'_content',"id='{$id}'");
						mysql::delete('top',"model='{$type}' AND parent='{$id}'");
						mysql::delete('tag',"type='{$type}' AND parent='{$id}'");
						if($res = mysql::select_all('id,parent','tag',"type='{$type}' AND FIND_IN_SET('{$id}',parent)")){
							foreach($res as $v){
								mysql::update(array('parent'=>trim(str_replace(",{$id},",',',",{$v['parent']},"),',')),'tag',"id='{$v['id']}'");
							}
						}
						if($G['config']['shop_open'] && $G['config']['shop_model']==$type){
							into::load_class('plugin','shop','shop','new')->delete($id);
						}
					}else{
						$error[]=$id;
					}
				}
			}
			if($error){
				alert('ID为'.implode(',',$error).'操作失败');
			}else{
				alert('操作成功', $_SERVER['HTTP_REFERER']);
			}
		}else{
			alert('没有提交信息');
		}
	}
	
	public function edit()
	{
		global $G;
		$G['cover'] = $this->cover('group');
		$G['no_copyright'] = $G['get']['simple'];
		$data = array();
		$data['items'] = $G['get']['items'];
		$type = $G['get']['type'];
		if($res=mysql::select_one('*','items',"id='{$data['items']}'")){
			if(!$type && $res){
				$type = $res['type'];
			}
			if($res['comments'] && mysql::total('models',"id='{$type}' AND comments=1")){
				$G['comments'] = true;
			}
		}
		$table = array_search($type,$G['pass']['type']);
		$data['ctime'] = $data['mtime'] = date('Y-m-d H:i:s',TIME);
		if($id = $G['get']['id']){
			$data = mysql::select_one('*',$table,"id='{$id}'");
			if($data){
				if($res = mysql::select_one('*',$table.'_content',"id='{$id}'")){
					$data = $data+$res;
				}
				if($res = mysql::select_one('*','shop',"id='{$id}'")){
					$data = $data+$res;
				}
				$data['ctime'] = date('Y-m-d H:i:s',$data['ctime']);
				$data['mtime'] = date('Y-m-d H:i:s',$data['mtime']);
				if($data['top'] && $top=mysql::select_one('etime','top',"model='{$type}' AND parent='{$id}'")){
					if($top['etime']>TIME){
						$G['top'][$top['etime']] = '过期时间 '.date('Y-m-d',$top['etime']);
						$data['top'] = $top['etime'];
					}else{
						$data['top'] = 0;
					}
				}
			}
			$data['recommend'] = $data['recommend']=='1'?array('c'):explode(',',$data['recommend']);
			$G['tag'] = array();
			$tag_list = page::tag($type, $id);
			foreach($tag_list as $v){
				$G['tag'][] = $v['title'];
			}
			$G['tag'] = json::encode($G['tag']);
		}
		$G['top'][0] = '默认排序';
		foreach($G['option']['term'] as $k=>$v){
			if($k<0){
				$G['top'][strtotime('+'.abs($k).'day',TIME)] = '置顶'.$v;
			}else if($k>0){
				$G['top'][strtotime("+{$k} month",TIME)] = '置顶'.$v;
			}else{
				$G['top'][1] = '置顶'.$v;
			}
		}
		if($type>=20){
			$G['field'] = page::field($type,'*','display=1');
		}else{
			$config = load::config();
			$G['transfer'] = isset($config['transfer'][$table])?$config['transfer'][$table]:array();
		}
		$G['grade'] = $this->grade();
		if($type==5){
			$G['dgrade'] = $G['grade'];
			$G['dgrade'][0] = '不限会员';
			unset($G['dgrade'][-1]);
		}
		if(!$this->allow()){
			if(is_numeric($data['weight'])){
				$res = $this->weight($G['grade'],$data['weight']);
				$key = array_key_first($res);
				$grade[$key] = $res[$key];
			}
			$grade = array(-1 => $G['grade'][-1]);
			$G['grade'] = $grade;
		}
		$G['page'] = array();
		$tpl = dir::read(load::theme().'/html/'.preg_replace('/^model_/','',$table).'_detail');
		foreach($tpl['file'] as $v){
			$G['page'][$v] = $v;
		}
		$G['subarr'] = page::items_option(0,false,array(),false,$G['get']['type']?$type:'^(2|3|4|5)\d?$');
		$G['models'] = arrOption(mysql::select_all('id,type','items',"FIND_IN_SET(id,'".implode(',',array_keys($G['subarr']))."')"),'id','type');
		$G['get']['type'] = $type;
		if(isset($G['config']['attrflag'])){
			$G['attrflag'] = json::decode($G['config']['attrflag']);
		}else{
			into::basic_json('attrflag');
		}
		echo $this->theme('group/edit', $data);
	}
	
	/* b o s s c m s */
	public function add()
	{	
		global $G;
		$this->cover('group',arrExist($G['get'],'id')?'M':'A');
		if(isset($G['post'])){
			$subcon = strSub(addslashes(strip_tags(delFilter($G['post']['content']))),0,100);
			$data = array(
				'name'        => $G['post']['name'],
				'items'       => $G['post']['items'],
				'sort'        => $G['post']['sort'],
				'notice'      => $G['post']['notice'],
				'recommend'   => $G['post']['recommend']?implode(',',$G['post']['recommend']):'',
				'top'         => $G['post']['top']>0?1:0,
				'display'     => $G['post']['display'],
				'recycle'     => 0,
				'static'      => arrExist($G['post'],'static'),
				'link'        => $G['post']['recommend']&&in_array('j',$G['post']['recommend'])?$G['post']['link']:'',
				'ctime'       => $G['post']['ctime']?strtotime($G['post']['ctime']):TIME,
				'mtime'       => $G['post']['mtime']?strtotime($G['post']['mtime']):TIME
			);
			$dcon = array(
				'theme'       => $G['post']['theme'],
				'title'       => $G['post']['title'],
				'keywords'    => $G['post']['keywords'],
				'description' => $G['post']['description']?$G['post']['description']:$subcon,
				'alt'         => $G['post']['alt'],
				'target'      => $G['post']['target'],
				'author'      => $G['post']['author'],
				'comments'    => $G['post']['comments']?1:0,
				'golds'       => $G['post']['golds'],
				'color'       => $G['post']['color']
			);
			if(!($type = arrExist($G['get'],'type'))){
				alert('没有指定栏目类型');
			}
			$table = array_search($type,$G['pass']['type']);
			if(preg_match('/^(2|3|4|5)$/',$type)){
				$dcon['text']      = $G['post']['text']?$G['post']['text']:$subcon;
				$dcon['content']   = $G['post']['content'];
				$dcon['container'] = arrExist($G['post'],'container');
				if(!$dcon['image'] = arrExist($G['post'],'image')){
					preg_match('/<img src="([^"]+)"/',delFilter($dcon['content']),$match);
					if(isset($match[1])){
						$dcon['image'] = addslashes($match[1]);
					}
				}
			}
			if(preg_match('/^(2|3|4)$/',$type)){
				$dcon['text1']    = arrExist($G['post'],'text1');
				$dcon['text2']    = arrExist($G['post'],'text2');
				$dcon['text3']    = arrExist($G['post'],'text3');
				$dcon['image1']   = arrExist($G['post'],'image1');
				$dcon['image2']   = arrExist($G['post'],'image2');
				$dcon['image3']   = arrExist($G['post'],'image3');
				$dcon['images']   = arrExist($G['post'],'images');
			}
			if($type == 3){
				$dcon['icon'] = arrExist($G['post'],'icon');
				$dcon['video'] = arrExist($G['post'],'video');
				$dcon['content1'] = arrExist($G['post'],'content1');
				$dcon['content2'] = arrExist($G['post'],'content2');
				$dcon['content3'] = arrExist($G['post'],'content3');
				$dcon['content4'] = arrExist($G['post'],'content4');
				$dcon['price'] = arrExist($G['post'],'price');
			}else if($type == 5){
				$bosscms_ = true;
				$dcon['dweight'] = $G['post']['dweight'];
				$dcon['dfiles'] = json::enfilter($G['post']['dfiles']);
				$dcon['file'] = $G['post']['file'];
				$dcon['down'] = $G['post']['down'];
				$dcon['size'] = $G['post']['size'];
				$dcon['icon'] = arrExist($G['post'],'icon');
				if($dcon['file'] && !$dcon['size']){
					$file = url::upload($dcon['file'],'sub',ROOT_PATH);
					$dcon['size'] = is_file($file)?@filesize($file):0;
				}
			}
			if(preg_match('/^(2|3|4|5)\d$/',$type)){
				$field = page::field($type);
				foreach($field as $v){
					$n = $v['name'];
					if($v['display']){
						$dcon[$n] = $G['post'][$n];
						if(is_array($dcon[$n])){
							$dcon[$n] = json::enfilter($dcon[$n]);
						}
					}else{
						$dcon[$n] = preg_match('/^int/',$v['type'])?0:'';
					}
				}
			}
			
			$items = arrExist($G['get'],'items');
			if($items && mysql::total('items',"id='{$items}'")){
				if($id = arrExist($G['get'],'id')){
					if($result = mysql::select_one('id,mtime',$table,"id='{$id}'")){
						if($result['mtime'] == $data['mtime']){
							$data['mtime'] = TIME;
						}
						if($this->allow()){
							$data['weight'] = $G['post']['weight'];
						}
						if(mysql::update($data,$table,"id='{$id}'")){
							if($G['post']['top']>1){
								mysql::select_set(array('model'=>$type,'parent'=>$id,'etime'=>$G['post']['top']),'top',array('etime'));
							}else{
								mysql::delete('top',"model='{$type}' AND parent='{$id}'");
							}
						}
						if(mysql::total($table.'_content',"id='{$id}'")){
							mysql::update($dcon,$table.'_content',"id='{$id}'");
						}else{
							$dcon['id'] = $id;
							mysql::insert($dcon,$table.'_content');
						}
					}else{
						alert('没有内容');
					}
				}else{
					$data['weight'] = $this->allow()?$G['post']['weight']:-1;
					$data['issuer'] = $G['manager']['id'];
					if(!$dcon['author']){
						$dcon['author'] = $G['manager']['alias']?$G['manager']['alias']:$G['manager']['username'];
					}
					if($id = mysql::insert($data,$table)){
						$dcon['id'] = $id;
						mysql::insert($dcon,$table.'_content');
						if($G['post']['top']>1){
							mysql::insert(array('model'=>$type,'parent'=>$id,'etime'=>$G['post']['top']),'top');
						}else{
							mysql::delete('top',"model='{$type}' AND parent='{$id}'");
						}
					}
					$this->sitemap();
				}
				if($G['config']['rule_static_auto']){
					mysql::update(array('static'=>into::load_class('admin','seo','rule','new')->repstatic($data['name'],$id)),$table,"id='{$id}'");
				}
				$tag_list = page::tag($type, $id);
				if($tag = arrExist($G['post'],'tag')){
					$tag = json::defilter($tag);
					foreach($tag as $t){
						if($res = mysql::select_one('*','tag',"type='{$type}' AND title='{$t}'")){
							if(strstr(",{$res['parent']},",",{$id},")){
								foreach($tag_list as $i=>$l){
									if($l['title']==stripslashes($t)){
										unset($tag_list[$i]);
									}
								}
							}else{
								mysql::update(array('parent'=>($res['parent']?$res['parent'].',':'').$id),'tag',"id='{$res['id']}'");
							}
						}else{
							mysql::insert(array('type'=>$type,'title'=>$t,'parent'=>$id,'name'=>'','seo_title'=>'','keywords'=>'','description'=>''),'tag');
						}
					}
				}
				foreach($tag_list as $l){
					mysql::update(array('parent'=>preg_replace("/^{$id}$|^{$id},|,{$id},|,{$id}$/i",'',$l['parent'])),'tag',"id='{$l['id']}'");
				}
				$tags = mysql::select_all('id,parent','tag',"type='{$type}' AND FIND_IN_SET('{$id}',parent)");
				foreach($tags as $v){
					mysql::update(array('amount'=>arrExist(mysql::select_one("COUNT(*) AS amount",$table,"FIND_IN_SET(id,'{$v['parent']}') AND display=1 AND recycle=0 AND weight>=0"),'amount')),'tag',"id='{$v['id']}'");
				}
				if($type!=2 && isset($G['post']['tc'])){
					value::set($G['post']['tc'], $id, $type);
				}
				if($G['config']['shop_open'] && $G['config']['shop_model']==$type){
					into::load_class('plugin','shop','shop','new')->add($id);
				}
				alert('操作成功', url::mpf('group','group','edit',array('id'=>$id,'success'=>'ok')));
			}else{
				alert('没有指定栏目');
			}
		}else{
			alert('没有提交信息');
		}
	}
	
	public function attr()
	{
		global $G;
		$id = $G['get']['id'];
		$type = $G['get']['type'];
		$flag = $G['get']['flag'];
		$top = $G['get']['top'];
		if(is_numeric($id) && ($flag || $top) && $table=array_search($type,$G['pass']['type'])){
			if($top){
				if(mysql::update(array('top'=>0),$table,"id='{$id}'")){
					mysql::delete('top',"model='{$type}' AND parent='{$id}'");
				}
			}else if($res = mysql::select_one('recommend',$table,"id='{$id}'")){
				if($flag == 'c'){
					$res['recommend'] = str_replace(1,'',$res['recommend']);
				}
				$data = array('recommend'=>trim(str_replace(',,',',',str_replace($flag,'',$res['recommend'])),','));
				if($flag == 'j'){
					$data['link'] = '';
				}
				mysql::update($data,$table,"id='{$id}'");
			}
			alert('修改成功', $_SERVER['HTTP_REFERER']);
		}else{
			alert('没有提交信息');
		}
	}
	
	public function attrflag()
	{
		global $G;
		if(isset($G['config']['attrflag'])){
			$G['attrflag'] = json::decode($G['config']['attrflag']);
		}else{
			into::basic_json('attrflag');
		}
		unset($G['attrflag']['j']);
		echo $this->theme('group/attrflag', $data);
	}
	
	public function attrs()
	{
		global $G;
		if($G['post']['recommend'] && $arr=explode(',',$G['get']['id'])){
			foreach($arr as $typeid){
				list($type,$id) = explode('_',$typeid);
				$table = array_search($type,$G['pass']['type']);
				if(is_numeric($id) && $res=mysql::select_one('recommend',$table,"id='{$id}'")){
					$res['recommend'] = trim(preg_replace('/0,?/','',$res['recommend']),',');
					foreach($G['post']['recommend'] as $v){
						if($G['post']['operate']){
							if(!strstr($res['recommend'],$v)){
								$res['recommend'] = $res['recommend'].','.$v;
							}
						}else{
							if($v == 'c'){
								$res['recommend'] = str_replace(1,'',$res['recommend']);
							}
							$res['recommend'] = str_replace(',,',',',str_replace($v,'',$res['recommend']));
						}
					}
					mysql::update(array('recommend'=>trim($res['recommend'],',')),$table,"id='{$id}'");
				}
			}
			if($G['post']['operate']){
				alert('修改成功', url::param($_SERVER['HTTP_REFERER'],'success','ok'));
			}else{
				alert('删除成功', url::param($_SERVER['HTTP_REFERER'],'success','ok'));
			}
		}else{
			alert('没有提交信息');
		}
	}
	
	public function paste()
	{
		global $G;
		$G['cover'] = $this->cover('group');
		if(preg_match('/^(copys|move)$/',$G['get']['action'])){
			$data['action'] = $G['get']['action'];
			$data['subarr'] = page::items_option(0,false,array(),false,$G['get']['type']?$G['get']['type']:'^(2|3|4|5)\d?$');
			echo $this->theme('group/paste',$data);
		}
	}
	
	public function copys()
	{
		global $G;
		$this->cover('group','A');
		if(isset($G['get']['id'])){
			$copys = $G['post']['copys'];
			if(is_numeric($copys) && $res=mysql::select_one('type','items',"id='{$copys}'")){
				$success = $error = array();
				$arr = explode(',',$G['get']['id']);
				foreach($arr as $typeid){
					list($type,$id) = explode('_',$typeid);
					$table = array_search($type,$G['pass']['type']);
					if(is_numeric($id) && $type==$res['type'] && $data=mysql::select_one('*',$table,"id='{$id}'")){
						unset($data['id']);
						$data['items'] = $copys;
						$data['ctime'] = $data['mtime'] = TIME;
						$data['notice'] = 0;
						$data['static'] = '';
						if($nid=mysql::insert($data,$table)){
							if($con=mysql::select_one('*',$table.'_content',"id='{$id}'")){
								$con['id']=$nid;
								mysql::insert($con,$table.'_content');
							}
							$theme = mysql::select_all('*','theme',"extent='{$type}' AND parent='{$id}'");
							foreach($theme as $val){
								unset($val['id']);
								$val['parent'] = $nid;
								mysql::insert($val,"theme");
							}
							if($G['config']['rule_static_auto']){
								mysql::update(array('static'=>into::load_class('admin','seo','rule','new')->repstatic($data['name'],$nid)),$table,"id='{$nid}'");
							}
							if($G['config']['shop_open'] && $G['config']['shop_model']==$type){
								into::load_class('plugin','shop','shop','new')->copys($nid, $id);
							}
							$success[] = $id;
						}else{
							$error[] = $id;
						}
					}else{
						$error[] = $id;
					}
				}
				if(!$error && $success){
					$this->sitemap();
					alert('复制成功', url::mpf('group','group','paste',array('action'=>'copys','success'=>'ok')));
				}else if($error && !$success){
					alert('复制失败');
				}else if($success){
					alert('复制成功'.count($success).'个,失败'.count($error).'个', url::mpf('group','group','paste',array('action'=>'copys','success'=>'ok')));
				}
			}else{
				alert('没有指定栏目');
			}		
		}
		alert('没有提交信息');
	}
	
	public function move()
	{
		global $G;	
		$this->cover('group','M');
		if(isset($G['get']['id'])){
			$move = $G['post']['move'];
			if(is_numeric($move) && $res=mysql::select_one('type','items',"id='{$move}'")){
				$success = $error = array();
				$arr = explode(',',$G['get']['id']);
				foreach($arr as $typeid){
					list($type,$id) = explode('_',$typeid);
					$table = array_search($type,$G['pass']['type']);
					if(is_numeric($id) && $type==$res['type'] && mysql::total($table,"id='{$id}' AND items!='{$move}'")){
						if(mysql::update(array('items'=>$move),$table,"id='{$id}'")){
							$success[] = $id;
						}else{
							$error[] = $id;
						}
					}else{
						$error[] = $id;
					}
				}
				if(!$error && $success){
					$this->sitemap();
					alert('移动成功', url::mpf('group','group','paste',array('action'=>'move','success'=>'ok')));
				}else if($error && !$success){
					alert('移动失败');
				}else if($success){
					alert('移动成功'.count($success).'个,失败'.count($error).'个', url::mpf('group','group','paste',array('action'=>'move','success'=>'ok')));
				}
			}else{
				alert('没有指定栏目');
			}
		}
		alert('没有提交信息');
	}
	
	public function delete()
	{
		global $G;	
		$this->cover('group','D');
		if(isset($G['post']['url']) && isset($G['get']['id'])){
			$success = $error = array();
			$arr = explode(',',$G['get']['id']);
			foreach($arr as $typeid){
				list($type,$id) = explode('_',$typeid);
				$table = array_search($type,$G['pass']['type']);
				if(is_numeric($id) && mysql::total($table,"id='{$id}'")){
					if($G['config']['group_recycle']){
						if(!is_numeric(mysql::update(array('recycle'=>1),$table,"id='{$id}'"))){
							$error[] = $id;
						}
					}else{
						if(is_numeric(mysql::delete($table,"id='{$id}'"))){
							mysql::delete($table.'_content',"id='{$id}'");
							mysql::delete('top',"model='{$type}' AND parent='{$id}'");
							mysql::delete('tag',"type='{$type}' AND parent='{$id}'");
							if($res = mysql::select_all('id,parent','tag',"type='{$type}' AND FIND_IN_SET('{$id}',parent)")){
								foreach($res as $v){
									mysql::update(array('parent'=>trim(str_replace(",{$id},",',',",{$v['parent']},"),',')),'tag',"id='{$v['id']}'");
								}
							}
							if($G['config']['shop_open'] && $G['config']['shop_model']==$type){
								into::load_class('plugin','shop','shop','new')->delete($id);
							}
						}else{
							$error[] = $id;
						}
					}
				}else{
					$error[] = $id;
				}
			}
			if($error){
				alert('ID为'.implode(',',$error).'删除失败');
			}else{
				$this->sitemap();
				alert('删除成功', $_SERVER['HTTP_REFERER']);
			}	
		}
		alert('没有提交信息');
	}

	public function grade()
	{
		$data = array();
		$data[0] = '开放阅读';
		$data[-1] = '待审内容';
		if($grade = page::grade_list()){
			foreach($grade as $v){
				$data[$v['weight']] = $v['name'];
			}
		}
		return $data;
	}

	public function weight($grade, $str)
	{
		if($weight = $grade[$str]){
			return array($str=>$weight);
		}else if($str>0){
			$weight = array();
			foreach($grade as $k2=>$v2){
				if($str>$k2){
					$weight = array($k2=>$v2);
				}else{
					break;
				}
			}
			return $weight;
		}
		return array();
	}

	public function allow($name='audit')
	{
		global $G;
		if($G['manager']['level']==1 || !$G['manager']['allow'] || $G['manager']['allow'][$name]){
			return true;
		}else{
			return false;
		}
	}
}
?>