Revision | 2b92bec1fe17dc0c690cc66df6f7d5ed64f9c60b (tree) |
---|---|
Time | 2014-11-30 09:36:00 |
Author | henoheno <henoheno> |
Commiter | umorigu |
BugTrack2/264: Compute MD5 if needed, not everytime! (patched by ioio & ryu1)
@@ -449,7 +449,11 @@ class AttachFile | ||
449 | 449 | $this->logname = $this->basename . '.log'; |
450 | 450 | $this->exist = file_exists($this->filename); |
451 | 451 | $this->time = $this->exist ? filemtime($this->filename) - LOCALZONE : 0; |
452 | - $this->md5hash = $this->exist ? md5_file($this->filename) : ''; | |
452 | + } | |
453 | + | |
454 | + function gethash() | |
455 | + { | |
456 | + return $this->exist ? md5_file($this->filename) : ''; | |
453 | 457 | } |
454 | 458 | |
455 | 459 | // ファイル情報取得 |
@@ -563,6 +567,7 @@ class AttachFile | ||
563 | 567 | } |
564 | 568 | } |
565 | 569 | $info = $this->toString(TRUE, FALSE); |
570 | + $hash = $this->gethash(); | |
566 | 571 | |
567 | 572 | $retval = array('msg'=>sprintf($_attach_messages['msg_info'], htmlsc($this->file))); |
568 | 573 | $retval['body'] = <<< EOD |
@@ -574,7 +579,7 @@ class AttachFile | ||
574 | 579 | <dt>$info</dt> |
575 | 580 | <dd>{$_attach_messages['msg_page']}:$s_page</dd> |
576 | 581 | <dd>{$_attach_messages['msg_filename']}:{$this->filename}</dd> |
577 | - <dd>{$_attach_messages['msg_md5hash']}:{$this->md5hash}</dd> | |
582 | + <dd>{$_attach_messages['msg_md5hash']}:$hash</dd> | |
578 | 583 | <dd>{$_attach_messages['msg_filesize']}:{$this->size_str} ({$this->size} bytes)</dd> |
579 | 584 | <dd>Content-type:{$this->type}</dd> |
580 | 585 | <dd>{$_attach_messages['msg_date']}:{$this->time_str}</dd> |