Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[补丁] 版主申请加强版 For D4 版主评分乱码修正

[复制链接]
moods 发表于 2005-12-23 18:57:30 | 显示全部楼层 |阅读模式
原帖: 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 中查找
  1. rateusername varchar(10) NOT NULL
复制代码


10 改为 100

查找
  1. rate varchar(100) DEFAULT '0' NOT NULL
复制代码


100 改为 200

运行 modsetup.php,点击“卸载安装”,删掉原来的插件的数据表,然后点击“全新安装”,重新添加数据表。

2. 用下面的代码替换 modapp.php 文件:

  1. <?php

  2. require_once './include/common.inc.php';
  3. require_once DISCUZ_ROOT.'./include/discuzcode.func.php';

  4. $discuz_action = 185;

  5. if (!$discuz_uid) {
  6.           showmessage("对不起,本服务只对注册会员开放","index.php");
  7. }

  8. $modappsettings = getmodappconfig();

  9. $ch_credit = trim($modappsettings['vars']['ch_credit']);
  10. $ch_apply = trim($modappsettings['vars']['ch_apply']);
  11. $maxotname = trim($modappsettings['vars']['maxotname']);
  12. $maxotherm = trim($modappsettings['vars']['maxotherm']);
  13. $maxname = trim($modappsettings['vars']['maxname']);
  14. $maxsites = trim($modappsettings['vars']['maxsites']);
  15. $maxabout = trim($modappsettings['vars']['maxabout']);
  16. $maxregdate = trim($modappsettings['vars']['maxregdate']);
  17. $maxposts = trim($modappsettings['vars']['maxposts']);

  18. function forumselect($groupselectable = 0) {
  19.         global $_DCACHE, $discuz_uid, $groupid;

  20.         $forumlist = '';
  21.         if(!isset($_DCACHE['forums'])) {
  22.                 require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
  23.         }

  24.         foreach($_DCACHE['forums'] as $fid1 => $forum1) {
  25.                 if($forum1['type'] == 'group') {
  26.                         $forumlist .= '<option value="<a href=index.php?gid='.$forum1['fid'].' target=_blank>'.$forum1['name'].'</a>">'.$forum1['name'].'</option>';
  27.                         foreach($_DCACHE['forums'] as $fid2 => $forum2) {
  28.                                 if($forum2['fup'] == $fid1 && $forum2['type'] == 'forum' && (!$forum2['viewperm'] || ($forum2['viewperm'] && forumperm($forum2['viewperm'])) || strstr($forum2['users'], "\t$discuz_uid\t"))) {
  29.                                         $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid2.' target=_blank>'.$forum2['name'].'</a>">&nbsp; &gt; '.$forum2['name'].'</option>';
  30.                                         foreach($_DCACHE['forums'] as $fid3 => $forum3) {
  31.                                                 if($forum3['fup'] == $fid2 && $forum3['type'] == 'sub' && (!$forum3['viewperm'] || ($forum3['viewperm'] && forumperm($forum3['viewperm'])) || strstr($forum3['users'], "\t$discuz_uid\t"))) {
  32.                                                         $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid3.' target=_blank>'.$forum3['name'].'</a>">&nbsp; &nbsp; &nbsp; &gt; '.$forum3['name'].'</option>';
  33.                                                 }
  34.                                         }
  35.                                 }
  36.                         }
  37.                         $forumlist .= '<option value="">&nbsp;</option>';
  38.                 } elseif(!$forum1['fup'] && $forum1['type'] == 'forum' && (!$forum1['viewperm'] || ($forum1['viewperm'] && forumperm($forum1['viewperm'])) || strstr($forum1['users'], "\t$discuz_uid\t"))) {
  39.                         $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid1.' target=_blank>'.$forum1['name'].'</a>"> &nbsp; &gt; '.$forum1['name'].'</option>';
  40.                         foreach($_DCACHE['forums'] as $fid2 => $forum2) {
  41.                                 if($forum2['fup'] == $fid1 && $forum2['type'] == 'sub' && (!$forum2['viewperm'] || ($forum2['viewperm'] && forumperm($forum2['viewperm'])) || strstr($forum2['users'], "\t$discuz_uid\t"))) {
  42.                                         $forumlist .= '<option value="<a href=forumdisplay.php?fid='.$fid2.' target=_blank>'.$forum2['name'].'</a>">&nbsp; &nbsp; &nbsp; &gt; '.$forum2['name'].'</option>';
  43.                                 }
  44.                         }
  45.                         $forumlist .= '<option value="">&nbsp;</option>';
  46.                 }

  47.         }

  48.         return $forumlist;
  49. }
  50. $forumselect = forumselect();

  51. $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");
  52.         $post=$db->fetch_array($query);
  53. $post['bemem'] = intval(($timestamp - $post['regdate'])/(3600*24));

  54. $chquery = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_modapp WHERE userid=$post[uid]");
  55. $apply = $db->result($chquery, 0);
  56.         if($apply >= $ch_apply) {showmessage("抱歉,每位会员只可申请 $ch_apply 次!",'usermodapp.php'); }

  57. if (isset($submit)) {
  58.         if($apply >= $ch_apply) {showmessage("抱歉,每位会员只可申请 $ch_apply 次!",'usermodapp.php'); }

  59.         if($maxposts > $post[posts])
  60.                 showmessage("抱歉,发帖需超过 $maxposts 篇,才会接受申请","usermodapp.php");
  61.         if($maxregdate > $post['bemem'])
  62.                 showmessage("抱歉,您的注册天数未达到申请版主最低要求","usermodapp.php");
  63.         if($ch_credit > $post[credits])
  64.                 showmessage("抱歉,您的积分未达到申请版主最低要求","usermodapp.php");
  65.         if($theone=='')
  66.                 showmessage("您觉得自己不符合条件吗?返回上一页");
  67.         if($wichforum=='')
  68.                 showmessage("您要申请 [ $bbname ] 哪版版主?返回上一页");
  69.         if($name=='')
  70.                 showmessage("您不想填写真实姓名,可填会员名称!返回上一页");               
  71.         if($about=='')
  72.                 showmessage("您有什么贡献及建议忘了填!返回上一页");
  73.         if(strlen($about) > $maxabout)
  74.                 showmessage("您的建议与想法超过 $maxabout 字元!返回上一页");

  75.         $about = preg_replace("/\</is", "&lt;", $about);
  76.         $other_forum_names = preg_replace("/\</is", "&lt;", $other_forum_names);
  77.         $other_m = preg_replace("/\</is", "&lt;", $other_m);
  78.         $name = preg_replace("/\</is", "&lt;", $name);
  79.         $websites = preg_replace("/\</is", "&lt;", $websites);

  80.         $about = preg_replace("/\n/is", "<br>", $about);

  81.         $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')";
  82.                  $result = mysql_query($lala) or
  83.                     die("INSERT Error: " . mysql_error() . " in Query: $query");
  84.                                 showmessage("您的版主申请表提交完成!","usermodapp.php");
  85.         exit;
  86.   
  87. }
  88. if ($discuz_user) {
  89.         include template('modapp');
  90. } else {
  91.           showmessage("对不起,本服务只对注册会员开放","index.php");
  92. }

  93. function getmodappconfig() {
  94.         @include DISCUZ_ROOT.'./forumdata/cache/plugin_modapp.php';
  95.         return $_DPLUGIN['modapp'];
  96.         }
  97. ?>
