此插件原来开发过一次,不过这次将更大解决已存在的BUG.

  解决:
  发帖点击提交即时本地化,影响速度及经常发帖失败.
  部分用户限制使用不完美.
  输出目录要人工创建问题,及单目录输出问题.
  图片大小限制不准确的问题.

  新功能:
  兼容5.0 4.0PHP服务器版本下运行.
  可选择性开放水印及用户使用权限.
  自动生成输出目录, 以月为单位.
  仅本地化一次,二次访问,速度不受影响.
  
  注意:
  请正确添写自己的配置.
  请不要过份修改已经本地化的帖子,本地化的图片无法自动删除.

  安装方法:

  打开: viewthread.php
  查找:

    1. while($post = $db->fetch_array($query)) {
    复制代码
    在它的下一行增加:
    1. if($post['first']==1&&!eregi('post\.php\?action=',dreferer())&&in_array($adminid, array(1, 2, 3))){  //判断第一楼可以,判断管理组可用..
       
    2.                 preg_match_all('/\[img\](http:\/\/.*)\[\/img\]/isU',$post['message'],$simg);
       
    3.                 $simg=max($simg);
       
    4.                 foreach ($simg as $imgval){
       
    5.                         $sum++;
       
    6.                         $imgsize = getimagesize($imgval); //获得远程图片的长宽
       
    7.                         if(!eregi('127.0.0.1',$imgval)&&$imgsize[0]>50&&$imgsize[1]>50&&$imgsize[0]<800&&$imgsize[1]<700)  //搜索一下,如果地址中包含自己的域就退出.. 后面四个数值分别是最小宽 最小高 最大宽 最大高   图片限制之后,能够本地化的图片就全部是比较中等的图片了.. //把域名换成自己的.
       
    8.                         imgadmin($imgval,$sum);
       
    9.                 }}
    复制代码
    然后 查找:
    1. $newpostanchor = $postcount = $ratelogpids = 0;
    复制代码


在它的上一行增加:

    1. function imgadmin($img,$sum){
       
    2.                 $urlname='http://www.fenanr.com';   //你的URL 后面不要加/
       
    3.                 $imgxp=1;  //为0关闭水印..
       
    4.                 $path = DISCUZ_ROOT;
       
    5.                 set_time_limit(0);
       
    6.                 if($imgxp==1)
       
    7.         require_once DISCUZ_ROOT.'./include/image.class.php';  //处理图片水印..
       
    8.                 global $db,$tablepre,$tid;
       
    9.                 $datename=date("Y-m",time());
       
    10.                 $imgpath="$path/attachments/$datename/";
       
    11.                 if(!file_exists($imgpath))
       
    12.                 mkdir($imgpath);
       
    13.                 if(preg_match('/\..{3}$/isU',$img,$imgarr)&&file_exists($imgpath))
       
    14.                 {
       
    15.                         if(!file_exists("$imgpath$tid-$sum{$imgarr[0]}")){
       
    16.                         $imgfile=file($img);
       
    17.                         $imgfile=implode($imgfile);
       
    18.                         $fop=fopen("$imgpath$tid-$sum{$imgarr[0]}",'w+');
       
    19.                         fwrite($fop,$imgfile);
       
    20.                         if($imgxp==1){
       
    21.                         $image = new Image($attachedfile,"$imgpath$tid-$sum{$imgarr[0]}",$attach);
       
    22.                        $image->Watermark();
       
    23.                 $attach = $image->attach;}
       
    24.                         $db->query("UPDATE `{$tablepre}posts` SET `message` = replace(message,'$img' ,'$urlname/attachments/$datename/$tid-$sum{$imgarr[0]}') WHERE `tid`='$tid'");
       
    25.                         }
       
    26.                 }elseif (file_exists($imgpath))  //处理没有后缀名的图片..
       
    27.                 {
       
    28.                         if(!file_exists("$imgpath$tid-P{$sum}.gif")){
       
    29.                         $imgfile=file($img);
       
    30.                         $imgfile=implode($imgfile);
       
    31.                         $fop=fopen("$imgpath$tid-P{$sum}.gif",'w+');
       
    32.                         fwrite($fop,$imgfile);
       
    33.                         if($imgxp==1){
       
    34.                         $image = new Image($attachedfile,"$imgpath$tid-P{$sum}.gif",$attach);
       
    35.                        $image->Watermark();
       
    36.                 $attach = $image->attach;}
       
    37.                         $db->query("UPDATE `{$tablepre}posts` SET `message` = replace(message,'$img' ,'$urlname/attachments/$datename/$tid-P{$sum}.gif') WHERE `tid`='$tid'");
       
    38.                 }}
       
    39.         }
    复制代码


然后修改弹出显示,此修改将影响所有的外部链接图片,无论有没有本地化..
  打开:discuzcode.func.php
  查找:

    1. <img src=\"%s\" border=\"0\" onclick=\"zoom(this)\" onload=\"attachimg(this, \'load\')\" alt=\"\" />
    复制代码


将这一句替换成:

    1. <a href=\"###zoom\"><img src=\"%s\" border=\"0\" onclick=\"zoom(this,\'%s\')\" alt=\"\" /></a>
    复制代码


安装完成..现在开始本地化吧..

 

 
 
 
  1.         function imgadmin($img,$sum){
     

  2.  
  3.                 $urlname='http://www.fenanr.com';   //你的URL 后面不要加/
     

  4.  
  5.                 $imgxp=1;  //为0关闭水印..
     

  6.  
  7.                 $path = DISCUZ_ROOT;
     

  8.  
  9.                 set_time_limit(0);
     

  10.  
  11.                 if($imgxp==1)
     

  12.  
  13.         require_once DISCUZ_ROOT.'./include/image.class.php';  //处理图片水印..
     

  14.  
  15.                 global $db,$tablepre,$tid;
     

  16.  
  17.                 $datename=date("Y-m",time());
     

  18.  
  19.                 $imgpath="$path/attachments/$datename/";
     

  20.  
  21.                 if(!file_exists($imgpath))
     

  22.  
  23.                 mkdir($imgpath);
     

  24.  
  25.                 if(preg_match('/\..{3}$/isU',$img,$imgarr)&&file_exists($imgpath))
     

  26.  
  27.                 {   
     

  28.  
  29.                         if(!file_exists("$imgpath$tid-$sum{$imgarr[0]}")){
     

  30.  
  31.                         $imgfile=file($img);
     

  32.  
  33.                         $imgfile=implode($imgfile);
     

  34.  
  35.                         $fop=fopen("$imgpath$tid-$sum{$imgarr[0]}",'w+');
     

  36.  
  37.                         fwrite($fop,$imgfile);
     

  38.  
  39.                         if($imgxp==1){
     

  40.  
  41.                         $image = new Image($attachedfile,"$imgpath$tid-$sum{$imgarr[0]}",$attach);
     

  42.  
  43.                        $image->Watermark();
     

  44.  
  45.                 $attach = $image->attach;}
     

  46.  
  47.                 if(filesize("$imgpath$tid-$sum{$imgarr[0]}")>100)
     

  48.  
  49.                         $db->query("UPDATE `{$tablepre}posts` SET `message` = replace(message,'$img' ,'$urlname/attachments/$datename/$tid-$sum{$imgarr[0]}') WHERE `tid`='$tid'");
     

  50.  
  51.                         }else {
     

  52.  
  53.                                 if(filesize("$imgpath$tid-$sum{$imgarr[0]}")<100)
     

  54.  
  55.                                 unlink("$imgpath$tid-$sum{$imgarr[0]}");
     

  56.  
  57.                         }
     

  58.  
  59.                 }elseif (file_exists($imgpath))  //处理没有后缀名的图片..
     

  60.  
  61.                 {        
     

  62.  
  63.                         if(!file_exists("$imgpath$tid-P{$sum}.gif")){
     

  64.  
  65.                         $imgfile=file($img);
     

  66.  
  67.                         $imgfile=implode($imgfile);
     

  68.  
  69.                         $fop=fopen("$imgpath$tid-P{$sum}.gif",'w+');
     

  70.  
  71.                         fwrite($fop,$imgfile);
     

  72.  
  73.                         if($imgxp==1){
     

  74.  
  75.                         $image = new Image($attachedfile,"$imgpath$tid-P{$sum}.gif",$attach);
     

  76.  
  77.                        $image->Watermark();
     

  78.  
  79.                 $attach = $image->attach;}
     

  80.  
  81.                 if(filesize("$imgpath$tid-P{$sum}.gif")>100){
     

  82.  
  83.                         $db->query("UPDATE `{$tablepre}posts` SET `message` = replace(message,'$img' ,'$urlname/attachments/$datename/$tid-P{$sum}.gif') WHERE `tid`='$tid'");
     

  84.  
  85.                         }else {
     

  86.  
  87.                                 if(filesize("$imgpath$tid-P{$sum}.gif")<100)
     

  88.  
  89.                                 unlink("$imgpath$tid-P{$sum}.gif");
     

  90.  
  91.                         }
     

  92.  
  93.                         }}
     

  94.  
  95.         }
复制代码
那个函数放成这个..就100%本地化了..