Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>ISS Spotter</title></head>
- <body>
- <?php
- /*
- Title: ISS Spotter Script
- Abstract: This PHP script is designed to track the International Space
- Station (ISS) using NASA's Spot the Station data. It fetches XML data
- from NASA's specified URL, which contains information about the ISS's
- passing times over a specific location (in this case, Remscheid, Germany).
- The script uses cURL to retrieve this data and then parses it using
- SimpleXMLElement. It extracts and formats relevant information such as
- passing date, time, duration, and maximum elevation of the ISS. The script
- then calculates the timestamp for the next ISS pass and sets up a shell
- command to trigger an external script ('iss-fader.sh') that will execute
- corresponding actions (e.g., lighting control) at the right time. This
- setup provides a user-friendly interface to display the next ISS passing
- time and other details on a web page. It's a unique way to engage with
- space through web technology.
- */
- $url = "https://spotthestation.nasa.gov/sightings/xml_files.cfm?filename=Germany_None_Remscheid.xml";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "$url");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- curl_close($ch);
- $jetzt = time();
- $iss = new SimpleXMLElement($output);
- foreach ($iss->channel->item as $flug) {
- $desc = $flug->description;
- $zeilen = explode("<br/>", $flug->description);
- $zeilen[0] = str_replace("Date: ", "", $zeilen[0]);
- $zeilen[1] = str_replace("Time: ", "", $zeilen[1]);
- $zeit = "$zeilen[0] $zeilen[1]";
- $dauer = $zeilen[2];
- $max = $zeilen[3];
- $timestamp = strtotime($zeit);
- if ($timestamp > $jetzt) {break;}
- }
- if ($timestamp < $jetzt) {echo "Kein ISS Pass in der Zukunft gefunden. <a href=\"$url\">NASA</a>"; die;}
- $dauer = preg_replace("/[^0-9]/","",$dauer);
- $dauer = $dauer * 60;
- $max = str_replace("Maximum Elevation: ", "", $max);
- $max = substr($max, 0, -3);
- // DEBUG
- //$dauer = 10;
- //$timestamp = $jetzt + $dauer;
- // DEBUG
- $output = shell_exec("nohup /bin/bash /path/to/iss-fader.sh $dauer $timestamp > /dev/null 2>&1 &");
- echo "iss-fader.sh für <b>$zeit</b> ($timestamp).<br><a href=\"$url\">Dauer $dauer s, maximale Höhe $max°</a><br><br>";
- echo "$desc<br><br>";
- //$output = shell_exec("ps aux | grep '[iss]-fader' | wc -l");
- // 2 Zeilen bedeutet, dass diese Instanz läuft UND eine andere. Abbrechen!
- //if ($output >= 1) {
- // echo '<b>Abbruch! Programm wartet bereits.</b><br>';
- $countdown = ($timestamp - $jetzt) / 60;
- $countdown = round($countdown, 1);
- echo "<br>T-$countdown min";
- $countdown = $countdown / 60;
- $countdown = round($countdown, 1);
- echo "/$countdown h";
- ob_flush();
- flush();
- sleep(1);
- $output = shell_exec("ps aux | grep '[iss]-fader'");
- echo "<pre>USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\n$output</pre>";
- // }
- ?>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement