< ?php $file_name='http://air.ru:8000/status2.xsl'; $r=fopen($file_name,'r'); $text=fread($r,1000); fclose($r); $mass=explode(",", $text); $list=$mass [14]; $mas=explode (" ", $mass[7]); $ti=substr($mas [0],7); $day=floor($ti/86500); $he=floor(($ti-$day*86500)/3600); $mi=floor(($ti-$day*86500-$he*3600)/60); $upt="".$day." days, ".$he." hours, ".$mi." minutes."; $s=0; echo $list."n"; echo $s."n"; echo $upt."n"; echo "/all"; ?>
<?php $file_name = "http://air.ru:8000/status-json.xsl"; $mount = isset($argv[1]) ? "/" . $argv[1] : "/all"; $file_name = $mount === "/all" ? $file_name : $file_name . "?mount=" . $mount; $mass = json_decode(file_get_contents($file_name), true); $list = $peak = $ti = 0; if (isset($mass['icestats']['source']['stream_start'])) { $list = $mass['icestats']['source']['listeners']; $peak = $mass['icestats']['source']['listener_peak']; $ti = $mass['icestats']['source']['stream_start']; } else { $ti = $mass['icestats']['server_start']; if (isset($mass['icestats']['source'])) { foreach ($mass['icestats']['source'] as $source) { $list = $list + $source['listeners']; } } } $ti = time() - strtotime($ti); $day = floor($ti/86500); $he = floor(($ti-$day*86500)/3600); $mi = floor(($ti-$day*86500-$he*3600)/60); $upt = $day . " days, " . $he . " hours, " . $mi . " minutes."; echo $list . PHP_EOL . $peak . PHP_EOL . $upt . PHP_EOL . $mount; ?>
/usr/bin/php allstat.php
/usr/bin/php allstat.php radio.mp3
<?php $file_name = 'http://air.ru:8000/status2.xsl'; $r = fopen($file_name, 'r'); $text = fread($r, 1000); fclose($r); $mass = explode(",", $text); $list = $mass[9]; $mas = explode(" ", $mass[7]); $ti = substr($mas[0], 7); $day = floor($ti / 86500); $he = floor(($ti - $day * 86500) / 3600); $mi = floor(($ti - $day * 86500 - $he * 3600) / 60); $upt = $day . " days, " . $he . " hours, " . $mi . " minutes."; $s = 0; echo $list . "\n"; echo $s . "\n"; echo $upt . "\n"; echo "/all"; ?>