演示:http://fbi.com.tw/pm.php?action=archive
作者:BBGHOST·FBI新天地 (bbghost@gmail.com)
安裝需求:Discuz 2.5F/2.5FSP1
安裝程度:簡單
修改文件:
pm.php
templates/default/pm.htm
簡體在2樓
安裝後發現MYSQL錯誤的請按此到27樓修改
新增文件 :
templates/default/pm_archive.htm
除了有D4現使用的功能外, 還可以選擇性會員名稱打包.
截圖:
1. 將以下內容上傳為 templates/default/pm_archive.htm
- <script>
- function pmuser(a){
- var msgfromid = "$msgfromid";
- msgfromid = msgfromid.split(",");
- var msgfromname = "$msgfromuser";
- msgfromname = msgfromname.split("||");
- var msgtoid = "$msgtoid";
- msgtoid = msgtoid.split(",");
- var msgtoname = "$msgtouser";
- msgtoname = msgtoname.split("||");
- var xHTML = "";
- if (a == 'inbox'){
- var target = "發";
- for(key in msgfromid){
- xHTML += "<option value=""+msgfromid[key]+"">"+msgfromname[key]+"</option>"
- }
- }else{
- var target = "收";
- for(key in msgtoid){
- xHTML += "<option value=""+msgtoid[key]+"">"+msgtoname[key]+"</option>"
- }
- }
- xHTML="<select name="puid"><option value="0">所有"+target+"訊人</option>"+xHTML+"</select>";
- select.innerHTML = xHTML;
- }
- </script>
- <form method="post" action="pm.php?action=archive&folder=$folder">
- <input type="hidden" name="formhash" value="{FORMHASH}">
- <table cellspacing="1" cellpadding="4" width="99%" class="tableborder">
- <tr>
- <td class="header" colspan="2">導出短訊息</td>
- </tr>
- <tr>
- <td valign="top" class="altbg1">刪除:</td>
- <td class="altbg2"><input type="checkbox" name="delete" value="1"> 導出後刪除短訊息</td>
- </tr>
- <tr>
- <td class="altbg1" width="15%">文件夾:</td>
- <td class="altbg2" width="75%"><input type="radio" name="folder" value="inbox" checked onclick="pmuser(this.value);"> 收件箱 <input type="radio" name="folder" value="outbox" onclick="pmuser(this.value);"> 發件箱</td>
- </tr>
- <tr>
- <td class="altbg1">時間範圍:</td>
- <td class="altbg2"><select name="days">
- <option value="1">1 天</option>
- <option value="2">2 天</option>
- <option value="7">1 周</option>
- <option value="30">1 個月</option>
- <option value="90">3 個月</option>
- <option value="180">6 個月</option>
- <option value="365">1 年</option>
- <option value="0">全部</option>
- </select> <select name="newerolder">
- <option value="newer">以來</option>
- <option value="older">以前</option>
- </select></td>
- </tr>
- <tr>
- <td class="altbg1">會員選擇:</td>
- <td class="altbg2"><span name="select" id="select"></span></td>
- </tr>
- <tr>
- <td class="altbg1">導出短消息數量:</td>
- <td class="altbg2"><select name="amount">
- <option value="0">所有</option>
- <option value="10">10</option>
- <option value="20">20</option>
- <option value="30">30</option>
- <option value="40">40</option>
- <option value="50">50</option>
- </select></td>
- </tr>
- </table>
- <br><table cellspacing="0" cellpadding="0" width="99%">
- <tr><td align="center"><input type="submit" name="archivesubmit" value="提 交"></td></tr>
- </table>
- </form>
- <script>
- pmuser('inbox')
- </script>
复制代码
2. 打開 pm.php
在
- include template('pm');
- ?>
复制代码
前增加 :
- elseif($action == 'archive') {
- if(!submitcheck('archivesubmit')) {
- $query = $db->query("SELECT uid,username FROM $table_members WHERE uid IN (SELECT msgfromid from cdb_pms WHERE msgtoid = $discuz_uid AND folder = 'inbox')");
- while(@$msgfromlist = $db->fetch_array($query)){
- $msgfromid .= ($msgfromid)?",":"";
- $msgfromuser .= ($msgfromuser)?"||":"";
- $msgfromid .= $msgfromlist[uid];
- $msgfromuser .= $msgfromlist[username];
- }
- $query = $db->query("SELECT uid,username FROM $table_members WHERE uid IN (SELECT msgtoid from cdb_pms WHERE msgfromid = $discuz_uid AND folder = 'outbox') ");
- while(@$msgtolist = $db->fetch_array($query)){
- $msgtoid .= ($msgtoid)?",":"";
- $msgtouser .= ($msgtouser)?"||":"";
- $msgtoid .= $msgtolist[uid];
- $msgtouser .= $msgtolist[username];
- }
- } else {
- $pmslist = $msguid = $msguname = $uname = $dellist = array();
- $puid = intval($puid);
- $delete = ($delete)?1:0;
- $days = intval($days);
- $amount = intval($amount);
- $days = ($days > 0)? $timestamp - ($days*3600*24):"$days";
- $target = ($folder == 'inbox')?"msgtoid":"msgfromid";
- $target_ = ($folder == 'inbox')?"msgfromid":"msgtoid";
- $target__ = ($folder == 'inbox')?"inbox":"outbox";
- $query_add = " p.$target='".$discuz_uid."' AND p.folder='".$target__."'";
- $query_add .= (!$puid)?"":" AND p.$target_ ='".$puid."'";
- $query_add .= ($days > 0)? ($newerolder == 'newer')? " AND p.dateline > $days" : " AND p.dateline < $days" : "";
- $query_add .= ($amount > 0) ? " LIMIT 0,$amount":"";
- $query = $db->query("SELECT p.*, m.username FROM $table_pms p
- LEFT JOIN $table_members m ON m.uid=p.".$target_.
- " WHERE $query_add ");
- while($pm = $db->fetch_array($query)){
- $pm['dateline'] = gmdate("$dateformat $timeformat", $pm['dateline'] + $timeoffset * 3600);
- $pm['message'] = postify($pm['message'], 0, 0, 1, 0, 1, 1, 0);
- $pmslist[] = $pm;
- $pm_mem = ($puid)?$pm['username']:"";
- if ($delete){$dellist[] = $pm['pmid'];}
- }
- if ($delete){
- $dellist = implode(",",$dellist);
- $query = $db->query("DELETE FROM $table_pms WHERE pmid IN ($dellist)");
- }
-
- $export = "<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=big5" />
- <title>$bbname$navtitle - powered by Discuz!</title>
- <style type="text/css">
- body { background-color: #FFFFFF; color: #000000; font-family: Verdana, Tahoma; font-size: 12px; margin: 20px; padding: 0px; }
- #largetext { font-size: 18px; font-weight: bold; margin-bottom: 10px; padding-top: 3px; width: auto; }
- #userinfo { font-size: 12px; color: #888888; text-align: right; width: auto; }
- #copyright { margin-top: 30px; font-size: 11px; text-align: center; }
- .wrapper { }
- .subject { font-size: 14px; font-weight: bold; padding: 3px; margin-bottom: 10px; border: 1px solid #A8A8A8; }
- .pm { color: #000000; padding: 10px; margin-top:10px; border: 1px solid #888888; }
- .content { color: #888888; }
- </style>
- </head>
- <body>
- <div id="wrapper">
- <div id="largetext">導出短訊息</div>
- <div id="userinfo"><a href="$siteurl/viewpro.php?uid=$discuz_uid" target="_blank">$discuz_user @ ".gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600)."</a></div>
- ";
- foreach($pmslist AS $key => $pm){
- $export .="<br />
- <div class="pm">
- <div class="subject">".$pm['subject']."</div>
- <strong>時間:</strong> ".$pm['dateline']."<br />
- <strong>文件夾:</strong>\n".
- ($folder=='inbox' ? "收件箱<br />\n" : "發件箱<br />\n").
- $pm['message']
- ."\n</div>
- </div>
- </div>";
- }
- $export .="<div id='copyright'>
- Powered by <strong><a href="https://discuz.dismall.com" target="_blank">Discuz!</a> 4.0.0RCFinal</strong></a>
- © 2001-2005 <a href="http://www.comsenz.com" target="_blank">Comsenz Technology Ltd</a>
- </div>
- </body>
- </html>";
- ob_end_clean();
- header('Content-Encoding: none');
- header('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
- header('Content-Disposition: attachment; filename="PM_'.$discuz_user.'_'.($puid ? "$pm_mem".'_' : 'ALL_').gmdate("y"."n"."j"."_"."Gi", $timestamp + $timeoffset * 3600).'.html"');
- header('Content-Length: '.strlen($export));
- header('Pragma: no-cache');
- header('Expires: 0');
- echo $export;
-
- dexit();
- }
- }
复制代码
3. 打開 templates/default/pm.htm
尋找 :
- <!--{if $action == 'send'}--><b>{lang pm_send}</b><!--{else}--><a href="pm.php?action=send">{lang pm_send}</a><!--{/if}--></td></tr>
- <tr><td bgcolor="{ALTBG1}" width="20" align="center"><img src="{IMGDIR}/pm_folder.gif"></td><td bgcolor="{ALTBG2}">
复制代码
在下面增加 :
- <!--{if $action == 'archive'}--><b>短訊息打包</b><!--{else}--><a href="pm.php?action=archive">短訊息打包</a><!--{/if}-->
- <tr><td bgcolor="{ALTBG1}" width="20" align="center"><img src="{IMGDIR}/pm_folder.gif"></td><td bgcolor="{ALTBG2}">
复制代码
找
- <!--{elseif $action == 'ignore'}-->
- {template pm_ignore}
复制代码
在下面增加
- <!--{elseif $action == 'archive'}-->
- {template pm_archive}
复制代码
OK,大功告成
[ 本帖最后由 BBghost2004 于 2005-9-3 11:39 编辑 ] |