~ubuntu-branches/ubuntu/lucid/ampache/lucid

« back to all changes in this revision

Viewing changes to lib/class/radio.class.php

  • Committer: Bazaar Package Importer
  • Author(s): Charlie Smotherman
  • Date: 2009-07-07 07:23:35 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090707072335-soq0jyo59mgopzd2
Tags: 3.5.1-0ubuntu1
 * New upstream release.  Summary of new features:  (LP: #377016)
   - Make the PHP error a little clearer for windows users by indicating
     that their version of PHP is < 5.3 (required for windows)
   - Fix random methods not working for Localplay
   - Fix extra space on prefixed albums (Thx ibizaman)
   - Add missing operator on tag and rating searches so they will
     work with other methods (Thx kiehnet@netscape.net)
   - Fix get_art_url() so it returns something... 
   - Fix problem with creating new playlists where it doesn't work
     but appending to an existing did. 
   - Fixed issue with url_to_song, also cleaned up the code a bit
   - Fixed issue with Random All Catalogs
   - Fixed issues with API and Tag methods not working as advertised
   - Fix endless loop in getid3() with malformed genre tags in mp3s
   - Fixed show test page always returning false on web path
   - Update Man page to adhear to newer Debian rules
   - Fixed issue with Videos being incorrectly registered with stats
     and now playing as songs. 
   - Fixed missing > in HTML for song row
 * Bumped Standards-Version to 3.8.2, no changes needed.
 * Bumped debhelper to dh 7.
   - increased debian/compat to 7.
   - debian/rules removed dh_clean -k in favor of dh_prep
 * Lintian complains of FreeMonoMedium.ttf being an embeded fonts package.
   FreeMonoMedium.ttf is actually part of the ttf-freefont package.
   - added ttf-freefont to the Depends section of debian/control.
   - added -XFreeMono-Medium to dh_install in debian/rules.
   - added FreeMono.ttf symbolic link to debian/links.
 * Lintian complains of the wrong file permissions for 
   -  /locale/base/gather-messages.sh, added -Xgather-messages.sh to 
   debian/rules, gather-messages.sh is not used by ampache proper and 
   can be safely removed.  It is only utilized by developers who are 
   creating or editing the translation files.
   -  /locale/pl_PL/LC_MESSAGES/messages.po added find and chmod rule 
   to debian/rules.
   -  /locale/pl_PL/LC_MESSAGES/messages.mo added find and chmod rule 
   to debian/rules.
   -  /docs/CHANGELOG added find and chmod rule to debian/rules.
 * Lintian complains of wrong-name-for-upstream-changelog
   -  install upstream CHANGELOG to /usr/share/ampache/www/docs
   -  added find and gzip -9 rule to debian/rules
   -  added symlink creation to debian/links to link
      /usr/share/ampache/www/docs/CHANGELOG.gz to 
      /usr/share/doc/ampache/changelog.gz  
 * Lacy Marrow has responded and has stated that he is dropping the GPL-3 
   licensing of his work and is now releasing version 5.9.5 of the 
   XSPF JukeBox under the same BSD license that the original version of XSPF 
   Music Player was released under (XSPF JukeBox is based on XSPF Music 
   Player).  So now XSPF Music Player and XSPF JukeBox are now released under
   the same BSD type license.  This closes RC Bug #526719.  Closes: #526719
   - Updated debian/copyright to refect this.
 * Added dh_installman to debian/rules so the manpage now installs correctly.
   - Added debian/ampache.manpages.
 * debian/ampache.config downgraded db_input to medium
 * debian/copyright removed (C) in favor of the word copyright.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 * This handles the internet radio stuff, that is inserted into live_stream
26
26
 * this can include podcasts or what-have-you
27
27
 */
28
 
class Radio {
 
28
class Radio extends database_object implements media {
29
29
 
30
30
        /* DB based variables */
31
31
        public $id; 
34
34
        public $url; 
35
35
        public $frequency;
36
36
        public $call_sign;
37
 
        public $genre; 
38
37
        public $catalog; 
39
38
 
40
39
        /**
43
42
         */
44
43
        public function __construct($id) { 
45
44
 
46
 
                $this->id = intval($id);
47
 
 
48
 
                if (!$this->id) { return false; }
49
 
 
50
 
                $info = $this->_get_info();
 
45
                $info = $this->get_info($id,'live_stream');
51
46
 
52
47
                // Set the vars
53
48
                foreach ($info as $key=>$value) { 
57
52
        } // constructor
58
53
 
59
54
        /**
60
 
         * _get_info
61
 
         * Private function for getting the information for this object from the database 
62
 
         */
63
 
        private function _get_info() { 
64
 
 
65
 
                $id = Dba::escape($this->id);
66
 
 
67
 
                $sql = "SELECT * FROM `live_stream` WHERE `id`='$id'";
68
 
                $db_results = Dba::query($sql);
69
 
 
70
 
                $results = Dba::fetch_assoc($db_results);
71
 
                
72
 
                return $results;
73
 
 
74
 
        } // _get_info
75
 
 
76
 
        /**
77
55
         * format
78
56
         * This takes the normal data from the database and makes it pretty
79
57
         * for the users, the new variables are put in f_??? and f_???_link
87
65
                $this->f_callsign       = scrub_out($this->call_sign); 
88
66
                $this->f_frequency      = scrub_out($this->frequency); 
89
67
 
90
 
                $genre = new Genre($this->genre); 
91
 
                $genre->format(); 
92
 
                $this->f_genre          = $genre->f_link; 
93
 
 
94
68
                return true; 
95
69
 
96
70
        } // format
97
71
 
98
72
        /**
99
 
         * get_url      
100
 
         * This returns the URL for this live stream
101
 
         */
102
 
        public function get_url() { 
103
 
 
104
 
                
105
 
 
106
 
        } // get_url 
107
 
 
108
 
        /**
109
73
         * update
110
74
         * This is a static function that takes a key'd array for input
111
75
         * it depends on a ID element to determine which radio element it 
115
79
 
116
80
                // Verify the incoming data
117
81
                if (!$data['id']) { 
 
82
                        // FIXME: Untranslated
118
83
                        Error::add('general','Missing ID'); 
119
84
                } 
120
85
 
121
86
                if (!$data['name']) { 
 
87
                        // FIXME: Untranslated
122
88
                        Error::add('general','Name Required'); 
123
89
                } 
124
90
 
125
 
                if (!preg_match("/^https?:\/\/.+/",$data['url'])) { 
126
 
                        Error::add('general','Invalid URL must be https:// or http://'); 
127
 
                } 
128
 
 
129
 
                $genre = new Genre($data['genre']); 
130
 
                if (!$genre->name) { 
131
 
                        Error::add('general','Invalid Genre Selected'); 
132
 
                } 
133
 
 
134
 
                if (Error::$state) { 
 
91
                $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp'); 
 
92
 
 
93
                $elements = explode(":",$data['url']); 
 
94
                
 
95
                if (!in_array($elements['0'],$allowed_array)) { 
 
96
                        // FIXME: Untranslated
 
97
                        Error::add('general','Invalid URL must be mms:// , https:// or http://'); 
 
98
                } 
 
99
 
 
100
                if (Error::occurred()) { 
135
101
                        return false; 
136
102
                } 
137
103
 
141
107
                $url            = Dba::escape($data['url']); 
142
108
                $frequency      = Dba::escape($data['frequency']); 
143
109
                $call_sign      = Dba::escape($data['call_sign']); 
144
 
                $genre          = Dba::escape($data['genre']); 
145
110
                $id             = Dba::escape($data['id']); 
146
111
 
147
 
                $sql = "UPDATE `live_stream` SET `name`='$name',`site_url`='$site_url',`url`='$url',`genre`='$genre'" . 
 
112
                $sql = "UPDATE `live_stream` SET `name`='$name',`site_url`='$site_url',`url`='$url'" . 
148
113
                        ",`frequency`='$frequency',`call_sign`='$call_sign' WHERE `id`='$id'"; 
149
114
                $db_results = Dba::query($sql); 
150
115
 
161
126
 
162
127
                // Make sure we've got a name
163
128
                if (!strlen($data['name'])) { 
 
129
                        // FIXME: Untranslated
164
130
                        Error::add('name','Name Required'); 
165
131
                } 
166
132
 
167
 
                if (!preg_match("/^https?:\/\/.+/",$data['url'])) { 
 
133
                $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp'); 
 
134
 
 
135
                $elements = explode(":",$data['url']); 
 
136
                
 
137
                if (!in_array($elements['0'],$allowed_array)) { 
168
138
                        Error::add('url','Invalid URL must be http:// or https://'); 
169
139
                } 
170
140
 
171
 
                // If they specified other try to use that
172
 
                if (strlen($data['other_genre'])) { 
173
 
                        $data['genre'] = Catalog::check_genre($data['other_genre']); 
174
 
                } 
175
 
 
176
 
                // Make sure it's a real genre
177
 
                $genre = new Genre($data['genre']); 
178
 
                if (!$genre->name) { 
179
 
                        Error::add('genre','Invalid Genre'); 
180
 
                } 
181
 
 
182
141
                // Make sure it's a real catalog
183
142
                $catalog = new Catalog($data['catalog']); 
184
143
                if (!$catalog->name) { 
 
144
                        // FIXME: Untranslated
185
145
                        Error::add('catalog','Invalid Catalog'); 
186
146
                } 
187
147
 
188
 
                if (Error::$state) { return false; } 
 
148
                if (Error::occurred()) { return false; } 
189
149
 
190
150
                // Clean up the input
191
151
                $name           = Dba::escape($data['name']); 
192
152
                $site_url       = Dba::escape($data['site_url']); 
193
153
                $url            = Dba::escape($data['url']); 
194
 
                $genre          = $genre->id; 
195
154
                $catalog        = $catalog->id; 
196
155
                $frequency      = Dba::escape($data['frequency']); 
197
156
                $call_sign      = Dba::escape($data['call_sign']); 
198
157
 
199
158
                // If we've made it this far everything must be ok... I hope
200
 
                $sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`genre`,`catalog`,`frequency`,`call_sign`) " . 
201
 
                        "VALUES ('$name','$site_url','$url','$genre','$catalog','$frequency','$call_sign')"; 
 
159
                $sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`frequency`,`call_sign`) " . 
 
160
                        "VALUES ('$name','$site_url','$url','$catalog','$frequency','$call_sign')"; 
202
161
                $db_results = Dba::query($sql); 
203
162
 
204
163
                return $db_results;  
220
179
 
221
180
        } // delete
222
181
 
 
182
        /**
 
183
         * native_stream
 
184
         * This is needed by the media interface
 
185
         */
 
186
        public function native_stream() { 
 
187
 
 
188
 
 
189
 
 
190
        } // native_stream 
 
191
 
 
192
        /**
 
193
         * play_url
 
194
         * This is needed by the media interface
 
195
         */
 
196
        public static function play_url($oid,$sid='',$force_http='') { 
 
197
 
 
198
                $radio = new Radio($oid); 
 
199
                
 
200
                return $radio->url; 
 
201
 
 
202
        } // play_url  
 
203
 
 
204
        /**
 
205
         * has_flag
 
206
         * This is needed by the media interface
 
207
         */
 
208
        public function has_flag() { 
 
209
 
 
210
 
 
211
 
 
212
        } // has_flag
 
213
 
 
214
        /**
 
215
         * stream_cmd
 
216
         * Needed by the media interface
 
217
         */
 
218
        public function stream_cmd() { 
 
219
 
 
220
 
 
221
        } // stream_cmd
 
222
 
223
223
} //end of radio class
224
224
 
225
225
?>