예제 #1
0
 /**
  * Add a song to the library
  *
  * @param artist_id  int: the related artist primary key
  * @param album_id   int: the related album primary key
  * @param genre_id   int: the related genre primary key
  * @param song_array array: the array of song info
  * @return          int: the song insert id
  * @see apps/client/lib/MediaScan.class.php for information about the song_array
  */
 public function addSong($artist_id, $album_id, $last_scan_id, $song_array)
 {
     if (isset($song_array['filename']) && !empty($song_array['filename']) && isset($song_array['mtime']) && !empty($song_array['mtime']) && $last_scan_id) {
         $song = new Song();
         $song->unique_id = sha1(uniqid('', true) . mt_rand(1, 99999999));
         $song->artist_id = (int) $artist_id;
         $song->album_id = (int) $album_id;
         $song->scan_id = (int) $last_scan_id;
         $song->name = $song_array['song_name'];
         $song->length = $song_array['song_length'];
         $song->accurate_length = (int) $song_array['accurate_length'];
         $song->filesize = (int) $song_array['filesize'];
         $song->bitrate = (int) $song_array['bitrate'];
         $song->yearpublished = (int) $song_array['yearpublished'];
         $song->tracknumber = (int) $song_array['tracknumber'];
         $song->label = $song_array['label'];
         $song->mtime = (int) $song_array['mtime'];
         $song->atime = (int) $song_array['atime'];
         $song->filename = $song_array['filename'];
         $song->save();
         $id = $song->getId();
         $song->free();
         unset($song, $song_array);
         return $id;
     }
     return false;
 }
예제 #2
0
 /**
  * File/Folder safe name of song
  *
  * @return string
  * @throws SMException
  */
 public function getFileSafeTitle()
 {
     if (empty($this->song)) {
         throw new SMException('Song myst be set');
     }
     return Utility::GenerateSafeFileName($this->song->getTitle());
 }
예제 #3
0
파일: batch.lib.php 프로젝트: nioc/ampache
/**
 * get_media_files
 *
 * Takes an array of media ids and returns an array of the actual filenames
 *
 * @param    array    $media_ids    Media IDs.
 */
function get_media_files($media_ids)
{
    $media_files = array();
    $total_size = 0;
    foreach ($media_ids as $element) {
        if (is_array($element)) {
            if (isset($element['object_type'])) {
                $type = $element['object_type'];
                $id = $element['object_id'];
            } else {
                $type = array_shift($element);
                $id = array_shift($element);
            }
            $media = new $type($id);
        } else {
            $media = new Song($element);
        }
        if ($media->enabled) {
            $media->format();
            $total_size += sprintf("%.2f", $media->size / 1048576);
            $dirname = '';
            $parent = $media->get_parent();
            if ($parent != null) {
                $pobj = new $parent['object_type']($parent['object_id']);
                $pobj->format();
                $dirname = $pobj->get_fullname();
            }
            if (!array_key_exists($dirname, $media_files)) {
                $media_files[$dirname] = array();
            }
            array_push($media_files[$dirname], Core::conv_lc_file($media->file));
        }
    }
    return array($media_files, $total_size);
}
예제 #4
0
파일: Liste.php 프로젝트: hlag/svs
 public function getSongs($status)
 {
     if ($status == 'all') {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website ORDER BY title");
     } elseif ($status == 'repertoire') {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe != 1 AND probe != 5 ORDER BY title");
     } elseif ($status == 'uebrige') {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe != 1 AND probe != 5 ORDER BY g_id,  title");
     } elseif ($status == 'erschienen') {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website  ORDER BY erschienen DESC");
     } elseif ($status == 2) {
         $dringend = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 3 ORDER BY title");
         $proben = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 2 ORDER BY title");
         $sonstige = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = 4 ORDER BY letzteProbe");
         $songs = array_merge($dringend, $proben, $sonstige);
     } elseif ($status == 5) {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE\n                    angefangen > '" . date("Y-m-d", time() - 3600 * 24 * 21) . "' OR probe = '5' ORDER BY angefangen DESC");
     } else {
         $songs = AGDO::getInstance()->GetAll("SELECT * FROM SVsongs LEFT OUTER JOIN sv_song_genres ON g_id = website WHERE probe = '" . $status . "' ORDER BY title");
     }
     foreach ($songs as $song) {
         $song['b'] = $song['c'];
         $song['arr_b'] = $song['arr_c'];
         $song['arr_t'] = '';
         $song['arr_p'] = '';
         $S = new Song();
         $S->setSong($song);
         $this->songs[$song['id']] = $S;
     }
     return $this->songs;
 }
