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/tag/tag.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 tag extends admin
{	
	public function nav2()
	{
		global $G;
		$nav = array();
		foreach($G['option']['type'] as $k=>$v){
			if(preg_match('/^(2|3|4|5)\d?$/',$k)){
				$nav[$k] = array(
					'name' => $v,
					'mold' => 'tag',
					'param' => array('type'=>$k)
				);
			}
		}
		return $nav;
	}
	
	public function init()
	{
		global $G;
		$G['cover'] = $this->cover();
		$G['navs0'] = self::nav2();
		$type = arrExist($G['get'],'type');
		if(!$type){
			$G['get']['type'] = $type = key($G['navs0']);
		}
		$G['navs0'][$type]['active'] = true;
		$folder = arrExist(mysql::select_one('folder','items',"type='{$type}'",'sort DESC, id ASC'),'folder');
		$data = page::tag_pages($type,null,$G['rows']=$this->rows(20));
		$table = array_search($type,$G['pass']['type']);
		foreach($data['list'] as $k=>$v){
			if($v['parent']){
				$data['list'][$k]['parent'] = $parent = arrExist(mysql::select_one("GROUP_CONCAT(id SEPARATOR ',') AS parent",$table,"id IN ({$v['parent']})"),'parent');
				$data['list'][$k]['amount'] = $amount = arrExist(mysql::select_one("COUNT(*) AS amount",$table,"id IN ({$v['parent']}) AND display=1 AND recycle=0 AND weight>=0"),'amount');
				mysql::update(array('parent'=>$parent,'amount'=>$amount),'tag',"id='{$v['id']}'");
			}
			$data['list'][$k]['url'] = url::tag($folder, $v);
		}
		echo $this->theme('tag/tag', $data);
	}
	
	
	public function edit()
	{
		global $G;
		/* boss_CMS */
		$G['cover'] = $this->cover('tag');
		$data = array();
		foreach($G['option']['type'] as $k=>$v){
			if(preg_match('/^(2|3|4|5)\d?$/',$k)){
				$G['type'][$k] = $v;
			}
		}
		if(isset($G['get']['id'])){
			$data = mysql::select_one('*','tag',"id='{$G['get']['id']}'");
		}
		echo $this->theme('tag/edit', $data);
	}
	
	public function add()
	{	
		global $G;
		$this->cover('tag',$G['get']['id']?'M':'A');
		if($title = arrExist($G['post'],'title')){
			if($id = $G['get']['id']){
				$data = array(
					'type'        => $G['get']['type'],
					'name'        => $G['post']['name'],
					'title'       => $title
				);
				if($result = mysql::select_one('id','tag',"id='{$id}'")){
					if(mysql::total("tag","title='{$data['title']}' AND type='{$G['get']['type']}' AND id!='{$id}'")){
						alert('标签名称已经存在');
					}
					if(preg_match('/^\d+$/',$data['name'])){
						alert('路径名称不能为纯数字');
					}
					if($data['name'] && mysql::total("tag","name='{$data['name']}' AND type='{$G['get']['type']}' AND id!='{$id}'")){
						alert('路径名称已经存在');
					}
					mysql::update($data,"tag","id='{$id}'");
				}
				alert('操作成功', url::mpf('tag','tag','edit',array('id'=>$id,'success'=>'ok')));
			}else{
				$has = array();
				foreach($G['post']['type'] as $type){
					$title = json::defilter($title);
					foreach($title as $v){
						if($v !== ''){
							$data = array(
								'type'        => $type,
								'name'        => '',
								'title'       => $v,
								'parent'      => '',
								'seo_title'   => '',
								'keywords'    => '',
								'description' => ''
							);
							if(mysql::total("tag","title='{$v}' AND type='{$type}'")){
								$has[] = $v;
							}else{
								$id = mysql::insert($data,"tag");
							}
						}
					}
				}
				alert('操作成功', url::mpf('tag','tag','edit',array('id'=>$id,'success'=>'ok')));
			}
		}else{
			alert('没有提交信息');
		}
	}

	
	public function seo()
	{
		global $G;
		$G['cover'] = $this->cover('tag');
		if(isset($G['get']['id'])){
			$data = mysql::select_one('*','tag',"id='{$G['get']['id']}'");
			echo $this->theme('tag/seo', $data);
		}
	}
	
	public function addseo()
	{	
		global $G;
		$this->cover('tag','M');
		if($G['post'] && $id = $G['get']['id']){
			$data = array(
				'seo_title'   => $G['post']['seo_title'],
				'keywords'    => $G['post']['keywords'],
				'description' => $G['post']['description']
			);
			mysql::update($data,"tag","id='{$id}'");
			alert('操作成功', url::mpf('tag','tag','seo',array('id'=>$id,'success'=>'ok')));
		}else{
			alert('没有提交信息');
		}
	}

	
	public function select()
	{
		global $G;
		$G['cover'] = $this->cover('tag');
		$type = arrExist($G['get'],'type');
		if(is_numeric($type)){
			$res = mysql::select_all('*','tag',"type='{$type}'");
			echo json::encode($res);
		}
	}
	
	 
	public function delete()
	{
		global $G;	
		$this->cover('tag','D');
		if(isset($G['post']['url']) && isset($G['get']['id'])){
			$del = array();
			$arr = explode(',',$G['get']['id']);
			foreach($arr as $id){
				if(is_numeric($id)){
					$del[$id] = $id;
				}
			}
			if($del){
				$error=array();
				foreach($del as $id=>$name){
					if(is_numeric(mysql::delete("tag","id='{$id}'"))){
						
					}else{
						$error[]=$id;
					}
				}
				if($error){
					alert('ID为'.implode(',',$error).'删除失败');
				}else{
					alert('删除成功', url::mpf('tag','tag','init'));
				}
			}else{
				$_booscms;
				alert('没有删除对象id');
			}			
		}
		alert('没有提交信息');
	}
}
?>