/docs/api/_md5_8php_source.html
HTML | 131 lines | 130 code | 0 blank | 1 comment | 0 complexity | c132ef3413ca37b8a79332052f3948cf MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <title>openbiz: E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Validate/File/Md5.php Source File</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <link href="doxygen.css" rel="stylesheet" type="text/css"/>
- </head>
- <body>
- <!-- Generated by Doxygen 1.7.2 -->
- <div class="navigation" id="top">
- <div class="tabs">
- <ul class="tablist">
- <li><a href="main.html"><span>Main Page</span></a></li>
- <li><a href="pages.html"><span>Related Pages</span></a></li>
- <li><a href="namespaces.html"><span>Namespaces</span></a></li>
- <li><a href="annotated.html"><span>Data Structures</span></a></li>
- <li class="current"><a href="files.html"><span>Files</span></a></li>
- <li><a href="examples.html"><span>Examples</span></a></li>
- </ul>
- </div>
- <div class="tabs2">
- <ul class="tablist">
- <li><a href="files.html"><span>File List</span></a></li>
- </ul>
- </div>
- <div class="header">
- <div class="headertitle">
- <h1>E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Validate/File/Md5.php</h1> </div>
- </div>
- <div class="contents">
- <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <?php
- <a name="l00025"></a>00025 require_once <span class="stringliteral">'Zend/Validate/File/Hash.php'</span>;
- <a name="l00026"></a>00026
- <a name="l00035"></a><a class="code" href="class_zend___validate___file___md5.html">00035</a> <span class="keyword">class </span><a class="code" href="class_zend___validate___file___md5.html">Zend_Validate_File_Md5</a> <span class="keyword">extends</span> <a class="code" href="class_zend___validate___file___hash.html">Zend_Validate_File_Hash</a>
- <a name="l00036"></a>00036 {
- <a name="l00040"></a><a class="code" href="class_zend___validate___file___md5.html#a0e9755eea7ef4ea25cd96ff8ced4d734">00040</a> <span class="keyword">const</span> <a class="code" href="class_zend___validate___file___md5.html#a0e9755eea7ef4ea25cd96ff8ced4d734">DOES_NOT_MATCH</a> = <span class="stringliteral">'fileMd5DoesNotMatch'</span>;
- <a name="l00041"></a>00041 <span class="keyword">const</span> NOT_DETECTED = <span class="stringliteral">'fileMd5NotDetected'</span>;
- <a name="l00042"></a>00042 <span class="keyword">const</span> NOT_FOUND = <span class="stringliteral">'fileMd5NotFound'</span>;
- <a name="l00043"></a>00043
- <a name="l00047"></a>00047 <span class="keyword">protected</span> $_messageTemplates = array(
- <a name="l00048"></a>00048 self::DOES_NOT_MATCH => <span class="stringliteral">"The file '%value%' does not match the given md5 hashes"</span>,
- <a name="l00049"></a>00049 self::NOT_DETECTED => <span class="stringliteral">"There was no md5 hash detected for the given file"</span>,
- <a name="l00050"></a>00050 self::NOT_FOUND => <span class="stringliteral">"The file '%value%' could not be found"</span>
- <a name="l00051"></a>00051 );
- <a name="l00052"></a>00052
- <a name="l00058"></a>00058 <span class="keyword">protected</span> $_hash;
- <a name="l00059"></a>00059
- <a name="l00068"></a><a class="code" href="class_zend___validate___file___md5.html#ae8b8e1144b807ac13f20a916fd073b32">00068</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#ae8b8e1144b807ac13f20a916fd073b32">__construct</a>($options)
- <a name="l00069"></a>00069 {
- <a name="l00070"></a>00070 <span class="keywordflow">if</span> ($options instanceof <a class="code" href="class_zend___config.html">Zend_Config</a>) {
- <a name="l00071"></a>00071 $options = $options->toArray();
- <a name="l00072"></a>00072 } elseif (is_scalar($options)) {
- <a name="l00073"></a>00073 $options = array(<span class="stringliteral">'hash1'</span> => $options);
- <a name="l00074"></a>00074 } elseif (!is_array($options)) {
- <a name="l00075"></a>00075 require_once <span class="stringliteral">'Zend/Validate/Exception.php'</span>;
- <a name="l00076"></a>00076 <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="class_zend___validate___exception.html">Zend_Validate_Exception</a>(<span class="stringliteral">'Invalid options to validator provided'</span>);
- <a name="l00077"></a>00077 }
- <a name="l00078"></a>00078
- <a name="l00079"></a>00079 $this-><a class="code" href="class_zend___validate___file___md5.html#a838c699d63acedd05f69035892db10fd">setMd5</a>($options);
- <a name="l00080"></a>00080 }
- <a name="l00081"></a>00081
- <a name="l00087"></a><a class="code" href="class_zend___validate___file___md5.html#a8ffe7cebad881b26dc1bb014dea34d4b">00087</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#a8ffe7cebad881b26dc1bb014dea34d4b">getMd5</a>()
- <a name="l00088"></a>00088 {
- <a name="l00089"></a>00089 <span class="keywordflow">return</span> $this-><a class="code" href="class_zend___validate___file___hash.html#a10220afb27800deb78f48b4698a74742">getHash</a>();
- <a name="l00090"></a>00090 }
- <a name="l00091"></a>00091
- <a name="l00099"></a><a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">00099</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">setHash</a>($options)
- <a name="l00100"></a>00100 {
- <a name="l00101"></a>00101 <span class="keywordflow">if</span> (!is_array($options)) {
- <a name="l00102"></a>00102 $options = (array) $options;
- <a name="l00103"></a>00103 }
- <a name="l00104"></a>00104
- <a name="l00105"></a>00105 $options[<span class="stringliteral">'algorithm'</span>] = <span class="stringliteral">'md5'</span>;
- <a name="l00106"></a>00106 <a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">parent::setHash</a>($options);
- <a name="l00107"></a>00107 <span class="keywordflow">return</span> $this;
- <a name="l00108"></a>00108 }
- <a name="l00109"></a>00109
- <a name="l00116"></a><a class="code" href="class_zend___validate___file___md5.html#a838c699d63acedd05f69035892db10fd">00116</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#a838c699d63acedd05f69035892db10fd">setMd5</a>($options)
- <a name="l00117"></a>00117 {
- <a name="l00118"></a>00118 $this-><a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">setHash</a>($options);
- <a name="l00119"></a>00119 <span class="keywordflow">return</span> $this;
- <a name="l00120"></a>00120 }
- <a name="l00121"></a>00121
- <a name="l00129"></a><a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">00129</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">addHash</a>($options)
- <a name="l00130"></a>00130 {
- <a name="l00131"></a>00131 <span class="keywordflow">if</span> (!is_array($options)) {
- <a name="l00132"></a>00132 $options = (array) $options;
- <a name="l00133"></a>00133 }
- <a name="l00134"></a>00134
- <a name="l00135"></a>00135 $options[<span class="stringliteral">'algorithm'</span>] = <span class="stringliteral">'md5'</span>;
- <a name="l00136"></a>00136 <a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">parent::addHash</a>($options);
- <a name="l00137"></a>00137 <span class="keywordflow">return</span> $this;
- <a name="l00138"></a>00138 }
- <a name="l00139"></a>00139
- <a name="l00146"></a><a class="code" href="class_zend___validate___file___md5.html#addb853ff803761b2c0bb04759046d2a4">00146</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#addb853ff803761b2c0bb04759046d2a4">addMd5</a>($options)
- <a name="l00147"></a>00147 {
- <a name="l00148"></a>00148 $this-><a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">addHash</a>($options);
- <a name="l00149"></a>00149 <span class="keywordflow">return</span> $this;
- <a name="l00150"></a>00150 }
- <a name="l00151"></a>00151
- <a name="l00161"></a><a class="code" href="class_zend___validate___file___md5.html#a4c64e22c3400b190836ceb80b2fdf41a">00161</a> <span class="keyword">public</span> function <a class="code" href="class_zend___validate___file___md5.html#a4c64e22c3400b190836ceb80b2fdf41a">isValid</a>($value, $file = null)
- <a name="l00162"></a>00162 {
- <a name="l00163"></a>00163 <span class="comment">// Is file readable ?</span>
- <a name="l00164"></a>00164 require_once <span class="stringliteral">'Zend/Loader.php'</span>;
- <a name="l00165"></a>00165 <span class="keywordflow">if</span> (!<a class="code" href="class_zend___loader.html#a994c67ffb8518bf6228fef12b47d6934">Zend_Loader::isReadable</a>($value)) {
- <a name="l00166"></a>00166 <span class="keywordflow">return</span> $this-><a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::NOT_FOUND);
- <a name="l00167"></a>00167 }
- <a name="l00168"></a>00168
- <a name="l00169"></a>00169 $hashes = array_unique(array_keys($this->_hash));
- <a name="l00170"></a>00170 $filehash = hash_file(<span class="stringliteral">'md5'</span>, $value);
- <a name="l00171"></a>00171 <span class="keywordflow">if</span> ($filehash === <span class="keyword">false</span>) {
- <a name="l00172"></a>00172 <span class="keywordflow">return</span> $this-><a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::NOT_DETECTED);
- <a name="l00173"></a>00173 }
- <a name="l00174"></a>00174
- <a name="l00175"></a>00175 <span class="keywordflow">foreach</span>($hashes as $hash) {
- <a name="l00176"></a>00176 <span class="keywordflow">if</span> ($filehash === $hash) {
- <a name="l00177"></a>00177 <span class="keywordflow">return</span> <span class="keyword">true</span>;
- <a name="l00178"></a>00178 }
- <a name="l00179"></a>00179 }
- <a name="l00180"></a>00180
- <a name="l00181"></a>00181 <span class="keywordflow">return</span> $this-><a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::DOES_NOT_MATCH);
- <a name="l00182"></a>00182 }
- <a name="l00183"></a>00183 }
- </pre></div></div>
- </div>
- <hr class="footer"/><address class="footer"><small>Generated on Thu Apr 19 2012 17:01:18 for openbiz by 
- <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
- </body>
- </html>