예제 #5
0
파일: song.php 프로젝트: laiello/atm-music
 public function action_add_song()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $song = new Song();
         $form = $_POST;
         $song->set_id_kind(null);
         if ($_POST['name'] != "") {
             $song->set_title_song($_POST['name']);
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Il y a une erreur dans le titre. </br>";
         }
         if (isset($_POST['genre'])) {
             $song->set_id_kind($_POST['genre']);
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Il faut sélectionner au moins 1 genre. </br>";
         }
         if (is_numeric($_POST['anneeF']) and preg_match("/^[0-2][0-9]{3}+\$/", $_POST['anneeF']) == 1) {
             $song->set_date_song($_POST['anneeF']);
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Le format de l'année n'est pas valable. (Format:AAAA). </br>";
         }
         if (is_numeric($_POST['num'])) {
             $song->set_track_song($_POST['num']);
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Le numéro dans l'album doit être numérique. </br>";
         }
         if (isset($_POST['path'])) {
             $path = str_replace(' ', '_', $_POST['path']);
             $song->set_path_song(str_replace('public', '', URL::base()) . 'song/' . $path);
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Vous devez rentrez un fichier dans le formulaire de téléversement. </br>";
         }
         if ($this->_error_form == false) {
             $song->set_length_song($_POST['lengthM'], $_POST['lengthS']);
         }
         //var_dump(isset($_POST['album']));
         if (isset($_POST['album'])) {
             $song->_id_album = $_POST['album'];
         } else {
             $this->_error_form = true;
             $this->_error_msg .= "Ce groupe n'a pas encore d'album, veuillez le créer. </br>";
         }
         if ($this->_error_form == false and !$song->check_exists()) {
             $song->set_id_user_lif($user->get_id_user_lif());
             $song->add();
             $this->_error_msg .= "Chanson ajoutée avec succés!";
             $form = null;
         }
         return Redirect::to_action('song@add')->with('error', true)->with('form', $form)->with('error_msg', $this->_error_msg);
     }
 }
예제 #6
0
 /**
  * Get a song waveform.
  * @param int $song_id
  * @return binary|string|null
  */
 public static function get($song_id)
 {
     $song = new Song($song_id);
     $waveform = null;
     if ($song->id) {
         $song->format();
         $waveform = $song->waveform;
         if (!$waveform) {
             $catalog = Catalog::create_from_id($song->catalog);
             if ($catalog->get_type() == 'local') {
                 $transcode_to = 'wav';
                 $transcode_cfg = AmpConfig::get('transcode');
                 $valid_types = $song->get_stream_types();
                 if ($song->type != $transcode_to) {
                     $basedir = AmpConfig::get('tmp_dir_path');
                     if ($basedir) {
                         if ($transcode_cfg != 'never' && in_array('transcode', $valid_types)) {
                             $tmpfile = tempnam($basedir, $transcode_to);
                             $tfp = fopen($tmpfile, 'wb');
                             if (!is_resource($tfp)) {
                                 debug_event('waveform', "Failed to open " . $tmpfile, 3);
                                 return null;
                             }
                             $transcoder = Stream::start_transcode($song, $transcode_to);
                             $fp = $transcoder['handle'];
                             if (!is_resource($fp)) {
                                 debug_event('waveform', "Failed to open " . $song->file . " for waveform.", 3);
                                 return null;
                             }
                             do {
                                 $buf = fread($fp, 2048);
                                 fwrite($tfp, $buf);
                             } while (!feof($fp));
                             fclose($fp);
                             fclose($tfp);
                             Stream::kill_process($transcoder);
                             $waveform = self::create_waveform($tmpfile);
                             //$waveform = self::create_waveform("C:\\tmp\\test.wav");
                             @unlink($tmpfile);
                         } else {
                             debug_event('waveform', 'transcode setting to wav required for waveform.', '3');
                         }
                     } else {
                         debug_event('waveform', 'tmp_dir_path setting required for waveform.', '3');
                     }
                 } else {
                     $waveform = self::create_waveform($song->file);
                 }
             }
             if ($waveform) {
                 self::save_to_db($song_id, $waveform);
             }
         }
     }
     return $waveform;
 }
