AL8 Forum
»
Discuz 5.0 及 5.5 插件發佈
» 附件 Hashcalc 校驗碼計算
‹‹ 上一主題
|
下一主題 ››
標題:
[D5.5]
附件 Hashcalc 校驗碼計算
打印
|
推薦
|
訂閱
|
收藏
風星
0049132
頭銜: Newbie
帖子: 5
精華: 0
積分: 90 點
現金: 0 元
存款: 160 元
閱讀權限: 10
註冊: 2006-8-2
狀態: 離線
#1
大
中
小
發表於 2007-4-7 22:12
資料
個人空間
短消息
加為好友
附件 Hashcalc 校驗碼計算
☆效果如附件☆
開 ./templates/default/viewthread_attachlist.htm
找到
[Copy to clipboard]
[
-
]
CODE:
<!--{if $attach['description']}-->{$attach[description]}<br><!--{/if}-->
下一行增加
[Copy to clipboard]
[
-
]
CODE:
MD5:<!--{eval echo md5_file($attach[url]."/".$attach[attachment]);}--><br>
當然,還可以加上 SHA1及CRC32
[Copy to clipboard]
[
-
]
CODE:
SHA1 :<!--{eval echo sha1_file($attach[url]."/".$attach[attachment]);}--><br>
CRC32:<!--{eval echo strtoupper(dechex(crc32(file_get_contents($attach[url]."/".$attach[attachment]))));}--><br>
=======================================================
將上述代碼用
[Copy to clipboard]
[
-
]
CODE:
<!--{if ($forum['ismoderator'] && $alloweditpost && !(in_array($post['adminid'], array(1, 2, 3)) && $adminid > $post['adminid'])) || ($forum['alloweditpost'] && $discuz_uid && $post['authorid'] == $discuz_uid)}-->
及
[Copy to clipboard]
[
-
]
CODE:
<!--{/if}-->
包起來,就成了只有發帖者及版面管理人員方能觀看該運算資訊,能稍微減少伺服器運算,不過這樣就變成上傳者利用此方法判斷是否上傳失敗而已
=======================================================
↓修改利用 attach 語法提至上層之附件亦會計算 Hashcalc 校驗碼~
Open ./include/discuzcode.func.php
Find
[Copy to clipboard]
[
-
]
CODE:
($attach['description'] ? $attach['description'].'<br>' : '').
After Line,Add
[Copy to clipboard]
[
-
]
CODE:
md5_file($attach['url']."/".$attach['attachment']).'<br>'.
(當然,在這邊同樣可以加 SAH1 及 CRC32)
★此套件在附件檔越大越多時運算越多,速度就越慢~~★
QUOTE:
想說很多功能都有人作了,就來作個『與眾不同』的XD
可以讓你上傳檔案後用本機的 WinMD5 判斷是否在上傳過程中 Lose ,下載時也可以這樣判斷,雖然 WinRAR 本身就有用 CRC 作驗證了(所以說與眾不同不如說沒人會去作XD~)
其實要節省伺服器運算也是可以,在上傳時就將這些資訊寫入資料庫,這樣下次只要讀資料庫的值就行,不用重覆幫那個驗算
而且還可以讓他作運算判斷實際檔案跟資料庫紀錄的是否有不同,驗證是否有被人變更過~XD~不過這就變麻煩了,嘖~
資料庫版本在 #3
[
本帖最後由 風星 於 2007-4-26 09:02 編輯
]
附件:
您所在的用戶組無法下載或查看附件
AL8 Forum © All rights reserved.
harrypk
0048118
頭銜: Member
帖子: 61
精華: 0
積分: 680 點
現金: 47 元
存款: 0 元
閱讀權限: 15
註冊: 2006-7-16
狀態: 離線
#2
大
中
小
發表於 2007-4-8 12:40
資料
個人空間
短消息
加為好友
不錯用的說....
AL8 Forum © All rights reserved.
風星
0049132
頭銜: Newbie
帖子: 5
精華: 0
積分: 90 點
現金: 0 元
存款: 160 元
閱讀權限: 10
註冊: 2006-8-2
狀態: 離線
#3
大
中
小
發表於 2007-4-26 01:10
資料
個人空間
短消息
加為好友
將 hashcalc 編碼加至資料庫,讓頁面載入速度不會因為這個東西降了下來
================================================
升級資料庫
[Copy to clipboard]
[
-
]
CODE:
ALTER TABLE `cdb_attachments` ADD `md5` VARCHAR( 32 ) NOT NULL ;
ALTER TABLE `cdb_attachments` ADD `sha1` VARCHAR( 40 ) NOT NULL ;
ALTER TABLE `cdb_attachments` ADD `crc32` VARCHAR( 8 ) NOT NULL ;
開 ./include/post.func.php
找
[Copy to clipboard]
[
-
]
CODE:
$attach['price'] = $maxprice ? (intval($attachprice[$key]) <= $maxprice ? intval($attachprice[$key]) : $maxprice) : 0;
後,加入
[Copy to clipboard]
[
-
]
CODE:
//Hashcalc Code
$attach['md5'] = md5_file($target);
$attach['sha1'] = sha1_file($target);
$attach['crc32'] = strtoupper(dechex(crc32(file_get_contents($target))));
//Hashcalc Code
開 ./include/editpost.inc.php
找
[Copy to clipboard]
[
-
]
CODE:
$attachfileadd = ', dateline=\''.$timestamp.'\',
filename=\''.$uattachments[$paid]['name'].'\',
filetype=\''.$uattachments[$paid]['type'].'\',
filesize=\''.$uattachments[$paid]['size'].'\',
attachment=\''.$uattachments[$paid]['attachment'].'\',
thumb=\''.$uattachments[$paid]['thumb'].'\',
isimage=\''.$uattachments[$paid]['isimage'].'\',
remote=\''.$uattachments[$paid]['remote'].'\'';
取代成
[Copy to clipboard]
[
-
]
CODE:
$attachfileadd = ', dateline=\''.$timestamp.'\',
filename=\''.$uattachments[$paid]['name'].'\',
filetype=\''.$uattachments[$paid]['type'].'\',
filesize=\''.$uattachments[$paid]['size'].'\',
attachment=\''.$uattachments[$paid]['attachment'].'\',
thumb=\''.$uattachments[$paid]['thumb'].'\',
isimage=\''.$uattachments[$paid]['isimage'].'\',
remote=\''.$uattachments[$paid]['remote'].'\',
md5=\''.$uattachments[$paid]['md5'].'\',
sha1=\''.$uattachments[$paid]['sha1'].'\',
crc32=\''.$uattachments[$paid]['crc32'].'\'';
找
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
取代成
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, md5, sha1, crc32)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]', '$attach[md5]', '$attach[sha1]', '$attach[crc32]')");
開./include/newthread.inc.php
找
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
取代成
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, md5, sha1, crc32)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]', '$attach[md5]', '$attach[sha1]', '$attach[crc32]')");
開./include/newreply.inc.php
找
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
取代成
[Copy to clipboard]
[
-
]
CODE:
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, md5, sha1, crc32)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]', '$attach[md5]', '$attach[sha1]', '$attach[crc32]')");
開./templates/default/viewthread_attachlist.htm
找
[Copy to clipboard]
[
-
]
CODE:
<!--{if $attach['description']}-->{$attach[description]}<!--{/if}-->
後加入
[Copy to clipboard]
[
-
]
CODE:
MD5:<!--{$attach[md5]}--><br>
SHA1 :<!--{$attach[sha1]}--><br>
CRC32:<!--{$attach[crc32]}--><br>
開./include/discuzcode.func.php
找
[Copy to clipboard]
[
-
]
CODE:
($attach['description'] ? $attach['description'].'<br>' : '').
後加入
[Copy to clipboard]
[
-
]
CODE:
$attach[md5].'<br>'.
$attach[sha1].'<br>'.
$attach[crc32].'<br>'.
done...
附件的插件裡邊有兩個功能,一個是計算之前插件的 hashcalc 編碼(會自己分批計算^^"~)
至於另一個,我雖然有另一個可以跳頁的版本,可這樣好像又無法達成一目瞭然知道有那個附件跟上傳時不一樣XD~
[
本帖最後由 風星 於 2007-4-26 01:20 編輯
]
附件:
您所在的用戶組無法下載或查看附件
AL8 Forum © All rights reserved.
044003
0045908
頭銜: Forum Legend
暱稱: Jeff 044003
自述: Jeff 044003
帖子: 2928
精華: 0
積分: 24894 點
現金: 0 元
存款: 13366 元
閱讀權限: 70
註冊: 2006-5-31
來自: 香港
狀態: 離線
#4
大
中
小
發表於 2007-4-28 09:20
資料
個人空間
短消息
加為好友
地毯
好東西
[
本帖最後由 044003 於 2007-4-28 09:26 編輯
]
by Jeff@@044003 - UTF-8
AL8 Forum © All rights reserved.
martinfung
0034011
頭銜: Moderator
帖子: 2689
精華: 0
積分: 26203 點
現金: 293 元
存款: 520 元
閱讀權限: 100
註冊: 2005-11-2
狀態: 離線
#5
大
中
小
發表於 2007-4-30 21:51
資料
個人空間
短消息
加為好友
好東西沒有人頂嗎?>
AL8 Forum © All rights reserved.
Eric03
0046130
頭銜: Discuz Team
暱稱: 遲去換機 ...
帖子: 6902
精華: 0
積分: -78 點
現金: 100 元
存款: 0 元
閱讀權限: 70
註冊: 2006-6-4
狀態: 離線
#6
大
中
小
發表於 2007-4-30 22:58
資料
個人空間
短消息
加為好友
可以這樣說
再頂
以上言論只是個人意見, 如有雷同, 實屬巧合, 不喜勿插
AL8 Forum © All rights reserved.
過兒
0045078
頭銜: Lord
帖子: 543
精華: 0
積分: 6130 點
現金: 40 元
存款: 1000 元
閱讀權限: 25
註冊: 2006-5-15
狀態: 離線
#7
大
中
小
發表於 2007-4-30 23:15
資料
個人空間
短消息
加為好友
不明有咩用..有冇人可解一解
AL8 Forum © All rights reserved.
笨笨小小子
0041863
頭銜: Forum Legend
自述: Newbie
帖子: 1053
精華: 0
積分: 100 點
現金: 0 元
存款: 9215 元
閱讀權限: 70
註冊: 2006-3-18
狀態: 離線
#8
大
中
小
發表於 2007-4-30 23:43
資料
個人空間
短消息
加為好友
支持,稍後再裝
論壇已倒閉
AL8 Forum © All rights reserved.
zhouyu
0046955
頭銜: Newbie
帖子: 38
精華: 0
積分: 400 點
現金: 70 元
存款: 0 元
閱讀權限: 10
註冊: 2006-6-21
狀態: 離線
#9
大
中
小
發表於 2007-8-2 16:18
資料
個人空間
短消息
加為好友
多謝指教先
thanks
AL8 Forum © All rights reserved.
yori
0055798
頭銜: Conqueror
帖子: 262
精華: 0
積分: 2634 點
現金: 47 元
存款: 0 元
閱讀權限: 20
註冊: 2006-10-21
狀態: 離線
#10
大
中
小
發表於 2007-8-2 19:38
資料
個人空間
短消息
加為好友
唔明有乜用...
唔裝住......
AL8 Forum © All rights reserved.
Fiona
0045153
頭銜: King
帖子: 865
精華: 0
積分: 11360 點
現金: 884 元
存款: 0 元
閱讀權限: 30
註冊: 2006-5-17
狀態: 離線
#11
大
中
小
發表於 2007-8-2 21:06
資料
個人空間
短消息
加為好友
純支持你,,太詳細
AL8 Forum © All rights reserved.
O不夜天O
0049985
頭銜: Lord
帖子: 528
精華: 0
積分: 6100 點
現金: 788 元
存款: 0 元
閱讀權限: 25
註冊: 2006-8-15
狀態: 離線
#12
大
中
小
發表於 2007-8-2 22:51
資料
個人空間
短消息
加為好友
唔知有物用/.
AL8 Forum © All rights reserved.
kyty27
0058199
頭銜: King
帖子: 989
精華: 0
積分: 80 點
現金: 7335 元
存款: 2003 元
閱讀權限: 30
註冊: 2006-11-17
來自: al8
狀態: 離線
#13
大
中
小
發表於 2007-8-3 09:43
資料
個人空間
短消息
加為好友
掂~
dz6.0出佐即睇睇裝唔裝到~
thx
▌▌▌▌█ 以上全部亂嗡
▌▌▌▌█ ALL ARE NOT APPROVED
AL8 Forum © All rights reserved.
Eric03
0046130
頭銜: Discuz Team
暱稱: 遲去換機 ...
帖子: 6902
精華: 0
積分: -78 點
現金: 100 元
存款: 0 元
閱讀權限: 70
註冊: 2006-6-4
狀態: 離線
#14
大
中
小
發表於 2007-8-3 09:48
資料
個人空間
短消息
加為好友
DEL...
[
本帖最後由 Eric03 於 2007-8-3 09:49 編輯
]
AL8 Forum © All rights reserved.
你看不見我
0061436
頭銜: King
帖子: 632
精華: 0
積分: 6190 點
現金: 0 元
存款: 39 元
閱讀權限: 30
註冊: 2006-12-19
來自: 你的頭腦
狀態: 離線
#15
大
中
小
發表於 2007-8-3 13:53
資料
個人空間
短消息
加為好友
不懂作用
AL8 Forum © All rights reserved.
聯繫我們
-
AL8 Forum
- 網頁空間由
I-SERVICES
提供 -
Archiver
-
WAP
界面風格
----------
默認風格
Air
Leobbs
Christmas
清除 Cookies
, 當前時區 GMT+8, 現在時間是 2008-11-21 02:33
Processed in 0.036240 second(s), 7 queries , Gzip enabled
Powered by
Discuz!
5.5.0
© 2001-2007
Comsenz Inc.