[問題]Insert Attachment Into Post v1.0.2 (插入圖像附件到文章指定地

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
草兄弟
星球普通子民
星球普通子民
文章: 27
註冊時間: 2005-08-29 22:42

[問題]Insert Attachment Into Post v1.0.2 (插入圖像附件到文章指定地

文章 草兄弟 »

問題外掛:Insert Attachment Into Post v1.0.2 (插入圖像附件到文章指定地方)
參考連結: http://phpbb-tw.net/phpbb/viewtopic.php?t=40357
使用版本:phpBB 2.0.19 / Attachment Mod 2.4.1
網站位置:http://www.ramble.com.hk
狀況描述: 能加入圖片在文章中, 但文章底部的附件卻仍然出現\r

試著安了這個mod, 卻發現有一些問題, 安了以後不能用, 因此我改了一些地方:
#
#-----[ OPEN ]---------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------------------
#
function emoticon(text) {

#
#-----[ BEFORE, ADD ]--------------------------------------
#
function inserturl(fileName, showImg) {
var fileDotPos = fileName.lastIndexOf('.');
if (fileDotPos != -1 && fileDotPos < fileName.length) {
var fileExt = fileName.substring(fileDotPos + 1).toLowerCase();
var url = 'http:\/\/' + location.hostname + '/phpBB/files/' + fileName;
if (showImg == true) {
if (fileExt == 'jpg' || fileExt == 'jpeg' || fileExt == 'gif' || fileExt == 'png') {
url = '\[img\]' + url + '\[\/img\]';
}
}
url = url + '
';
if (document.post.message.createTextRange && document.post.message.caretPos) {
var caretPos = document.post.message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? url + ' ' : url;
} else {
document.post.message.value += url;
}
}
}
以上的一段紅色的地方要改成自己的網站的路徑!

還有:
#
#-----[ OPEN ]---------------------------------------------
#
display.php

#
#-----[ FIND ]---------------------------------------------
#
$attachments = array();

#
#-----[ AFTER, ADD ]---------------------------------------
#
$post_text = '';

#
#-----[ FIND ]---------------------------------------------
#
//

// Generate the Display Assign File Link

//

#
#-----[ BEFORE, ADD ]--------------------------------------
#
function get_post_text($message)

{
global $post_text;

$post_text = $message;

}

#
#-----[ FIND ]---------------------------------------------
# around line 485
if (!$denied)

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Hide attachments that are inserted into post

if (stristr($post_text, $filename)){

$denied = true;

}

#
#-----[ FIND ]---------------------------------------------
# around line 745
if (!$denied)

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Hide attachments that are inserted into post

if (stristr($post_text, $filename)){

$denied = true;

}
紅色的地方要改成:

代碼: 選擇全部

/*


//
// Generate the Display Assign File Link
//
藍色的地方要改成:

代碼: 選擇全部

		if (!$denied || $userdata['user_level'] == ADMIN)
而修改的檔中:

display.php >改成> attach_mod/displaying.php
posting_attachments.php >改成> attach_mod/posting_attachments.php

現在是可以把圖片放在文章裏啦, 但就有一點問題...

安了"插入附件到文章"以後, 雖然是加了圖片在文章中, 但在文章底部是重覆出現了那個檔, 現在不知道要怎麼改呢? :?:
漫步在線‧你的健康寫意生活網站

http://www.ramble.com.hk
belton2
星球普通子民
星球普通子民
文章: 14
註冊時間: 2005-11-21 15:59

文章 belton2 »

而修改的檔中:

display.php >改成> attach_mod/displaying.php
posting_attachments.php >改成> attach_mod/posting_attachments.php
我有 display.php 及 posting_attachments.php
也只有

代碼: 選擇全部

if (!$denied)
卻沒有

代碼: 選擇全部

if (!$denied || $userdata['user_level'] == ADMIN) 
我用的是 Attachment Mod v2.3.14,, 與您的是否不同的呢?
無論如何我改成: 搜尋 "if (!$denied" 便可以了
更完整的源碼是這樣子的:

代碼: 選擇全部

if (!$denied)
		{
			//
			// Some basic Template Vars
			//
			$template->assign_vars(array(
				'L_DESCRIPTION' => $lang['Description'],
				'L_DOWNLOAD' => $lang['Download'],
				'L_FILENAME' => $lang['File_name'],
				'L_FILESIZE' => $lang['Filesize'])
			);
安了"插入附件到文章"以後, 雖然是加了圖片在文章中, 但在文章底部是重覆出現了那個檔, 現在不知道要怎麼改呢?
請注意 "if (!$denied" 出現兩次的, 如果還是不成,
便需要追蹤一下 $denied 這個變數,
如果檔名出現在 post text 中, 就把 $denied 設成 true,
這樣就看不到了附件在底部
草兄弟
星球普通子民
星球普通子民
文章: 27
註冊時間: 2005-08-29 22:42

文章 草兄弟 »

謝謝你的回覆呀~ :mrgreen:

我安的是Attachment Mod 2.4.1, 我想這個已經改了一點吧~

我在displaying.php裏找, 只找到兩個 "if (!$denied"

一個是在4百多行的

代碼: 選擇全部

$denied = false;

			// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
			if (!in_array($extension, $allowed_extensions))
			{
				$denied = true;

				$template->assign_block_vars('postrow.attach.denyrow', array(
					'L_DENIED'		=> sprintf($lang['Extension_disabled_after_posting'], $extension))
				);
			} 

			if (!$denied)
			{
				// Some basic Template Vars
				$template->assign_vars(array(
					'L_DESCRIPTION'		=> $lang['Description'],
					'L_DOWNLOAD'		=> $lang['Download'],
					'L_FILENAME'		=> $lang['File_name'],
					'L_FILESIZE'		=> $lang['Filesize'])
				);
		
				// define category
				$image = FALSE;
				$stream = FALSE;
				$swf = FALSE;
				$thumbnail = FALSE;
				$link = FALSE;

另一個是在6百多行的

代碼: 選擇全部

		$denied = false;

		// Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin
		if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions))
		{
			$denied = true;

			$template->assign_block_vars('postrow.attach.denyrow', array(
				'L_DENIED'	=> sprintf($lang['Extension_disabled_after_posting'], $attachments['_' . $post_id][$i]['extension']))
			);
		} 

		if (!$denied || $userdata['user_level'] == ADMIN)
		{
			// Some basic Template Vars
			$template->assign_vars(array(
				'L_DESCRIPTION'		=> $lang['Description'],
				'L_DOWNLOAD'		=> $lang['Download'],
				'L_FILENAME'		=> $lang['File_name'],
				'L_FILESIZE'		=> $lang['Filesize'])
			);
			
			// define category
			$image = FALSE;
			$stream = FALSE;
			$swf = FALSE;
			$thumbnail = FALSE;
			$link = FALSE;
不知道要怎麼改才可以隱藏那個圖片檔呢? :-?
漫步在線‧你的健康寫意生活網站

http://www.ramble.com.hk
belton2
星球普通子民
星球普通子民
文章: 14
註冊時間: 2005-11-21 15:59

文章 belton2 »

看了更新了的源碼沒有? http://www.phpbb-tw.net/phpbb/viewtopic.php?t=40357

重點是文中出現附件的 URL 時便把 denied 設成 true, 使附件之不能顯示出來:
所以請檢查 $post_text 是否能正常取得內文, 及 denied 是否會設成 true
#
#-----[ FIND ]---------------------------------------------
# around line 745
if (!$denied

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Hide attachments that are inserted into post

if (stristr($post_text, $filename)){

$denied = true;

}
kenwood
星球普通子民
星球普通子民
文章: 1
註冊時間: 2006-06-13 17:22

文章 kenwood »

belton2 寫:看了更新了的源碼沒有? http://www.phpbb-tw.net/phpbb/viewtopic.php?t=40357

重點是文中出現附件的 URL 時便把 denied 設成 true, 使附件之不能顯示出來:
所以請檢查 $post_text 是否能正常取得內文, 及 denied 是否會設成 true
#
#-----[ FIND ]---------------------------------------------
# around line 745
if (!$denied

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Hide attachments that are inserted into post

if (stristr($post_text, $filename)){

$denied = true;

}
我的$post_text 不能取得內文, 請問有沒有方法可以解決到呢???謝謝...
註:一個php的新手...= =
飞鹰007
星球公民
星球公民
文章: 40
註冊時間: 2006-06-18 13:08
聯繫:

文章 飞鹰007 »

很久都沒有得到更新了。最新版的phpbb無法使用。
http://www.fy007.org
飞鹰007游戏插件MOD中心,致力于提供国内外优秀FPS射击类游戏相关MOD插件下载及相关技术讨论。
jimwest
星球普通子民
星球普通子民
文章: 1
註冊時間: 2006-12-11 16:33

文章 jimwest »

kenwood 寫:
belton2 寫:看了更新了的源碼沒有? http://www.phpbb-tw.net/phpbb/viewtopic.php?t=40357

重點是文中出現附件的 URL 時便把 denied 設成 true, 使附件之不能顯示出來:
所以請檢查 $post_text 是否能正常取得內文, 及 denied 是否會設成 true
#
#-----[ FIND ]---------------------------------------------
# around line 745
if (!$denied

#
#-----[ BEFORE, ADD ]--------------------------------------
#
// Hide attachments that are inserted into post

if (stristr($post_text, $filename)){

$denied = true;

}
我的$post_text 不能取得內文, 請問有沒有方法可以解決到呢???謝謝...
註:一個php的新手...= =
程式修改如下:
1.修改viewtopic.php
尋找
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
將原先之前加的
get_post_text($message); 移除掉

display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
修改為
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment'], $postrow[$i]['post_text']);

存檔

2.修改displaying.php
將原先的
$post_text = '';

function get_post_text($message)

{
global $post_text;

$post_text = $message;

}
移除掉。
尋找function display_post_attachments($post_id, $switch_attachment)

function display_post_attachments($post_id, $switch_attachment)
改為
function display_post_attachments($post_id, $switch_attachment,$post_text)
接下來在這function 下面第11行的
display_attachments($post_id);
改為
display_attachments($post_id,$post_text);

尋找
function display_attachments($post_id)

function display_attachments($post_id)
改為
function display_attachments($post_id, $post_text)

存檔。
ps:
1.修改前,請先將檔案備份。我是修改1.03版本。
2.此修改程式只針對文章的閱讀修正,發文及編修文章的預覽功能還是會看到附件,這部份恕小弟功力不夠。
3.若你是用系統管理者身份登入,還是會看到附件,如果不想看到,
請修改displaying.php
尋找
if (!$denied || $userdata['user_level'] == ADMIN)
將其改為
if (!$denied)
存檔即可。
第一次發文,多多指教!!謝謝!
ifubo
星球普通子民
星球普通子民
文章: 4
註冊時間: 2006-10-22 09:00
來自: 中国湖北

文章 ifubo »

此MOD是非常實用的一個MOD
我用的是最新的
PHPBB2.0.22和最新的attach_mod2.4.5
依照MOD提供的改法還是不能成功(原MOD的修改和參照樓上的大大的修改)
我的問題體現在
點擊插入附件到文章沒有反應

期待大大們更新此MOD
vaild
星球普通子民
星球普通子民
文章: 3
註冊時間: 2002-10-16 00:53
聯繫:

文章 vaild »

ifubo 寫:此MOD是非常實用的一個MOD
我用的是最新的
PHPBB2.0.22和最新的attach_mod2.4.5
依照MOD提供的改法還是不能成功(原MOD的修改和參照樓上的大大的修改)
我的問題體現在
點擊插入附件到文章沒有反應

期待大大們更新此MOD
總算找到那裡不對了...
#
#-----[ OPEN ]---------------------------------------------
#
templates/subSilver/posted_attachments_body.tpl

#
#-----[ FIND ]---------------------------------------------
#
<!-- BEGIN attach_row -->
<tr>
<td class="row1"><span class="gen"><b>{L_FILE_NAME}</b></span></td>
<td class="row2"><span class="gen"> <a class="gen" href="{attach_row.U_VIEW_ATTACHMENT}" target="_blank">{attach_row.FILE_NAME}</a></span>
</td>
</tr>

#
#-----[ IN-LINE FIND ]-------------------------------------
#
{attach_row.FILE_NAME}</a>

#
#-----[ AFTER, ADD ]---------------------------------------
#
&nbsp;&nbsp;&nbsp;<input type="button" onclick="inserturl('{attach_row.ATTACH_FILENAME}', true)" name="inserturlbtn" value="{L_INSERT_URL}" class="liteoption" />
把上述紅色的地方...改成
U_VIEW_ATTACHMENT
同上面藍色的字樣即可
然後....再做下述修改
#
#-----[ OPEN ]---------------------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------------------
#
function emoticon(text) {

#
#-----[ BEFORE, ADD ]--------------------------------------
#
function inserturl(fileName, showImg) {
var fileDotPos = fileName.lastIndexOf('.');
if (fileDotPos != -1 && fileDotPos < fileName.length) {
var fileExt = fileName.substring(fileDotPos + 1).toLowerCase();
var url = 'http:\/\/' + location.hostname + '/phpBB/files/' + fileName;
if (showImg == true) {
if (fileExt == 'jpg' || fileExt == 'jpeg' || fileExt == 'gif' || fileExt == 'png') {
url = '\[img\]' + url + '\[\/img\]';
}
}
url = url + '
';
if (document.post.message.createTextRange && document.post.message.caretPos) {
var caretPos = document.post.message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? url + ' ' : url;
} else {
document.post.message.value += url;
}
}
}
把紅色部份,改成只留 " / " 即可
不知為何... fileName 抓出來的檔名...
會有含 " file/ " 這個路徑...若還是不行..
請針對自己的路徑設定,做適當的修正~
vaild
星球普通子民
星球普通子民
文章: 3
註冊時間: 2002-10-16 00:53
聯繫:

文章 vaild »

另外...針對這個mod所加入的圖片...並不能直接"點選"...所以我做了一點點修改
function inserturl(fileName, showImg) {
var fileDotPos = fileName.lastIndexOf('.');
if (fileDotPos != -1 && fileDotPos < fileName.length) {
var fileExt = fileName.substring(fileDotPos + 1).toLowerCase();
if(fileName.substr(0,2)=='./')
fileName=fileName.substr(2);

var url = 'http:\/\/' + location.hostname + '/' + fileName;
if (showImg == true) {
if (fileExt == 'jpg' || fileExt == 'jpeg' || fileExt == 'gif' || fileExt == 'png') {
url = '\[url=' + url + '\]\[img\]' + url + '\[\/img\]\[\/url\]';
}
else{
url = '\[url=' + url + '\]' + url + '\[\/url\]';
}
}
url = url + ' ';
if (document.post.message.createTextRange && document.post.message.caretPos) {
var caretPos = document.post.message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? url + ' ' : url;
} else {
document.post.message.value += url;
}
}
}
上面有顏色的部份..是我有做修正的地方...
if(fileName.substr(0,2)=='./')
fileName=fileName.substr(2);

因為在修改文章時..
我的連結會變成"./Download.php?no=x"
所以多加此一判斷
然後...
{
url = '\[url=' + url + '\]\[img\]' + url + '\[\/img\]\[\/url\]';
}
else{
url = '\[url=' + url + '\]' + url + '\[\/url\]';
}
}
這邊就是判斷是否是圖片..而顯示與否而以...
很簡單的~
主題已鎖定

回到「外掛問題討論」