rendered paste body<?php function calc_time($time) { $hour = floor($time/3600); $min = floor(($time % 3600)/60); $sec = $time % 60; return (strlen($hour) < 2 ? "0$hour" : "$hour") .":". (strlen($min) < 2 ? "0$min" : "$min") .":". (strlen($sec) < 2 ? "0$sec" : "$sec"); } $con = fsockopen("capsaicin", 6600, $errno, $errstr, 3); if(!$con) { echo("Server down"); exit(); } $line = fgets($con); fputs($con, "currentsong\n"); while($line != "OK\n") { $line = fgets($con); if(substr($line, 0, 5) == "Title") $title = substr($line, 6); } fputs($con, "status\n"); $line = ""; while($line != "OK\n") { $line = fgets($con); if(substr($line, 0, 4) == "time") sscanf($line, "time: %d:%d\n", $pos, $time); } fclose($con); echo($title); echo("<span id=\"mp3time\">("); # Calculate time echo calc_time($pos); echo " / "; echo calc_time($time); echo(")</span>");?>