AL8 Forum
   登錄註冊幫助


標題: [D5.5] 附件 Hashcalc 校驗碼計算
 風星
 0049132
Rank: 1

頭銜: Newbie

帖子: 5

精華: 0

積分: 90 點

現金: 0 元

存款: 160 元

閱讀權限: 10

註冊: 2006-8-2

狀態: 離線
 
發表於 2007-4-7 22:12  資料  個人空間  短消息  加為好友 
附件 Hashcalc 校驗碼計算

☆效果如附件☆

開 ./templates/default/viewthread_attachlist.htm
找到
                 <!--{if $attach['description']}-->{$attach[description]}<br><!--{/if}-->

下一行增加
                 MD5:<!--{eval echo md5_file($attach[url]."/".$attach[attachment]);}--><br>

當然,還可以加上 SHA1及CRC32
                 SHA1 :<!--{eval echo sha1_file($attach[url]."/".$attach[attachment]);}--><br>
                 CRC32:<!--{eval echo strtoupper(dechex(crc32(file_get_contents($attach[url]."/".$attach[attachment]))));}--><br>

=======================================================
將上述代碼用
<!--{if ($forum['ismoderator'] && $alloweditpost && !(in_array($post['adminid'], array(1, 2, 3)) && $adminid > $post['adminid'])) || ($forum['alloweditpost'] && $discuz_uid && $post['authorid'] == $discuz_uid)}-->


<!--{/if}-->

包起來,就成了只有發帖者及版面管理人員方能觀看該運算資訊,能稍微減少伺服器運算,不過這樣就變成上傳者利用此方法判斷是否上傳失敗而已
=======================================================
↓修改利用 attach 語法提至上層之附件亦會計算 Hashcalc 校驗碼~
Open ./include/discuzcode.func.php
Find
($attach['description'] ? $attach['description'].'<br>' : '').

After Line,Add
                                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
Rank: 2Rank: 2

頭銜: Member

帖子: 61

精華: 0

積分: 680 點

現金: 47 元

存款: 0 元

閱讀權限: 15

註冊: 2006-7-16

狀態: 離線
 
發表於 2007-4-8 12:40  資料  個人空間  短消息  加為好友 
不錯用的說....




 AL8 Forum © All rights reserved.
頂部
 風星
 0049132
Rank: 1

頭銜: Newbie

帖子: 5

精華: 0

積分: 90 點

現金: 0 元

存款: 160 元

閱讀權限: 10

註冊: 2006-8-2

狀態: 離線
 
發表於 2007-4-26 01:10  資料  個人空間  短消息  加為好友 
將 hashcalc 編碼加至資料庫,讓頁面載入速度不會因為這個東西降了下來
================================================
升級資料庫
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

$attach['price'] = $maxprice ? (intval($attachprice[$key]) <= $maxprice ? intval($attachprice[$key]) : $maxprice) : 0;

後,加入
//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

                                        $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'].'\'';

取代成
                                        $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'].'\'';


                                        $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]')");

取代成
                                        $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

                        $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]')");

取代成
                        $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

                        $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]')");

取代成
                        $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

<!--{if $attach['description']}-->{$attach[description]}<!--{/if}-->

後加入
                 MD5:<!--{$attach[md5]}--><br>
                 SHA1 :<!--{$attach[sha1]}--><br>
                 CRC32:<!--{$attach[crc32]}--><br>

開./include/discuzcode.func.php

($attach['description'] ? $attach['description'].'<br>' : '').

後加入
                                $attach[md5].'<br>'.
                                $attach[sha1].'<br>'.
                                $attach[crc32].'<br>'.