예제 #7
0
파일: Helper.php 프로젝트: stdtabs/phptabs
 protected function isPercussionChannel(Song $song, $channelId)
 {
     $channels = $song->getChannels();
     foreach ($channels as $channel) {
         if ($channel->getChannelId() == $channelId) {
             return $channel->isPercussionChannel();
         }
     }
     return false;
 }
예제 #8
0
 public static function get_current_slideshow()
 {
     $songs = Song::get_recently_played($GLOBALS['user']->id);
     $images = array();
     if (count($songs) > 0) {
         $last_song = new Song($songs[0]['object_id']);
         $last_song->format();
         $images = self::get_images($last_song->f_artist);
     }
     return $images;
 }
 public function retrieveSongs()
 {
     global $db, $hades;
     if ($this->itemsPerPage > 0) {
         $modifier = $this->page - 1;
         $offset = $modifier * $this->itemsPerPage;
         $limit = 'LIMIT ' . $offset . ', ' . $this->itemsPerPage;
     } else {
         $limit = '';
     }
     try {
         $statement = $db->prepare('
             SELECT *
             FROM songs ' . $limit);
         $statement->execute();
         $results = $statement->fetchAll(PDO::FETCH_ASSOC);
         foreach ($results as $row) {
             array_push($this->songs, Song::fillValues($row));
         }
         $total = $db->query('
             SELECT *
             FROM songs
         ');
         $this->totalItems = $total->rowCount();
     } catch (Exception $e) {
         $hades->databaseError($e);
         exit;
     }
 }
예제 #10
0
파일: playlistSongs.php 프로젝트: hlag/svs
 public function setSong($song)
 {
     parent::setSong($song);
     $this->ps_id = $song['ps_id'];
     $this->pl_id = $song['pl_id'];
     $this->pb_id = $song['pb_id'];
     $this->pl_datum = $song['pl_datum'];
     $this->setPlayedButton();
 }
예제 #11
0
 public function execute($smarty, $params, $session)
 {
     $smarty->assign('name', $session['screen_name']);
     $artists = Artist::findAll();
     $smarty->assign('artists', $artists);
     $songs = Song::findAll();
     $smarty->assign('songs', $songs);
     $parts = Part::findAll();
     $smarty->assign('parts', $parts);
     $smarty->display('index.tpl');
 }
예제 #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function home()
 {
     $banners = $this->banners;
     $body = 'body goes here';
     $header = 'Header goes here';
     $tweets = Gtweet::get();
     $videos = Video::wherePin(true)->get();
     $songs = Song::get();
     $projects = Project::limit(8)->latest()->get();
     return View::make('pages.home')->with(compact('body', 'header', 'banners', 'tweets', 'videos', 'songs', 'projects'));
 }
예제 #13
0
 /**
  * Render a list page
  *
  * @param Song $song
  * The song that is currently playing
  *
  * @return string
  * The HTML of the rendered page
  */
 public static function render($song, $previous)
 {
     // instantiate the template engine
     $parser = new Rain\Tpl();
     // get the image data for the song
     $image_data = Song::getImageData($song['Artist'], $song['Album'], 320);
     // assign the values to the template parser
     $parser->assign(array('image' => $image_data, 'song' => $song, 'volume' => Music::getVolume(), 'previous' => $previous));
     // return the HTML
     return $parser->draw("now-playing-page", true);
 }
예제 #14
0
 public function get_latest_songs($count)
 {
     if (!is_numeric($count)) {
         Logger::log("get_latest_songs: invalid count value");
         return array();
     }
     if (!$this->initialised()) {
         Logger::log("get_latest_songs: user not initialised");
         return array();
     }
     return Song::get_users_latest_songs($this, $count);
 }
예제 #15
0
 public static function insertAndGet($pdo, $name, $artist)
 {
     $st = $pdo->prepare('select * from songs where name = ? and artist_id = ?');
     $st->execute(array($name, $artist->id));
     if ($row = $st->fetch()) {
         return Song::factory($row);
     } else {
         $st = $pdo->prepare('insert into songs(name, artist_id) values(?, ?)');
         $st->execute(array($name, $artist->id));
         return self::insertAndGet($pdo, $name, $artist);
     }
 }
예제 #16
0
 public function actionView()
 {
     $this->layout = 'hopam_detail';
     $hopam = Song::model()->findByPk($_GET['id']);
     $hopam->view += 1;
     $hopam->update(array('view'));
     //$comment = $this->newComment($hopam);
     $cs = Yii::app()->getClientScript();
     $js = $this->generateJs();
     $cs->registerScript('sharebox', $js, CClientScript::POS_READY);
     $this->render('view', array('hopam' => $hopam));
     //,'comment'=>$comment
 }
예제 #17
0
/**
 * get_song_files
 *
 * Takes an array of song ids and returns an array of the actual filenames
 *
 * @param    array    $media_ids    Media IDs.
 */
function get_song_files($media_ids)
{
    $media_files = array();
    $total_size = 0;
    foreach ($media_ids as $element) {
        if (is_array($element)) {
            $type = array_shift($element);
            $media = new $type(array_shift($element));
        } else {
            $media = new Song($element);
        }
        if ($media->enabled) {
            $total_size += sprintf("%.2f", $media->size / 1048576);
            $media->format();
            $dirname = $media->f_album_full;
            //debug_event('batch.lib.php', 'Songs file {'.$media->file.'}...', '5');
            if (!array_key_exists($dirname, $media_files)) {
                $media_files[$dirname] = array();
            }
            array_push($media_files[$dirname], $media->file);
        }
    }
    return array($media_files, $total_size);
}
예제 #18
0
파일: Player.php 프로젝트: nbar1/gs
 /**
  * Returns the token of the next song to play
  *
  * This method will mark the playing song as played, and next song as playing.
  * If there is not a next song it will get one based on the Autoplayer
  *
  * @return string Song token
  */
 public function playNextSong()
 {
     // This will mark a song as played if for some reason it wasn't already
     $currentPlayingSong = $this->getQueue()->getPlayingSong();
     if ($currentPlayingSong !== false) {
         $this->markSongPlayed($currentPlayingSong['id']);
     }
     // Load up an autoplayer song if no songs queued
     if ($this->getQueue()->getNextSong() === false && GS_AUTOPLAY === true) {
         // Get autoplay song
         $autoplay = new Autoplay();
         $autoplaySong = $autoplay->getAutoplaySong();
         $user = $this->getUser()->autoplayUser();
         $song = new Song();
         $song->setSongInformation($autoplaySong['SongID'], $autoplaySong['SongName'], $autoplaySong['ArtistName'], $autoplaySong['ArtistID'], $autoplaySong['CoverArtFilename'], 'low');
         $songID = $this->getQueue()->addSongToQueue($song, $this->getUser());
     }
     $nextSong = $this->getQueue()->getNextSong();
     if ($nextSong) {
         $this->markSongPlaying($nextSong['id']);
         return $nextSong['token'];
     }
     return false;
 }
예제 #19
0
 public function action_index()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $playlist = adminPlaylist::get_completed($user->get_id_user_lif());
         $search = "";
         if (isset($_POST['toSeek'])) {
             $search = $_POST['toSeek'];
         }
         $song = Song::all_completed($_POST['toSeek']);
         return View::make('search.index')->with('toSeek', $_POST['toSeek'])->with('playlist', $playlist)->with('count', count($song))->with('song', $song);
     }
 }
예제 #20
0
 public function action_display()
 {
     $user = $this->is_logged();
     if ($user === false) {
         return Redirect::to_action('login');
     } else {
         $id_playlist = URI::segment(3);
         $adminPlaylist = new adminPlaylist($user->get_id_user_lif(), $id_playlist);
         if ($adminPlaylist->check_exists() == 1) {
             $song_array = array();
             $all = SongPlaylist::all_from_ids($id_playlist);
             foreach ($all as $value) {
                 $song = new Song($value->id_song);
                 $song->load();
                 array_push($song_array, $song);
             }
             $playlist = new Playlist($id_playlist);
             $playlist->load();
             return View::make('playlist.display')->with('playlist', $playlist)->with('songs', $song_array);
         } else {
             return Redirect::to_action('home@index');
         }
     }
 }
예제 #21
0
파일: Queue.php 프로젝트: nbar1/gs
 /**
  * Add Song To Queue
  *
  * @param Song $song Song to be added
  * @param User $user User that added song
  * @return string Message sent to user
  */
 public function addSongToQueue(Song $song, User $user)
 {
     if ($this->isSongInQueue($song->getToken())) {
         return json_encode(array('msg' => 'song already queued'));
     }
     if ($user->getAvailablePromotions() < 1) {
         $song->setPriority('low');
     }
     $promoted_user = $song->getPriority() === 'high' ? $user->getId() : null;
     $data = array($song->getToken(), $song->getPriority(), $this->getNextQueuePosition(), $user->getId(), $promoted_user);
     if ($this->getDao()->addSongToQueue($data)) {
         if (!$song->hasMetadata()) {
             $song->storeMetadata();
         }
         return true;
     } else {
         return false;
     }
 }
예제 #22
0
 public function getStart()
 {
     // Needs logged in user with voting privileges
     if (!(Auth::check() && Auth::user()->canStartVoting())) {
         return Redirect::to('/');
     }
     $current = Voting::current()->get();
     if (count($current) == 0) {
         if (Song::requests()->count() > 0) {
             $voting = new Voting();
             $voting->created_by = Auth::user()->id;
             $voting->save();
         } else {
             Session::flash('error', 'Geen nummers om over te stemmen! D:');
         }
     }
     return Redirect::to('/vote');
 }
예제 #23
0
 /**
  * Constructor
  *
  * Song Preview class
  */
 public function __construct($id = null)
 {
     if (!$id) {
         return false;
     }
     $this->id = intval($id);
     if ($info = $this->_get_info()) {
         foreach ($info as $key => $value) {
             $this->{$key} = $value;
         }
         $data = pathinfo($this->file);
         $this->type = strtolower($data['extension']) ?: 'mp3';
         $this->mime = Song::type_to_mime($this->type);
     } else {
         $this->id = null;
         return false;
     }
     return true;
 }
예제 #24
0
 public function show($slug)
 {
     $hub = Hub::where('slug', '=', $slug)->first();
     if (!is_null($hub)) {
         $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
         $artists_list = [];
         $songs = [];
         $events = [];
         foreach ($artists as $a) {
             $artists_list[] = $a->id;
         }
         if (count($artists_list) > 0) {
             $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
             $events = ArtistEvent::whereIn('artist', $artists_list)->get();
         }
         $news = News::where('hub', '=', $hub->id)->take(3)->get();
         return View::make('hubs.main', ['hub' => $hub, 'news' => $news, 'artists' => $artists, 'songs' => $songs, 'events' => $events]);
     }
     App::abort(404);
 }
