无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 9897|回复: 5
打印 上一主题 下一主题

leobbs转discuz后,显示leobbs时期的旧图片,下载旧附件,discuz 3.2 有效

[复制链接]
跳转到指定楼层
1#
发表于 2007-8-5 20:02:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
目前已经解决了旧附件显示和下载的问题,大家帮助查一下,如果发现存在哪些问题,可以提出来,以便修正。

现在可能存在的问题,就是那些带有 snap3_(10位数字).xxx 格式的文件和图片附件,在移动分区以后,就会无法下载。
现在还不了解这种附件格式中的10位数字的含义,如果里面带有原来的分论坛号,就那办,现在看上去不象有这个信息。

-----------------------------------------------------------------------------------------------------------
leobbs转换为discuz以后,旧附件会无法查看,需要对旧论坛的附件进行调整。

leobbs附件的文件名有两种需要区别对待的格式:

1.   10位数字为标号:snap3_2343223422.gif/rar :”任意数字或字母组合“ + ”_“ + ”10位数字“ + ”."  + "gif|jpg|png|jpeg" 。

例:http://bbs.wuyou.net/forum.php?mod=viewthread&tid=33959&extra=page%3D2%26amp%3Bfilter%3Ddigest&page=1

2.   分论坛号为标号:34_234.gif:“1-2位数字”(分论坛号)  +  “_” + “多位数字" + [ _ “多位数字” ] + “." + "gif|jpg|png|jpeg"
例:http://bbs.wuyou.net/forum.php?mod=viewthread&tid=24438&extra=page%3D1

其中,论坛对图片和非图片的附件处理方法不同,图片直接显示出来,非图片附件要以下载形式。
这样,就有四种需要区别对待。

曾进行分区调整后的标准格式 非图片附件:http://bbs.wuyou.net/forum.php?mod=viewthread&tid=31996&extra=page%3D1&page=2
曾进行分区调整后的标准格式 图片附件:http://bbs.wuyou.net/forum.php?mod=viewthread&tid=31996&extra=page%3D1&page=23


具体方法如下:(discuzX 3.2)

在/source/function/function_discuzcode.php中
找到以下一行:

for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
                $message = str_replace("[\tDISCUZ_CODE_$i\t]", $_G['forum_discuzcode']['codehtml'][$i], $message);

