sanitycheck.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. require_once 'telemetry_settings.php';
  3. require_once 'telemetry_db.php';
  4. require_once '../backend/getIP_util.php';
  5. error_reporting(E_ALL);
  6. $pass="<span class='Pass'>Pass</span>";
  7. $failed="<span class='Failed'>failed</span>";
  8. $na="<span class='na'>N/A</span>";
  9. ?>
  10. <html>
  11. <head>
  12. <title>Speed Test installation sanity check</title>
  13. <style>
  14. table,th,td { border: 1px solid;}
  15. .Pass { color:green;}
  16. .Failed { color:red;}
  17. .na { color:orange;}
  18. .SectionHeading { font-style: italic;}
  19. </style>
  20. </head>
  21. <body>
  22. <table><tr><th>Item</th><th>Status</th><th>Comment</th></tr>
  23. <tr><td colspan="3" class='SectionHeading'>PHP extensions</td></tr>
  24. <tr><td>gd</td><td>
  25. <?php
  26. if(extension_loaded('gd')){
  27. echo $pass;
  28. } else {
  29. echo $failed;
  30. }
  31. ?>
  32. </td><td>Used to render result images.</td></tr>
  33. <tr><td>openssl</td><td>
  34. <?php
  35. if(extension_loaded('openssl')){
  36. echo $pass;
  37. } else {
  38. echo $failed;
  39. }
  40. ?>
  41. </td><td></td></tr>
  42. <tr><td>pdo_sqlsrv</td><td>
  43. <?php
  44. if(!isset($db_type) || $db_type != 'mssql'){
  45. echo $na;
  46. }elseif(extension_loaded('pdo_sqlsrv')){
  47. echo $pass;
  48. } else {
  49. echo $failed;
  50. }
  51. ?>
  52. </td><td>Only required if using MS SQL.</td></tr>
  53. <tr><td>pdo_mysql</td><td>
  54. <?php
  55. if(!isset($db_type) || $db_type != 'mysql'){
  56. echo $na;
  57. }elseif(extension_loaded('pdo_mysql')){
  58. echo $pass;
  59. } else {
  60. echo $failed;
  61. }
  62. ?>
  63. </td><td>Only required if using mysql.</td></tr>
  64. <tr><td>pdo_sqlite</td><td>
  65. <?php
  66. if(!isset($db_type) || $db_type != 'sqlite'){
  67. echo $na;
  68. }elseif(extension_loaded('pdo_sqlite')){
  69. echo $pass;
  70. } else {
  71. echo $failed;
  72. }
  73. ?>
  74. </td><td>Only required if using sqlite.</td></tr>
  75. <tr><td>pdo_pgsql</td><td>
  76. <?php
  77. if(!isset($db_type) || $db_type != 'postgresql'){
  78. echo $na;
  79. }elseif(extension_loaded('pdo_pgsql')){
  80. echo $pass;
  81. } else {
  82. echo $failed;
  83. }
  84. ?>
  85. </td><td>Only required if using postgresql.</td></tr>
  86. <tr><td colspan="3" class='SectionHeading'>Database check</td></tr>
  87. <tr><td>Connecting to DB</td><td>
  88. <?php
  89. $pdo = getPdo(true);
  90. if (($pdo instanceof PDO)) {
  91. echo $pass;
  92. echo "</td><td></td>";
  93. } else {
  94. echo $failed;
  95. echo "</td><td>". htmlspecialchars($pdo) . "</td>";
  96. }
  97. ?>
  98. </tr>
  99. <tr><td>Insert into DB</td><td>
  100. <?php
  101. $ip = getClientIp();
  102. $ispinfo="";
  103. $extra='{"DBTest":"This is a simple test of the database. No speed test was done."}';
  104. $ua = $_SERVER['HTTP_USER_AGENT'];
  105. $lang = '';
  106. if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  107. $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  108. }
  109. $dl=$ul=$ping=$jitter="";
  110. $log="";
  111. $insertResult = insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log, true);
  112. if(($insertResult instanceof Exception)){
  113. echo $failed;
  114. echo "</td><td>";
  115. echo htmlspecialchars($insertResult->getMessage()) . "</td>";
  116. } else {
  117. echo $pass;
  118. echo "</td><td></td>";
  119. }
  120. ?>
  121. </tr>
  122. <tr><td>Read from DB</td><td>
  123. <?php
  124. if(!($insertResult instanceof Exception)){
  125. $QueryResult = getSpeedtestUserById($insertResult,true);
  126. if(($QueryResult instanceof Exception)){
  127. echo $failed;
  128. echo "</td><td>";
  129. echo htmlspecialchars($insertResult->getMessage()) . "</td>";
  130. } elseif(!is_array($QueryResult)) {
  131. echo $failed;
  132. echo "</td><td>Test result not retrieved from database.</td>";
  133. } else {
  134. echo $pass;
  135. echo "</td><td></td>";
  136. }
  137. } else {
  138. echo "</td><td>Insert failed so can't test reading inserted data</td>";
  139. }
  140. ?>
  141. </tr>
  142. </table>
  143. </body>
  144. </html>
  145. <?php
  146. /*
  147. $speedtests = getLatestSpeedtestUsers();
  148. print_r ($speedtests);
  149. echo ' ';
  150. print_r($pdo);
  151. if(!isset($pdo)){
  152. echo 'got nothing';
  153. }
  154. if($pdo == false){
  155. echo 'got a false';
  156. }
  157. if (!($pdo instanceof PDO)) {
  158. echo 'not a PDO';
  159. }
  160. if (($pdo instanceof PDO)) {
  161. echo 'is PDO';
  162. }
  163. $speedtest = getSpeedtestUserById(1);
  164. print_r ($speedtest);
  165. */
  166. ?>