[软件发布] 远程调用URL地址附件 FOR DZ6.1

发帖子的时候就能看到,还是发个演示图吧:


1、attachment.php

找到
  1. dheader('location:'.$ftp['attachurl'].'/'.$attach['attachment']);
复制代码
替换为
  1.         
  2.         $attach['attachment'] = !preg_match('/^(https?|ftp):\/\//', $attach['attachment']) ? $ftp['attachurl'].'/'.$attach['attachment'] : $attach['attachment'];
  3.         dheader('location:'.$attach['attachment']);
复制代码
再找
  1. function getremotefile($file) {
  2. global $authkey, $ftp, $attachdir;
  3. @set_time_limit(0);
复制代码
在下面加入
  1.         
  2.         $file = !preg_match('/^(https?|ftp):\/\//', $file) ? $ftp['attachurl'].'/'.$file : $file;
复制代码
2、include/editpost.inc.php

找到
  1. // debug: update thread caches ?
复制代码
在上面加入
  1.         
  2.         if(is_array($ftpattachurl)) {
  3.                 $urlexists = FALSE;
  4.                 foreach($ftpattachurl as $key => $url) {
  5.                         if($url) {
  6.                                 $urlexists = TRUE;
  7.                                 $name = basename($url);
  8.                                 $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
  9.                                         VALUES ('$tid', '$pid', '$timestamp', '$ftpattachperm[$key]', '$ftpattachprice[$key]', '$name', '$ftpattachdesc[$key]', '', '0', '$url', '0', '0', '$discuz_uid', '0', '1')");
  10.                         }
  11.                 }
  12.                 if($urlexists) {
  13.                         $db->query("UPDATE {$tablepre}posts SET attachment='1' WHERE pid='$pid'", 'UNBUFFERED');
  14.                         $db->query("UPDATE {$tablepre}threads SET attachment='1' WHERE tid='$tid'", 'UNBUFFERED');
  15.                 }
  16.         }
复制代码
3、include/newreply.inc.php

找到
  1. updatecredits($discuz_uid, $postattachcredits, count($attachments));
  2. }
复制代码
在下面加入
  1.         
  2.         if(is_array($ftpattachurl)) {
  3.                 $urlexists = FALSE;
  4.                 foreach($ftpattachurl as $key => $url) {
  5.                         if($url) {
  6.                                 $urlexists = TRUE;
  7.                                 $name = basename($url);
  8.                                 $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
  9.                                         VALUES ('$tid', '$pid', '$timestamp', '$ftpattachperm[$key]', '$ftpattachprice[$key]', '$name', '$ftpattachdesc[$key]', '', '0', '$url', '0', '0', '$discuz_uid', '0', '1')");
  10.                         }
  11.                 }
  12.                 if($urlexists) {
  13.                         $db->query("UPDATE {$tablepre}posts SET attachment='1' WHERE pid='$pid'", 'UNBUFFERED');
  14.                         $db->query("UPDATE {$tablepre}threads SET attachment='1' WHERE tid='$tid'", 'UNBUFFERED');
  15.                 }
  16.         }
复制代码
4、include/newthread.inc.php

找到
  1. updatecredits($discuz_uid, $postattachcredits, count($attachments));
  2. }
复制代码
在下面加入
  1.         
  2.         if(is_array($ftpattachurl)) {
  3.                 $urlexists = FALSE;
  4.                 foreach($ftpattachurl as $key => $url) {
  5.                         if($url) {
  6.                                 $urlexists = TRUE;
  7.                                 $name = basename($url);
  8.                                 $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
  9.                                         VALUES ('$tid', '$pid', '$timestamp', '$ftpattachperm[$key]', '$ftpattachprice[$key]', '$name', '$ftpattachdesc[$key]', '', '0', '$url', '0', '0', '$discuz_uid', '0', '1')");
  10.                         }
  11.                 }
  12.                 if($urlexists) {
  13.                         $db->query("UPDATE {$tablepre}posts SET attachment='1' WHERE pid='$pid'", 'UNBUFFERED');
  14.                         $db->query("UPDATE {$tablepre}threads SET attachment='1' WHERE tid='$tid'", 'UNBUFFERED');
  15.                 }
  16.         }
复制代码
5、模板目录中的post_editor.htm

找到
  1. <th>{lang attachment_new}</th>
复制代码
在下面加入
  1. <td>URL</td>
复制代码
找到
  1.                                         <th>
  2.                                                 <input type="file" name="attach[]" />
  3.                                                 <span id="localfile[]"></span>
  4.                                                 <input type="hidden" name="localid[]" />
  5.                                         </th>
复制代码
在下面加入
  1. <td class="nums"><input type="text" name="ftpattachurl[]"  /></td>
复制代码
附件: 您需要登录才可以下载或查看附件。没有帐号?加入社区
--------------------------------------------------
◎中忆技术联盟◎    http://bbs.zyeo.net
QQ技术群
一:3605386  二:3406860  三:30188651
解卡手册地址 http://zyeo.net/sim/help