⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_npc.php

📁 天使宠物 V6 Final版 天使宠物 V6 Final版目前支持Discuz!6.0 和 Discuz!6.1论坛
💻 PHP
字号:
<?phpif(!defined('IN_DISCUZ')){exit('Access Denied');} if($gm==0){exit('无效的越权访问!');}$strarr=array(" ","\\'","\'","'","%",";","\\","\"","<",">");if($action=='edit'){	$act='editsave';	$show='编辑怪物';	$npcid=intval($npcid);	$npcinfo=$db->get_one("SELECT * FROM {$tablepre}wxnpcdata where npcid='$npcid'");	if(!$npcinfo){		showmessage("无效操作",'pet.php?index=admin&adminindex=npc');	}else{		$maplist=array(); 		$query = $db->query("SELECT mapid,mapname FROM {$tablepre}wxmap  ORDER BY mapid,requirejob");		while($mapinfo = $db->fetch_array($query)) {			$maplist[]=$mapinfo;		}	}}elseif($action=='add'){	$show='增加怪物';	$npcid=intval($npcid);	$npcinfo=$db->get_one("SELECT * FROM {$tablepre}wxnpcdata where npcid='$npcid'");	if(!$npcinfo){		$npcinfo=array();		$npcinfo['npcmoney']=$npcinfo['npcgold']=0;	}	$act='addsave';	$maplist=array(); 	$query = $db->query("SELECT mapid,mapname FROM {$tablepre}wxmap  ORDER BY mapid,requirejob");	while($mapinfo = $db->fetch_array($query)) {		$maplist[]=$mapinfo;	}}elseif($action=='del'){	$npcid=intval($npcid);	$npcinfo=$db->get_one("SELECT * FROM {$tablepre}wxnpcdata where npcid='$npcid'");	if(!$npcinfo){		showmessage("无效操作",'pet.php?index=admin&adminindex=npc');	}else{		$mapid=$npcinfo[mapid];		$db->query("delete from {$tablepre}wxnpcdata where npcid='$npcid'");		showmessage("删除怪物完成!<BR><BR><a href=pet.php?index=admin&adminindex=npc&mapid=$mapid>怪物设置</a>");	}}elseif($action=='addsave'){	$npcname=str_replace($strarr,"",$npcname);	$npctalk=str_replace($strarr,"",$npctalk);   	if($npcname=='' or cnstrlen($npcname)>20){		showmessage("请输入正确的怪物名称!","javascript:history.back()");	}elseif(!preg_match("/^[a-zA-Z0-9\.\/\-_]{1,16}\.(jpg|gif|bmp|png)$/", strtolower($npcpic))){		showmessage("请输入正确的怪物图片地址!","javascript:history.back()");	}elseif(!in_array($npcsx,array('金','木','水','火','土','光','暗'))){		showmessage("怪物属性有误,请输入【金、木、水、火、土、光、暗】的一种!","javascript:history.back()");	}elseif($npcitem!='' && !preg_match("/^[a-zA-Z0-9_]{3,15}$/", $npcitem)){		showmessage("请输入正确的掉落物品名称!","javascript:history.back()");	}else{		$npclevel=intval($npclevel);		$npcmaxhp=intval($npcmaxhp);		$npcexp=intval($npcexp);		$npcatk=intval($npcatk);		$npcdef=intval($npcdef);		$mapid=intval($mapid);		$npcgold=intval($npcgold);		$npctime=intval($npctime);		if($npcitem!=''){			$query=$db->get_one("select itemname from {$tablepre}wxitem where itemname='$npcitem'");			if(!$query){				showmessage("宠物系统中不存在此英文名字的物品!","javascript:history.back()");			}		}		$db->query("insert into {$tablepre}wxnpcdata (npcname,npcpic,npclevel,npcmaxhp,npcexp,npcatk,npcdef,npcsx,mapid,npcgold,npcitem,npctime,npctalk) values ('$npcname','$npcpic','$npclevel','$npcmaxhp','$npcexp','$npcatk','$npcdef','$npcsx','$mapid','$npcgold','$npcitem','$npctime','$npctalk')");		showmessage("怪物添加完成!<BR><BR><a href=pet.php?index=admin&adminindex=npc&mapid=$mapid>怪物设置</a>");	}}elseif($action=='editsave'){	$npcid=intval($npcid);	$npcname=str_replace($strarr,"",$npcname);	$npctalk=str_replace($strarr,"",$npctalk);	$npcinfo=$db->get_one("SELECT * FROM {$tablepre}wxnpcdata where npcid='$npcid'");	if(!$npcinfo){		showmessage("无效操作",'pet.php?index=admin&adminindex=npc');	}elseif($npcname=='' or cnstrlen($npcname)>20){		showmessage("请输入正确的怪物名称!","javascript:history.back()");	}elseif(!preg_match("/^[a-zA-Z0-9\.\/\-_]{1,16}\.(jpg|gif|bmp|png)$/", strtolower($npcpic))){		showmessage("请输入正确的怪物图片地址!","javascript:history.back()");	}elseif(!in_array($npcsx,array('金','木','水','火','土','光','暗'))){		showmessage("怪物属性有误,请输入【金、木、水、火、土、光、暗】的一种!","javascript:history.back()");	}elseif($npcitem!='' && !preg_match("/^[a-zA-Z0-9_]{3,15}$/", $npcitem)){		showmessage("请输入正确的掉落物品名称!","javascript:history.back()");	}else{		$npclevel=intval($npclevel);		$npcmaxhp=intval($npcmaxhp);		$npcexp=intval($npcexp);		$npcatk=intval($npcatk);		$npcdef=intval($npcdef);		$mapid=intval($mapid);		$npcgold=intval($npcgold);		$npctime=intval($npctime);		if($npcitem!=''){			$query=$db->get_one("select itemname from {$tablepre}wxitem where itemname='$npcitem'");			if(!$query){				showmessage("宠物系统中不存在此英文名字的物品!","javascript:history.back()");			}		}		$db->query("update {$tablepre}wxnpcdata set npcname='$npcname',npcpic='$npcpic',npclevel='$npclevel',npcmaxhp='$npcmaxhp',npcexp='$npcexp',npcatk='$npcatk',npcdef='$npcdef',npcsx='$npcsx',mapid='$mapid',npcgold='$npcgold',npcitem='$npcitem',npctalk='$npctalk',npctime='$npctime' where npcid='$npcid'");		showmessage("怪物编辑完成!<BR><BR><a href=pet.php?index=admin&adminindex=npc&mapid=$mapid>怪物设置</a>");	}	}else{	$action='show';	$mapid=($mapid=='')?-1:intval($mapid);	$npctype=intval($npctype);	if($mapid==-1){		$sqlaa="select count(*) as num from {$tablepre}wxnpcdata";		$sqlbb="";	}else{		$sqlaa="select count(*) as num from {$tablepre}wxnpcdata where mapid='$mapid'";		$sqlbb=" and a.mapid='$mapid' ";	}	$npcname=str_replace($strarr,"",$npcname);	if($npcname!=''){		$sqlaa="select count(*) as num from {$tablepre}wxnpcdata where npcname like '%".$npcname."%'";		$sqlbb=" and a.npcname like '%".$npcname."%'";		$npcname=rawurlencode($npcname);	}	if($npctype==1){		$sqlaa="select count(*) as num from {$tablepre}wxnpcdata where npcgold>0";		$sqlbb=" and a.npcgold>0";	}elseif($npctype==2){		$sqlaa="select count(*) as num from {$tablepre}wxnpcdata where npcitem!=''";		$sqlbb=" and a.npcitem!=''";	}else{		$npctype=0;	}		$perpage = 50;     $page=(intval($page)>0)?intval($page):1;		$query=$db->get_one($sqlaa);	$num = $query['num'];	$page=($page>ceil($num/$perpage))?ceil($num/$perpage):$page;	$mpurl = "pet.php?index=admin&adminindex=npc&action=show&mapid=$mapid&npcname=$npcname&npctype=$npctype";	$mulpage=multi($num, $perpage, $page, $mpurl);	$star = $num==0?0:($page * $perpage - $perpage); 	$npclist=array(); 	$query = $db->query("SELECT a.*,b.mapname,c.cname FROM {$tablepre}wxnpcdata a left join  {$tablepre}wxmap b on a.mapid=b.mapid left join {$tablepre}wxitem c on a.npcitem=c.itemname where 1 $sqlbb   ORDER BY a.mapid,a.npclevel,a.npcexp  LIMIT $star,$perpage");	while($npcinfo = $db->fetch_array($query)) {		if($npcinfo[mapname]==''){			$npcinfo[mapname]='任意地图';		}		if($npcinfo['npctime']==0){			$npcinfo['npctime']="不限";		}else{			$npcinfo['npctime']="<font color=red>".$npcinfo['npctime']."分钟<br>".gmdate('Y-m-d H:i',$npcinfo['pktime']+$timeoffset*3600)."</font>";		}			$npclist[]=$npcinfo;	}}include template('admin_npc',9938,'wxpet/templates');?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -