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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?PHP
  2. /* Poidsy 0.4 - http://chris.smith.name/projects/poidsy
  3. * Copyright (c) 2008 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.0', '>='), 'Poidsy requires PHP version 5.2.0 or greater to run');
  54. echo '<tr><th colspan="2">Associate mode requirements</th></tr>';
  55. 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');
  56. 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.');
  57. echo '<tr><th colspan="2">Diffie-Hellman key exchange requirements</th></tr>';
  58. $extensions = array(
  59. array('modules' => array('gmp', 'php_gmp'),
  60. 'extension' => 'gmp'),
  61. array('modules' => array('bcmath', 'php_bcmath'),
  62. 'extension' => 'bcmath')
  63. );
  64. $best = '';
  65. foreach ($extensions as $ext) {
  66. if ($ext['extension'] && extension_loaded($ext['extension'])) {
  67. $loaded = true;
  68. } else {
  69. foreach ($ext['modules'] as $module) {
  70. if (@dl($module . "." . PHP_SHLIB_SUFFIX)) {
  71. $loaded = true;
  72. break;
  73. }
  74. }
  75. }
  76. if ($loaded) {
  77. $best = $ext['extension'];
  78. break;
  79. }
  80. }
  81. echo '<tr><th>Bigmath support</th>';
  82. echo '<td class="', $best == 'gmp' ? 'succ' : $best == 'bcmath' ? 'warn' : 'error', '">';
  83. echo $best != '' ? $best : 'Failed';
  84. echo '</td>';
  85. if ($best == 'bcmath') {
  86. echo '<td>Your version of PHP has bcmath support, which is good enough for Poidsy to use, but is much slower than gmp.</td>';
  87. } else if ($best == '') {
  88. 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>';
  89. }
  90. echo '</tr>';
  91. ?>
  92. </table>
  93. </body>
  94. </html>