复制代码


3. 用下面的代码替换 usermodapp.php 文件:

  1. <?php

  2. require_once './include/common.inc.php';
  3. require_once DISCUZ_ROOT.'./include/forum.func.php';
  4. require_once DISCUZ_ROOT.'./include/discuzcode.func.php';

  5. if (!$discuz_uid) {
  6.           showmessage("对不起,本服务只对注册会员开放","index.php");
  7. }

  8. $discuz_action = 185;

  9. $modpage = 20; // 申请列表分页显示数量

  10. if($page) {
  11.                 $start_limit = ($page-1) * $modpage;
  12.         } else {
  13.                 $start_limit = 0;
  14.                 $page = 1;
  15.         }

  16.         $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");

  17.         $post=$db->fetch_array($query);

  18. // ###################### Start View #######################

  19. if ($action=="" and !isset($submit))
  20.         $action='view';
  21. if ($action=="view"){

  22. $query=$db->query("select count(*) as rows from {$tablepre}plugin_modapp");
  23. $aaa = $db->fetch_array($query);
  24. $rows = $aaa['rows'];
  25. unset($aaa);

  26.         $altbg1 = ALTBG2;
  27.         $altbg2 = ALTBG1;
  28.         $postcount = 0;

  29.         $multipage = multi($rows, $modpage, $page, "usermodapp.php?action=view");
  30.         $query = $db->query("SELECT * FROM {$tablepre}plugin_modapp ORDER BY theone DESC LIMIT $start_limit, $modpage");
  31.         while($appmod=$db->fetch_array($query)){
  32.         $usernameurl=$appmod[username];
  33.         $appmod[username]=urldecode($appmod[username]);
  34.         $appmod[wichforum]=urldecode($appmod[wichforum]);
  35.         $appmod[thetime]=$appmod[theone];
  36.         $appmod[theone] = gmdate("$dateformat $timeformat", $appmod[theone] + ($timeoffset * 3600));

  37.                 $bgno = $postcount++ % 2 + 1;
  38.                 $appmod['thisbg'] = ${'altbg'.$bgno};

  39.                  $appmodlist[] = $appmod;
  40.         }
  41.         include template('modapp_view');
  42. }
  43. // ###################### Start rate #######################
  44. if ($action=="del"){

  45.         if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
  46.         showmessage("真的要删除 <font color=red>[ $deluser ]</font> 版主的申请吗?<br><br><br>
  47.                         <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'">
  48.                         &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="delSubmit" value="放弃删除" OnClick='javascript:history.back()'">"
  49.                 );
  50.         } else {
  51.                 showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
  52.         }
  53. }

  54. if ($action=="delsure"){
  55.         if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
  56.         $db->query("DELETE FROM {$tablepre}plugin_modapp WHERE appid='".$id."'");
  57.           $db->query("DELETE FROM {$tablepre}plugin_modappuser WHERE rateuserid='".$id."'");
  58.           showmessage("操作成功!","usermodapp.php?action=$actions&page=$page");
  59.         } else {
  60.                 showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
  61.         }
  62. }

  63. if ($action=="delme"){

  64.         if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {
  65.         showmessage("真的要删除 <font color=red>[ $rateusername ]</font> 的评分吗?<br><br><br>
  66.                         <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'">
  67.                         &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="delSubmit" value="放弃删除" OnClick='javascript:history.back()'">"
  68.                 );
  69.         } else {
  70.                 showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
  71.         }
  72. }


  73. if ($action=="delmesure"){

  74.         if($post[uid] == $userid || $adminid == '1' || $adminid == '2') {

  75.         if (preg_match("/\D/",$rate)){
  76.         $setrate = "0";
  77.         }else{
  78.         $setrate = "$rate";
  79.         }

  80.         $setratetotal = "$ratetotal";
  81.         $query = $db->query("UPDATE {$tablepre}plugin_modapp SET ratetotal=$setratetotal-$setrate WHERE appid='".$appid."'");
  82.           $query = $db->query("DELETE FROM {$tablepre}plugin_modappuser WHERE rateid='".$rateid."'");
  83.           showmessage("操作成功!","usermodapp.php?action=$actions&userid=$userid&rateuserid=$appid");

  84.         } else {
  85.                 showmessage("对不起,您没有权限进行此项操作!","usermodapp.php");
  86.         }
  87. }

  88. if (isset($submit)) {
  89.         if(!$admin_other){
  90.         if(!$userrate){ showmessage("请选择要评的分数!请返回上页!"); } }

  91.         $query = $db->query("SELECT * FROM {$tablepre}members WHERE uid='$discuz_uid'");
  92.         $post=$db->fetch_array($query);       

  93.         $chquery = $db->query("SELECT * FROM {$tablepre}plugin_modapp WHERE userid='".$post[uid]."' AND appid='".$rateuserid."'");
  94.         if($db->num_rows($chquery)>0)
  95.                 showmessage("对不起,您不能对自己的申请进行评分!",'usermodapp.php');

  96.         $query = $db->query("SELECT * FROM {$tablepre}plugin_modappuser WHERE rateusername='".urlencode($discuz_user)."' and rateuserid='".$rateuserid."'");
  97.         if($db->num_rows($query)>0)
  98.                 showmessage("对不起,您不能对同一篇申请重复评分!",'usermodapp.php');

  99.         if($admin_other){
  100.         $user = "INSERT INTO {$tablepre}plugin_modappuser (rateid,userid,rateuserid,rateusername,rate) VALUES(NULL,'$post[uid]','".addslashes($rateuserid)."','".urlencode($discuz_user)."','".urlencode(addslashes($admin_other))."')";
  101.                  $rate = mysql_query($user) or
  102.                     die("INSERT Error: " . mysql_error() . " in Query: $query");
  103.         }else{
  104.         $user = "INSERT INTO {$tablepre}plugin_modappuser (rateid,userid,rateuserid,rateusername,rate) VALUES(NULL,'$post[uid]','".addslashes($rateuserid)."','".urlencode($discuz_user)."','$userrate')";
  105.                  $rate = mysql_query($user) or
  106.                     die("INSERT Error: " . mysql_error() . " in Query: $query");
  107.         }

  108.         if(!$admin_other){
  109.         $lala = "UPDATE {$tablepre}plugin_modapp SET ratetotal=ratetotal+$userrate WHERE appid=$rateuserid";
  110.                  $result = mysql_query($lala) or
  111.                     die("INSERT Error: " . mysql_error() . " in Query: $query");
  112.         }

  113.                 showmessage('感谢你参与对申请人的评分。','usermodapp.php');
  114.         exit();  
  115. }

  116. if ($action=="rate") {
  117.   
  118.         $query = $db->query("SELECT * FROM {$tablepre}plugin_modapp where appid=$rateuserid");
  119.         $allmod = $db->num_rows($query);
  120.         while ($mods =$db->fetch_array($query)) {

  121.                 $mods[username]=urldecode($mods[username]);
  122.                 $mods[name]=urldecode($mods[name]);
  123.                 $mods[about]=urldecode($mods[about]);
  124.                 $mods[english]=urldecode($mods[english]);
  125.                 $mods[wichforum]=urldecode($mods[wichforum]);
  126.                 $mods[other_forum_names]=urldecode($mods[other_forum_names]);
  127.                 $mods[other_m]=urldecode($mods[other_m]);
  128.                 $mods[other]=urldecode($mods[other]);
  129.                 $mods[connection]=urldecode($mods[connection]);
  130.                 $mods[internet]=urldecode($mods[internet]);
  131.                 $mods[websites]=urldecode($mods[websites]);

  132.                 $time = gmdate("$dateformat $timeformat", $mods[theone] + ($timeoffset * 3600));
  133.                 $modslist[] = $mods;
  134.         }
  135.         $award = $db->query("SELECT * FROM {$tablepre}plugin_modappuser where rateuserid=$rateuserid");
  136.         $allshit = $db->num_rows($award);
  137.         while($shit = $db->fetch_array($award) ) {
  138.                 $shit[rateusername]=urldecode($shit[rateusername]);
  139.                 $shit[rate]=urldecode($shit[rate]);
  140.                 $shitlist[] = $shit;
  141.         }

  142.         if($allmod == 0){
  143.                  showmessage('目前还没有人申请版主!','index.php');
  144.         }
  145.         include template('modapp_rate');
  146. }
  147. ?>
