0) { /* We don't need the first row, it's just a header */ $status = array_slice($status, 1); /* Loop through gmirror status output. */ foreach ($status as $line) { /* Split the line by whitespace */ $all = preg_split("/[\s\t]+/", trim($line), 3); if (count($all) == 3) { /* If there are three items on a line, it is mirror name, status, and component */ $currentmirror = $all[0]; $mirrors[$currentmirror]["name"] = $all[0]; $mirrors[$currentmirror]["status"] = $all[1]; $mirrors[$currentmirror]["components"] = array(); $mirrors[$currentmirror]["components"][] = $all[2]; } elseif ((trim($line) != "") && (count($all) > 0)) { /* If there is just one item on a line, it is a component name of the previous mirror */ $mirrors[$currentmirror]["components"][] = trim($line); } } } /* Return an hash of mirrors and components */ return $mirrors; } function gmirror_html_status() { $mirrors = gmirror_get_status(); $output = ""; if (count($mirrors) > 0) { $output .= "\n"; $output .= "Name\n"; $output .= "Status\n"; $output .= "Component\n"; $output .= "\n"; foreach ($mirrors as $mirror => $name) { $components = count($name["components"]); $output .= "\n"; $output .= "{$name['name']}\n"; $output .= "{$name['status']}\n"; $output .= "{$name['components'][0]}\n"; $output .= "\n"; if (count($name["components"]) > 1) { $morecomponents = array_slice($name["components"], 1); foreach ($morecomponents as $component) { $output .= "\n"; $output .= "{$component}\n"; $output .= "\n"; } } } } else { $output .= "No Mirrors Found\n"; } // $output .= "Updated at " . date("F j, Y, g:i:s a") . "\n"; return $output; } ?>