文章按发帖子日期排序方法 文章按发帖子日期排序方法 打开forumdisplay.php 找到 PHP: isset($orderby) && in_array($orderby, array('dateline', 'replies', 'views')) ? $forumdisplayadd .= "&orderby=$orderby" : $orderby = 'lastpost'; isset($ascdesc) && $ascdesc == 'ASC' ? $forumdisplayadd .= '&ascdesc=ASC' : $ascdesc = 'DESC'; 改为 PHP: isset($orderby) && in_array($orderby, array('dateline', 'replies', 'views')) ? $forumdisplayadd .= "&orderby=$orderby" : $orderby = 'dateline'; isset($ascdesc) && $ascdesc == 'ASC' ? $forumdisplayadd .= '&ascdesc=ASC' : $ascdesc = 'DESC';
首页在线用户[IP-来自]显示(后台设置管理组允许查看 IP) IP和来自哪里 后台设置管理组允许查看 IP 修改:index.php 找到: PHP: $query = $db->query("SELECT uid, username, groupid, invisible, action, lastactivity, fid FROM {$tablepre}sessions ORDER BY uid DESC"); 在uid, 后面添加 PHP: ip1, ip2, ip3, ip4, 再找到: PHP: $whosonline[] = $online; 在上面填加: PHP: $online['ip'] = $online['ip1'].'.'.$online['ip2'].'.'.$online['ip3'].'.'.$online['ip4']; if($allowviewip && !($adminid == 2 && $member['adminid'] == 1) && !($adminid == 3 && ($member['adminid'] == 1 || $member['adminid'] == 2))) { require_once DISCUZ_ROOT.'./include/misc.func.php'; $online['iplocation'] = convertip($online['ip']); } else { $allowviewip = 0; } 5.修改模版 index.htm 找到: HTML: <a href="viewpro.php?uid=$online[uid]" title="{lang time}: $online[lastactivity]{LF} {lang action}: $online[action] <!--{if $online['fid']}-->{LF}{lang forum}: $online[fid]<!--{/if}-->"> $online[username]</a> 修改为: HTML: <a href="viewpro.php?uid=$online[uid]" title="{lang time}: $online[lastactivity]{LF} {lang action}: $online[action] <!--{if $online['fid']}-->{LF}{lang forum}: $online[fid]<!--{/if}--> <!--{if $allowviewip}-->{LF}{lang online_ip}: $online[ip]{LF}来自:$online[iplocation]<!--{/if}-->"> $online[username]</a> 如果装了这个 [首页显示游客 for4.0] 首页显示IP的,也想看看游客IP 应该在 index.php 查找 PHP: $guestonline[]=$guest; 前面加上 PHP: $guest['ip'] = $online['ip1'].'.'.$online['ip2'].'.'.$online['ip3'].'.'.$online['ip4']; if($allowviewip && !($adminid == 2 && $member['adminid'] == 1) && !($adminid == 3 && ($member['adminid'] == 1 || $member['adminid'] == 2))) { require_once DISCUZ_ROOT.'./include/misc.func.php'; $guest['iplocation'] = convertip($guest['ip']); } else { $allowviewip = 0; }
贴图失效时友情提示 编辑include/discuzcode.func.php 查找 替换成 查找 替换成 ./images/common/img_no.gif为图片地址无效时候调用的图片,自行修改。 如果贴图无效就显示下面的。
从discuz2.5升级到4.0 第一步,首先把disucz3.12的所有文件覆盖原discuz2.5,然后再把下面代码保存为up312.php文件,放在discuz根目录,执行它,把数据库升级到3.12 代码: <?php // Upgrade Discuz! Board from 2.5F to 3.1.2 header("Content-Type: text/html; charset=gb2312"); set_time_limit(1000); define('IN_DISCUZ', TRUE); if(file_exists('./config.php')) { require "./config.php"; } else { require "./config.inc.php"; } require "./include/db_mysql.php"; error_reporting(E_ERROR | E_WARNING | E_PARSE); @set_magic_quotes_runtime(0); $action = ($HTTP_POST_VARS[action]) ? $HTTP_POST_VARS[action] : $HTTP_GET_VARS[action]; $step = $HTTP_GET_VARS[step]; $start = $HTTP_GET_VARS[start]; $upgrade1 = <<<EOT DROP TABLE cdb_caches; DROP TABLE cdb_plugins; DROP TABLE cdb_plugins_settings; DELETE FROM cdb_settings WHERE variable = 'attachimgcheck' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'attachsoftdownload' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'attach_max' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'attach_newpost' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'attach_editpost' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'attach_replypost' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'statcacherefresh' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'delayeditpost' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'delaykarma' LIMIT 1; DELETE FROM cdb_settings WHERE variable = 'useimagemessage' LIMIT 1; UPDATE cdb_settings SET value = '3.1' WHERE variable = 'version' LIMIT 1 ; INSERT INTO cdb_settings ( variable , value ) VALUES ('dotfolders', '0'); ALTER TABLE cdb_settings ORDER BY variable; ALTER TABLE cdb_adminsessions CHANGE uid sid CHAR( 6 ) BINARY DEFAULT '' NOT NULL,DROP ip,DROP PRIMARY KEY; ALTER TABLE cdb_admingroups CHANGE admingid admingid TINYINT( 1 ) UNSIGNED DEFAULT '0',DROP admintitle,DROP adminglobal,DROP allowhighlight,DROP allowdigest,DROP allowclose,DROP allowmove,DROP allowtop,DROP allowmerge,DROP allowsplit; ALTER TABLE cdb_announcements DROP posturl; ALTER TABLE cdb_karmalog DROP kid,CHANGE score score TINYINT( 3 ) UNSIGNED DEFAULT '0' NOT NULL,DROP INDEX pid,DROP INDEX dateline; DROP TABLE IF EXISTS cdb_profilefields; CREATE TABLE cdb_profilefields ( fieldid smallint(6) unsigned NOT NULL auto_increment, available tinyint(1) NOT NULL default '0', invisible tinyint(1) NOT NULL default '0', title varchar(50) NOT NULL default '', description varchar(255) NOT NULL default '', size tinyint(3) unsigned NOT NULL default '0', displayorder smallint(6) NOT NULL default '0', required tinyint(1) NOT NULL default '0', showinthread tinyint(1) NOT NULL default '0', selective tinyint(1) NOT NULL default '0', choices text NOT NULL, PRIMARY KEY (fieldid) ) TYPE=MyISAM; ALTER TABLE cdb_attachments DROP uid,DROP dateline,DROP INDEX tid,DROP INDEX pid,CHANGE downloads downloads SMALLINT( 6 ) DEFAULT '0' NOT NULL; EOT; $upgrade2 = <<<EOT ALTER TABLE cdb_members CHANGE adminid adminid TINYINT( 1 ) DEFAULT '0' NOT NULL; EOT; $upgrade3 = <<<EOT ALTER TABLE cdb_posts CHANGE aid aid MEDIUMINT( 8 ) UNSIGNED DEFAULT '0' NOT NULL,ADD INDEX dotfolder ( tid , authorid ); EOT; if(!$action) { echo"<title>Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; echo"本程序用于升级 Discuz! 2.5F 到 Discuz! 3.12,请确认之前已经顺利安装 Discuz! 2.5F<br><br><br>"; echo"<b><font color=\"red\">本升级程序只能从 2.5F 升级到 3.1.2,运行之前,请确认已经上传 3.1.2 的全部文件和目录</font></b><br>"; echo"<b><font color=\"red\">升级前请打开浏览器 JavaScript 支持,整个过程是自动完成的,不需人工点击和干预.<br><b>升级之前务必备份数据库资料,否则可能产生无法恢复的后果!</b><br><br>本次升级可能需要耗时很多,并可能占用大量CPU资源,根据您的数据量有关,请在服务器空闲时进行.<br>请确保服务器上 PHP 没有在安全模式,或没有脚本运行时间的硬性限制,否则请在本地机器升级后上传数据库。</font></b><br><br>"; echo"正确的升级方法为:<br>1. 关闭原有论坛,上传 Discuz! 3.1.2 版的全部文件和目录,覆盖服务器上的 2.5F<br>2. 根据安装说明,设置目录announcement、customavatars、forumdata/accesslogs属性777<br>3. 上传本程序到 Discuz! 目录中;<br>4. 运行本程序,直到出现升级完成的提示;<br><br>"; echo"<a href=\"$PHP_SELF?action=upgrade&step=1\">如果您已确认完成上面的步骤,请点这里升级</a>"; } else { $tables = array('attachments', 'announcements', 'banned', 'caches', 'favorites', 'forumlinks', 'forums', 'karmalog', 'members', 'memo', 'news', 'polls', 'posts', 'searchindex', 'sessions', 'settings', 'styles', 'smilies', 'stats', 'subscriptions', 'templates', 'themes', 'threads', 'pm', 'pms', 'usergroups', 'words', 'buddys', 'stylevars'); foreach($tables as $tablename) { ${"table_".$tablename} = $tablepre.$tablename; } unset($tablename); $db = new dbstuff; $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect); $db->select_db($dbname); unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect); if($step == 1) { $query = $db->query("SELECT value FROM ".$tablepre."settings WHERE variable='version'"); if(($db->result($query, 0)) != '2.5') { echo"<title>发生错误!</title>"; exit('您当前数据库数据版本不是2.5,无法升级<br><a href="javascript:history.go(-1)">返回</a>'); //debug } echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; runquery($upgrade1); echo "第 $step 步升级成功<br>"; redirect("$PHP_SELF?action=upgrade&step=".($step + 1)); } elseif($step == 2) { echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; runquery($upgrade2); echo "第 $step 步升级成功<br>"; redirect("$PHP_SELF?action=upgrade&step=".($step + 1)); } elseif($step == 3) { echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; runquery($upgrade3); echo "第 $step 步升级成功<br>"; redirect("$PHP_SELF?action=upgrade&step=".($step + 1)); } elseif($step == 4) { echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; $tagArray = array( 'fly'=>'\'\', 0, \'fly\', \'<marquee width="90%" behavior="alternate" scrollamount="3">{1}</marquee>\', \'[fly]This is sample text[/fly]\', \'Make text move horizontal, the same effect as html tag <marquee>. NOTE: Only Internet Explorer supports this feature\', 1, 1', 'wmv'=>'\'\', 0, \'wmv\', \'<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="OBJECT" id="MediaPlayer" width="500" height="350" >\r\n<param name="ShowStatusBar" value="-1">\r\n<param name="Filename" value="{1}">\r\n<embed type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" flename="wmv" src="{1}" width="500" height="350">\r\n</embed></object>\', \'[wmv]mms://your.com/example.wmv[/wmv]\', \'Embed Windows media file in thread page\', 1, 1', 'rm'=>'\'\', 0, \'rm\', \'<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="500" height="300" id="Player" viewastext>\r\n<param name="_ExtentX" value="12726">\r\n<param name="_ExtentY" value="8520">\r\n<param name="AUTOSTART" value="0">\r\n<param name="SHUFFLE" value="0">\r\n<param name="PREFETCH" value="0">\r\n<param name="NOLABELS" value="0">\r\n<param name="CONTROLS" value="ImageWindow">\r\n<param name="CONSOLE" value="_master">\r\n<param name="LOOP" value="0">\r\n<param name="NUMLOOP" value="0">\r\n<param name="CENTER" value="0">\r\n<param name="MAINTAINASPECT" value="{1}">\r\n<param name="BACKGROUNDCOLOR" value="#000000">\r\n</object><br><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="500" height="50" id="Player" viewastext>\r\n<param name="_ExtentX" value="18256">\r\n<param name="_ExtentY" value="794">\r\n<param name="AUTOSTART" value="-1">\r\n<param name="SHUFFLE" value="0">\r\n<param name="PREFETCH" value="0">\r\n<param name="NOLABELS" value="0">\r\n<param name="CONTROLS" value="controlpanel">\r\n<param name="CONSOLE" value="_master">\r\n<param name="LOOP" value="0">\r\n<param name="NUMLOOP" value="0">\r\n<param name="CENTER" value="0">\r\n<param name="MAINTAINASPECT" value="0">\r\n<param name="BACKGROUNDCOLOR" value="#000000">\r\n<param name="SRC" value="{1}"></object>\', \'[rm]rtsp://your.com/example.rm[/rm]\', \'Embed Real Movie in thread page\', 1, 1' ); foreach ($tagArray AS $value=>$content) { $query = $db->query("SELECT * FROM ".$tablepre."bbcodes WHERE tag='$value'"); $exists = mysql_num_rows($query); if ($exists == 0) { $InsertQuery = $db->query("INSERT INTO ".$tablepre."bbcodes (id, available, tag, replacement, example, explanation, params, nest) VALUES ($content);"); } } echo "第 $step 步升级成功<br>"; redirect("$PHP_SELF?action=upgrade&step=".($step + 1)); } elseif($step == 5) { $many = 2000; $start = intval($start); $start = $start < 1 ? 0 : $start; $end = $start + $many; $continue = 0; echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; echo "正在进行第 $step 步(转换POSTS表):<br>"; echo "如果您的附件很多本步可能需要时间较长<br>"; echo "当前影响第 $start 行到 $end 行数据。<br>"; $query = $db->query("SELECT * FROM ".$tablepre."attachments LIMIT $start,$many;"); while($a = $db->fetch_array($query)) { $query2 = $db->query("UPDATE ".$tablepre."posts SET aid='$a[aid]' WHERE pid='$a[pid]';"); $continue = 1; } if ($continue) { echo "操作继续。<br>"; redirect("$PHP_SELF?action=upgrade&step=$step&start=$end"); } else { echo "第 $step 步升级成功<br>"; redirect("$PHP_SELF?action=upgrade&step=".($step + 1)); } } elseif($step == 6) { @unlink('./forumdata/cache/cache_settings.php'); echo"<title>$step .Discuz!升级程序: 2.5F 到 3.12(共六步)</title>"; echo "恭喜您升级成功,请删除本程序。<a href='./index.php' target=_blank>点击这里进入您的论坛</a>"; } } function runquery($query) { global $db, $tablepre; $expquery = explode(";", $query); foreach($expquery as $sql) { $sql = trim($sql); if($sql != "" && $sql[0] != "#") { $db->query(str_replace("cdb_", $tablepre, $sql)); } } } function redirect($url) { echo"<script>"; echo"function redirect() {window.location.replace('$url');}\n"; echo"setTimeout('redirect();', 2000);\n"; echo"</script>"; echo"<br><br><a href=\"$url\">如果您的浏览器没有自动跳转,请点击这里</a>"; } ?> 第二步,把discuz4.0覆盖到原3.12,并把压缩包里面utilities文件夹下的upgrade5.php复制到discuz根目录,运行,就可以把数据库从3.12升级到4.0。 升级完毕后再在PHPMYADMIN中运行以下数据 代码: DROP TABLE IF EXISTS cdb_plugins; CREATE TABLE cdb_plugins ( pluginid smallint(6) unsigned NOT NULL auto_increment, available tinyint(1) NOT NULL default '0', adminid tinyint(1) unsigned NOT NULL default '0', name varchar(40) NOT NULL default '', identifier varchar(40) NOT NULL default '', description varchar(255) NOT NULL default '', datatables varchar(255) NOT NULL default '', `directory` varchar(100) NOT NULL default '', copyright varchar(100) NOT NULL default '', modules text NOT NULL, PRIMARY KEY (pluginid), UNIQUE KEY identifier (identifier) ) Type=MyISAM;
短信息MSN提示+震动功能 《新功能加入及修改》 1) 模仿MSN messager加入了『震盪功能』 2) 美化了原本的MSN形PM 升級數據庫: PHP: ALTER TABLE `cdb_pms` ADD `shake` tinyint(1) DEFAULT '0' NOT NULL; 1.修改pm.php,找: PHP: if(!submitcheck('pmsubmit')) { $discuz_action = 103; 上加,並且可修改金額(震盪功能是以現金作費用): PHP: --------PM震盪功能 $pmsmoney = '20'; //使用金額 //--------PM震盪功能 找: PHP: foreach($msgto as $uid) { 上加: PHP: if ($shake) { if ($usermoney < $pmsmoney) { showmessage('抱歉,你的現金不足,無法使用震盪功能!'); } else { $cshake = 1; $db->query("UPDATE $table_members SET money=money-$pmsmoney WHERE uid='$discuz_uid'"); } } 找2處,2處都要修改: PHP: $db->query("INSERT INTO $table_pms (msgfrom, msgfromid, msgtoid, folder, new, subject, dateline, message 後加: PHP: , shake 找: PHP: VALUES('$discuz_user', '$discuz_uid', '$uid', 'inbox', '1', '$subject', '$timestamp', '$message' 後加: PHP: , '$cshake' 找: PHP: VALUES('$discuz_user', '$discuz_uid', '$msgto[0]', 'outbox', '1', '$subject', '$timestamp', '$message' 後加: PHP: , '$cshake' 2. 修改./include/pmprompt.php,把: PHP: $pmlist = array(); $pmdetail = ''; while($pm = $db->fetch_array($query)) { $pm['subject'] = cutstr($pm['subject'], 20); $pm['message'] = dhtmlspecialchars(cutstr($pm['message'], 50)); $pmlist[] = $pm; } 換成: PHP: $pm = $db->fetch_array($query); $pm['subject'] = cutstr($pm['subject'], 20); $pm['message'] = dhtmlspecialchars(cutstr($pm['message'], 50)); 找: PHP: $query = $db->query("SELECT pmid, msgfrom, msgfromid, subject, message FROM $table_pms WHERE msgtoid='$discuz_uid' AND folder='inbox' AND new='1'"); 換成: PHP: $query = $db->query("SELECT pmid, msgfrom, msgfromid, subject, message FROM $table_pms WHERE msgtoid='$discuz_uid' AND folder='inbox' AND new='1' ORDER BY pmid DESC LIMIT 1"); 3. 修改pm_send模版,找: PHP: <tr> <td bgcolor="{ALTBG1}">{lang subject}:</td> <td bgcolor="{ALTBG2}"><input type="text" name="subject" size="65" value="$subject"></td> </tr> 上加: PHP: <tr> <td bgcolor="{ALTBG1}">震盪功能:</td> <td bgcolor="{ALTBG2}"><span class="smalltxt"> <input type="checkbox" name="shake" value="1">使用震盪功能 <font color="#FF0000"> (需扣除現金 $pmsmoney )</font></span></td> </tr> 4. 修改pm_view模版,找: PHP: <tr> <td bgcolor="{ALTBG1}">{lang time}:</td> <td bgcolor="{ALTBG2}">$pm[dateline]</td> </tr> 下加: PHP: <tr> <td bgcolor="{ALTBG1}">震盪功能:</td> <td bgcolor="{ALTBG2}"><!--{if $pm[shake]==1}--><font color="#FF0000">有</font><!--{else}-->沒有<!--{/if}--></td> </tr> 在最頂部加上: PHP: <!--{if $pm[shake]==1}--> <bgsound src="images/pmshake.mp3" border="0"> <script> function shake(n) { if (self.moveBy){ for (i = 10; i > 0; i--) { for (j = n; j > 0; j--) { self.moveBy(0,i); self.moveBy(i,0); self.moveBy(0,-i); self.moveBy(-i,0); }} } }; setTimeout("shake(1)",500); </script> <!--{/if}--> 5. 最後下載附件,解壓後依原本的位置上傳 ./images/msn_b.gif ./images/msn_g.gif ./images/msn_h.gif ./images/msn_x.gif ./images/msn_xb.gif ./images/newpm.wav ./images/pmshake.mp3 ./templates/default/pmprompt.htm 6.附加修改: 《在特殊短訊息也自動加入震盪功能》 一. 獎懲通知單 *必須已裝評分後發PM功能 1. 修改misc.php,找: PHP: $db->query("INSERT INTO $table_pms (msgfrom, msgfromid, msgtoid, folder, new, subject, dateline, message 後加: PHP: , shake 找: PHP: VALUES('$discuz_user', '$discuz_uid', '$post[authorid]', 'inbox', '1', '$kasubject', '$timestamp','$kamessage' 後加: PHP: ,'1' 完成! 二. 論壇通知 1.修改./admin/newsletter.php,找: PHP: $db->query("INSERT INTO $table_pms (msgfrom, msgfromid, msgtoid, folder, new, subject, dateline, message 後加: PHP: , shake 找: PHP: VALUES('$discuz_user', '$discuz_uid', '$member[uid]', 'inbox', '1', '$subject', '$timestamp', '$message' 後加: PHP: , '1'
组头像显示于星星位置插件 修改文件viewthread.htm viewthread.php 数据库修改:无 难易:易 修改方法: 第一步:修改viewthread.php PHP: $post['avatarshow'] = $avatarshowstatus && ($post['avatarshowid'] || $avatarshowdefault) ? avatarshow($post['avatarshowid'], $post['gender']) : ''; if($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) { $post['avatar'] = '<img src="'.$_DCACHE['usergroups'][$post['groupid']]['groupavatar'].'" border="0">'; } elseif($avatarshowstatus != 2 && $_DCACHE['usergroups'][$post['groupid']]['allowavatar'] && $post['avatar']) { $post['avatar'] = '<img src="'.$post['avatar'].'" width="'.$post['avatarwidth'].'" height="'.$post['avatarheight'].'" border="0">'; } else { $post['avatar'] = ''; } 用以下代码替换: PHP: post['avatarshow'] = $avatarshowstatus && ($post['avatarshowid'] || $avatarshowdefault) ? avatarshow($post['avatarshowid'], $post['gender']) : ''; if($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) { $post['stars'] = ''; $post['avatarcnhky'] = '<img src="'.$_DCACHE['usergroups'][$post['groupid']]['groupavatar'].'" border="0">'; } else { $post['avatarcnhky'] = ''; $post['stars'] = $_DCACHE['usergroups'][$post['groupid']]['stars']; } if($avatarshowstatus != 2 && $_DCACHE['usergroups'][$post['groupid']]['allowavatar'] && $post['avatar']) { $post['avatar'] = '<img src="'.$post['avatar'].'" width="'.$post['avatarwidth'].'" height="'.$post['avatarheight'].'" border="0">'; [color=Red] } else { $post['avatar'] = ''; }[/color] 修改viewthread.htm 找到 <br>{eval showstars($post['stars']);}<br> 在后面加上 $post[avatarcnhky]<br> 修改后如下: <br>{eval showstars($post['stars']);} $post[avatarcnhky]<br> 设置组头像不影响个人头像显示。但不显示星星。如果不设置组头像则依然以星星显示。