PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/elgg/mod/simplepie/sp_compatibility_test.php

https://bitbucket.org/rhizomatik/lorea_production/
PHP | 277 lines | 223 code | 39 blank | 15 comment | 25 complexity | 37fbc90ae343ca42982a8ccae687f394 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. // this is a quick hack of the compatibility script included with simple pie
  3. // Load Elgg engine
  4. require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
  5. $php_ok = (function_exists('version_compare') && version_compare(phpversion(), '4.3.0', '>='));
  6. $xml_ok = extension_loaded('xml');
  7. $pcre_ok = extension_loaded('pcre');
  8. $curl_ok = function_exists('curl_exec');
  9. $zlib_ok = extension_loaded('zlib');
  10. $mbstring_ok = extension_loaded('mbstring');
  11. $iconv_ok = extension_loaded('iconv');
  12. ob_start();
  13. ?>
  14. <style type="text/css">
  15. body {
  16. }
  17. #site {
  18. width:550px;
  19. margin:20px auto 0 auto;
  20. font:14px/1.4em "Lucida Grande", Verdana, Arial, Helvetica, Clean, Sans, sans-serif;
  21. letter-spacing:0px;
  22. color:#333;
  23. margin:0;
  24. padding:0;
  25. }
  26. #site a {
  27. color:#000;
  28. text-decoration:underline;
  29. padding:0 1px;
  30. }
  31. #site a:hover {
  32. color:#fff;
  33. background-color:#333;
  34. text-decoration:none;
  35. padding:0 1px;
  36. }
  37. #site p {
  38. margin:0;
  39. padding:5px 0;
  40. }
  41. #site em {
  42. font-style:normal;
  43. background-color:#ffc;
  44. }
  45. #site ul, ol {
  46. margin:10px 0 10px 20px;
  47. padding:0 0 0 15px;
  48. }
  49. #site ul li, ol li {
  50. margin:0 0 7px 0;
  51. padding:0 0 0 3px;
  52. }
  53. #site h2 {
  54. font-size:18px;
  55. padding:0;
  56. margin:30px 0 10px 0;
  57. }
  58. #site h3 {
  59. font-size:16px;
  60. padding:0;
  61. margin:20px 0 5px 0;
  62. }
  63. #site h4 {
  64. font-size:14px;
  65. padding:0;
  66. margin:15px 0 5px 0;
  67. }
  68. #site code {
  69. font-size:1.1em;
  70. background-color:#f3f3ff;
  71. color:#000;
  72. }
  73. #site em strong {
  74. text-transform: uppercase;
  75. }
  76. table#chart {
  77. border-collapse:collapse;
  78. }
  79. table#chart th {
  80. background-color:#eee;
  81. padding:2px 3px;
  82. border:1px solid #fff;
  83. }
  84. table#chart td {
  85. text-align:center;
  86. padding:2px 3px;
  87. border:1px solid #eee;
  88. }
  89. table#chart tr.enabled td {
  90. /* Leave this alone */
  91. }
  92. table#chart tr.disabled td,
  93. table#chart tr.disabled td a {
  94. color:#999;
  95. font-style:italic;
  96. }
  97. table#chart tr.disabled td a {
  98. text-decoration:underline;
  99. }
  100. .chunk {
  101. margin:20px 0 0 0;
  102. padding:0 0 10px 0;
  103. border-bottom:1px solid #ccc;
  104. }
  105. .footnote,
  106. .footnote a {
  107. font:10px/12px verdana, sans-serif;
  108. color:#aaa;
  109. }
  110. .footnote em {
  111. background-color:transparent;
  112. font-style:italic;
  113. }
  114. </style>
  115. <div class="contentWrapper" style="margin:0;">
  116. <div id="elggreturn">
  117. <a href="javascript:history.go(-1)">Return to Tools Administration</a>
  118. </div>
  119. <div id="site">
  120. <div id="content">
  121. <div class="chunk">
  122. <h2 style="text-align:center;">SimplePie Compatibility Test</h2>
  123. <table cellpadding="0" cellspacing="0" border="0" width="100%" id="chart">
  124. <thead>
  125. <tr>
  126. <th>Test</th>
  127. <th>Should Be</th>
  128. <th>What You Have</th>
  129. </tr>
  130. </thead>
  131. <tbody>
  132. <tr class="<?php echo ($php_ok) ? 'enabled' : 'disabled'; ?>">
  133. <td>PHP&sup1;</td>
  134. <td>4.3.0 or higher</td>
  135. <td><?php echo phpversion(); ?></td>
  136. </tr>
  137. <tr class="<?php echo ($xml_ok) ? 'enabled' : 'disabled'; ?>">
  138. <td><a href="http://php.net/xml">XML</a></td>
  139. <td>Enabled</td>
  140. <td><?php echo ($xml_ok) ? 'Enabled' : 'Disabled'; ?></td>
  141. </tr>
  142. <tr class="<?php echo ($pcre_ok) ? 'enabled' : 'disabled'; ?>">
  143. <td><a href="http://php.net/pcre">PCRE</a>&sup2;</td>
  144. <td>Enabled</td>
  145. <td><?php echo ($pcre_ok) ? 'Enabled' : 'Disabled'; ?></td>
  146. </tr>
  147. <tr class="<?php echo ($curl_ok) ? 'enabled' : 'disabled'; ?>">
  148. <td><a href="http://php.net/curl">cURL</a></td>
  149. <td>Enabled</td>
  150. <td><?php echo (extension_loaded('curl')) ? 'Enabled' : 'Disabled'; ?></td>
  151. </tr>
  152. <tr class="<?php echo ($zlib_ok) ? 'enabled' : 'disabled'; ?>">
  153. <td><a href="http://php.net/zlib">Zlib</a></td>
  154. <td>Enabled</td>
  155. <td><?php echo ($zlib_ok) ? 'Enabled' : 'Disabled'; ?></td>
  156. </tr>
  157. <tr class="<?php echo ($mbstring_ok) ? 'enabled' : 'disabled'; ?>">
  158. <td><a href="http://php.net/mbstring">mbstring</a></td>
  159. <td>Enabled</td>
  160. <td><?php echo ($mbstring_ok) ? 'Enabled' : 'Disabled'; ?></td>
  161. </tr>
  162. <tr class="<?php echo ($iconv_ok) ? 'enabled' : 'disabled'; ?>">
  163. <td><a href="http://php.net/iconv">iconv</a></td>
  164. <td>Enabled</td>
  165. <td><?php echo ($iconv_ok) ? 'Enabled' : 'Disabled'; ?></td>
  166. </tr>
  167. </tbody>
  168. </table>
  169. </div>
  170. <div class="chunk">
  171. <h3>What does this mean?</h3>
  172. <ol>
  173. <?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok && $curl_ok && $zlib_ok): ?>
  174. <li><em>You have everything you need to run SimplePie properly! Congratulations!</em></li>
  175. <?php else: ?>
  176. <?php if ($php_ok): ?>
  177. <li><strong>PHP:</strong> You are running a supported version of PHP. <em>No problems here.</em></li>
  178. <?php if ($xml_ok): ?>
  179. <li><strong>XML:</strong> You have XML support installed. <em>No problems here.</em></li>
  180. <?php if ($pcre_ok): ?>
  181. <li><strong>PCRE:</strong> You have PCRE support installed. <em>No problems here.</em></li>
  182. <?php if ($curl_ok): ?>
  183. <li><strong>cURL:</strong> You have <code>cURL</code> support installed. <em>No problems here.</em></li>
  184. <?php else: ?>
  185. <li><strong>cURL:</strong> The <code>cURL</code> extension is not available. SimplePie will use <code>fsockopen()</code> instead.</li>
  186. <?php endif; ?>
  187. <?php if ($zlib_ok): ?>
  188. <li><strong>Zlib:</strong> You have <code>Zlib</code> enabled. This allows SimplePie to support GZIP-encoded feeds. <em>No problems here.</em></li>
  189. <?php else: ?>
  190. <li><strong>Zlib:</strong> The <code>Zlib</code> extension is not available. SimplePie will ignore any GZIP-encoding, and instead handle feeds as uncompressed text.</li>
  191. <?php endif; ?>
  192. <?php if ($mbstring_ok && $iconv_ok): ?>
  193. <li><strong>mbstring and iconv:</strong> You have both <code>mbstring</code> and <code>iconv</code> installed! This will allow SimplePie to handle the greatest number of languages. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
  194. <?php elseif ($mbstring_ok): ?>
  195. <li><strong>mbstring:</strong> <code>mbstring</code> is installed, but <code>iconv</code> is not. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
  196. <?php elseif ($iconv_ok): ?>
  197. <li><strong>iconv:</strong> <code>iconv</code> is installed, but <code>mbstring</code> is not. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
  198. <?php else: ?>
  199. <li><strong>mbstring and iconv:</strong> <em>You do not have either of the extensions installed.</em> This will significantly impair your ability to read non-English feeds, as well as even some English ones. Check the <a href="http://simplepie.org/wiki/faq/supported_character_encodings">Supported Character Encodings</a> chart to see what's supported on your webhost.</li>
  200. <?php endif; ?>
  201. <?php else: ?>
  202. <li><strong>PCRE:</strong> Your PHP installation doesn't support Perl-Compatible Regular Expressions. <em>SimplePie is a no-go at the moment.</em></li>
  203. <?php endif; ?>
  204. <?php else: ?>
  205. <li><strong>XML:</strong> Your PHP installation doesn't support XML parsing. <em>SimplePie is a no-go at the moment.</em></li>
  206. <?php endif; ?>
  207. <?php else: ?>
  208. <li><strong>PHP:</strong> You are running an unsupported version of PHP. <em>SimplePie is a no-go at the moment.</em></li>
  209. <?php endif; ?>
  210. <?php endif; ?>
  211. </ol>
  212. </div>
  213. <div class="chunk">
  214. <?php if ($php_ok && $xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok) { ?>
  215. <h3>Bottom Line: Yes, you can!</h3>
  216. <p><em>Your webhost has its act together!</em></p>
  217. <p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
  218. <?php } else if ($php_ok && $xml_ok && $pcre_ok) { ?>
  219. <h3>Bottom Line: Yes, you can!</h3>
  220. <p><em>For most feeds, it'll run with no problems.</em> There are <a href="http://simplepie.org/wiki/faq/supported_character_encodings">certain languages</a> that you might have a hard time with though.</p>
  221. <p class="footnote"><em><strong>Note</strong></em>: Passing this test does not guarantee that SimplePie will run on your webhost &mdash; it only ensures that the basic requirements have been addressed.</p>
  222. <?php } else { ?>
  223. <h3>Bottom Line: We're sorry…</h3>
  224. <p><em>Your webhost does not support the minimum requirements for SimplePie.</em> It may be a good idea to contact your webhost, and ask them to install a more recent version of PHP as well as the <code>xml</code>, <code>mbstring</code>, <code>iconv</code>, <code>curl</code>, and <code>zlib</code> extensions.</p>
  225. <?php } ?>
  226. </div>
  227. <div class="chunk">
  228. <p class="footnote">&sup1; &mdash; SimplePie 2 will not support PHP 4.x. The core PHP team has discontinued PHP 4.x patches and support. <a href="http://simplepie.org/blog/2007/07/13/simplepie-is-going-php5-only/">Read the announcement.</a></p>
  229. <p class="footnote">&sup2; &mdash; Some recent versions of the PCRE (PERL-Compatible Regular Expression) engine compiled into PHP have been buggy, and are the source of PHP segmentation faults (e.g. crashes) which cause random things like blank, white screens. Check the <a href="http://simplepie.org/support/">Support Forums</a> for the latest information on patches and ongoing fixes.</p>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. <?php
  235. $content = ob_get_clean();
  236. $body = elgg_view_layout('one_column', $content);
  237. echo page_draw(null, $body);
  238. ?>