From 2b92bec1fe17dc0c690cc66df6f7d5ed64f9c60b Mon Sep 17 00:00:00 2001 From: henoheno Date: Mon, 30 Jul 2007 23:30:14 +0900 Subject: [PATCH] BugTrack2/264: Compute MD5 if needed, not everytime! (patched by ioio & ryu1) --- plugin/attach.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/attach.inc.php b/plugin/attach.inc.php index 5679b21..4e04a6c 100644 --- a/plugin/attach.inc.php +++ b/plugin/attach.inc.php @@ -449,7 +449,11 @@ class AttachFile $this->logname = $this->basename . '.log'; $this->exist = file_exists($this->filename); $this->time = $this->exist ? filemtime($this->filename) - LOCALZONE : 0; - $this->md5hash = $this->exist ? md5_file($this->filename) : ''; + } + + function gethash() + { + return $this->exist ? md5_file($this->filename) : ''; } // ¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ @@ -563,6 +567,7 @@ class AttachFile } } $info = $this->toString(TRUE, FALSE); + $hash = $this->gethash(); $retval = array('msg'=>sprintf($_attach_messages['msg_info'], htmlsc($this->file))); $retval['body'] = <<< EOD @@ -574,7 +579,7 @@ class AttachFile
$info
{$_attach_messages['msg_page']}:$s_page
{$_attach_messages['msg_filename']}:{$this->filename}
-
{$_attach_messages['msg_md5hash']}:{$this->md5hash}
+
{$_attach_messages['msg_md5hash']}:$hash
{$_attach_messages['msg_filesize']}:{$this->size_str} ({$this->size} bytes)
Content-type:{$this->type}
{$_attach_messages['msg_date']}:{$this->time_str}
-- 2.11.0