<?php error_reporting(0); ?>
<?php header('Content-Type: application/json'); ?>
<?php include './library/PEAR/Services/JSON.php'; ?>


<?php
// https://developer.skype.com/Docs/Web

$url = 'http://mystatus.skype.com/***-INSERT-SKYPE-NAME-HERE-***.num';
$contents = file_get_contents($url);
$status = intval($contents);

$pres['skype_name'] = "***-INSERT-SKYPE-NAME-HERE-***";
$pres['name'] = "***-INSERT-NAME-HERE-***";

if ($status == 1) {
	// 1 | OFFLINE
	$pres['show'] = 'offline';
} elseif ($status == 2) {
	// 2 | ONLINE
	$pres['show'] = 'available';
} elseif ($status == 3) {
	// 3 | AWAY
	$pres['show'] = 'away';
} elseif ($status == 4) {
	// 4 | NOT AVAILABLE
	$pres['show'] = 'away';
} elseif ($status == 5) {
	// 5 | DO NOT DISTURB
	$pres['show'] = 'dnd';
} elseif ($status == 6) {
	// 6 | INVISIBLE
	$pres['show'] = 'offline';
} elseif ($status == 7) {
	// 7 | SKYPE ME
	$pres['show'] = 'chat';
}


$encoder = new Services_JSON();
$output = $encoder->encode($pres);

?>

<?php print $output; ?>
