diff options
Diffstat (limited to 'lib/class/stream.class.php')
-rw-r--r-- | lib/class/stream.class.php | 488 |
1 files changed, 244 insertions, 244 deletions
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 3ae532e1..1b4a7225 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -3,7 +3,7 @@ /* Copyright (c) Ampache.org - All rights reserved. + 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 v2 @@ -16,7 +16,7 @@ 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. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -33,15 +33,15 @@ class Stream { public $type; public $web_path; public $media = array(); - public $urls = array(); + public $urls = array(); public $sess; - public $user_id; + public $user_id; // Generate once an object is constructed - public static $session; + public static $session; // Let's us tell if the session has been activated - private static $session_inserted; + private static $session_inserted; /** * Constructor for the stream class takes a type and an array @@ -52,8 +52,8 @@ class Stream { $this->type = $type; $this->media = $media_ids; $this->user_id = $GLOBALS['user']->id; - - if (!is_array($this->media)) { settype($this->media,'array'); } + + if (!is_array($this->media)) { settype($this->media,'array'); } } // Constructor @@ -64,26 +64,26 @@ class Stream { */ public function start() { - if (!count($this->media) AND !count($this->urls)) { + if (!count($this->media) AND !count($this->urls)) { debug_event('stream','Error: No Songs Passed on ' . $this->type . ' stream','2'); - return false; + return false; } // We're starting insert the session into session_stream - if (!self::get_session()) { - debug_event('stream','Session Insertion failure, aborting','3'); - return false; + if (!self::get_session()) { + debug_event('stream','Session Insertion failure, aborting','3'); + return false; } $methods = get_class_methods('Stream'); - $create_function = "create_" . $this->type; + $create_function = "create_" . $this->type; // If in the class, call it if (in_array($create_function,$methods)) { $this->{$create_function}(); } // Assume M3u incase they've pooched the type - else { + else { $this->create_m3u(); } @@ -91,14 +91,14 @@ class Stream { /** * add_urls - * Add an array of urls, it may be a single one who knows, this + * Add an array of urls, it may be a single one who knows, this * is used for things that aren't coming from media objects */ - public function add_urls($urls=array()) { + public function add_urls($urls=array()) { + + if (!is_array($urls)) { return false; } - if (!is_array($urls)) { return false; } - - $this->urls = array_merge($urls,$this->urls); + $this->urls = array_merge($urls,$this->urls); } // manual_url_add @@ -106,13 +106,13 @@ class Stream { * get_session * This returns the current stream session */ - public static function get_session() { + public static function get_session() { - if (!self::$session_inserted) { + if (!self::$session_inserted) { self::insert_session(self::$session); - } + } - return self::$session; + return self::$session; } // get_session @@ -122,10 +122,10 @@ class Stream { * an additional session into the database, should be called * with care */ - public static function set_session($sid) { + public static function set_session($sid) { - self::$session_inserted = true; - self::$session=$sid; + self::$session_inserted = true; + self::$session=$sid; } // set_session @@ -133,42 +133,42 @@ class Stream { * insert_session * This inserts a row into the session_stream table */ - public static function insert_session($sid='',$uid='') { + public static function insert_session($sid='',$uid='') { - $sid = $sid ? Dba::escape($sid) : Dba::escape(self::$session); - $uid = $uid ? Dba::escape($uid) : Dba::escape($GLOBALS['user']->id); + $sid = $sid ? Dba::escape($sid) : Dba::escape(self::$session); + $uid = $uid ? Dba::escape($uid) : Dba::escape($GLOBALS['user']->id); - $expire = time() + Config::get('stream_length'); + $expire = time() + Config::get('stream_length'); - $sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " . - "VALUES('$sid','$expire','$uid')"; - $db_results = Dba::write($sql); + $sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " . + "VALUES('$sid','$expire','$uid')"; + $db_results = Dba::write($sql); - if (!$db_results) { return false; } + if (!$db_results) { return false; } - self::$session_inserted = true; + self::$session_inserted = true; - return true; + return true; } // insert_session /** * session_exists - * This checks to see if the passed stream session exists and is valid + * This checks to see if the passed stream session exists and is valid */ - public static function session_exists($sid) { + public static function session_exists($sid) { - $sid = Dba::escape($sid); - $time = time(); + $sid = Dba::escape($sid); + $time = time(); - $sql = "SELECT * FROM `session_stream` WHERE `id`='$sid' AND `expire` > '$time'"; - $db_results = Dba::write($sql); + $sql = "SELECT * FROM `session_stream` WHERE `id`='$sid' AND `expire` > '$time'"; + $db_results = Dba::write($sql); - if ($row = Dba::fetch_assoc($db_results)) { - return true; - } - - return false; + if ($row = Dba::fetch_assoc($db_results)) { + return true; + } + + return false; } // session_exists @@ -177,49 +177,49 @@ class Stream { * This function performes the garbage collection stuff, run on extend and on now playing refresh * There is an array of agents that we will never GC because of their nature, MPD being the best example */ - public static function gc_session($ip='',$agent='',$uid='',$sid='') { + public static function gc_session($ip='',$agent='',$uid='',$sid='') { - $append_array = array('MPD'); + $append_array = array('MPD'); - $time = time(); - $sql = "DELETE FROM `session_stream` WHERE `expire` < '$time'"; - $db_results = Dba::write($sql); - - foreach ($append_array as $append_agent) { - if (strstr(strtoupper($agent),$append_agent)) { + $time = time(); + $sql = "DELETE FROM `session_stream` WHERE `expire` < '$time'"; + $db_results = Dba::write($sql); + + foreach ($append_array as $append_agent) { + if (strstr(strtoupper($agent),$append_agent)) { // We're done here jump ship! - return true; - } + return true; + } } // end foreach // We need all of this to run this query - if ($ip AND $agent AND $uid AND $sid) { - $sql = "DELETE FROM `session_stream` WHERE `ip`='$ip' AND `agent`='$agent' AND `user`='$uid' AND `id` != '$sid'"; - $db_results = Dba::write($sql); - } + if ($ip AND $agent AND $uid AND $sid) { + $sql = "DELETE FROM `session_stream` WHERE `ip`='$ip' AND `agent`='$agent' AND `user`='$uid' AND `id` != '$sid'"; + $db_results = Dba::write($sql); + } - } // gc_session + } // gc_session /** * extend_session * This takes the passed sid and does a replace into also setting the user * agent and IP also do a little GC in this function */ - public static function extend_session($sid,$uid) { + public static function extend_session($sid,$uid) { - $expire = time() + Config::get('stream_length'); - $sid = Dba::escape($sid); - $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']); - $ip = Dba::escape(inet_pton($_SERVER['REMOTE_ADDR'])); - $uid = Dba::escape($uid); + $expire = time() + Config::get('stream_length'); + $sid = Dba::escape($sid); + $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']); + $ip = Dba::escape(inet_pton($_SERVER['REMOTE_ADDR'])); + $uid = Dba::escape($uid); - $sql = "UPDATE `session_stream` SET `expire`='$expire', `agent`='$agent', `ip`='$ip' " . - "WHERE `id`='$sid'"; - $db_results = Dba::write($sql); + $sql = "UPDATE `session_stream` SET `expire`='$expire', `agent`='$agent', `ip`='$ip' " . + "WHERE `id`='$sid'"; + $db_results = Dba::write($sql); - self::gc_session($ip,$agent,$uid,$sid); + self::gc_session($ip,$agent,$uid,$sid); - return true; + return true; } // extend_session @@ -234,16 +234,16 @@ class Stream { header("Content-Type: audio/x-mpegurl;"); // Flip for the poping! - asort($this->urls); + asort($this->urls); /* Foreach songs */ - foreach ($this->media as $element) { + foreach ($this->media as $element) { $type = array_shift($element); - echo call_user_func(array($type,'play_url'),array_shift($element)) . "\n"; + echo call_user_func(array($type,'play_url'),array_shift($element)) . "\n"; } // end foreach /* Foreach the additional URLs */ - foreach ($this->urls as $url) { + foreach ($this->urls as $url) { echo "$url\n"; } @@ -254,7 +254,7 @@ class Stream { * creates an m3u file, this includes the EXTINFO and as such can be * large with very long playlsits */ - public function create_m3u() { + public function create_m3u() { // Send the client an m3u playlist header("Cache-control: public"); @@ -264,31 +264,31 @@ class Stream { // Foreach the songs in this stream object foreach ($this->media as $element) { - $type = array_shift($element); - $media = new $type(array_shift($element)); - $media->format(); - switch ($type) { - case 'song': + $type = array_shift($element); + $media = new $type(array_shift($element)); + $media->format(); + switch ($type) { + case 'song': echo "#EXTINF:$media->time," . $media->f_artist_full . " - " . $media->title . "\n"; break; - case 'video': + case 'video': echo "#EXTINF: Video - $media->title\n"; break; - case 'radio': - echo "#EXTINF: Radio - $media->name [$media->frequency] ($media->site_url)\n"; - break; - case 'random': - echo "#EXTINF:Random URL\n"; - break; - default: + case 'radio': + echo "#EXTINF: Radio - $media->name [$media->frequency] ($media->site_url)\n"; + break; + case 'random': + echo "#EXTINF:Random URL\n"; + break; + default: echo "#EXTINF:URL-Add\n"; break; - } - echo call_user_func(array($type,'play_url'),$media->id) . "\n"; + } + echo call_user_func(array($type,'play_url'),$media->id) . "\n"; } // end foreach /* Foreach URLS */ - foreach ($this->urls as $url) { + foreach ($this->urls as $url) { echo "#EXTINF: URL-Add\n"; echo $url . "\n"; } @@ -300,10 +300,10 @@ class Stream { * This creates a new pls file from an array of songs and * urls, exciting I know */ - public function create_pls() { + public function create_pls() { /* Count entries */ - $total_entries = count($this->media) + count($this->urls); + $total_entries = count($this->media) + count($this->urls); // Send the client a pls playlist header("Cache-control: public"); @@ -311,30 +311,30 @@ class Stream { header("Content-Type: audio/x-scpls;"); echo "[Playlist]\n"; echo "NumberOfEntries=$total_entries\n"; - foreach ($this->media as $element) { + foreach ($this->media as $element) { $i++; - $type = array_shift($element); - $media = new $type(array_shift($element)); - $media->format(); - switch ($type) { - case 'song': + $type = array_shift($element); + $media = new $type(array_shift($element)); + $media->format(); + switch ($type) { + case 'song': $name = $media->f_artist_full . " - " . $media->title . "." . $media->type; - $length = $media->time; - break; - default: - $name = 'URL-Add'; - $length='-1'; - break; - } + $length = $media->time; + break; + default: + $name = 'URL-Add'; + $length='-1'; + break; + } $url = call_user_func(array($type,'play_url'),$media->id); echo "File" . $i . "=$url\n"; echo "Title" . $i . "=$name\n"; echo "Length" . $i . "=$length\n"; - } // end foreach songs + } // end foreach songs /* Foreach Additional URLs */ - foreach ($this->urls as $url) { + foreach ($this->urls as $url) { $i++; echo "File" . $i ."=$url\n"; echo "Title". $i . "=AddedURL\n"; @@ -348,32 +348,32 @@ class Stream { /** * create_asx * creates an ASX playlist (Thx Samir Kuthiala) This should really only be used - * if all of the content is ASF files. + * if all of the content is ASF files. */ - public function create_asx() { + public function create_asx() { header("Cache-control: public"); header("Content-Disposition: filename=ampache_playlist.asx"); header("Content-Type: video/x-ms-wmv;"); - + echo "<ASX version = \"3.0\" BANNERBAR=\"AUTO\">\n"; echo "<TITLE>Ampache ASX Playlist</TITLE>"; - + foreach ($this->media as $element) { - $type = array_shift($element); - $media = new $type(array_shift($element)); - $media->format(); - switch ($type) { - case 'song': + $type = array_shift($element); + $media = new $type(array_shift($element)); + $media->format(); + switch ($type) { + case 'song': $name = $media->f_album_full . " - " . $media->title . "." . $media->type; - $author = $media->f_artist_full; - break; + $author = $media->f_artist_full; + break; default: - $author = 'Ampache'; + $author = 'Ampache'; $name = 'URL-Add'; - break; - } // end switch - $url = call_user_func(array($type,'play_url'),$media->id); + break; + } // end switch + $url = call_user_func(array($type,'play_url'),$media->id); echo "<ENTRY>\n"; echo "<TITLE>$name</TITLE>\n"; @@ -386,17 +386,17 @@ class Stream { echo "\t\t<PARAM NAME=\"Prebuffer\" Value=\"false\" />\n"; echo "<REF HREF = \"". $url . "\" />\n"; echo "</ENTRY>\n"; - + } // end foreach /* Foreach urls */ - foreach ($this->urls as $url) { + foreach ($this->urls as $url) { echo "<ENTRY>\n"; echo "<TITLE>AddURL</TITLE>\n"; echo "<AUTHOR>AddURL</AUTHOR>\n"; echo "<REF HREF=\"$url\" />\n"; echo "</ENTRY>\n"; - } // end foreach + } // end foreach echo "</ASX>\n"; @@ -406,26 +406,26 @@ class Stream { * create_xspf * creates an XSPF playlist (Thx PB1DFT) */ - public function create_xspf() { + public function create_xspf() { // Itterate through the songs foreach ($this->media as $element) { - $type = array_shift($element); - $media = new $type(array_shift($element)); - $media->format(); + $type = array_shift($element); + $media = new $type(array_shift($element)); + $media->format(); $xml = array(); - switch ($type) { + switch ($type) { default: - case 'song': + case 'song': $xml['track']['title'] = $media->title; $xml['track']['creator'] = $media->f_artist_full; $xml['track']['info'] = Config::get('web_path') . "/albums.php?action=show&album=" . $media->album; $xml['track']['image'] = Config::get('web_path') . "/image.php?id=" . $media->album . "&thumb=3"; $xml['track']['album'] = $media->f_album_full; - $length = $media->time; - break; + $length = $media->time; + break; } // type $xml['track']['location'] = call_user_func(array($type,'play_url'),$media->id); @@ -435,15 +435,15 @@ class Stream { $result .= xmlData::keyed_array($xml,1); } // end foreach - - xmlData::set_type('xspf'); + + xmlData::set_type('xspf'); header("Cache-control: public"); header("Content-Disposition: filename=ampache_playlist.xspf"); header("Content-Type: application/xspf+xml; charset=utf-8"); - echo xmlData::header(); + echo xmlData::header(); echo $result; - echo xmlData::footer(); + echo xmlData::footer(); } // create_xspf @@ -453,7 +453,7 @@ class Stream { * have to do a little 'cheating' to make this work, we are going to take * advantage of tmp_playlists to do all of this hotness */ - public function create_xspf_player() { + public function create_xspf_player() { /* Build the extra info we need to have it pass */ $play_info = "?action=show&tmpplaylist_id=" . $GLOBALS['user']->playlist->id; @@ -462,7 +462,7 @@ class Stream { //FIXME: This needs to go in a template, here for now though //FIXME: This preference doesn't even exists, we'll eventually //FIXME: just make it the default - if (Config::get('embed_xspf') == 1 ){ + if (Config::get('embed_xspf') == 1 ){ header("Location: ".Config::get('web_path')."/index.php?xspf&play_info=".$GLOBALS['user']->playlist->id); } else { @@ -474,13 +474,13 @@ class Stream { // We do a little check here to see if it's a Wii! if (false !== stristr($_SERVER['HTTP_USER_AGENT'], 'Nintendo Wii')) { echo "window.location=URL;\n"; - } + } // Else go ahead and do the normal stuff else { echo "window.open(URL, 'XSPF_player', 'width=400,height=170,scrollbars=0,toolbar=0,location=0,directories=0,status=0,resizable=0');\n"; echo "window.location = '" . return_referer() . "';\n"; echo "return false;\n"; - } + } echo "}\n"; echo "// end -->\n"; echo "</script>\n"; @@ -491,41 +491,41 @@ class Stream { echo "</html>\n"; } } // create_xspf_player - + /** * create_localplay - * This calls the Localplay API and attempts to + * This calls the Localplay API and attempts to * add, and then start playback */ - public function create_localplay() { + public function create_localplay() { // First figure out what their current one is and create the object - $localplay = new Localplay(Config::get('localplay_controller')); - $localplay->connect(); - foreach ($this->media as $element) { + $localplay = new Localplay(Config::get('localplay_controller')); + $localplay->connect(); + foreach ($this->media as $element) { $type = array_shift($element); - switch ($type) { - case 'video': + switch ($type) { + case 'video': // Add check for video support - case 'song': - case 'radio': - case 'random': - $media = new $type(array_shift($element)); - break; - default: - $media = array_shift($element); - break; - } // switch on types - $localplay->add($media); + case 'song': + case 'radio': + case 'random': + $media = new $type(array_shift($element)); + break; + default: + $media = array_shift($element); + break; + } // switch on types + $localplay->add($media); } // foreach object /** * Add urls after the fact */ - foreach ($this->urls as $url) { - $localplay->add($url); - } - + foreach ($this->urls as $url) { + $localplay->add($url); + } + $localplay->play(); } // create_localplay @@ -535,10 +535,10 @@ class Stream { * This 'votes' on the songs it inserts them into * a tmp_playlist with user of -1 (System) */ - public function create_democratic() { + public function create_democratic() { $democratic = Democratic::get_current_playlist(); - $democratic->set_parent(); + $democratic->set_parent(); $democratic->vote($this->media); } // create_democratic @@ -548,21 +548,21 @@ class Stream { * This prompts for a download of the song, only a single * element can by in song_ids */ - private function create_download() { + private function create_download() { - // There should only be one here... - foreach ($this->media as $element) { + // There should only be one here... + foreach ($this->media as $element) { $type = array_shift($element); $media = new $type(array_shift($element)); - $url = call_user_func(array($type,'play_url'),$media->id); - + $url = call_user_func(array($type,'play_url'),$media->id); + // Append the fact we are downloading - $url .= '&action=download'; + $url .= '&action=download'; // Header redirect baby! - header("Location: $url"); - exit; - } + header("Location: $url"); + exit; + } } //create_download @@ -570,26 +570,26 @@ class Stream { * create_ram *this functions creates a RAM file for use by Real Player */ - public function create_ram() { + public function create_ram() { header("Cache-control: public"); header("Content-Disposition: filename=ampache_playlist.ram"); header("Content-Type: audio/x-pn-realaudio ram;"); foreach ($this->media as $element) { $type = array_shift($element); - echo $url = call_user_func(array($type,'play_url'),array_shift($element)) . "\n"; + echo $url = call_user_func(array($type,'play_url'),array_shift($element)) . "\n"; } // foreach songs } // create_ram /** * start_downsample - * This is a rather complext function that starts the downsampling of a song and returns the + * This is a rather complext function that starts the downsampling of a song and returns the * opened file handled a reference to the song object is passed so that the changes we make - * in here affect the external object, References++ + * in here affect the external object, References++ */ public static function start_downsample(&$song,$now_playing_id=0,$song_name=0,$start=0) { - + /* Check to see if bitrates are set if so let's go ahead and optomize! */ $max_bitrate = Config::get('max_bit_rate'); $min_bitrate = Config::get('min_bit_rate'); @@ -611,8 +611,8 @@ class Stream { $results = Dba::fetch_row($db_results); // Current number of active streams (current is already in now playing, worst case make it 1) - $active_streams = intval($results[0]); - if (!$active_streams) { $active_streams = '1'; } + $active_streams = intval($results[0]); + if (!$active_streams) { $active_streams = '1'; } /* If only one user, they'll get all available. Otherwise split up equally. */ $sample_rate = floor($max_bitrate/$active_streams); @@ -630,7 +630,7 @@ class Stream { $sample_rate = floor($max_bitrate/$active_streams); } // end else - // Never go over the users sample rate + // Never go over the users sample rate if ($sample_rate > $user_sample_rate) { $sample_rate = $user_sample_rate; } debug_event('downsample',"Downsampled: $active_streams current active streams, downsampling to $sample_rate",'2'); @@ -653,7 +653,7 @@ class Stream { /* Set the Sample Ratio */ $sample_ratio = $sample_rate/($song->bitrate/1000); } - + // Set the new size for the song $song->size = floor($sample_ratio*$song->size); @@ -677,9 +677,9 @@ class Stream { $downsample_command = str_replace("%EOF%",$eof,$downsample_command,$eof_exists); $downsample_command = str_replace("%SAMPLE%",$sample_rate,$downsample_command,$sample_exists); - if (!$file_exists || !$offset_exists || !$eof_exists || !$sample_exists) { - debug_event('downsample','Error: Downsample command missing a varaible values are File:' . $file_exists . ' Offset:' . $offset_exists . ' Eof:' . $eof_exists . ' Sample:' . $sample_exists,'1'); - } + if (!$file_exists || !$offset_exists || !$eof_exists || !$sample_exists) { + debug_event('downsample','Error: Downsample command missing a varaible values are File:' . $file_exists . ' Offset:' . $offset_exists . ' Eof:' . $eof_exists . ' Sample:' . $sample_exists,'1'); + } // If we are debugging log this event $message = "Start Downsample: $downsample_command"; @@ -692,7 +692,7 @@ class Stream { } // start_downsample - /** + /** * validate_bitrate * this function takes a bitrate and returns a valid one */ @@ -701,17 +701,17 @@ class Stream { /* Round to standard bitrates */ $sample_rate = 16*(floor($bitrate/16)); - return $sample_rate; + return $sample_rate; } // validate_bitrate /** * gc_now_playing - * This will garbage collect the now playing data, + * This will garbage collect the now playing data, * this is done on every play start */ - public static function gc_now_playing() { + public static function gc_now_playing() { // Remove any now playing entries for session_streams that have been GC'd $sql = "DELETE FROM `now_playing` USING `now_playing` " . @@ -731,7 +731,7 @@ class Stream { $time = intval(time()+$length); $session_id = Dba::escape($sid); - $object_type = Dba::escape(strtolower($type)); + $object_type = Dba::escape(strtolower($type)); // Do a replace into ensuring that this client always only has a single row $sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" . @@ -758,7 +758,7 @@ class Stream { * get_now_playing * This returns the now playing information */ - public static function get_now_playing($filter=NULL) { + public static function get_now_playing($filter=NULL) { $sql = "SELECT `session_stream`.`agent`,`now_playing`.* " . "FROM `now_playing` " . @@ -766,17 +766,17 @@ class Stream { "ORDER BY `now_playing`.`expire` DESC"; $db_results = Dba::read($sql); - $results = array(); + $results = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $type = $row['object_type']; - $media = new $type($row['object_id']); - $media->format(); - $client = new User($row['user']); - $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']); + while ($row = Dba::fetch_assoc($db_results)) { + $type = $row['object_type']; + $media = new $type($row['object_id']); + $media->format(); + $client = new User($row['user']); + $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']); } // end while - return $results; + return $results; } // get_now_playing @@ -785,20 +785,20 @@ class Stream { * This checks to see if the media is already being played, if it is then it returns false * else return true */ - public static function check_lock_media($media_id,$type) { + public static function check_lock_media($media_id,$type) { - $media_id = Dba::escape($media_id); - $type = Dba::escape($type); + $media_id = Dba::escape($media_id); + $type = Dba::escape($type); - $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'"; - $db_results = Dba::read($sql); + $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'"; + $db_results = Dba::read($sql); - if (Dba::num_rows($db_results)) { - debug_event('Stream','Unable to play media currently locked by another user','3'); + if (Dba::num_rows($db_results)) { + debug_event('Stream','Unable to play media currently locked by another user','3'); return false; - } + } - return true; + return true; } // check_lock_media @@ -806,7 +806,7 @@ class Stream { * auto_init * This is called on class load it sets the session */ - public static function _auto_init() { + public static function _auto_init() { // Generate the session ID self::$session = md5(uniqid(rand(), true)); @@ -817,31 +817,31 @@ class Stream { * run_playlist_method * This takes care of the different types of 'playlist methods' the reason this is here * is because it deals with streaming rather then playlist mojo. If something needs to happen - * this will echo the javascript required to cause a reload of the iframe. + * this will echo the javascript required to cause a reload of the iframe. */ - public static function run_playlist_method() { + public static function run_playlist_method() { - // If this wasn't ajax included run away - if (AJAX_INCLUDE != '1') { return false; } + // If this wasn't ajax included run away + if (AJAX_INCLUDE != '1') { return false; } // If we're doin the flash magic then run away as well - if (Config::get('play_type') == 'xspf_player') { return false; } + if (Config::get('play_type') == 'xspf_player') { return false; } - switch (Config::get('playlist_method')) { - default: - case 'clear': - case 'default': - return true; + switch (Config::get('playlist_method')) { + default: + case 'clear': + case 'default': + return true; break; - case 'send': + case 'send': $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket'; break; - case 'send_clear': - $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=clear'; - break; - } // end switch on method + case 'send_clear': + $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=clear'; + break; + } // end switch on method - // Load our javascript + // Load our javascript echo "<script type=\"text/javascript\">"; //echo "reload_util();"; echo "reload_util('".$_SESSION['iframe']['target']."');"; @@ -853,7 +853,7 @@ class Stream { * get_base_url * This returns the base requirements for a stream URL this does not include anything after the index.php?sid=???? */ - public static function get_base_url() { + public static function get_base_url() { if (Config::get('require_session')) { $session_string = 'ssid=' . Stream::get_session() . '&'; @@ -864,18 +864,18 @@ class Stream { if (Config::get('force_http_play') OR !empty(self::$force_http)) { $web_path = str_replace("https://", "http://",$web_path); } - if (Config::get('http_port') != '80') { - if (preg_match("/:(\d+)/",$web_path,$matches)) { - $web_path = str_replace(':' . $matches['1'],':' . Config::get('http_port'),$web_path); - } - else { - $web_path = str_replace($_SERVER['HTTP_HOST'],$_SERVER['HTTP_HOST'] . ':' . Config::get('http_port'),$web_path); - } - } - - $url = $web_path . "/play/index.php?$session_string"; - - return $url; + if (Config::get('http_port') != '80') { + if (preg_match("/:(\d+)/",$web_path,$matches)) { + $web_path = str_replace(':' . $matches['1'],':' . Config::get('http_port'),$web_path); + } + else { + $web_path = str_replace($_SERVER['HTTP_HOST'],$_SERVER['HTTP_HOST'] . ':' . Config::get('http_port'),$web_path); + } + } + + $url = $web_path . "/play/index.php?$session_string"; + + return $url; } // get_base_url |