tohtml.php (5169B)
1 #!/usr/bin/php 2 <!DOCTYPE html> 3 <html> 4 <head> 5 <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> 6 <title>XMPP Compliance Suite 2016: Server Test Results</title> 7 <meta name="twitter:card" content="summary_large_image"> 8 <meta name="twitter:creator" content="@iNPUTmice"> 9 <meta property="og:image" content="https://conversations.im/compliance/cover.png"> 10 <meta property="og:title" content="XMPP Compliance Suite - Server Results"> 11 <meta property="og:url" content="https://conversations.im/compliance/"> 12 <meta property="og:description" content="Pick and choose your Jabber server from a list of compatible servers or check if your current server supports all required features."> 13 <meta property="og:locale" content="en_US"> 14 <meta charset="UTF-8"> 15 <style type="text/css"> 16 body { 17 color: rgba(0,0,0,0.87); 18 font-family: 'Roboto', sans-serif; 19 font-weight: 400; 20 font-size: 13pt; 21 background-color: #fafafa; 22 } 23 table tbody tr td { 24 white-space: nowrap; 25 } 26 table tbody tr td.passed { 27 background-color: #43a047; 28 } 29 table tbody tr td.failed { 30 background-color: #e53935; 31 } 32 table tbody tr td.missing { 33 background-color: #757575; 34 } 35 table tr:hover td.passed { 36 background-color: #2e7d32; 37 } 38 table tr:hover td.failed { 39 background-color: #c62828; 40 } 41 table tr:hover td.missing { 42 background-color: #424242; 43 } 44 table tr:hover td { 45 background-color: #e0e0e0; 46 } 47 a { 48 color: #3f51b5; 49 } 50 p.small { 51 font-size: 10pt; 52 } 53 div.banner { 54 margin-left: auto; 55 margin-right: auto; 56 margin-bottom: 12pt; 57 padding-left: 10pt; 58 padding-right: 11pt; 59 width: 60%; 60 min-width: 640px; 61 max-width: 1024px; 62 border-width: 1px; 63 border-style: solid; 64 border-color: rgba(0,0,0,0.12); 65 } 66 .banner p { 67 color: rgba(0,0,0,0.54); 68 font-size: 11pt; 69 } 70 </style> 71 </head> 72 <body> 73 <?php 74 function count_frequency($needle, $reports) { 75 $count = 0; 76 foreach($reports as $report) { 77 foreach($report as $key => $value) { 78 if ($key === $needle && $value == "PASSED") { 79 $count++; 80 } 81 } 82 } 83 return $count; 84 } 85 function comp_header($a, $b) { 86 $reports = $GLOBALS["reports"]; 87 $count_a = count_frequency($a, $reports); 88 $count_b = count_frequency($b, $reports); 89 if ($count_a == $count_b) { 90 return 0; 91 } 92 return ($count_a > $count_b) ? -1 : 1; 93 } 94 function comp_report($a, $b) { 95 $count_a = calc_score($a); 96 $count_b = calc_score($b); 97 if ($count_a == $count_b) { 98 return 0; 99 } 100 return ($count_a > $count_b) ? -1 : 1; 101 } 102 function calc_score($report) { 103 $headers = $GLOBALS["headers"]; 104 $score = 0; 105 $i = 1; 106 foreach($headers as $key) { 107 if (array_key_exists($key,$report) && 'PASSED' === $report[$key]) { 108 $score += pow(2,$i); 109 } 110 $i++; 111 } 112 return $score; 113 } 114 $reports = json_decode(file_get_contents('complete.json'),true); 115 $headers = array(); 116 foreach($reports as &$report) { 117 $h = array_keys($report); 118 if (count($h) > count($headers)) { 119 $headers = $h; 120 } 121 } 122 if (count($argv) >= 2 && $argv[1] === 'ranked') { 123 usort($headers, "comp_header"); 124 uasort($reports, "comp_report"); 125 } 126 ?> 127 <div class="banner"> 128 <p><strong>Advertisement</strong><br>Are you looking for an XMPP server that is very well maintained, always has the latest features and is running in a German data center? 129 <br>Are you willing to spend a little money for a reliable service? Have a look at <a href="https://account.conversations.im">conversations.im</a>. Your first six month are free. No cancellation required.</p> 130 <p>We are also offering <a href="https://account.conversations.im/domain">Jabber/XMPP domain hosting</a> if you want to bring your own domain.</p> 131 </div> 132 <table> 133 <thead> 134 <tr> 135 <th></th> 136 <?php 137 foreach($headers as &$head) { 138 echo "<th>".htmlentities($head); 139 if (strpos($head,'OMEMO') !== false) { 140 echo ' <sup><a href="https://github.com/iNPUTmice/ComplianceTester/blob/master/src/main/java/eu/siacs/compliance/tests/OMEMO.java#L12-L17">?</a></sup>'; 141 } 142 echo "</th>"; 143 } 144 ?> 145 </tr> 146 </thead> 147 <tbody> 148 <?php 149 foreach($reports as $server => $report) { 150 echo '<tr>'; 151 echo '<td>'.htmlentities($server).'</td>'; 152 foreach($headers as $c) { 153 if (!array_key_exists($c, $report)) { 154 $class = 'missing'; 155 } else if ('PASSED' === $report[$c]) { 156 $class = 'passed'; 157 } else { 158 $class = 'failed'; 159 } 160 echo '<td class="'.$class.'"></td>'; 161 } 162 echo '</tr>'; 163 } 164 ?> 165 </tbody> 166 </table> 167 <p class="small">Copyright 2016 <a href="https://gultsch.de">Daniel Gultsch</a> · Data gathered with <a href="https://github.com/iNPUTmice/ComplianceTester">XMPP Compliance Tester</a> · Last update <?= date("Y-m-d")?> (actual data might be older)</p> 168 </body> 169 </html>