在其上方添加以下代码:

  1. //leobbs 转换数据后显示旧图片附件专用 $tid是你主题的最大id
  2.         global $_G;
  3.         $fid = $_G['fid'];
  4.         $tid = $_G['tid'];

  5.         if ($tid < 77038) {
  6.                 $lbfilepath = './data/attachment/forum/lbupfile/';
  7.                 $message = preg_replace(array(
  8.                  "/\[UploadFile=(.{1,20}_\d{10})\.(gif|jpg|png|bmp|jpeg)\]/ies",
  9.                                 "/\[UploadFile=(\d{1,2})_(.{1,20})\.(gif|jpg|png|bmp|jpeg)\]/ies",
  10.                                 "/\[UploadFile=(.{1,20}_\d{10})\.(torrent|zip|rar|doc|txt)\]/ies",
  11.                  "/\[UploadFile=(\d{1,2})_(.{1,20})\.(torrent|zip|rar|doc|txt)\]/ies"),
  12.                                 array(
  13.                                 "'<center><img src="".$lbfilepath.$fid."/\\1.\\2" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\';}" onmouseover="if(this.resized) this.style.cursor=\'hand\';" onclick="if(this.resized) {window.open(\'%s\');}"></center><br>'",
  14.                                 "'<center><img src="".$lbfilepath."\\1/\\1_\\2.\\3" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\';}" onmouseover="if(this.resized) this.style.cursor=\'hand\';" onclick="if(this.resized) {window.open(\'%s\');}"></center><br>'",
  15.                                 "'<a href="".$lbfilepath.$fid."/\\1.\\2" target="_blank" style="color:#0000FF;font-weight:bold">点击下载文件</a>'",
  16.                  "'<a href="".$lbfilepath."\\1/\\1_\\2.\\3" target="_blank" style="color:#0000FF;font-weight:bold">点击下载文件</a>'"),$message);

  17.         }
  18.         unset($fid,$tid,$lbfilepath);
  19. //discuz 3.2 可用
复制代码
2#
 楼主| 发表于 2013-4-10 16:48:47 | 只看该作者
现在需要解决转到discuz x2.0,如何处理这些贴子和附件的问题,最好是直接在后台执行sql替换掉,方便以后操作。
现在想办法解决leobbs论坛时期的附件问题,尽管是很久远的东西。

贴子如下:
http://bbs.wuyou.net/forum.php?m ... mp;extra=page%3D989

附件代码类似以下
  1. [UploadFile=2_2162.gif]
复制代码
实际地址:
http://bbs.wuyou.net/data/attachment/forum/lbupfile/2/2_2162.gif
回复

使用道具 举报

3#
 楼主| 发表于 2013-4-11 01:03:32 | 只看该作者
经测试,本方法试用于Discuz 2.0,只是稍有变化;

具体方法如下:

在/source/function/function_discuzcode.php中
找到以下一行:

  1.         for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
  2.                 $message = str_replace("[\tDISCUZ_CODE_$i\t]", $_G['forum_discuzcode']['codehtml'][$i], $message);
复制代码
加入楼主的代码即可

不过 $lbfilepath = './data/attachment/forum/lbupfile/';  要改这样。

03.        global $fid,$tid; 这一行要改成以下:

        global $_G;
        $fid = $_G['fid'];
        $tid = $_G['tid'];

这样 $tid < 77038 这个判断也有效了。
回复

使用道具 举报

4#
 楼主| 发表于 2013-4-29 09:21:36 | 只看该作者
完整新代码如下:

  1. 在 for($i = 0; $i <= $discuzcodes['pcodecount']; $i++) { 上面添加

  2. //LeoBBS X转换数据后专用 $tid是你主题的最大id
  3.         global $_G;
  4.         $fid = $_G['fid'];
  5.         $tid = $_G['tid'];

  6.         if ($tid < 77038) {
  7.                 $lbfilepath = './data/attachment/forum/lbupfile/';
  8.                 $message = preg_replace(array(
  9.                                 "/\[UploadFile=([^\[]+?)\.(gif|jpg|png|bmp|jpeg)\]/ies",
  10.                                 "/\[UploadFile=(.*)\]/ies"),
  11.                                 array(
  12.                                 "bbcodeurl('\\1', '<center><img src="".$lbfilepath.$fid."/\\1.\\2" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\';}" onmouseover="if(this.resized) this.style.cursor=\'hand\';" onclick="if(this.resized) {window.open(\'%s\');}"></center><br>')",
  13.                                 "bbcodeurl('\\1', '【<a href="".$lbfilepath.$fid."/\\1" target="_blank" style="color:#0000FF;font-weight:bold">点击下载文件</a>】')"),
  14.                                 $message);
  15.         }
  16.         unset($fid,$tid,$lbfilepath);
  17. //LeoBBS X转换数据后专用
复制代码
回复

使用道具 举报

5#
 楼主| 发表于 2013-4-29 09:22:26 | 只看该作者
测试一下 [UploadFile=2_2162.gif]

因为本贴是非转换贴,不应该显示出图片。
回复

使用道具 举报

6#
 楼主| 发表于 2013-4-29 09:42:55 | 只看该作者
发现一个问题,那就是对旧贴跟贴时,[UploadFile=2_2162.gif] 这样的标签还有效,属多余处理了,解决中。
估计得对改discuz后的第一个pid(pid=801445) 做判断,才能解决。
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2025-12-23 18:49

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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