原帖由 freddy 于 2005-11-26 00:01 发表
#46更新了~你自己加一下那个!重定义变量!
<?
/*
**********************************************
完美监狱 http://www.51happy365.com/bbs
Ver : 2.0
DiscuzVer : 3.0F
Mod by : Freddy
Original by : rel4x,pk0909,童虎)
LastUpdate: 2005.11.23
**********************************************
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
@include DISCUZ_ROOT.'./forumdata/cache/cache_plugins.php';
@include DISCUZ_ROOT.'./forumdata/cache/plugin_jail.php';
$jailsettings = $_DPLUGIN['jail']['vars'];
$jailinfo = $_DPLUGIN['jail'];
if(!$isadmin && $jailsettings['close']) showmessage($jailsettings['clomess'],'index.php');
if($jailsettings['jailadmin'] <> '') $isjailadmin = checkjailadmin($discuz_user);
require "./include/forum.func.php";
$forumselect = forumselect();
if(!$discuz_user) {
showmessage('not_loggedin');
}
if (!isset($action) or $action=='') {
$action="showroom";
}
$postban='cdb_postban'; //本人技术有限。。。如果你论坛前缀为其它的,请把cdb改掉。然后在global.func.php里的那个函数也作相应的修改。
if($action=="showroom") {
$num=9; //每页显示数量
if($page) {
$start_limit = ($page - 1) * $num;
} else {
$start_limit = 0;
$page = 1;
}
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}postban");
$zjnum=$db->result($query, 0);
$multipage = multi($db->result($query, 0), $num, $page, "plugin.php?identifier=jail&module=jail&");
$db->query("DELETE FROM {$tablepre}postban where timelimit<$timestamp");
$query = $db->query("SELECT * FROM {$tablepre}postban ORDER BY pb_id DESC LIMIT $start_limit, $num");
$break = 1;
while($pbdata = $db->fetch_array($query)){
$pbid=$pbdata['pb_id'];
$pbdata[tr] = $break;
$break++;
$pblist[] = $pbdata;
}
//----jailadmin show----------
$jailadminshow = '';
if ($jailsettings['jailadmin']<>'') {
$jailadminlist = explode(',', $jailsettings[jailadmin]);
foreach($jailadminlist as $jailadminnow) {
$query = $db->query("SELECT posts,credits,extcredits5 FROM {$tablepre}members WHERE username='$jailadminnow'");
$query2 = $db->query("SELECT avatar FROM {$tablepre}memberfields WHERE username='$jailadminnow'");
$userjailadmin=$db->fetch_array($query);
$userjailadmin['avatar'] = $userjailadmin['avatar'] ? image($userjailadmin['avatar']) : "<img src='images/common/jyz.jpg' border=0>";
$jailadminshow .= "<table border=0 width=200 align=left><tr><td height=160 width=160 align=bottom>$userjailadmin[avatar]</td></tr><tr><td height=20>狱长: <font color=red>$jailadminnow</font></td></tr><tr><td height=20>发贴: $userjailadmin[posts]<br>积分: $userjailadmin[credits]<br>现金: $userjailadmin[extcredits5]</td></tr></table>";
}
}
//----jailadmin show end------
}
if($action=="see") {
if (!$id) showmessage('未指定要探监犯人的编号','plugin.php?identifier=jail&module=jail');
$id=intval($id);
$query=$db->query("SELECT p.*, f.name as fname FROM {$tablepre}postban p LEFT JOIN {$tablepre}forums f ON p.fid=f.fid WHERE p.pb_id='$id'");
$pbdata = $db->fetch_array($query);
if(!$id or !$pbdata[pb_id]){showmessage('这个编号的犯人已经被释放','plugin.php?identifier=jail&module=jail');}
if ($pbdata['fid'] != 65535) {
$pbfw='<a href="forumdisplay.php?fid='.$pbdata['fid'].'">'.$pbdata['fname'].'</a>';
} else {
$pbfw='全社区设施'; }
$pbreason=htmlspecialchars($pbdata['reason']);
$pbtlim = gmdate("$dateformat $timeformat", $pbdata['timelimit'] + $timeoffset * 3600);
$pbstim = gmdate("$dateformat $timeformat", $pbdata['starttime'] + $timeoffset * 3600);
if($pbdata['pbmoney']==0){$pbmoney="不能保释";}
//----保释金额必须为正整数
else{$pbmoney=intval($pbdata['pbmoney']);}
//-----保释金额必须为正整数 END
$query = $db->query("SELECT opername FROM {$tablepre}postban WHERE pb_id='$id'");
$opruser = $db->result($query,0);
}
if($action=="baoshi") {
if (!$id) showmessage('未指定要保释犯人的编号','plugin.php?identifier=jail&module=jail');
$id=intval($id);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}postban where username='$discuz_user'");
$zjnum=$db->result($query, 0);
if($zjnum>0){showmessage('泥菩萨过河自身难保,还来保释别人','plugin.php?identifier=jail&module=jail');}
else{
$query = $db->query("SELECT * FROM {$tablepre}postban where pb_id='$id'");
$pbdata = $db->fetch_array($query);
if (!$pbdata) showmessage('该编号的犯人不存在','plugin.php?identifier=jail&module=jail');
if($pbdata['pbmoney']==0){showmessage('监狱重犯,不予保释','plugin.php?identifier=jail&module=jail');}
if($pbdata['username']==$discuz_user){showmessage('不能自己保释自己','plugin.php?identifier=jail&module=jail');}
//---bug fix for money----
$query = $db->query("SELECT `extcredits5` FROM {$tablepre}members WHERE username = '$discuz_user'");
$usermoney = $db->result($query,0);
//-------fix end-------
if($usermoney < intval($pbdata['pbmoney'])){showmessage('你的现金不够保释罪犯','plugin.php?identifier=jail&module=jail');}
else{
$pbmoney= intval($pbdata['pbmoney']);
$db->query("UPDATE {$tablepre}members SET extcredits5=extcredits5-$pbmoney WHERE username ='$discuz_user'");
$db->query("DELETE FROM {$tablepre}postban where pb_id='$id'");
showmessage('成功保释犯人','plugin.php?identifier=jail&module=jail');}}}
if($action=="rob") {
if (!$id) showmessage('未指定要劫狱犯人的编号','plugin.php?identifier=jail&module=jail');
$id=intval($id);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}postban where username='$discuz_user'");
$zjnum=$db->result($query, 0);
if($zjnum>0){showmessage('泥菩萨过河自身难保,还来劫狱','plugin.php?identifier=jail&module=jail');}
else{
$query = $db->query("SELECT * FROM {$tablepre}postban where pb_id='$id'");
$pbdata = $db->fetch_array($query);
if (!$pbdata) showmessage('该编号的犯人不存在','plugin.php?identifier=jail&module=jail');
if($pbdata['pbmoney']==0){$pbnum=95;}
else{$pbnum=80;}
if($pbdata['username']==$discuz_user){showmessage('社区监狱固若金汤,想逃狱门儿都没有','plugin.php?identifier=jail&module=jail');}
$randnum=rand(1,100);
if($randnum>$pbnum){
$db->query("DELETE FROM {$tablepre}postban where pb_id='$id'");
showmessage('成功劫狱,带走犯人','plugin.php?identifier=jail&module=jail');}
else{
$timelimit = 3*3600 + $timestamp;
$starttime=time();
$db->query("INSERT INTO {$tablepre}postban (username, fid, opername, timelimit, starttime, pbmoney, reason) VALUES ('$discuz_user', '65535', '社区警察', '$timelimit','$starttime', '200000','企图劫狱')");
showmessage('劫狱失败,关押3个小时','plugin.php?identifier=jail&module=jail');}}}
if ($action=='add' && submitcheck('pb_submit')) {
if (!$pb_name || !$pb_fid || !$pb_time || !$pb_fid || !$pb_reason) {
showmessage('信息填写不完整,请返回修改','plugin.php?identifier=jail&module=jail');
}
$pb_fid=intval($pb_fid);
$pb_time=intval($pb_time);
if (!$isjailadmin && !$isadmin) showmessage('仅限监狱长和管理员可以进行抓人','plugin.php?identifier=jail&module=jail');
if (strlen($pb_reason)>300) showmessage("原因太长!<br>请不要超过150个汉字或者300个英文字母",'plugin.php?identifier=jail&module=jail');
if ($pb_name==$discuz_user) showmessage('您还好吧,逮捕自己?','plugin.php?identifier=jail&module=jail');
if ($pb_fid!=65535) {
$forum_ava=$db->result($db->query("select count(*) FROM {$tablepre}forums where fid='$pb_fid' AND (type='forum' or type='sub')"), 0);
} else {
$forum_ava=1;
}
if ($pb_fid < 1 || $forum_ava!=1) showmessage('fid输入错误,请返回修改','plugin.php?identifier=jail&module=jail');
if ($pb_time < 1 || $pb_time>8760) showmessage('时间输入错误,请返回修改','plugin.php?identifier=jail&module=jail');
$timelimit = $pb_time*3600 + $timestamp;
$starttime=time();
$banned=$db->result($db->query("select count(*) FROM {$tablepre}postban where username='$pb_name' AND fid='$pb_fid'"), 0);
if ($banned) showmessage("$pb_name 已经被逮捕",'plugin.php?identifier=jail&module=jail');
$query=$db->query("SELECT * FROM {$tablepre}members WHERE username='$pb_name'");
$pb_banuser_ava = 0;
while($pb_banuser = $db->fetch_array($query)) {
if ($ispbnamejailadmin = checkjailadmin($pb_name)) showmessage('什么,监狱长,监狱里他最大了,你都敢逮捕,发烧了?','plugin.php?identifier=jail&module=jail');
$pb_banuseruid=$pb_banuser[uid];
$pb_banuser_ava++;
}
if (!$pb_banuser_ava) showmessage("用户 $pb_name 不存在,请返回修改",'plugin.php?identifier=jail&module=jail');
//-----------检查输入的保释金额----
$pbmoney = intval($pbmoney);
if($pbmoney < 0) showmessage('晕,您别啊,本来论坛就不富裕,抓个人还要倒贴吗?','plugin.php?identifier=jail&module=jail');
//------------end---------------
$db->query("INSERT INTO {$tablepre}postban (username, fid, opername, timelimit, starttime, pbmoney, reason) VALUES ('$pb_name', '$pb_fid', '$discuz_user', '$timelimit','$starttime', '$pbmoney','$pb_reason')");
if ($pb_fid!=65535) {
$fname=$db->result($db->query("select name FROM {$tablepre}forums where fid='$pb_fid'"), 0);
} else {
$fname='所有版块';
}
$pb_msg="鉴于你的所作所为, $discuz_user 禁止你在 $fname 发贴直到".gmdate("Y-n-j H:i", $timelimit + $timeoffset * 3600)."。理由是: $pb_reason";
$db->query("INSERT INTO {$tablepre}pms (msgtoid, msgfrom, folder, new, subject, dateline, message)
VALUES ('$pb_banuseruid', 'System Message', 'inbox', '1', '逮捕令!', '$timestamp','$pb_msg')");
$db->query("UPDATE {$tablepre}members set newpm='1' where username='$pb_name'");
showmessage("逮捕成功", "plugin.php?identifier=jail&module=jail");
}
if ($action=='delpb') {
if (!$isadmin && !$isjailadmin) showmessage('仅限监狱长和管理员可以放人','plugin.php?identifier=jail&module=jail');
if (!$id) showmessage('未指定要释放犯人的编号','plugin.php?identifier=jail&module=jail');
$id=intval($id);
$query=$db->query("SELECT p.*, f.name as fname FROM {$tablepre}postban p LEFT JOIN {$tablepre}forums f ON p.fid=f.fid WHERE p.pb_id='$id'");
$ppp=$db->num_rows($query);
if ($ppp != 1) showmessage('该编号的犯人不存在','plugin.php?identifier=jail&module=jail');
$pb_name = $db->result($db->query("SELECT username FROM {$tablepre}postban WHERE pb_id='$id'"),0);
$pb_id = $db->result($db->query("SELECT uid FROM {$tablepre}members WHERE username='$pb_name'"),0);
if ($db->query("DELETE FROM {$tablepre}postban where pb_id='$id'")){
if($pb_name){
$pb_msg = "由于你积极接受劳动改造, $discuz_user 现决定提前将你释放,希望你以后好好做人,不要违反论坛规定了!";
$db->query("INSERT INTO {$tablepre}pms (msgtoid, msgfrom, folder, new, subject, dateline, message)
VALUES ('$pb_id', 'System Message', 'inbox', '1', '释放通知', '$timestamp','$pb_msg')");
$db->query("UPDATE {$tablepre}members set newpm='1' where uid='$pb_id'");
}
showmessage('犯人已经被提前释放!', 'plugin.php?identifier=jail&module=jail');
}else showmessage('释放犯人失败,请联系管理员,并说明详情','plugin.php?identifier=jail&module=jail');
}
include template('jail');
//some functions below ..
function checkjailadmin($ckusername) { //监狱长判断
global $jailsettings;
$ckisjailadmin = 0;
if ($jailsettings['jailadmin'] <> '') {
$ckuserold = explode(',', $jailsettings['jailadmin']);
foreach($ckuserold as $ckusernow) {
if ($ckusernow == $ckusername) {
$ckisjailadmin = 1;
break;
}
}
}
return $ckisjailadmin;
}
?>
不中 哈 |