复制代码


4. 修正完毕。

评分

1

查看全部评分

xslxld 发表于 2005-12-23 20:30:42 | 显示全部楼层
沙发一个.还没出现这个问题
回复

使用道具 举报

freddy 发表于 2005-12-26 14:06:36 | 显示全部楼层
不好意思.没看到...
回复

使用道具 举报

janbobo 发表于 2005-12-26 14:41:58 | 显示全部楼层
支持上去 目前无问题
回复

使用道具 举报

baibbs 发表于 2005-12-26 14:46:47 | 显示全部楼层
wichforum varchar(100) NOT NULL,


应该设置大一点吧


刚刚没有看到 不好意思~~
回复

使用道具 举报

 楼主| moods 发表于 2005-12-26 15:02:15 | 显示全部楼层
原帖由 baibbs 于 2005-12-26 14:46 发表


应该设置大一点吧


刚刚没有看到 不好意思~~

如果版块名称显示不完全,就加大点,主要看你自己的版块设置。:)
回复

使用道具 举报

madness 发表于 2006-1-1 02:32:26 | 显示全部楼层
谢谢
回复

使用道具 举报

keigo583 发表于 2006-1-12 09:37:32 | 显示全部楼层
您注册了 13160 天 &#187; 恭喜,有资格申请版主

