Jump to navigation

You are currently browsing all posts tagged with 'discuz'

discuz 新注册用户无法设置默认编辑器模式,只能以源代码方式发贴

  • Posted on September 4, 2010 at 12:41 pm

discuz 7.2

discuz 新注册用户无法设置默认编辑器模式,只能以源代码方式发贴

后台确定是设置的默认为所见即所得模式。

新注册用户登录之后, 即使在个人设置的“论坛个性化”设置里面,
设置编辑器为所见即所得,也无效。

后来看到include/post.php中:

if($prompt) {
if($taskon && ($prompt & 8)) {
$prompts['newbietask'] = 1;
$disallowfloat = str_replace('task', '', $disallowfloat);
$disallowfloat .= '|newthread|reply';
$editormode = 0;
}
如果论坛开启了任务,但是新用户并没有完成新手任务, 就设置 editormode为0,表示源代码编辑器。
ps:为2的话,表示使用论坛默认编辑器。 为1表示所见即所得编辑器.

保护好你的discuz模板,不要被别人偷走

  • Posted on July 20, 2010 at 4:57 pm

通常,我们自己辛辛苦苦做好的discuz模板,
会放到/templates/xxxx 目录下面
然后呢?
如果有人想偷你的模板,它完全可以把此目录里面的文件全部下载走。
只要用IE打开,然后查看源码,另存一下就可以了!
因为,所有模板的文件名都是符合default模板的命名规范的,
URL一猜就中啊!
我擦!

这帮B不注意保护版权。

怎么办?
在apache的配置文件里面,禁止用户对templates目录的直接访问。
或者放一个.htaccess

下面是nginx里面的配置:

        location ~ ^/template {
                deny all;
        }

注意:
这样做之后,万一你在模板目录里面放了一些图片,那么这些图片就访问不到了。
所以请在模板目录里面只放.htm文件,
css文件也请命名为css_append.htm
其它类型的文件请放到模板目录外面!

discuz 短消息群发给版主的功能

  • Posted on May 31, 2010 at 9:48 am

discuz 添加短消息群发给版主的功能

版本:discuz 7.2 gbk.

在discuz的短消息功能里面,我们只能群发短消息给好友
对于管理组来说,有必要增加群发给版主/总版主的功能。

修改 pm.php
在 204行

$buddyarray = array();
if($uids) {
	$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE uid IN (".implodeids($uids).")");
	while($buddy = $db->fetch_array($query)) {
		$buddyarray[] = $buddy;
	}
}

下面增加:

       if (intval($_DSESSION['groupid'])==1 || intval($_DSESSION['groupid'])==2 || intval($_DSESSION['groupid'])==3 )
        {   
                //to banzhu:
                $banzhuarray = array();
                $query = $db->query("SELECT uid,username FROM {$tablepre}members WHERE  groupid=3 ");
                while($banzhu = $db->fetch_array($query))
                {   
                        $banzhuarray[] = $banzhu;
                }   
 
                //to zongbanzhu:
                $zongbanzhuarray = array();
                $query = $db->query("SELECT uid,username FROM {$tablepre}members WHERE  groupid=2 ");
                while($zongbanzhu = $db->fetch_array($query))
                {   
                        $zongbanzhuarray[] = $zongbanzhu;
                }   
 
	}

继续修改pm.php:
找到

} elseif($action == 'send' && submitcheck('pmsubmit')) {
....
                        foreach($buddyarray as $buddy) {
                                $uids[] = $buddy['friendid'];
                        }
                        $msgto = $p = '';

把下面的

                                foreach($msgtos as $uid) {
                                        $msgto .= in_array($uid, $uids) ? $p.$uid : '';
                                        $p = ',';
                                }

替换成:

                        if (intval($_DSESSION['groupid'])==1 || intval($_DSESSION['groupid'])==2 || intval($_DSESSION['groupi
d'])==3 )
                        {
                                foreach($msgtos as $uid) {
                                        $msgto .= $p.$uid;
                                        $p = ',';
                                }
                        }
                        else
                        {
                                foreach($msgtos as $uid) {
                                        $msgto .= in_array($uid, $uids) ? $p.$uid : '';
                                        $p = ',';
                                }
                        }

然后修改模板templates/default/pm_send.htm
在24行:

                                                        <input name="msgto" value="$username" class="txt" tabindex="1" />
                                                        <!--{if $buddyarray}--><a href="javascript:display('buddies');" class="dropmenu">
{lang pm_to_buddy}</a><!--{/if}-->

后面添加:

<!--{if $banzhuarray}--><a href="javascript:display('banzhu');" class="dropmenu">版主群发</a><!--{/if}-->                        
<!--{if $zongbanzhuarray}--><a href="javascript:display('zongbanzhu')
;" class="dropmenu">总版主群发</a><!--{/if}-->

然后在

                                        <!--{if $buddyarray}-->
                                        <tbody id="buddies" style="display: none;">
                                        <tr><td colspan=5 align=center><font color=RED>好友群发</font></td></tr>
                                        <tr>
                                                <td width="60"></td>
                                                <td>
                                                        <ul class="s_clear">
                                                        <!--{loop $buddyarray $buddy}-->
                                                                <li><label for="msgto_$buddy[uid]">
<input id="msgto_$buddy[uid]" name="msgtos[]" type="checkbox" value="$buddy[uid]"> $buddy[username]</label></li>
                                                        <!--{/loop}-->
                                                        </ul>
                                                </td>
                                        </tr>
                                        </tbody>
                                        <!--{/if}-->

后面加添加

                                        <!--{if $banzhuarray}-->
                                        <tbody id="banzhu" style="display: none;" class="modify_buddies">
                                        <tr><td colspan=5 align=center><font color=RED>版主群发</font></td></tr>
                                        <tr>
                                                <td width="60"></td>
                                                <td>
                                                        <ul class="s_clear">
                                                        <!--{loop $banzhuarray $buddy}-->
                                                                <li><label for="msgto_$buddy[uid]">
<input id="msgto_$buddy[uid]" name="msgtos[]" type="checkbox" value="$buddy[uid]"> $buddy[username]</label></li>
                                                        <!--{/loop}-->
                                                        </ul>
                                                </td>
                                        </tr>
                                        </tbody>
                                        <!--{/if}-->
                                        <!--{if $zongbanzhuarray}-->
                                        <tbody id="zongbanzhu" style="display: none;" class="modify_buddies">
                                        <tr><td colspan=5 align=center><font color=RED>总版主群发</font></td></tr>
                                        <tr>
                                                <td width="60"></td>
                                                <td>
                                                        <ul class="s_clear">
                                                        <!--{loop $zongbanzhuarray $buddy}-->
                                                                <li><label for="msgto_$buddy[uid]">
<input id="msgto_$buddy[uid]" name="msgtos[]" type="checkbox" value="$buddy[uid]"> $buddy[username]</label></li>
                                                        <!--{/loop}-->
                                                        </ul>
                                                </td>
                                        </tr>
                                        </tbody>
                                        <!--{/if}-->

没想到uc_client里面又一次检查了收信人是否为发信人的好友。。。
再修改uc_client/control/pm.php
在 function onsendpm() 里面
找到

                        $this->load('friend');

把下面的

if(count($msgto) > 1 && !($is_friend = $_ENV['friend']->is_friend($fromuid, $msgto, 3))) {
                                        return PMMSGTONOTFRIEND;
                                }

替换成:

                        $modify_userinfo = $_ENV['user']->db->fetch_first("SELECT * FROM cdb_members WHERE uid='$fromuid'");
                        if (intval($modify_userinfo['groupid'])==1 || intval($modify_userinfo['groupid'])==2 || intval($modif
y_userinfo['groupid'])==3 )
                        {
                        }
                        else
                        {
                                if(count($msgto) > 1 && !($is_friend = $_ENV['friend']->is_friend($fromuid, $msgto, 3))) {
                                        return PMMSGTONOTFRIEND;
                                }
                        }

discuz中无法上传大附件的解决办法

  • Posted on May 8, 2010 at 10:19 am

经常有同学反映,discuz中无法上传较大的附件(2M以上)
让我们做以下的检查:

第一步:
检查php.ini

post_max_size = 256M
file_uploads = On
upload_max_filesize = 100M

PS:
修改php.ini之后,需要重启WEB服务,新的配置才会生效。

第二步:
检查nginx.conf

client_max_body_size 100m;

第三步:
检查discuz 后台中对此用户组所作的附件大小限制
编辑用户组-》附件相关

第四步:
检查discuz 后台中对此类型附件所作的大小限制
其它->附件类型管理

本功能可限定某特定类型附件的最大尺寸,当这里设定的尺寸小于用户组允许的最大尺寸时,指定类型的附件尺寸限制将按本设定为准。
您可以设置某类附件最大尺寸为 0 以整体禁止这类附件被上传。

discuz中添加新的论坛动态

  • Posted on April 25, 2010 at 7:12 pm

discuz 7.2 gbk版
discuz 有一个论坛动态的功能,就是一些feeds,比如某人等级提升啦,某人的贴子被置顶啦,某人的贴子回复数超过1000啦之类的。

为了活跃论坛气氛,我们决定加入一个新的动态:某人回复了某个贴子。

先来看一下添加feed的函数:
include/global.func.php

function add_feed($arg, $data, $template = '') {
	global $tablepre, $db, $timestamp;
	...
 
	$db->query("INSERT INTO {$tablepre}feeds (type, fid, typeid, sortid, appid, uid, username, data, template, dateline)VALUES ('$type', '$fid', '$typeid', '$sortid', '$appid', '$uid', '$username', '".addslashes(serialize($data))."', '".addslashes(serialize($template))."', '$timestamp')");
	return $db->insert_id();

数据结构:
mysql> desc cdb_feeds;
+———-+———————–+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+———-+———————–+——+—–+———+—————-+
| feed_id | mediumint(8) unsigned | NO | PRI | NULL | auto_increment |
| type | varchar(255) | NO | MUL | default | |
| fid | smallint(6) unsigned | NO | | 0 | |
| typeid | smallint(6) unsigned | NO | | 0 | |
| sortid | smallint(6) unsigned | NO | | 0 | |
| appid | varchar(30) | NO | MUL | | |
| uid | mediumint(8) unsigned | NO | MUL | 0 | |
| username | varchar(15) | NO | | | |
| data | text | NO | | NULL | |
| template | text | NO | | NULL | |
| dateline | int(10) unsigned | NO | MUL | 0 | |
+———-+———————–+——+—–+———+—————-+

mysql> select * from cdb_feeds limit 1 \G
*************************** 1. row ***************************
feed_id: 2696
type: user_usergroup
fid: 0
typeid: 0
sortid: 0
appid:
uid: 129385
username: wogksthrPth
data: a:1:{s:5:”title”;a:2:{s:5:”actor”;s:62:”wogksthrPth“;s:9:”usergroup”;s:82:”秀才“;}}
template: s:0:”";
dateline: 1271894327

fid typeid sortid 都是主题相关的参数
appid 可能是应用相关的参数

如果template为空字符串的话,在显示feed的时候,就会去templates/default/dz_feeds.lang.php加载 ‘feed_$template’ 模板。

修改feed的模板文件:
templates/default/dz_feeds.lang.php
添加一行:

'feed_new_reply_title'=> '{actor} 回复了贴子:{subject}',

然后在include/newreply.inc.php中添加feed

                if (1)
                {
                        $arg = $data = array();
                        $arg['type'] = 'new_reply';
                        $arg['fid'] = $thread['fid'];
                        $arg['typeid'] = $thread['typeid'];
                        $arg['sortid'] = $thread['sortid'];
                        $arg['uid'] = $discuz_uid;
                        $arg['username'] = $discuz_userss;
                        $data['title']['actor'] = "<a href=\"space.php?uid={$discuz_uid}\" target=\"_blank\">{$discz_userss}</a>" ;u
                        $data['title']['subject'] = "<a href=\"viewthread.php?tid={$thread[tid]}\" target=\"_blank\">{$thread[subject]}</a>";                  
                        add_feed($arg, $data);
                }

再创建 images/feeds/new_reply.gif

更新缓存即可。

chrome浏览器下discuz ajaxget函数中的问题

  • Posted on April 20, 2010 at 2:54 pm

discuz7.2 gbk版
经过测试发现:
/include/js/common.js:

function ajaxget(url, showid, waitid, loading, display, recall)

使用此函数以ajax的GET方式从url取到html代码,并且通过ajaxinnerhtml()把代码填充到某个页面元素(比如div)里面。
如果取到的html代码中含有

<script src='http://xxxx.com/xxxx.php?a=xx&b=xxx'></script>

或者类似的代码,
在chrome和firefox浏览器里面,页面会跳转到

http://xxxx.com/xxxx.php?a=xx&b=xxx

而浏览器地址栏的地址却是正确的。

IE没有问题。

另外在使用chrome逛天涯论坛的时候,偶尔也会出现类似情况:
点击某个版块之后,比如“ 天涯摄影”, 然后整个页面变成空白,
只显示一个120×600的google图片广告,
此时地址栏中的地址是“天涯摄影”的地址,
刷新即恢复正常。
tianya_google

在discuz中禁止用户复制贴子

  • Posted on March 7, 2010 at 7:26 pm

没什么意思,糊弄小孩子玩的。

<SCRIPT language=JavaScript>
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
</SCRIPT>

discuz7.2勋章模块中的bug

  • Posted on February 28, 2010 at 7:06 pm

discuz 7.2 gbk版

/medal.php中,

}elseif($action == 'apply' && submitcheck('medalsubmit')) {

里面

if($medalpermission[0]) {

里面:

$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$discuz_uid', '$medalid', '1', '$timestamp', '$expiration', '0')");

$expiration的值永远为0.

所带来的影响就是: 如果用户符合领取某勋章的要求, 点击“领取”之后,领取到的勋章永远都不会到期。

解决办法:

可以继续往下看代码:

} else {
  $expiration = empty($medal['expiration'])? 0 : $timestamp + $medal['expiration'] * 86400;

这个else是处理”申请“勋章的情况。这里就很好地处理了$expiration。

所以把这一行加到

$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$discuz_uid', '$medalid', '1', '$timestamp', '$expiration', '0')");

前面就可以了。

把新短消息加入到discuz的提醒里面

  • Posted on February 28, 2010 at 5:03 pm

discuz 7.2 gbk版

discuz的默认情况:
接收到新短消息之后,会发出声音;有了新的提醒之后,“提醒”二个字前面会出现红色信封。 新短消息和提醒之间没有任何的联系。
如果用户的电脑没有打开声音,就无法知道是否有了新的短消息。因此,需要把新短消息加入到提醒里面。

在forumdata/cache/cache_settings.php中,我们可以看到
632   ‘promptkeys’ =>
633   array (
634     1 => ‘pm’,
635     2 => ‘announcepm’,
636     3 => ‘task’,
637     4 => ‘systempm’,
638     5 => ‘friend’,
639     6 => ‘threads’,
640   ),
641   ‘prompts’ =>
642   array (
643     ‘pm’ =>
644     array (
645       ‘name’ => ‘私人消息’,
646       ‘script’ => ‘pm.php?filter=newpm’,
647       ‘id’ => ’1′,
648       ‘new’ => 0,
649     ),
650     ‘announcepm’ =>
651     array (
652       ‘name’ => ‘公共消息’,
653       ‘script’ => ‘pm.php?filter=announcepm’,
654       ‘id’ => ’2′,
655       ‘new’ => 0,
656     ),
657     ‘task’ =>
658     array (
659       ‘name’ => ‘论坛任务’,
660       ‘script’ => ‘task.php?item=doing’,
661       ‘id’ => ’3′,
662       ‘new’ => 0,
663     ),
664     ‘systempm’ =>
665     array (
666       ‘name’ => ‘系统消息’,
667       ‘script’ => ”,
668       ‘id’ => ’4′,
669       ‘new’ => 0,
670     ),
671     ‘friend’ =>
672     array (
673       ‘name’ => ‘好友消息’,
674       ‘script’ => ”,
675       ‘id’ => ’5′,
676       ‘new’ => 0,
677     ),
678     ‘threads’ =>
679     array (
680       ‘name’ => ‘帖子消息’,
681       ‘script’ => ”,
682       ‘id’ => ’6′,
683       ‘new’ => 0,
684     ),
685   ),

dz已经预留了pm与announcepm 专门给新短消息来用。
我们需要做的就是 在用户发送完短消息后,插入一条提醒就可以了。
修改uc_client/control/pm.php   function onsendpm()
加入一行

require_once $_SERVER['DOCUMENT_ROOT']."/include/global.func.php";

然后在本函数中搜索

$lastpmid = $_ENV['pm']->sendpm(

在这一行之后,加入:

if ($fromuid)
$notice_message = "<div>收到新的短消息  来自:<a target=_blank href=\"{boardurl}space-uid-".$this->user['uid'].".html\">".$this->user['username']."</a><BR>".htmlspecialchars($message)."<BR><a href=\"{boardurl}pm.php?filter=newpm&uid=".$this->user['uid']."#new\" target=_blank>查看消息</a></div>";
else
$notice_message = "<div>收到新的短消息  <BR>".htmlspecialchars($message)."<BR><a href=\"{boardurl}pm.php?filter=newpm\" target=_blank>查看消息</a></div>";
sendnotice($uid, $notice_message, $notice_typeid);

等等,还没完,还有其它文件要改。
修改 /notice.php

$typeadd = $filter ? "AND typeid='".$prompts[$filter]['id']."'" : "AND typeid IN (".implodeids($promptpmids).")";

之前,加一行:

array_push($promptpmids, 1);

从promptkeys数组中可以看到,1对应的是”pm”.

还要改一下模板:
templates/default/notice.htm
在 <!–{loop $prompts $promptkey $promptdata}–> 里面,把下面的if改成:

<!--{if $promptkey!='announcepm'}-->

即可。

discuz7.2数据调用之主题附件(图片附件)存在的问题

  • Posted on February 26, 2010 at 10:30 am

discuz 7.2 GBK版

工具->数据调用->主题附件->图片附件

经过测试发现,

附件排序方式选择’按最后更新日期排序’或者是’按下载次数倒序排序’的时候,只能取到最近30天内的图片附件列表。

文件include/request.func.php 中:

在function updaterequest中

466                 $orderbysql = $historytime = '';
467                 switch($orderby) {
468                         case 'dateline':
469                                 $orderbysql = "ORDER BY `attach`.`dateline` DESC";
470                         break;
471                         case 'downloads':
472                                 $orderbysql = "ORDER BY `attach`.`downloads` DESC";
473                         break;
474                         case 'hourdownloads';
475                                 $historytime = $timestamp - 3600 * intval($hours);
476                                 $orderbysql = "ORDER BY `attach`.`downloads` DESC";

493                  $historytime = !$historytime ? $timestamp - 2592000 : $historytime;
494 $htsql = "`attach`.`dateline`>=$historytime";

493行改为

$historytime = !$historytime ? 0: $historytime;

即可。

原因我也不想讲了。 2592000秒 = 30天

Top