原帖: https://discuz.dismall.com/viewthread.php?tid=180557
相关补丁: 版主申请加强版 For D4 modapp.php文件修正(https://discuz.dismall.com/viewthread.php?tid=204992)
修正说明: 如果在打完以前的版主申请加强版 For D4 modapp.php文件修正(https://discuz.dismall.com/viewthread.php?tid=204992)补丁后,版主评分没有乱码问题的,请不要做此修正,版主评分由于数据库字符集问题仍有乱码的,请做此修正。
-------------------------------------------------------------------------
1. modsetup.php 中查找
- rateusername varchar(10) NOT NULL
复制代码
10 改为 100
查找
- rate varchar(100) DEFAULT '0' NOT NULL
复制代码
100 改为 200
运行 modsetup.php,点击“卸载安装”,删掉原来的插件的数据表,然后点击“全新安装”,重新添加数据表。
2. 用下面的代码替换 modapp.php 文件:
- <?php
- require_once './include/common.inc.php';
- require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
- $discuz_action = 185;
- if (!$discuz_uid) {
- showmessage("对不起,本服务只对注册会员开放","index.php");
- }
- $modappsettings = getmodappconfig();
- $ch_credit = trim($modappsettings['vars']['ch_credit']);
- $ch_apply = trim($modappsettings['vars']['ch_apply']);
- $maxotname = trim($modappsettings['vars']['maxotname']);
- $maxotherm = trim($modappsettings['vars']['maxotherm']);
- $maxname = trim($modappsettings['vars']['maxname']);
- $maxsites = trim($modappsettings['vars']['maxsites']);
- $maxabout = trim($modappsettings['vars']['maxabout']);
- $maxregdate = trim($modappsettings['vars']['maxregdate']);
- $maxposts = trim($modappsettings['vars']['maxposts']);
- function forumselect($groupselectable = 0) {
- global $_DCACHE, $discuz_uid, $groupid;
- $forumlist = '';
- if(!isset($_DCACHE['forums'])) {
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
- }
- foreach($_DCACHE['forums'] as $fid1 => $forum1) {
- if($forum1['type'] == 'group') {
- $forumlist .= '<option value="<a href=index.php?gid='.$forum1['fid'].' target=_blank>'.$forum1['name'].'</a>">'.$forum1['name'].'</option>';
- foreach($_DCACHE['forums'] as $fid2 => $forum2) {
- if($forum2['fup'] == $fid1 && $forum2['type'] == 'forum' && (!$forum2['viewperm'] || ($forum2['viewperm'] && forumperm($forum2['viewperm'])) || strstr($forum2['users'], "\t$discuz_uid\t"))) {
- $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid2.' target=_blank>'.$forum2['name'].'</a>"> > '.$forum2['name'].'</option>';
- foreach($_DCACHE['forums'] as $fid3 => $forum3) {
- if($forum3['fup'] == $fid2 && $forum3['type'] == 'sub' && (!$forum3['viewperm'] || ($forum3['viewperm'] && forumperm($forum3['viewperm'])) || strstr($forum3['users'], "\t$discuz_uid\t"))) {
- $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid3.' target=_blank>'.$forum3['name'].'</a>"> > '.$forum3['name'].'</option>';
- }
- }
- }
- }
- $forumlist .= '<option value=""> </option>';
- } elseif(!$forum1['fup'] && $forum1['type'] == 'forum' && (!$forum1['viewperm'] || ($forum1['viewperm'] && forumperm($forum1['viewperm'])) || strstr($forum1['users'], "\t$discuz_uid\t"))) {
- $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid1.' target=_blank>'.$forum1['name'].'</a>"> > '.$forum1['name'].'</option>';
- foreach($_DCACHE['forums'] as $fid2 => $forum2) {
- if($forum2['fup'] == $fid1 && $forum2['type'] == 'sub' && (!$forum2['viewperm'] || ($forum2['viewperm'] && forumperm($forum2['viewperm'])) || strstr($forum2['users'], "\t$discuz_uid\t"))) {
- $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid2.' target=_blank>'.$forum2['name'].'</a>"> > '.$forum2['name'].'</option>';
- }
- }
- $forumlist .= '<option value=""> </option>';
- }
- }
- return $forumlist;
- }
- $forumselect = forumselect();
- $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");
- $post=$db->fetch_array($query);
- $post['bemem'] = intval(($timestamp - $post['regdate'])/(3600*24));
- $chquery = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_modapp WHERE userid=$post[uid]");
- $apply = $db->result($chquery, 0);
- if($apply >= $ch_apply) {showmessage("抱歉,每位会员只可申请 $ch_apply 次!",'usermodapp.php'); }
- if (isset($submit)) {
- if($apply >= $ch_apply) {showmessage("抱歉,每位会员只可申请 $ch_apply 次!",'usermodapp.php'); }
- if($maxposts > $post[posts])
- showmessage("抱歉,发帖需超过 $maxposts 篇,才会接受申请","usermodapp.php");
- if($maxregdate > $post['bemem'])
- showmessage("抱歉,您的注册天数未达到申请版主最低要求","usermodapp.php");
- if($ch_credit > $post[credits])
- showmessage("抱歉,您的积分未达到申请版主最低要求","usermodapp.php");
- if($theone=='')
- showmessage("您觉得自己不符合条件吗?返回上一页");
- if($wichforum=='')
- showmessage("您要申请 [ $bbname ] 哪版版主?返回上一页");
- if($name=='')
- showmessage("您不想填写真实姓名,可填会员名称!返回上一页");
- if($about=='')
- showmessage("您有什么贡献及建议忘了填!返回上一页");
- if(strlen($about) > $maxabout)
- showmessage("您的建议与想法超过 $maxabout 字元!返回上一页");
- $about = preg_replace("/\</is", "<", $about);
- $other_forum_names = preg_replace("/\</is", "<", $other_forum_names);
- $other_m = preg_replace("/\</is", "<", $other_m);
- $name = preg_replace("/\</is", "<", $name);
- $websites = preg_replace("/\</is", "<", $websites);
- $about = preg_replace("/\n/is", "<br>", $about);
- $lala = "INSERT into {$tablepre}plugin_modapp (appid,userid,theone,wichforum,connection,internet,other,other_forum_names,english,other_m,name,email,username,websites,about,ratetotal) VALUES ('NULL','".urlencode($post[uid])."','$timestamp','".urlencode(addslashes($wichforum))."','".urlencode($connection)."','".urlencode($internet)."','".urlencode($other)."','".urlencode(addslashes($other_forum_names))."','".urlencode($english)."','".urlencode(addslashes($other_m))."','".urlencode(addslashes($name))."','$email','".urlencode($discuz_user)."','".urlencode($websites)."','".urlencode(addslashes($about))."','0')";
- $result = mysql_query($lala) or
- die("INSERT Error: " . mysql_error() . " in Query: $query");
- showmessage("您的版主申请表提交完成!","usermodapp.php");
- exit;
-
- }
- if ($discuz_user) {
- include template('modapp');
- } else {
- showmessage("对不起,本服务只对注册会员开放","index.php");
- }
- function getmodappconfig() {
- @include DISCUZ_ROOT.'./forumdata/cache/plugin_modapp.php';
- return $_DPLUGIN['modapp'];
- }
- ?>
复制代码
3. 用下面的代码替换 usermodapp.php 文件:
- <?php
- require_once './include/common.inc.php';
- require_once DISCUZ_ROOT.'./include/forum.func.php';
- require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
- if (!$discuz_uid) {
- showmessage("对不起,本服务只对注册会员开放","index.php");
- }
- $discuz_action = 185;
- $modpage = 20; // 申请列表分页显示数量
- if($page) {
- $start_limit = ($page-1) * $modpage;
- } else {
- $start_limit = 0;
- $page = 1;
- }
- $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");
- $post=$db->fetch_array($query);
- // ###################### Start View #######################
- if ($action=="" and !isset($submit))
- $action='view';
- if ($action=="view"){
- $query=$db->query("select count(*) as rows from {$tablepre}plugin_modapp");
- $aaa = $db->fetch_array($query);
- $rows = $aaa['rows'];
- unset($aaa);
- $altbg1 = ALTBG2;
- $altbg2 = ALTBG1;
- $postcount = 0;
- $multipage = multi($rows, $modpage, $page, "usermodapp.php?action=view");
- $query = $db->query("SELECT * FROM {$tablepre}plugin_modapp ORDER BY theone DESC LIMIT $start_limit, $modpage");
- while($appmod=$db->fetch_array($query)){
- $usernameurl=$appmod[username];
- $appmod[username]=urldecode($appmod[username]);
- $appmod[wichforum]=urldecode($appmod[wichforum]);
- $appmod[thetime]=$appmod[theone];
- $appmod[theone] = gmdate("$dateformat $timeformat", $appmod[theone] + ($timeoffset * 3600));
- $bgno = $postcount++ % 2 + 1;
- $appmod['thisbg'] = ${'altbg'.$bgno};
- $appmodlist[] = $appmod;
- }
- include template('modapp_view');
- }
- // ###################### Start rate #######################
- if ($action=="del"){
- if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
- showmessage("真的要删除 <font color=red>[ $deluser ]</font> 版主的申请吗?<br><br><br>
- <input type="button" name="delSubmit" style="color:red" value="确定删除" onClick="javascript:window.location.href='usermodapp.php?action=delsure&id=".$id."&userid=".$userid."&actions=$actions&page=$page'">
- <input type="button" name="delSubmit" value="放弃删除" OnClick='javascript:history.back()'">"
- );
- } else {
- showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
- }
- }
- if ($action=="delsure"){
- if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
- $db->query("DELETE FROM {$tablepre}plugin_modapp WHERE appid='".$id."'");
- $db->query("DELETE FROM {$tablepre}plugin_modappuser WHERE rateuserid='".$id."'");
- showmessage("操作成功!","usermodapp.php?action=$actions&page=$page");
- } else {
- showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
- }
- }
- if ($action=="delme"){
- if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
- showmessage("真的要删除 <font color=red>[ $rateusername ]</font> 的评分吗?<br><br><br>
- <input type="button" name="delSubmit" style="color:red" value="确定删除" onClick="javascript:window.location.href='usermodapp.php?action=delmesure&rateid=".$rateid."&userid=".$userid."&rate=".$rate."&appid=".$appid."&ratetotal=".$ratetotal."&actions=$actions'">
- <input type="button" name="delSubmit" value="放弃删除" OnClick='javascript:history.back()'">"
- );
- } else {
- showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
- }
- }
- if ($action=="delmesure"){
- if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
- if (preg_match("/\D/",$rate)){
- $setrate = "0";
- }else{
- $setrate = "$rate";
- }
- $setratetotal = "$ratetotal";
- $query = $db->query("UPDATE {$tablepre}plugin_modapp SET ratetotal=$setratetotal-$setrate WHERE appid='".$appid."'");
- $query = $db->query("DELETE FROM {$tablepre}plugin_modappuser WHERE rateid='".$rateid."'");
- showmessage("操作成功!","usermodapp.php?action=$actions&userid=$userid&rateuserid=$appid");
- } else {
- showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
- }
- }
- if (isset($submit)) {
- if(!$admin_other){
- if(!$userrate){ showmessage("请选择要评的分数!请返回上页!"); } }
- $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");
- $post=$db->fetch_array($query);
- $chquery = $db->query("SELECT * FROM {$tablepre}plugin_modapp WHERE userid='".$post[uid]."' AND appid='".$rateuserid."'");
- if($db->num_rows($chquery)>0)
- showmessage("对不起,您不能对自己的申请进行评分!",'usermodapp.php');
- $query = $db->query("SELECT * FROM {$tablepre}plugin_modappuser WHERE rateusername='".urlencode($discuz_user)."' and rateuserid='".$rateuserid."'");
- if($db->num_rows($query)>0)
- showmessage("对不起,您不能对同一篇申请重复评分!",'usermodapp.php');
- if($admin_other){
- $user = "INSERT INTO {$tablepre}plugin_modappuser (rateid,userid,rateuserid,rateusername,rate) VALUES(NULL,'$post[uid]','".addslashes($rateuserid)."','".urlencode($discuz_user)."','".urlencode(addslashes($admin_other))."')";
- $rate = mysql_query($user) or
- die("INSERT Error: " . mysql_error() . " in Query: $query");
- }else{
- $user = "INSERT INTO {$tablepre}plugin_modappuser (rateid,userid,rateuserid,rateusername,rate) VALUES(NULL,'$post[uid]','".addslashes($rateuserid)."','".urlencode($discuz_user)."','$userrate')";
- $rate = mysql_query($user) or
- die("INSERT Error: " . mysql_error() . " in Query: $query");
- }
- if(!$admin_other){
- $lala = "UPDATE {$tablepre}plugin_modapp SET ratetotal=ratetotal+$userrate WHERE appid=$rateuserid";
- $result = mysql_query($lala) or
- die("INSERT Error: " . mysql_error() . " in Query: $query");
- }
- showmessage('感谢你参与对申请人的评分。','usermodapp.php');
- exit();
- }
- if ($action=="rate") {
-
- $query = $db->query("SELECT * FROM {$tablepre}plugin_modapp where appid=$rateuserid");
- $allmod = $db->num_rows($query);
- while ($mods =$db->fetch_array($query)) {
- $mods[username]=urldecode($mods[username]);
- $mods[name]=urldecode($mods[name]);
- $mods[about]=urldecode($mods[about]);
- $mods[english]=urldecode($mods[english]);
- $mods[wichforum]=urldecode($mods[wichforum]);
- $mods[other_forum_names]=urldecode($mods[other_forum_names]);
- $mods[other_m]=urldecode($mods[other_m]);
- $mods[other]=urldecode($mods[other]);
- $mods[connection]=urldecode($mods[connection]);
- $mods[internet]=urldecode($mods[internet]);
- $mods[websites]=urldecode($mods[websites]);
- $time = gmdate("$dateformat $timeformat", $mods[theone] + ($timeoffset * 3600));
- $modslist[] = $mods;
- }
- $award = $db->query("SELECT * FROM {$tablepre}plugin_modappuser where rateuserid=$rateuserid");
- $allshit = $db->num_rows($award);
- while($shit = $db->fetch_array($award) ) {
- $shit[rateusername]=urldecode($shit[rateusername]);
- $shit[rate]=urldecode($shit[rate]);
- $shitlist[] = $shit;
- }
- if($allmod == 0){
- showmessage('目前还没有人申请版主!','index.php');
- }
- include template('modapp_rate');
- }
- ?>
复制代码
4. 修正完毕。 |