done...
附件的插件裡邊有兩個功能,一個是計算之前插件的 hashcalc 編碼(會自己分批計算^^"~)
至於另一個,我雖然有另一個可以跳頁的版本,可這樣好像又無法達成一目瞭然知道有那個附件跟上傳時不一樣XD~

[ 本帖最後由 風星 於 2007-4-26 01:20 編輯 ]



 附件: 您所在的用戶組無法下載或查看附件



 AL8 Forum © All rights reserved.
頂部
 044003
 0045908
Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6

頭銜: Forum Legend

暱稱: Jeff 044003

自述: Jeff 044003

帖子: 2928

精華: 0

積分: 24894 點

現金: 0 元

存款: 13366 元

閱讀權限: 70

註冊: 2006-5-31

來自: 香港

狀態: 離線
 
發表於 2007-4-28 09:20  資料  個人空間  短消息  加為好友  添加 044003 為MSN好友 通過MSN和 044003 交談 Yahoo!
地毯
好東西

[ 本帖最後由 044003 於 2007-4-28 09:26 編輯 ]




by Jeff@@044003 - UTF-8
 AL8 Forum © All rights reserved.
頂部
 martinfung
 0034011
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Moderator

帖子: 2689

精華: 0

積分: 26203 點

現金: 293 元

存款: 520 元

閱讀權限: 100

註冊: 2005-11-2

狀態: 離線
 
發表於 2007-4-30 21:51  資料  個人空間  短消息  加為好友 
好東西沒有人頂嗎?>




 AL8 Forum © All rights reserved.
頂部
 Eric03
 0046130
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Discuz Team

暱稱: 遲去換機 ...

帖子: 6902

精華: 0

積分: -78 點

現金: 100 元

存款: 0 元

閱讀權限: 70

註冊: 2006-6-4

狀態: 離線
 
發表於 2007-4-30 22:58  資料  個人空間  短消息  加為好友  添加 Eric03 為MSN好友 通過MSN和 Eric03 交談
可以這樣說
再頂




以上言論只是個人意見, 如有雷同, 實屬巧合, 不喜勿插
 AL8 Forum © All rights reserved.
頂部
 過兒
 0045078
Rank: 4Rank: 4Rank: 4Rank: 4

頭銜: Lord

帖子: 543

精華: 0

積分: 6130 點

現金: 40 元

存款: 1000 元

閱讀權限: 25

註冊: 2006-5-15

狀態: 離線
 
發表於 2007-4-30 23:15  資料  個人空間  短消息  加為好友 
不明有咩用..有冇人可解一解




 AL8 Forum © All rights reserved.
頂部
 笨笨小小子
 0041863
Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6Rank: 6
點擊查看 笨笨小小子 的詳細資料

頭銜: Forum Legend

自述: Newbie

帖子: 1053

精華: 0

積分: 100 點

現金: 0 元

存款: 9215 元

閱讀權限: 70

註冊: 2006-3-18

狀態: 離線
 
發表於 2007-4-30 23:43  資料  個人空間  短消息  加為好友  添加 笨笨小小子 為MSN好友 通過MSN和 笨笨小小子 交談
支持,稍後再裝




論壇已倒閉
 AL8 Forum © All rights reserved.
頂部
 zhouyu
 0046955
Rank: 1

頭銜: Newbie

帖子: 38

精華: 0

積分: 400 點

現金: 70 元

存款: 0 元

閱讀權限: 10

註冊: 2006-6-21

狀態: 離線
 
發表於 2007-8-2 16:18  資料  個人空間  短消息  加為好友 
多謝指教先
thanks




 AL8 Forum © All rights reserved.
頂部
 yori
 0055798
Rank: 3Rank: 3Rank: 3
點擊查看 yori 的詳細資料

頭銜: Conqueror

帖子: 262

精華: 0

積分: 2634 點

現金: 47 元

存款: 0 元

閱讀權限: 20

註冊: 2006-10-21

狀態: 離線
 
發表於 2007-8-2 19:38  資料  個人空間  短消息  加為好友  添加 yori 為MSN好友 通過MSN和 yori 交談
唔明有乜用...
唔裝住......




 AL8 Forum © All rights reserved.
頂部
 Fiona
 0045153
Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

頭銜: King

帖子: 865

精華: 0

積分: 11360 點

現金: 884 元

存款: 0 元

閱讀權限: 30

註冊: 2006-5-17

狀態: 離線
 
發表於 2007-8-2 21:06  資料  個人空間  短消息  加為好友 
純支持你,,太詳細




 AL8 Forum © All rights reserved.
頂部
 O不夜天O
 0049985
Rank: 4Rank: 4Rank: 4Rank: 4

頭銜: Lord

帖子: 528

精華: 0

積分: 6100 點

現金: 788 元

存款: 0 元

閱讀權限: 25

註冊: 2006-8-15

狀態: 離線
 
發表於 2007-8-2 22:51  資料  個人空間  短消息  加為好友 
唔知有物用/.




 AL8 Forum © All rights reserved.
頂部
 kyty27
 0058199
Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

頭銜: King

帖子: 989

精華: 0

積分: 80 點

現金: 7335 元

存款: 2003 元

閱讀權限: 30

註冊: 2006-11-17

來自: al8

狀態: 離線
 
發表於 2007-8-3 09:43  資料  個人空間  短消息  加為好友 
掂~
dz6.0出佐即睇睇裝唔裝到~
thx




▌▌▌▌█ 以上全部亂嗡
▌▌▌▌█ ALL ARE NOT APPROVED
 AL8 Forum © All rights reserved.
頂部
 Eric03
 0046130
Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

頭銜: Discuz Team

暱稱: 遲去換機 ...

帖子: 6902

精華: 0

積分: -78 點

現金: 100 元

存款: 0 元

閱讀權限: 70

註冊: 2006-6-4

狀態: 離線
 
發表於 2007-8-3 09:48  資料  個人空間  短消息  加為好友  添加 Eric03 為MSN好友 通過MSN和 Eric03 交談
DEL...

[ 本帖最後由 Eric03 於 2007-8-3 09:49 編輯 ]




 AL8 Forum © All rights reserved.
頂部
 你看不見我
 0061436
Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5
點擊查看 你看不見我 的詳細資料

頭銜: King

帖子: 632

精華: 0

積分: 6190 點

現金: 0 元

存款: 39 元

閱讀權限: 30

註冊: 2006-12-19

來自: 你的頭腦

狀態: 離線
 
發表於 2007-8-3 13:53  資料  個人空間  短消息  加為好友  添加 你看不見我 為MSN好友 通過MSN和 你看不見我 交談 Yahoo!
不懂作用




 AL8 Forum © All rights reserved.
頂部

聯繫我們 - AL8 Forum - 網頁空間由 I-SERVICES 提供 - Archiver - WAP
清除 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.