Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $jsonTable = json_decode($_GET['jsonTable']);
- $columns = (int)$jsonTable[0];
- $timePattern = '/^\s*Reply\s+from\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*\: bytes=\d{1,4}\s+time=\s*(\d+)\s*ms\s+TTL=\d{1,4}\s*$/';
- $message = '';
- for ($i = 1; $i < count($jsonTable[1]); $i++) {
- $ping = $jsonTable[1][$i];
- preg_match($timePattern, $ping, $matches);
- $milliseconds = (int)$matches[1];
- $message .= chr($milliseconds);
- }
- $words = explode('*', $message);
- $style = "style='background:#CAF'";
- echo '<table border=\'1\' cellpadding=\'5\'>';
- foreach ($words as $word) {
- $rows = ceil(strlen($word) / $columns);
- $charCounter = 0;
- for ($i = 0; $i < $rows; $i++) {
- echo '<tr>';
- for ($col = 0; $col < $columns; $col++) {
- if ($charCounter < strlen($word) && $word[$charCounter] != ' ') {
- echo "<td {$style}>" . htmlspecialchars($word[$charCounter]) . '</td>';
- } else {
- echo '<td></td>';
- }
- $charCounter++;
- }
- echo '</tr>';
- }
- }
- echo '</table>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement