60 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
require '../header.php';
 | 
						|
 | 
						|
if ( isset($_REQUEST['debug']) ) {
 | 
						|
   $debug = true;
 | 
						|
} else {
 | 
						|
   $debug = false;
 | 
						|
}
 | 
						|
 | 
						|
$data = array();
 | 
						|
 | 
						|
if ( $debug ) echo "<pre>";
 | 
						|
$query = "SELECT value FROM " . SETTINGSTABLE . " WHERE parameter='CHRISTMAS'";
 | 
						|
$sth = $globaldbh->prepare($query);
 | 
						|
$sth->execute();
 | 
						|
$row = $sth->fetch();
 | 
						|
$data['christmas'] = ($row['value'] == 'true') ? true : false;
 | 
						|
 | 
						|
$query = "SELECT value FROM " . SETTINGSTABLE . " WHERE parameter='CHRISTMASFREQ'";
 | 
						|
$sth = $globaldbh->prepare($query);
 | 
						|
$sth->execute();
 | 
						|
$row = $sth->fetch();
 | 
						|
$data['christmasfreq'] = $row['value'];
 | 
						|
 | 
						|
$query = "SELECT songid FROM " . RECENTSTABLE . " ORDER BY timeplayed DESC limit 15";
 | 
						|
$sth = $globaldbh->prepare($query);
 | 
						|
$sth->execute();
 | 
						|
$data['volume'] = getSystemVolume();
 | 
						|
system("HOME=" . WEBUSERHOMEDIR . " && ../scripts/homeaudio_togglemute.pl -show", $retval);
 | 
						|
$data['muted'] = ($retval == 0) ? false : true;
 | 
						|
$data['currentsong'] = array("art"=>"", "title"=>"", "artist"=>"", "album"=>"", "year"=>"");
 | 
						|
$data['songhistory'] = array();
 | 
						|
if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
 | 
						|
   $song = new Song($row['songid']);
 | 
						|
   $data['currentsong']["id"] = $song->getID();
 | 
						|
   $data['currentsong']["arturl"] = $song->getArtFile(ARTURL);
 | 
						|
   $data['currentsong']["title"] = $song->getTitle(HTMLSAFE);
 | 
						|
   $data['currentsong']["artist"] = $song->getArtist(HTMLSAFE);
 | 
						|
   $data['currentsong']["album"] = $song->getAlbum(HTMLSAFE);
 | 
						|
   $data['currentsong']["year"] = $song->getYear(HTMLSAFE);
 | 
						|
}
 | 
						|
while ( $row = $sth->fetch() ) {
 | 
						|
   $song = new Song($row['songid']);
 | 
						|
   $curdata = array();
 | 
						|
   $curdata["id"] = $song->getID();
 | 
						|
   $curdata["arturl"] = $song->getArtFile(ARTURL);
 | 
						|
   $curdata["title"] = $song->getTitle(HTMLSAFE);
 | 
						|
   $curdata["artist"] = $song->getArtist(HTMLSAFE);
 | 
						|
   $curdata["album"] = $song->getAlbum(HTMLSAFE);
 | 
						|
   $curdata["year"] = $song->getYear(HTMLSAFE);
 | 
						|
   $data['songhistory'][] = $curdata;
 | 
						|
}
 | 
						|
 | 
						|
header('Content-Type: application/json');
 | 
						|
echo json_encode($data);
 | 
						|
exit();
 | 
						|
 | 
						|
// vim: set ts=3 sw=3 ai:
 |