这段的源码计算也有问题。我论坛运行才1个月。

您注册了 <font color=red>$post[bemem]</font> 天 &raquo; 恭喜,有资格申请版主

不知道应该怎么改,还是有其它什么问题
回复

使用道具 举报

 楼主| moods 发表于 2006-1-12 10:59:48 | 显示全部楼层
后台更新缓存试试。
回复

使用道具 举报

大澤木小鐵 发表于 2006-1-23 17:11:10 | 显示全部楼层
無法安裝
一安裝就出現
SQL:
CREATE TABLE cdb_plugin_modapp (
appid smallint(5) unsigned NOT NULL auto_increment,
userid smallint(4) NOT NULL,
theone varchar(100) NOT NULL,
wichforum varchar(100) NOT NULL,
connection varchar(100) NOT NULL,
internet varchar(100) NOT NULL,
other varchar(100) NOT NULL,
other_forum_names varchar(100) NOT NULL,
english varchar(100) NOT NULL,
other_m varchar(100) NOT NULL,
name varchar(100) NOT NULL,
email varchar(100) NOT NULL,
username varchar(100) NOT NULL,
websites varchar(100) NOT NULL,
about varchar(200) NOT NULL,
ratetotal varchar(100) NOT NULL,
PRIMARY KEY (appid)
);
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'connection varchar(100) NOT NULL,
internet varchar(100) NOT N
Errno.: 1064

An error report has been dispatched to our administrator.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-24 08:18 , Processed in 0.034086 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表