PHP OpenID consumer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?PHP
  2. /* Poidsy 0.6 - http://chris.smith.name/projects/poidsy
  3. * Copyright (c) 2008-2010 Chris Smith
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. // This file tests to see if your environment is compatible with Poidsy.
  24. ?>
  25. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  26. "http://www.w3.org/TR/html4/strict.dtd">
  27. <html>
  28. <head>
  29. <title>Poidsy compatibility test</title>
  30. <style type="text/css">
  31. table { border-collapse: collapse; }
  32. td, th { border: 1px solid #000; padding: 10px; }
  33. td.error { text-align: center; color: #fff; background-color: #c00; }
  34. td.succ { text-align: center; color: #fff; background-color: #0c0; }
  35. td.warn { text-align: center; color: #fff; background-color: #c70; }
  36. td { max-width: 400px; }
  37. code { font-size: small; }
  38. </style>
  39. </head>
  40. <body>
  41. <h1>Poidsy compatibility test</h1>
  42. <table>
  43. <?PHP
  44. function doTest($name, $result, $failinfo) {
  45. echo '<tr><th>', htmlentities($name), '</th>';
  46. echo '<td class="', $result ? 'succ' : 'error', '">';
  47. echo $result ? 'Passed' : 'Failed';
  48. echo '</td>';
  49. if (!$result) { echo '<td>', $failinfo, '</td>'; }
  50. echo '</tr>';
  51. }
  52. echo '<tr><th colspan="2">Poidsy requirements</th></tr>';
  53. doTest('PHP Version', version_compare(PHP_VERSION, '5.2.10', '>='), 'Poidsy requires PHP version 5.2.10 or greater to run');
  54. doTest('Allow_url_fopen', ini_get('allow_url_fopen'), 'Poidsy requires allow_url_fopen to be configured to true');
  55. echo '<tr><th colspan="2">Associate mode requirements</th></tr>';
  56. doTest('hash_hmac function', function_exists('hash_hmac'), 'Poidsy requires the hash_hmac function to use associate mode. It should be available in PHP 5.2.0 or greater, unless you\'ve explicitly disabled it when compiling PHP');
  57. doTest('Keycache writable', is_writable(dirname(__FILE__) . '/keycache.php'), 'Poidsy requires write access to the keycache.php file in its directory. Without it, Poidsy will be unable to use associate mode.');
  58. echo '<tr><th colspan="2">Diffie-Hellman key exchange requirements</th></tr>';
  59. $extensions = array(
  60. array('modules' => array('gmp', 'php_gmp'),
  61. 'extension' => 'gmp'),
  62. array('modules' => array('bcmath', 'php_bcmath'),
  63. 'extension' => 'bcmath')
  64. );
  65. $best = '';
  66. foreach ($extensions as $ext) {
  67. if ($ext['extension'] && extension_loaded($ext['extension'])) {
  68. $loaded = true;
  69. } elseif (function_exists('dl')) {
  70. foreach ($ext['modules'] as $module) {
  71. if (@dl($module . "." . PHP_SHLIB_SUFFIX)) {
  72. $loaded = true;
  73. break;
  74. }
  75. }
  76. }
  77. if ($loaded) {
  78. $best = $ext['extension'];
  79. break;
  80. }
  81. }
  82. echo '<tr><th>Bigmath support</th>';
  83. echo '<td class="', $best == 'gmp' ? 'succ' : ($best == 'bcmath' ? 'warn' : 'error'), '">';
  84. echo $best != '' ? $best : 'Failed';
  85. echo '</td>';
  86. if ($best == 'bcmath') {
  87. echo '<td>Your version of PHP has bcmath support, which is good enough for Poidsy to use, but is much slower than gmp.</td>';
  88. } else if ($best == '') {
  89. echo '<td>Your version of PHP doesn\'t have support for either gmp (preferred) or bcmath. Poidsy needs one of these libraries to perform D-H key exchange.</td>';
  90. }
  91. echo '</tr>';
  92. ?>
  93. </table>
  94. </body>
  95. </html>