예제 #25
0
    public static function add($userId, $artistName, $songName, $partName)
    {
        $pdo = new PDO('mysql:host=localhost; dbname=twitter_band', 'root', '');
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $artist = Artist::insertAndGet($pdo, $artistName);
        $song = Song::insertAndGet($pdo, $songName, $artist);
        $part = Part::insertAndGet($pdo, $partName);
        $st = $pdo->prepare('
			select * from repertoire 
			where user_id = ? and artist_id = ? and song_id = ? and part_id = ?');
        $st->execute(array($userId, $artist->id, $song->id, $part->id));
        if ($row = $st->fetch()) {
            return true;
        } else {
            $st = $pdo->prepare('			
				insert into repertoire(user_id, artist_id, song_id, part_id) values(?,?,?,?)');
            $res = $st->execute(array($userId, $artist->id, $song->id, $part->id));
            return true;
        }
    }
예제 #26
0
 /**
  * show_objects
  * This takes an array of objects
  * and requires the correct template based on the
  * type that we are currently browsing
  *
  * @param int[] $object_ids
  */
 public function show_objects($object_ids = null, $argument = null)
 {
     if ($this->is_simple() || !is_array($object_ids)) {
         $object_ids = $this->get_saved();
     } else {
         $this->save_objects($object_ids);
     }
     // Limit is based on the user's preferences if this is not a
     // simple browse because we've got too much here
     if ($this->get_start() >= 0 && count($object_ids) > $this->get_start() && !$this->is_simple()) {
         $object_ids = array_slice($object_ids, $this->get_start(), $this->get_offset(), true);
     } else {
         if (!count($object_ids)) {
             $this->set_total(0);
         }
     }
     // Load any additional object we need for this
     $extra_objects = $this->get_supplemental_objects();
     $browse = $this;
     foreach ($extra_objects as $class_name => $id) {
         ${$class_name} = new $class_name($id);
     }
     $match = '';
     // Format any matches we have so we can show them to the masses
     if ($filter_value = $this->get_filter('alpha_match')) {
         $match = ' (' . $filter_value . ')';
     } elseif ($filter_value = $this->get_filter('starts_with')) {
         $match = ' (' . $filter_value . ')';
         /*} elseif ($filter_value = $this->get_filter('regex_match')) {
               $match = ' (' . $filter_value . ')';
           } elseif ($filter_value = $this->get_filter('regex_not_match')) {
               $match = ' (' . $filter_value . ')';*/
     } elseif ($filter_value = $this->get_filter('catalog')) {
         // Get the catalog title
         $catalog = Catalog::create_from_id(intval($filter_value));
         $match = ' (' . $catalog->name . ')';
     }
     $type = $this->get_type();
     // Update the session value only if it's allowed on the current browser
     if ($this->get_update_session()) {
         $_SESSION['browse_current_' . $type]['start'] = $browse->get_start();
     }
     // Set the correct classes based on type
     $class = "box browse_" . $type;
     $argument_param = $argument ? '&argument=' . scrub_in($argument) : '';
     debug_event('browse', 'Show objects called for type {' . $type . '}', '5');
     $limit_threshold = $this->get_threshold();
     // Switch on the type of browsing we're doing
     switch ($type) {
         case 'song':
             $box_title = T_('Songs') . $match;
             Song::build_cache($object_ids, $limit_threshold);
             $box_req = AmpConfig::get('prefix') . '/templates/show_songs.inc.php';
             break;
         case 'album':
             Album::build_cache($object_ids);
             $box_title = T_('Albums') . $match;
             if (is_array($argument)) {
                 $allow_group_disks = $argument['group_disks'];
                 if ($argument['title']) {
                     $box_title = $argument['title'];
                 }
             } else {
                 $allow_group_disks = false;
             }
             $box_req = AmpConfig::get('prefix') . '/templates/show_albums.inc.php';
             break;
         case 'user':
             $box_title = T_('Users') . $match;
             $box_req = AmpConfig::get('prefix') . '/templates/show_users.inc.php';
             break;
         case 'artist':
             $box_title = T_('Artists') . $match;
             Artist::build_cache($object_ids, true, $limit_threshold);
             $box_req = AmpConfig::get('prefix') . '/templates/show_artists.inc.php';
             break;
         case 'live_stream':
             require_once AmpConfig::get('prefix') . '/templates/show_live_stream.inc.php';
             $box_title = T_('Radio Stations') . $match;
             $box_req = AmpConfig::get('prefix') . '/templates/show_live_streams.inc.php';
             break;
         case 'playlist':
             Playlist::build_cache($object_ids);
             $box_title = T_('Playlists') . $match;
             $box_req = AmpConfig::get('prefix') . '/templates/show_playlists.inc.php';
             break;
         case 'playlist_song':
             $box_title = T_('Playlist Songs') . $match;
             $box_req = AmpConfig::get('prefix') . '/templates/show_playlist_songs.inc.php';
             break;
         case 'playlist_localplay':
             $box_title = T_('Current Playlist');
             $box_req = AmpConfig::get('prefix') . '/templates/show_localplay_playlist.inc.php';
             UI::show_box_bottom();
             break;
         case 'smartplaylist':
             $box_title = T_('Smart Playlists') . $match;
             $box_req = AmpConfig::get('prefix') . '/templates/show_searches.inc.php';
             break;
         case 'catalog':
             $box_title = T_('Catalogs');
             $box_req = AmpConfig::get('prefix') . '/templates/show_catalogs.inc.php';
             break;
         case 'shoutbox':
             $box_title = T_('Shoutbox Records');
             $box_req = AmpConfig::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
             break;
         case 'tag':
             Tag::build_cache($object_ids);
             $box_title = T_('Tag Cloud');
             $box_req = AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php';
             break;
         case 'video':
             Video::build_cache($object_ids);
             $video_type = 'video';
             $box_title = T_('Videos');
             $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
             break;
         case 'democratic':
             $box_title = T_('Democratic Playlist');
             $box_req = AmpConfig::get('prefix') . '/templates/show_democratic_playlist.inc.php';
             break;
         case 'wanted':
             $box_title = T_('Wanted Albums');
             $box_req = AmpConfig::get('prefix') . '/templates/show_wanted_albums.inc.php';
             break;
         case 'share':
             $box_title = T_('Shared Objects');
             $box_req = AmpConfig::get('prefix') . '/templates/show_shared_objects.inc.php';
             break;
         case 'song_preview':
             $box_title = T_('Songs');
             $box_req = AmpConfig::get('prefix') . '/templates/show_song_previews.inc.php';
             break;
         case 'channel':
             $box_title = T_('Channels');
             $box_req = AmpConfig::get('prefix') . '/templates/show_channels.inc.php';
             break;
         case 'broadcast':
             $box_title = T_('Broadcasts');
             $box_req = AmpConfig::get('prefix') . '/templates/show_broadcasts.inc.php';
             break;
         case 'license':
             $box_title = T_('Media Licenses');
             $box_req = AmpConfig::get('prefix') . '/templates/show_manage_license.inc.php';
             break;
         case 'tvshow':
             $box_title = T_('TV Shows');
             $box_req = AmpConfig::get('prefix') . '/templates/show_tvshows.inc.php';
             break;
         case 'tvshow_season':
             $box_title = T_('Seasons');
             $box_req = AmpConfig::get('prefix') . '/templates/show_tvshow_seasons.inc.php';
             break;
         case 'tvshow_episode':
             $box_title = T_('Episodes');
             $video_type = $type;
             $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
             break;
         case 'movie':
             $box_title = T_('Movies');
             $video_type = $type;
             $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
             break;
         case 'clip':
             $box_title = T_('Clips');
             $video_type = $type;
             $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
             break;
         case 'personal_video':
             $box_title = T_('Personal Videos');
             $video_type = $type;
             $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
             break;
         case 'label':
             $box_title = T_('Labels');
             $box_req = AmpConfig::get('prefix') . '/templates/show_labels.inc.php';
             break;
         case 'pvmsg':
             $box_title = T_('Private Messages');
             $box_req = AmpConfig::get('prefix') . '/templates/show_pvmsgs.inc.php';
             break;
         default:
             // Rien a faire
             break;
     }
     // end switch on type
     Ajax::start_container($this->get_content_div(), 'browse_content');
     if ($this->get_show_header()) {
         if (isset($box_req) && isset($box_title)) {
             UI::show_box_top($box_title, $class);
         }
     }
     if (isset($box_req)) {
         require $box_req;
     }
     if ($this->get_show_header()) {
         if (isset($box_req)) {
             UI::show_box_bottom();
         }
         echo '<script type="text/javascript">';
         echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id . $argument_param, '');
         echo ';</script>';
     } else {
         if (!$this->get_use_pages()) {
             $this->show_next_link($argument);
         }
     }
     Ajax::end_container();
 }
예제 #27
0
if (isset($argument) && $argument) {
    ++$thcount;
    ?>
            <th class="cel_drag essential"></th>
        <?php 
}
?>
        </tr>
    </thead>
    <tbody id="sortableplaylist_<?php 
echo $browse->get_filter('album');
?>
">
        <?php 
foreach ($object_ids as $song_id) {
    $song = new Song($song_id);
    $song->format();
    ?>
            <tr class="<?php 
    echo UI::flip_class();
    ?>
" id="song_<?php 
    echo $song->id;
    ?>
">
                <?php 
    require AmpConfig::get('prefix') . '/templates/show_song_row.inc.php';
    ?>
            </tr>
        <?php 
}
예제 #28
0
?>
</th>
        <th class="col_value"><?php 
echo T_('Value');
?>
</th>
        <th class="col_method"><?php 
echo T_('Method');
?>
</th>
    </tr>
    <tr>
        <td valign="top">
            <select name="field">
            <?php 
$fields = Song::get_fields();
foreach ($fields as $key => $value) {
    $name = ucfirst(str_replace('_', ' ', $key));
    ?>
                <option value="<?php 
    echo scrub_out($key);
    ?>
"><?php 
    echo scrub_out($name);
    ?>
</option>
            <?php 
}
?>
            </select>
        </td>
예제 #29
0
 /**
  * status
  * This returns bool/int values for features, loop, repeat and any other features
  * That this localplay method supports. required function
  * This works as in requesting the status.xml file from vlc.
  */
 public function status()
 {
     $arrayholder = $this->_vlc->fullstate();
     //get status.xml via parser xmltoarray
     /* Construct the Array */
     $currentstat = $arrayholder['root']['state']['value'];
     if ($currentstat == 'playing') {
         $state = 'play';
     }
     //change to something ampache understands
     if ($currentstat == 'stop') {
         $state = 'stop';
     }
     if ($currentstat == 'paused') {
         $state = 'pause';
     }
     $array['state'] = $state;
     $array['volume'] = intval(intval($arrayholder['root']['volume']['value']) / 2.6);
     $array['repeat'] = $arrayholder['root']['repeat']['value'];
     $array['random'] = $arrayholder['root']['random']['value'];
     $array['track'] = htmlspecialchars_decode($arrayholder['root']['information']['meta-information']['title']['value'], ENT_NOQUOTES);
     $url_data = $this->parse_url($array['track']);
     $song = new Song($url_data['oid']);
     if ($song->title || $song->get_artist_name() || $song->get_album_name()) {
         $array['track_title'] = $song->title;
         $array['track_artist'] = $song->get_artist_name();
         $array['track_album'] = $song->get_album_name();
     } else {
         $array['track_title'] = htmlspecialchars(substr($arrayholder['root']['information']['meta-information']['title']['value'], 0, 25));
         $array['track_artist'] = htmlspecialchars(substr($arrayholder['root']['information']['meta-information']['artist']['value'], 0, 20));
     }
     return $array;
 }
예제 #30
0
 /**
  * insert
  * This takes the string representation of an image and inserts it into
  * the database. You must also pass the mime type.
  * @param string $source
  * @param string $mime
  * @return boolean
  */
 public function insert($source, $mime = '')
 {
     // Disabled in demo mode cause people suck and upload p**n
     if (AmpConfig::get('demo_mode')) {
         return false;
     }
     // Check to make sure we like this image
     if (!self::test_image($source)) {
         debug_event('Art', 'Not inserting image, invalid data passed', 1);
         return false;
     }
     // Default to image/jpeg if they don't pass anything
     $mime = $mime ? $mime : 'image/jpeg';
     // Blow it away!
     $this->reset();
     if (AmpConfig::get('write_id3_art')) {
         if ($this->type == 'album') {
             $album = new Album($this->uid);
             debug_event('Art', 'Inserting image Album ' . $album->name . ' on songs.', 5);
             $songs = $album->get_songs();
             foreach ($songs as $song_id) {
                 $song = new Song($song_id);
                 $song->format();
                 $id3 = new vainfo($song->file);
                 $data = $id3->read_id3();
                 if (isset($data['tags']['id3v2'])) {
                     $image_from_tag = '';
                     if (isset($data['id3v2']['APIC'][0]['data'])) {
                         $image_from_tag = $data['id3v2']['APIC'][0]['data'];
                     }
                     if ($image_from_tag != $source) {
                         $ndata = array();
                         $ndata['APIC']['data'] = $source;
                         $ndata['APIC']['mime'] = $mime;
                         $ndata = array_merge($ndata, $song->get_metadata());
                         $id3->write_id3($ndata);
                     }
                 }
             }
         }
     }
     $dimensions = Core::image_dimensions($source);
     $width = intval($dimensions['width']);
     $height = intval($dimensions['height']);
     $sizetext = 'original';
     if (!self::check_dimensions($dimensions)) {
         return false;
     }
     if (AmpConfig::get('album_art_store_disk')) {
         self::write_to_dir($source, $sizetext, $this->type, $this->uid, $this->kind);
         $source = null;
     }
     // Insert it!
     $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `width`, `height`, `object_type`, `object_id`, `kind`) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
     Dba::write($sql, array($source, $mime, $sizetext, $width, $height, $this->type, $this->uid, $this->kind));
     return true;
 }