PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/api/_md5_8php_source.html

http://openbiz-cubi.googlecode.com/
HTML | 131 lines | 130 code | 0 blank | 1 comment | 0 complexity | c132ef3413ca37b8a79332052f3948cf MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>openbiz: E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Validate/File/Md5.php Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.2 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="main.html"><span>Main&#160;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  16. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  17. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. <li><a href="examples.html"><span>Examples</span></a></li>
  20. </ul>
  21. </div>
  22. <div class="tabs2">
  23. <ul class="tablist">
  24. <li><a href="files.html"><span>File&#160;List</span></a></li>
  25. </ul>
  26. </div>
  27. <div class="header">
  28. <div class="headertitle">
  29. <h1>E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Validate/File/Md5.php</h1> </div>
  30. </div>
  31. <div class="contents">
  32. <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
  33. <a name="l00025"></a>00025 require_once <span class="stringliteral">&#39;Zend/Validate/File/Hash.php&#39;</span>;
  34. <a name="l00026"></a>00026
  35. <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>
  36. <a name="l00036"></a>00036 {
  37. <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">&#39;fileMd5DoesNotMatch&#39;</span>;
  38. <a name="l00041"></a>00041 <span class="keyword">const</span> NOT_DETECTED = <span class="stringliteral">&#39;fileMd5NotDetected&#39;</span>;
  39. <a name="l00042"></a>00042 <span class="keyword">const</span> NOT_FOUND = <span class="stringliteral">&#39;fileMd5NotFound&#39;</span>;
  40. <a name="l00043"></a>00043
  41. <a name="l00047"></a>00047 <span class="keyword">protected</span> $_messageTemplates = array(
  42. <a name="l00048"></a>00048 self::DOES_NOT_MATCH =&gt; <span class="stringliteral">&quot;The file &#39;%value%&#39; does not match the given md5 hashes&quot;</span>,
  43. <a name="l00049"></a>00049 self::NOT_DETECTED =&gt; <span class="stringliteral">&quot;There was no md5 hash detected for the given file&quot;</span>,
  44. <a name="l00050"></a>00050 self::NOT_FOUND =&gt; <span class="stringliteral">&quot;The file &#39;%value%&#39; could not be found&quot;</span>
  45. <a name="l00051"></a>00051 );
  46. <a name="l00052"></a>00052
  47. <a name="l00058"></a>00058 <span class="keyword">protected</span> $_hash;
  48. <a name="l00059"></a>00059
  49. <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)
  50. <a name="l00069"></a>00069 {
  51. <a name="l00070"></a>00070 <span class="keywordflow">if</span> ($options instanceof <a class="code" href="class_zend___config.html">Zend_Config</a>) {
  52. <a name="l00071"></a>00071 $options = $options-&gt;toArray();
  53. <a name="l00072"></a>00072 } elseif (is_scalar($options)) {
  54. <a name="l00073"></a>00073 $options = array(<span class="stringliteral">&#39;hash1&#39;</span> =&gt; $options);
  55. <a name="l00074"></a>00074 } elseif (!is_array($options)) {
  56. <a name="l00075"></a>00075 require_once <span class="stringliteral">&#39;Zend/Validate/Exception.php&#39;</span>;
  57. <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">&#39;Invalid options to validator provided&#39;</span>);
  58. <a name="l00077"></a>00077 }
  59. <a name="l00078"></a>00078
  60. <a name="l00079"></a>00079 $this-&gt;<a class="code" href="class_zend___validate___file___md5.html#a838c699d63acedd05f69035892db10fd">setMd5</a>($options);
  61. <a name="l00080"></a>00080 }
  62. <a name="l00081"></a>00081
  63. <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>()
  64. <a name="l00088"></a>00088 {
  65. <a name="l00089"></a>00089 <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_zend___validate___file___hash.html#a10220afb27800deb78f48b4698a74742">getHash</a>();
  66. <a name="l00090"></a>00090 }
  67. <a name="l00091"></a>00091
  68. <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)
  69. <a name="l00100"></a>00100 {
  70. <a name="l00101"></a>00101 <span class="keywordflow">if</span> (!is_array($options)) {
  71. <a name="l00102"></a>00102 $options = (array) $options;
  72. <a name="l00103"></a>00103 }
  73. <a name="l00104"></a>00104
  74. <a name="l00105"></a>00105 $options[<span class="stringliteral">&#39;algorithm&#39;</span>] = <span class="stringliteral">&#39;md5&#39;</span>;
  75. <a name="l00106"></a>00106 <a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">parent::setHash</a>($options);
  76. <a name="l00107"></a>00107 <span class="keywordflow">return</span> $this;
  77. <a name="l00108"></a>00108 }
  78. <a name="l00109"></a>00109
  79. <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)
  80. <a name="l00117"></a>00117 {
  81. <a name="l00118"></a>00118 $this-&gt;<a class="code" href="class_zend___validate___file___md5.html#aecfcd4fe8f68562a6212602be8f185ad">setHash</a>($options);
  82. <a name="l00119"></a>00119 <span class="keywordflow">return</span> $this;
  83. <a name="l00120"></a>00120 }
  84. <a name="l00121"></a>00121
  85. <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)
  86. <a name="l00130"></a>00130 {
  87. <a name="l00131"></a>00131 <span class="keywordflow">if</span> (!is_array($options)) {
  88. <a name="l00132"></a>00132 $options = (array) $options;
  89. <a name="l00133"></a>00133 }
  90. <a name="l00134"></a>00134
  91. <a name="l00135"></a>00135 $options[<span class="stringliteral">&#39;algorithm&#39;</span>] = <span class="stringliteral">&#39;md5&#39;</span>;
  92. <a name="l00136"></a>00136 <a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">parent::addHash</a>($options);
  93. <a name="l00137"></a>00137 <span class="keywordflow">return</span> $this;
  94. <a name="l00138"></a>00138 }
  95. <a name="l00139"></a>00139
  96. <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)
  97. <a name="l00147"></a>00147 {
  98. <a name="l00148"></a>00148 $this-&gt;<a class="code" href="class_zend___validate___file___md5.html#a9d6165e21f8109e8743fa930d8fdb86a">addHash</a>($options);
  99. <a name="l00149"></a>00149 <span class="keywordflow">return</span> $this;
  100. <a name="l00150"></a>00150 }
  101. <a name="l00151"></a>00151
  102. <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)
  103. <a name="l00162"></a>00162 {
  104. <a name="l00163"></a>00163 <span class="comment">// Is file readable ?</span>
  105. <a name="l00164"></a>00164 require_once <span class="stringliteral">&#39;Zend/Loader.php&#39;</span>;
  106. <a name="l00165"></a>00165 <span class="keywordflow">if</span> (!<a class="code" href="class_zend___loader.html#a994c67ffb8518bf6228fef12b47d6934">Zend_Loader::isReadable</a>($value)) {
  107. <a name="l00166"></a>00166 <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::NOT_FOUND);
  108. <a name="l00167"></a>00167 }
  109. <a name="l00168"></a>00168
  110. <a name="l00169"></a>00169 $hashes = array_unique(array_keys($this-&gt;_hash));
  111. <a name="l00170"></a>00170 $filehash = hash_file(<span class="stringliteral">&#39;md5&#39;</span>, $value);
  112. <a name="l00171"></a>00171 <span class="keywordflow">if</span> ($filehash === <span class="keyword">false</span>) {
  113. <a name="l00172"></a>00172 <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::NOT_DETECTED);
  114. <a name="l00173"></a>00173 }
  115. <a name="l00174"></a>00174
  116. <a name="l00175"></a>00175 <span class="keywordflow">foreach</span>($hashes as $hash) {
  117. <a name="l00176"></a>00176 <span class="keywordflow">if</span> ($filehash === $hash) {
  118. <a name="l00177"></a>00177 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  119. <a name="l00178"></a>00178 }
  120. <a name="l00179"></a>00179 }
  121. <a name="l00180"></a>00180
  122. <a name="l00181"></a>00181 <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_zend___validate___file___hash.html#a02eddf80afa4a9e9e3d345d297905dc0">_throw</a>($file, self::DOES_NOT_MATCH);
  123. <a name="l00182"></a>00182 }
  124. <a name="l00183"></a>00183 }
  125. </pre></div></div>
  126. </div>
  127. <hr class="footer"/><address class="footer"><small>Generated on Thu Apr 19 2012 17:01:18 for openbiz by&#160;
  128. <a href="http://www.doxygen.org/index.html">
  129. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
  130. </body>
  131. </html>