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/link/link.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 link extends admin
{
	public function init()
	{
		global $G;
		$G['cover'] = $this->cover();
		if(is_numeric($G['get']['area'])){
			$where = "area='{$G['get']['area']}'";
		}else{
			$where = "area='0'";
		}
		$data = page::link_pages($G['rows']=$this->rows(20), null, null, null, 'pages', '*', $where);
		echo $this->theme('link/link', $data);
	}

	public function exchange()
	{
		global $G;
		$this->cover('link','R');
		if(is_numeric($G['get']['id'])){
			$res = mysql::select_one('link','link',"id='{$G['get']['id']}'");
			$host = parse_url($G['config']['domain'],PHP_URL_HOST);
			$json = json::get($file=ROOT_PATH.'cache/json/link_exchange.json');
			$md5 = md5($host.'-'.$res['link']);
			if($json[$md5] && $json[$md5]['time']<TIME+3600){
				$json[$md5]['id'] = $G['get']['id'];
				echo json::encode($json[$md5]);
				die();
			}else{
				into::basic_class('curl');
				preg_match("/<a[^>]+?{$host}[^>]+?>/i",curl::request($res['link']),$match);
				$data = array('id'=>$G['get']['id'],'time'=>TIME);
				if($match[0]){
					$data['msg'] = '成功';
					$data['state'] = 'success';
					$data['color'] = 'green';
					if(preg_match('/rel=([\'|"])nofollow\\1/',$match[0])){
						$data['msg'] .= '<small color="red">(nofollow)</small>';
					}
				}else{
					$data['msg'] = '失败';
					$data['state'] = 'error';
					$data['color'] = 'red';
				}
				echo json::encode($data);
				unset($data['id']);
				$json[$md5] = $data;
				json::put($file,$json);
				die();
			}
		}
	}
	
	public function modify()
	{
		global $G;
		$this->cover('link','M');
		if(isset($G['post']['id'])){
			$bosscms_error=array();
			foreach($G['post']['id'] as $id){
				if(isset($G['post']['sort'.$id])){
					$data = array('sort'=>$G['post']['sort'.$id]);
				}else if(isset($G['post']['display'.$id])){
					$data = array('display'=>$G['post']['display'.$id]);
				}
				if($data && !is_numeric(mysql::update($data,"link","id='{$id}'"))){
					$bosscms_error[]=$id;
				}
			}
			if($bosscms_error){
				alert('ID为'.implode(',',$bosscms_error).'修改失败');
			}else{
				alert('修改成功!', url::mpf('link','link','init'));
			}
		}else{
			alert('没有提交信息!');
		}
	}
	
	public function edit()
	{
		global $G;
		/* boss_CMS */
		$G['cover'] = $this->cover('link');
		$data = array();
		if(isset($G['get']['id']) && $G['get']['area']!='all'){
			$data = mysql::select_one('*','link',"id='{$G['get']['id']}'");
		}
		$data['subarr'] = page::items_option(0,false,array(),true);
		echo $this->theme('link/edit', $data);
	}
	
	public function add()
	{	
		global $G;
		$this->cover('link',$G['get']['id']?'M':'A');
		if(isset($G['post'])){
			$data = array(
				'name'        => $G['post']['name'],
				'items'       => $G['post']['items']?$G['post']['items']:'',
				'type'        => $G['post']['type'],
				'image'       => $G['post']['image'],
				'link'        => $G['post']['link'],
				'nofollow'    => $G['post']['nofollow'],
				'target'      => $G['post']['target'],
				'sort'        => $G['post']['sort'],
				'display'     => $G['post']['display']
			);
			if(is_numeric($G['get']['area'])){
				$data['area'] = $G['get']['area'];
			}else{
				$data['area'] = 0;
			}
			if(($id=$G['get']['id']) && $G['get']['area']!='all'){
				if($result = mysql::select_one('id','link',"id='{$id}'")){
					mysql::update($data,"link","id='{$id}'");
				}else{
					alert('没有内容');
				}
			}else{
				if($G['get']['area']=='all'){
					$areall = explode(',',$G['get']['id']);
					foreach($areall as $v){
						if(is_numeric($v)){
							$data['area'] = $v;
							$id = mysql::insert($data,"link");
							if($G['post']['continue']){
								$areall2 = mysql::select_all('id','area',"parent='{$v}'");
								foreach($areall2 as $v2){
									$data['area'] = $v2['id'];
									$id = mysql::insert($data,"link");
									$areall3 = mysql::select_all('id','area',"parent='{$v2['id']}'");
									foreach($areall3 as $v3){
										$data['area'] = $v3['id'];
										$id = mysql::insert($data,"link");
									}
								}
							}
						}
					}
				}else{
					$id = mysql::insert($data,"link");
				}
			}
			alert('操作成功', url::mpf('link','link','edit',array('id'=>$id,'success'=>'ok')));
		}else{
			alert('没有提交信息');
		}
	}
	
	public function delete()
	{
		global $G;
		$this->cover('link','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("link","id='{$id}'"))){
						
					}else{
						$error[]=$id;
					}
				}
				if($error){
					alert('ID为'.implode(',',$error).'删除失败');
				}else{
					alert('删除成功');
				}
			}else{
				$_booscms;
				alert('没有删除对象id');
			}			
		}
		alert('没有提交信息');
	}
}
?>