61
* Private function for getting the information for this object from the database
63
private function _get_info() {
65
$id = Dba::escape($this->id);
67
$sql = "SELECT * FROM `live_stream` WHERE `id`='$id'";
68
$db_results = Dba::query($sql);
70
$results = Dba::fetch_assoc($db_results);
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);
90
$genre = new Genre($this->genre);
92
$this->f_genre = $genre->f_link;
100
* This returns the URL for this live stream
102
public function get_url() {
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
116
80
// Verify the incoming data
117
81
if (!$data['id']) {
82
// FIXME: Untranslated
118
83
Error::add('general','Missing ID');
121
86
if (!$data['name']) {
87
// FIXME: Untranslated
122
88
Error::add('general','Name Required');
125
if (!preg_match("/^https?:\/\/.+/",$data['url'])) {
126
Error::add('general','Invalid URL must be https:// or http://');
129
$genre = new Genre($data['genre']);
131
Error::add('general','Invalid Genre Selected');
91
$allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
93
$elements = explode(":",$data['url']);
95
if (!in_array($elements['0'],$allowed_array)) {
96
// FIXME: Untranslated
97
Error::add('general','Invalid URL must be mms:// , https:// or http://');
100
if (Error::occurred()) {
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']);
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);
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');
167
if (!preg_match("/^https?:\/\/.+/",$data['url'])) {
133
$allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
135
$elements = explode(":",$data['url']);
137
if (!in_array($elements['0'],$allowed_array)) {
168
138
Error::add('url','Invalid URL must be http:// or https://');
171
// If they specified other try to use that
172
if (strlen($data['other_genre'])) {
173
$data['genre'] = Catalog::check_genre($data['other_genre']);
176
// Make sure it's a real genre
177
$genre = new Genre($data['genre']);
179
Error::add('genre','Invalid Genre');
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');
188
if (Error::$state) { return false; }
148
if (Error::occurred()) { return false; }
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']);
195
154
$catalog = $catalog->id;
196
155
$frequency = Dba::escape($data['frequency']);
197
156
$call_sign = Dba::escape($data['call_sign']);
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);
204
163
return $db_results;
184
* This is needed by the media interface
186
public function native_stream() {
194
* This is needed by the media interface
196
public static function play_url($oid,$sid='',$force_http='') {
198
$radio = new Radio($oid);
206
* This is needed by the media interface
208
public function has_flag() {
216
* Needed by the media interface
218
public function stream_cmd() {
223
223
} //end of radio class