作品名称:提问贴插件
作品作者:flyinleaf
功能简介:除正常贴,投票贴外,增加一种提问贴,发贴人可填写悬赏并扣除法帖人2倍悬赏的金币,法帖人采纳答案后,返回一半,并将悬赏金送到被采纳人手中,有短信通知。
适用版本:Dz 2.5/sp1 需要完美银行插件(要求cdb_members下有money列)
修改程序列表 : config.php,forumdisplay.php,viewthread.php,newthread.php,editpost.php,topicadmin.php,common.php
修改模版列表 : forumdisplay.htm,viewthread.htm,post_newthread.htm,topicadmin_moderate.htm
功能演示地址: http://pcmscs.org/~lovebear/bbs/forumdisplay.php?fid=43&
作品内容:
1-- 数据库升级
CREATE TABLE `asks` (
`tid` MEDIUMINT( 8 ) UNSIGNED NOT NULL ,
`tm` MEDIUMINT( 14 ) UNSIGNED NOT NULL ,
`aid` MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL ,
`aname` VARCHAR( 15 ) NOT NULL
);
2--把压缩包中的文件拷贝到对应文件夹
3--修改下列文件:
config.php
在最后加上
- $allowaskforumlist="1,2,3,4";
- //这里用户自行列出允许使用提问贴的论坛id(fid),用','(逗号)分割开(如 1,3,5)
复制代码
common.php
在 ?>前加入
- if($fid)
- {
- $allowask=0;
- $allowtemp = explode(',',$allowaskforumlist);
- foreach($allowtemp as $allowfid) {
- if ($allowfid==$fid) {$allowask=1;break;}
-
- }
- }
复制代码
forumdisplay.php
查找
- while($thread = $db->fetch_array($query)) {
复制代码
下面添加
- if($thread['poll']==2){
- $ttid=$thread['tid'];
- $conn = $db->query("select * from asks WHERE tid='$ttid'");
- $ask = $db->fetch_array($conn);
- $thread[tm]=$ask['tm'];
- $thread[aname]=$ask['aname'];
- $thread[answered]=($ask['aid']!='0');
-
- }
复制代码
forumdisplay.htm
查找两处
- <!--{if $allowpostpoll}--><a href="post.php?action=newthread&fid=$fid&poll=yes"><img src="{IMGDIR}/poll.gif" border="0"></a><!--{/if}-->
复制代码
后面加上
- <!--{if $allowask && $discuz_uid}--><a href="post.php?action=newthread&fid=$fid&poll=ask"><img src="{IMGDIR}/ask.gif" border="0"></a><!--{/if}-->
复制代码
查找
- <!--{elseif $thread['poll']}-->
- <img src="{IMGDIR}/pollsmall.gif" align="absmiddle"> {lang
- thread_poll}:
- <!--{/if}-->
- $thread[attachment]<a href="viewthread.php?tid=$thread[tid]&fpage=$page" $thread[highlight]>$thread[subject]</a>
复制代码
改为
- <!--{elseif $thread['poll']==1}-->
- <img src="{IMGDIR}/pollsmall.gif" align="absmiddle"> {lang
- thread_poll}:
- <!--{elseif $thread['poll']==2}-->
- <img src="{IMGDIR}/asksmall.gif" align="absmiddle">
- 询问:
- <!--{/if}-->
- $thread[attachment]<a href="viewthread.php?tid=$thread[tid]&fpage=$page" $thread[highlight]>$thread[subject]</a>
- <!--{if $thread['poll']==2}-->
- <!--{if $thread[answered]}-->
- [<font color=blue><b>已被</b><a href="./viewpro.php?username=$thread[aname]">$thread[aname]</a><b>解决</b></font>]
- <!--{else}-->
- - [悬赏: <font color=orange><b>{$thread[tm]}</b></font><img src="./images/common/money0.gif">]
- <!--{/if}-->
- <!--{/if}-->
复制代码
viewthread.php
查找
改为
查找
后面加:
- elseif($thread['poll']==2) {
- $sql = "select * from asks WHERE tid='$tid'";
- $query = mysql_query ($sql);
- $ask = mysql_fetch_array($query);
- }
复制代码
viewthread.htm
找到
- <tr style="color: {HEADERTEXT}"><td class="bold">{lang subject}: $thread[subject]
复制代码
后面加上
- <!--{if $thread['poll']==2}-->
- - 悬赏金:<font color=orange><b>$ask['tm']</b><img src="./images/common/money0.gif"></font>
- <!--{if $ask['aid']!='0'}-->
- - [已被<a href="./viewpro.php?username=$ask['aname']">$ask['aname']</a>解决]<!--{/if}--><!--{/if}-->
复制代码
查找
- #$post['postcount'] </span> $post[subject]</span><br><br>
复制代码
改为
- <!--{if $post['postcount']==1}-->
- <font color=red>『楼主』</font>
- <!--{else}-->
- <font color=black>『第$post['postcount']楼』</font>
- <!--{/if}-->
- <!--{if $ask['aid']==$post['pid']}-->
- <font color=red>【被采纳】</font>
- <!--{/if}--></div></span> $post[subject]</span><br><br>
复制代码
查找
- <a href="post.php?action=edit&fid=$fid&tid=$tid&pid=$post[pid]&page=$page"><img src="{IMGDIR}/edit.gif" border="0" alt="{lang edit_post}">
复制代码
前面加入
- <!--{if $thread['poll']==2 && $thread['authorid']==$discuz_uid && $ask['aid']==0 && $post['authorid']!=$thread['authorid']}--> <a href="thanks.php?tid=$tid&pid=$post[pid]"><img src="{IMGDIR}/thanks.gif" border="0" alt="{lang reply_quote}"></a><!--{/if}-->
复制代码
查找两处
- <!--{if $allowpostpoll}--><a href="post.php?action=newthread&fid=$fid&poll=yes"><img src="{IMGDIR}/poll.gif" border="0"></a><!--{/if}-->
复制代码
后面加
- <!--{if $allowask && $discuz_uid}--><a href="post.php?action=newthread&fid=$fid&poll=ask"><img src="{IMGDIR}/ask.gif" border="0"></a><!--{/if}-->
复制代码
newthread.php
查找
- $pollopts = addslashes(serialize($pollarray));
复制代码
后面加
- } else if($poll == 'ask' && $allowask) {
-
- $poll = 2;
- if($thanks<=0)
- {
- showmessage("您必须填写一个大于0的悬赏金","post.php?action=newthread&fid=$fid&poll=ask");
- }
复制代码
查找
- $db->query("INSERT INTO $table_threads (fid, creditsrequire, iconid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, poll, attachment)
- VALUES ('$fid', '$viewperm', '$iconid', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$discuz_user', '$displayorder', '$digest', '$poll', '".attachtype($last_attach_type, 'id')."')");
- $tid = $db->insert_id();
- if($poll) {
- $db->query("INSERT INTO $table_polls (tid, pollopts)
- VALUES ('$tid', '$pollopts')");
- }
复制代码
改为:
- if($poll!=2){
- $db->query("INSERT INTO $table_threads (fid, creditsrequire, iconid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, poll, attachment)
- VALUES ('$fid', '$viewperm', '$iconid', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$discuz_user', '$displayorder', '$digest', '$poll', '".attachtype($last_attach_type, 'id')."')");
-
-
-
- $tid = $db->insert_id();
- }
- if($poll==1) {
- $db->query("INSERT INTO $table_polls (tid, pollopts)
- VALUES ('$tid', '$pollopts')");
- } else if($poll==2) {
-
- $thank2=2*$thanks;
- $query = $db->query("SELECT money FROM $table_members WHERE uid='$discuz_uid'");
- $mem=$db->fetch_array($query);
- if($mem['money']>=$thank2)
- {
- $lastmoney=$mem['money']-$thank2;
- $db->query("update $table_members set money='$lastmoney' where uid='$discuz_uid'");
- $db->query("INSERT INTO $table_threads (fid, creditsrequire, iconid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, poll, attachment)
- VALUES ('$fid', '$viewperm', '$iconid', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '$timestamp', '$discuz_user', '$displayorder', '$digest', '$poll', '".attachtype($last_attach_type, 'id')."')");
- $tid = $db->insert_id();
- $db->query("INSERT INTO asks (tid, tm)
- VALUES ('$tid', '$thanks')");
-
- }else{
- showmessage("以".$thanks."作悬赏,需要".$thank2."作抵押,您的钱可能不足","post.php?action=newthread&fid=$fid&poll=ask");
- }
-
-
- }
复制代码
post_newthread.htm
查找:
- <textarea rows="4" cols="85" name="polloptions" tabindex="5">$polloptions</textarea></td>
- </tr>
- <!--{/if}-->
复制代码
后面加入
- <!--{if $poll == 'ask' && $allowask}--> <td bgcolor="{ALTBG1}">悬赏金:</td> <td bgcolor="{ALTBG2}" class="smalltxt"><input type="text" name="thanks" size="6" value="$thanks"> <input type="hidden" name="poll" value="ask"><font color=red>*系统会暂时扣除双倍金额的抵押,采纳后返回一半金额(此处提交后不允许修改!)</font></tr><!--{/if}-->
复制代码
editpost.php
查找
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
复制代码
后面加入
- $db->query("DELETE FROM asks WHERE tid='$tid'");
复制代码
topicadmin.php
查找
- $db->query("DELETE FROM $table_threads WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_polls WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_posts WHERE tid IN ($tids)");
复制代码
后面加上
- $db->query("DELETE FROM asks WHERE tid IN ($tids)");
复制代码
查找
- $db->query("DELETE FROM $table_threads WHERE tid='$tid'");
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
复制代码
后面加上
- $db->query("DELETE FROM asks WHERE tid='$tid'");
复制代码
topicadmin_moderate.htm
查找
- <!--{elseif $thread['poll']}--><img src="{IMGDIR}/pollsmall.gif" align="absmiddle">
- {lang thread_poll}:
复制代码
改为
- <!--{elseif $thread['poll']==1}--><img src="{IMGDIR}/pollsmall.gif" align="absmiddle">
- {lang thread_poll}:
- <!--{elseif $thread['poll']==2}--><img src="{IMGDIR}/asksmall.gif" align="absmiddle"> 询
- 问:
复制代码
以下是netboy_sd朋友帮忙整理的积分悬赏修改法
本插件不使用银行的修改方法:前提按楼主的贴修改完毕;
1、修改/thanks.php 将里面的“money”替换为“credit,全部替换。
2、修改/include/newthread 将里面的“money”替换为“credit,全部替换。
3、找到
-
- updatemember('+', $discuz_uid, $postcredits);
-
复制代码
剪切到下面代码的前面。
这样就OK了。
[ 本帖最后由 flyinleaf 于 2006-2-12 15:31 编辑 ] |