summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-26 00:51:36 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-26 00:51:36 +0000
commit30405b6c9930c5dd23c5ed30bc2276780a46ecbb (patch)
treeceec5f17237c710e6da3c348abcc22d30b06deee /templates
parent491eab55d8c581b42bcd0625cb137b6a53911259 (diff)
downloadampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.tar.gz
ampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.tar.bz2
ampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.zip
start of browse by x mojo
Diffstat (limited to 'templates')
-rw-r--r--templates/menu.inc9
-rw-r--r--templates/show_all_popular.inc.php42
2 files changed, 47 insertions, 4 deletions
diff --git a/templates/menu.inc b/templates/menu.inc
index a6047ba5..2ae05faf 100644
--- a/templates/menu.inc
+++ b/templates/menu.inc
@@ -32,10 +32,11 @@ if ($GLOBALS['user']->prefs['play_type'] == 'mpd' && conf('localplay_menu')) {
$items += array(_("Local Play") => htmlspecialchars(conf('web_path') . "/mpd.php"));
}
-$items += array(_("Albums") => htmlspecialchars(conf('web_path') . "/albums.php"),
- _("Artists") => htmlspecialchars(conf('web_path') . "/artists.php"),
- _("Playlists") => htmlspecialchars(conf('web_path') . "/playlist.php"),
- _("Search") => htmlspecialchars(conf('web_path') . "/search.php"),
+$items += array(_("Browse") => htmlspecialchars(conf('web_path') . "/browse.php"),
+ _("Albums") => htmlspecialchars(conf('web_path') . "/albums.php"),
+ _("Artists") => htmlspecialchars(conf('web_path') . "/artists.php"),
+ _("Playlists") => htmlspecialchars(conf('web_path') . "/playlist.php"),
+ _("Search") => htmlspecialchars(conf('web_path') . "/search.php"),
_("Preferences") => htmlspecialchars(conf('web_path') . "/preferences.php")
);
if ($GLOBALS['user']->prefs['upload']) {
diff --git a/templates/show_all_popular.inc.php b/templates/show_all_popular.inc.php
new file mode 100644
index 00000000..1c472949
--- /dev/null
+++ b/templates/show_all_popular.inc.php
@@ -0,0 +1,42 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+?>
+<table class="tabledata">
+<tr>
+ <td valign="top" align="right">
+ <?php show_info_box(_("Most Popular Artists"), 'artist', $artists); ?>
+ </td>
+ <td valign="top" align="left">
+ <?php show_info_box(_("Most Popular Songs"), 'song', $songs); ?>
+ </td>
+ <td valign="top" align="right">
+ <?php show_info_box(_("Most Popular Albums"), '', $albums); ?>
+ </td>
+</tr>
+<tr><td colspan="3">&nbsp;</td></tr>
+<tr>
+ <td valign="top" align="left">
+ <?php show_info_box(_("Most Popular Genres"), '', $genres); ?>
+ </td>
+</tr>
+</table>
href='#n268'>268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
<?php
/*

 Copyright (c) 2001 - 2005 Ampache.org
 All rights reserved.  

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 

*/

/*!
	@header Stream Class
*/

class Stream {

	/* Variables from DB */
	var $type;
	var $web_path;
	var $songs = array();
	var $sess;

	/*!
		@function stream 
		@discussion constructor for the stream class
	*/
	function Stream($type='m3u', $song_ids=0) {

		$this->type = $type;
		$this->songs = $song_ids;
		$this->web_path = conf('web_path');
		
		if (conf('force_http_play')) { 
			$port = conf('http_port');
			$this->web_path = preg_replace("/https/", "http",$this->web_path);
			$this->web_path = preg_replace("/:\d+/",":$port",$this->web_path);
		}
		
		$this->sess = session_id();
		$this->user_id = $_SESSION['userdata']['id'];

	} //constructor

	/*!
		@function start
		@discussion runs this and depending on the type passed it will
			call the correct function
	*/
	function start() {

		$methods = get_class_methods('Stream');
		$create_function = "create_" . $this->type;	
                if (in_array($create_function,$methods)) {
	                $this->{$create_function}();
                }
		// Assume M3u incase they've pooched the type
		else { 
			$this->create_m3u();
		}

	} // start

	/*!
		@function create_simplem3u
		@discussion this creates a simple m3u
			without any of the extended information
	*/
	function create_simple_m3u() {

		header("Cache-control: public");
		header("Content-Disposition: filename=playlist.m3u");
		header("Content-Type: audio/x-mpegurl;");
		foreach ($this->songs as $song_id) { 
			$song = new Song($song_id);
			if ($song->type == ".flac") { $song->type = ".ogg"; }
                        if($GLOBALS['user']->prefs['play_type'] == 'downsample') {
                                $ds = $GLOBALS['user']->prefs['sample_rate'];
                        }
			echo "$this->web_path/play/index.php?song=$song_id&uid=$this->user_id&sid=$this->sess&ds=$ds&stupidwinamp=." . $song->type . "\n"; 
		} // end foreach

	} // simple_m3u

	/*!
		@function create_m3u
		@discussion creates an m3u file
	*/
	function create_m3u() { 

	        // Send the client an m3u playlist
	        header("Cache-control: public");
	        header("Content-Disposition: filename=playlist.m3u");
	        header("Content-Type: audio/x-mpegurl;");
	        echo "#EXTM3U\n";
	        foreach($this->songs as $song_id) {
	        	$song = new Song($song_id);
	                $song->format_song();
			if ($song->type == ".flac") { $song->type = ".ogg"; }
	                $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
	                echo "#EXTINF:$song->time,$song_name\n";
	                $sess = $_COOKIE[libglue_param('sess_name')];
	                if($GLOBALS['user']->prefs['play_type'] == 'downsample') {
	                	$ds = $GLOBALS['user']->prefs['sample_rate'];
			}
                        echo "$this->web_path/play/index.php?song=$song_id&uid=$this->user_id&sid=$this->sess&ds=$ds&name=/" . rawurlencode($song_name) . "\n";
                } // end foreach

	} // create_m3u

	/*!
		@function create_pls
		@discussion creates a pls file
	*/
	function create_pls() { 

		// Send the client a pls playlist
		header("Cache-control: public");
		header("Content-Disposition: filename=playlist.pls");
		header("Content-Type: audio/x-scpls;");
		echo "[Playlist]\n";
		echo "NumberOfEntries=" . count($this->songs) . "\n";
		foreach ($this->songs as $song_id) { 
			$i++;
			$song = new Song($song_id);
			$song->format_song();
			if ($song->type == ".flac") { $song->type = ".ogg"; }
			$song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
                        if($GLOBALS['user']->prefs['play_type'] == 'downsample') {
                                $ds = $GLOBALS['user']->prefs['sample_rate'];
                        }
			$song_url = $this->web_path . "/play/index.php?song=$song_id&uid=$this->user_id&sid=$this->sess&ds=$ds&stupidwinamp=." . $song->type; 
			echo "File" . $i . "=$song_url\n";
			echo "Title" . $i . "=$song_name\n";
			echo "Length" . $i . "=-1\n";
		} // end foreach songs	
		echo "Version=2\n";

	} // create_pls

	/*!
		@function create_asx
		@discussion creates an ASZ playlist (Thx Samir Kuthiala)
	*/
	function create_asx() { 

	        header("Cache-control: public");
        	header("Content-Disposition: filename=playlist.asx");
		header("Content-Type: video/x-ms-asf;");
 
		echo "<ASX version = \"3.0\" BANNERBAR=\"AUTO\">\n";
                echo "<TITLE>Ampache ASX Playlist</TITLE>";
                
		foreach ($this->songs as $song_id) {
                	$song = new Song($song_id);
                        $song->format_song();   
                        $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
                        echo "<ENTRY>\n";
                        echo "<TITLE>".$song->f_album_full ." - ". $song->f_artist_full ." - ". $song->title ."</TITLE>\n";
                        echo "<AUTHOR>".$song->f_artist_full."</AUTHOR>\n";
                        $sess = $_COOKIE[libglue_param('sess_name')];
                        if ($GLOBALS['user']->prefs['play_type'] == 'downsample') {
	                        $ds = $GLOBALS['user']->prefs['sample_rate'];
			}
        	        echo "<REF HREF = \"". conf('web_path') . "/play/index.php?song=$song_id&uid=$this->user_id&sid=$sess&ds=$ds&name=/" . rawurlencode($song_name) . "\" />\n";
                        echo "</ENTRY>\n";
			
                } // end foreach

                echo "</ASX>\n";

	} // create_asx

	/*! 
		@function create_icecast2
		@discussion pushes an icecast stream
	*/
	function create_icecast2() { 

	        echo "ICECAST2<br>\n";

		// Play the song locally using local play configuration
	        if (count($this->songs) > 0) {
	        echo "ICECAST2<br>\n";
	        exec("killall ices");
	        $filename = conf('icecast_tracklist');
	        echo "$filename " . _("Opened for writting") . "<br>\n";

		/* Open the file for writting */
		if (!$handle = @fopen($filename, "w")) {
			log_event($_SESSION['userdata']['username'],"icecast","Fopen: $filename Failed");
		        echo _("Error, cannot write") . " $filename<br>\n";
	        	exit;
		}

		/* Foreach through songs */
		foreach($this->songs as $song_id) {
        		$song = new Song($song_id);
	        	echo "$song->file<br>\n";
	        	$line = "$song->file\n";
	                if (!fwrite($handle, $line)) {
				log_event($_SESSION['userdata']['username'],"icecast","Fwrite: Unabled to write $line into $filename");
	                	echo _("Error, cannot write song in file") . " $song->file --&gt; $filename";
				exit;
			} // if write fails

		} // foreach songs

		echo $filename . " " . _("Closed after write") . "<br>\n";
		fclose($handle);
		$cmd = conf('icecast_command');
                $cmd = str_replace("%FILE%", $filename, $cmd);
		if (conf('debug')) { 
			log_event($_SESSION['userdata']['username'],"icecast","Exec: $cmd");
		} 
		exec($cmd);
		exit;
	
		} // if songs


	} // create_icecast2

	/*!
		@function create_local_play
		@discussion pushes out localplay mojo
	*/
	function create_local_play() { 

                foreach($this->songs as $song_id) {
                        $song = new Song($song_id);
                        $song->format_song();
                        $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type;
                        $url = escapeshellarg("$this->web_path/play/?song=$song_id&uid=$this->user_id&sid=$this->sess&name=" . rawurlencode($song_name));
                        $localplay_add = conf('localplay_add');
                        $localplay_add = str_replace("%URL%", $url, $localplay_add);
                        if (conf('debug')) { 
				log_event($_SESSION['userdata']['username'],"localplay","Exec: $localplay_add"); 
			}
                        exec($localplay_add);
                        header("Location: " . conf('web_path') . "/index.php");
                }

	} // create_localplay

	/*!
		@function create_mpd
		@discussion function that passes information to 
			MPD
	*/
	function create_mpd() { 

		/* Create the MPD object */
		$myMpd = @new mpd(conf('mpd_host'),conf('mpd_port'),conf('mpd_pass'));

		/* Add the files to the MPD playlist */
		addToPlaylist($myMpd,$this->songs);

		/* If we've added songs we should start playing */
		$myMpd->Play();

		header ("Location: " . return_referer());

	} // create_mpd


	/*!
		@function create_slim
		@discussion this function passes the correct mojo to the slim
			class which is in turn passed to the slimserver
	*/
	function create_slim() { 





	} // create_slim
	

} //end of stream class

?>