OSDN Git Service

BugTrack2/264: Compute MD5 if needed, not everytime! (patched by ioio & ryu1)
authorhenoheno <henoheno>
Mon, 30 Jul 2007 14:30:14 +0000 (23:30 +0900)
committerumorigu <umorigu@gmail.com>
Sun, 30 Nov 2014 00:36:00 +0000 (09:36 +0900)
plugin/attach.inc.php

index 5679b21..4e04a6c 100644 (file)
@@ -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
  <dt>$info</dt>
  <dd>{$_attach_messages['msg_page']}:$s_page</dd>
  <dd>{$_attach_messages['msg_filename']}:{$this->filename}</dd>
- <dd>{$_attach_messages['msg_md5hash']}:{$this->md5hash}</dd>
+ <dd>{$_attach_messages['msg_md5hash']}:$hash</dd>
  <dd>{$_attach_messages['msg_filesize']}:{$this->size_str} ({$this->size} bytes)</dd>
  <dd>Content-type:{$this->type}</dd>
  <dd>{$_attach_messages['msg_date']}:{$this->time_str}</dd>