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/tight/item.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 item extends admin
{
	public function init()
	{
		global $G;
		/* boss_CMS */
		$G['cover'] = $this->cover('tight');
		$data = array();
		if(preg_match('/^\w+$/',$G['get']['id'])){
			$json = file_get_contents(ROOT_PATH.'system/web/common/tight/'.$G['get']['id'].'.json');
			$list = json::decode($json);
			$parent = setDefault($G['get']['parent'],0);
			foreach($list as $k=>$v){
				if(preg_match("/^{$parent},/",$k)){
					$data[] = array(
						'id' => substr($k,strpos($k,',')+1),
						'name' => $v
					);
				}
			}
			if($dn = count($data)){
				foreach($data as $k=>$v){
					$data[$k]['has'] = preg_match("/[\{|,]\"{$v['id']},\d+\"\:/",$json);
					$data[$k]['sort'] = $dn-$k;
				}
			}
		}
		echo $this->theme('tight/item', $data);
	}


	public function modify()
	{
		global $G;
		$this->cover('tight','M');
		if(isset($G['post']['id']) && preg_match('/^\w+$/',$G['get']['id'])){
			$file = ROOT_PATH.'system/web/common/tight/'.$G['get']['id'].'.json';
			$list = json::get($file);
			$parent = setDefault($G['get']['parent'],0);
			foreach($list as $k=>$v){
				if(preg_match("/^{$parent},/",$k)){
					$data[] = array($k,$v);
				}
			}
			$arr = array();
			if($dn = count($data)){
				foreach($data as $k=>$v){
					$id = substr($v[0],strpos($v[0],',')+1);
					if(in_array($id,$G['post']['id'])){
						$arr[$G['post']['sort'.$id].'.'.$k.'1'] = $v;
					}else{
						$arr[$dn-$k] = $v;
					}
				}
			}
			krsort($arr);
			$new = array();
			foreach($list as $k=>$v){
				if(preg_match("/^{$parent},/",$k)){
					if($arr){
						foreach($arr as $v2){
							$new[$v2[0]] = $v2[1];
						}
						unset($arr);
					}
				}else{
					$new[$k] = $v;
				}
			}
			dir::create($file,json::encode($new));
			alert('排序成功', url::mpf('tight','item','init'));
		}else{
			alert('没有提交信息');
		}
	}

	public function edit()
	{
		global $G;
		/* boss_CMS */
		$G['cover'] = $this->cover('tight');
		$data = array();
		if(isset($G['get']['did']) && preg_match('/^\w+$/',$G['get']['id'])){
			$file = ROOT_PATH.'system/web/common/tight/'.$G['get']['id'].'.json';
			$list = json::get($file);
			$data['name'] = $list[setDefault($G['get']['parent'],0).','.$G['get']['did']];
		}
		echo $this->theme('tight/iedit', $data);
	}

	public function add()
	{
		global $G;
		$G['cover'] = $this->cover('tight',$G['get']['did']?'M':'A');
		if(preg_match('/^\w+$/',$G['get']['id'])){
			$file = ROOT_PATH.'system/web/common/tight/'.$G['get']['id'].'.json';
			$list = json::get($file);
			$parent = setDefault($G['get']['parent'],0);
			if(isset($G['get']['did'])){
				$list[$parent.','.$G['get']['did']] = $G['post']['name'];
			}else{
				$res = json::defilter($G['post']['name']);
				$len = count($list)+1;
				foreach($res as $k=>$v){
					$list[$parent.','.($len+$k)] = $v;
				}
			}
			dir::create($file,json::encode($list));
			alert('修改成功', url::mpf('tight','item','edit',array('success'=>'ok')));
		}else{
			alert('没有提交信息');
		}
	}

	public function delete()
	{
		global $G;
		$this->cover('tight','D');
		if(isset($G['post']['url']) && isset($G['get']['id']) && preg_match('/^\w+$/',$G['get']['sign'])){
			$file = ROOT_PATH.'system/web/common/tight/'.$G['get']['sign'].'.json';
			$list = json::get($file);
			$arr = explode(',',$G['get']['id']);
			$parent = setDefault($G['get']['parent'],0);
			foreach($arr as $id){
				unset($list[$parent.','.$id]);
				$del = $this->relation($list, $id);
				foreach($del as $v){
					unset($list[$v]);
				}
			}
			dir::create($file,json::encode($list));
			alert('删除成功', url::mpf('tight','item','init',array('id'=>$G['get']['sign'])));
		}
		alert('没有提交信息');
	}

	public function relation($list, $parent, $data=array())
	{
		foreach($list as $k=>$v){
			if(preg_match("/^{$parent},/",$k)){
				$data[] = $k;
				$data = $data + $this->relation($list, substr($k,strpos($k,',')+1), $data);
			}
		}
		return $data;
	}
}
?>