/** * Modifies the URL to swap protocols from http to rtsp or vice versa */ function do_protocol_switch() { $parsed = parse_url($this->manager->get_value('url')); $protocol = $this->get_protocol(); if ($parsed['scheme'] != $protocol) { $new_url = alter_protocol($this->manager->get_value('url'), $parsed['scheme'], $protocol); $this->manager->set_value('url', $new_url); } }
/** * Returns the html markup to display the media work according the av module specifications. * @return string */ public function get_html_markup() { $av_files = $this->displayer->get_media_files(); $markup = ''; $av_file_count = count($av_files); if ($av_file_count > 0) { $prev_format = ''; $markup .= '<div class="avFiles">' . "\n"; $first_list = true; $query_args = array(); if (!empty($this->request['show_transcript'])) { $query_args['show_transcript'] = 'true'; } foreach ($av_files as $av_file) { if ($prev_format != $av_file->get_value('media_format')) { if (!$first_list) { $markup .= '</ul>' . "\n"; } else { $first_list = false; } $markup .= '<ul>' . "\n"; } if ($av_file_count == 1 || !empty($this->av_module->request['av_file_id']) && $this->av_module->request['av_file_id'] == $av_file->id()) { $is_current = true; $attrs = ' class="current"'; } else { $is_current = false; $attrs = ''; } $markup .= '<li' . $attrs . '>'; if ($is_current) { $markup .= '<strong>'; } elseif ($av_file->get_value('url')) { $args = $query_args + array('av_file_id' => $av_file->id()); $markup .= '<a href="' . $this->av_module->construct_link($this->media_work, $args) . '" title="' . $av_file->get_value('media_format') . " " . $av_file->get_value('av_type') . ': ' . htmlspecialchars($this->media_work->get_value('name')) . '" class="fileLink">'; } $file_desc = ''; if ($av_file->get_value('av_part_number')) { $file_desc .= 'Part ' . $av_file->get_value('av_part_number'); if ($av_file->get_value('av_part_total')) { $file_desc .= ' of ' . $av_file->get_value('av_part_total'); } $file_desc .= ': '; } if ($av_file->get_value('description')) { $file_desc .= $av_file->get_value('description') . ': '; } if (!empty($this->media_format_overrides[$av_file->get_value('media_format')])) { $file_desc .= $this->av_module->media_format_overrides[$av_file->get_value('media_format')]; } else { $file_desc .= $av_file->get_value('media_format'); } $file_desc .= ' ' . $av_file->get_value('av_type'); $markup .= $file_desc; if ($is_current) { $markup .= '</strong>'; } elseif ($av_file->get_value('url')) { $markup .= "</a>"; } if ($av_file->get_value('media_size') || $av_file->get_value('media_duration') || $av_file->get_value('media_quality')) { $markup .= " <span class='smallText'>("; $xtra_info = array(); if ($av_file->get_value('media_size')) { $xtra_info[] = $av_file->get_value('media_size'); } if ($av_file->get_value('media_duration')) { $xtra_info[] = $av_file->get_value('media_duration'); } if ($av_file->get_value('media_quality')) { $xtra_info[] = $av_file->get_value('media_quality'); } if ($av_file->get_value('default_media_delivery_method')) { $xtra_info[] = str_replace('_', ' ', $av_file->get_value('default_media_delivery_method')); } $markup .= implode(', ', $xtra_info); $markup .= ')</span>' . "\n"; } if ($is_current && $av_file->get_value('url')) { $this->displayer->set_current_media_file($av_file); $embed_markup = $this->displayer->get_display_markup(); if (!empty($embed_markup)) { $markup .= '<div class="player">' . "\n" . $embed_markup . "\n" . '</div>' . "\n"; $tech_note = $this->displayer->get_latest_tech_note(); if (!empty($tech_note)) { $markup .= '<div class="techNote">' . $tech_note . '</div>' . "\n"; } } $other_links = array(); if ($av_file->get_value('media_is_progressively_downloadable') == 'true') { $other_links[] = '<a href="' . alter_protocol($av_file->get_value('url'), 'rtsp', 'http') . '" title="Direct link to download "' . htmlspecialchars($this->media_work->get_value('name') . ': ' . $file_desc) . '"" class="download">Download file</a>'; } if ($av_file->get_value('media_is_streamed') == 'true') { $other_links[] = '<a href="' . alter_protocol($av_file->get_value('url'), 'http', 'rtsp') . '" title="Direct link to stream "' . htmlspecialchars($this->media_work->get_value('name') . ': ' . $file_desc) . '"" class="stream">Direct link to stream</a>'; } if (empty($other_links)) { $other_links[] = '<a href="' . $av_file->get_value('url') . '" title="Direct link to "' . htmlspecialchars($this->media_work->get_value('name') . ': ' . $file_desc) . '"">Direct link to file</a>'; } $markup .= '<p class="direct">' . implode(' ', $other_links) . '</p>' . "\n"; } if (!$av_file->get_value('url')) { $owner = $av_file->get_owner(); if (!empty($owner) && $owner->get_value('name_cache')) { $phrase = 'File not available online. Please contact site maintainer (' . $owner->get_value('name_cache') . ') for this file.'; } else { $phrase = 'File not available online. Please contact site maintainer for this file.'; } $markup .= ' <em>' . $phrase . '</em>'; } $markup .= "</li>\n"; $prev_format = $av_file->get_value('media_format'); } $markup .= '</ul>' . "\n"; $markup .= '</div>' . "\n"; } return $markup; }
function show_news_item(&$news_item) { $title = $news_item->get_value('release_title'); $parameters = $news_item->get_value('parameters'); $link = (strpos($news_item->get_value('page_url'), 'http') === false) // if it is not absoulte build the host for backwards compatibility ? '//' . REASON_HOST . $news_item->get_value('page_url') : $news_item->get_value('page_url'); // else it is what it is - an absolute multidomain safe URL if (!on_secure_page()) $link = alter_protocol($link, 'https', 'http'); // attempt to link over http if the home page is requested that way if (!empty($parameters)) { if ($this->textonly) $parameters['textonly'] = 1; foreach ($parameters as $k=>$v) { $param[$k] = $v; } $link .= '?' . implode_with_keys('&',$param); } echo '<a href="'. $link . '">'.$title.'</a>'; }
protected function get_dest_page_link($secure = null) { $parts = parse_url($this->dest_page); $fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : ''; if ($secure === true) { $link = alter_protocol($this->dest_page, 'http', securest_available_protocol()) . $fragment; } else { if ($secure === false) { $link = alter_protocol($this->dest_page, 'https', 'http') . $fragment; } else { $link = $this->dest_page; } } return $link; }
reason_include_once('classes/entity.php'); reason_include_once('function_libraries/url_utils.php'); $id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : ''; settype($id, 'integer'); $db = connectDB(REASON_DB); if (!empty($id)) { $file = new entity($id); } if (empty($id) or $file->get_value('type') != id_of('av_file') or $file->get_value('state') != 'Live') { if (empty($id)) { $xtra = 'Invalid id passed to script'; } elseif ($file->get_value('type') != id_of('av_file')) { $xtra = 'id passed to script is not the id of a media file'; } elseif ($file->get_value('state') != 'Live') { $xtra = 'media file requested is ' . strtolower($file->get_value('state')); } if (!empty($_SERVER['HTTP_REFERER'])) { $xtra .= ' ( Referrer: ' . $_SERVER['HTTP_REFERER'] . ' )'; } $file = null; trigger_error('Bad request on media link generator script - ' . $xtra); } else { $url = $file->get_value('url'); if ($file->get_value('reason_managed_media') && $file->get_value('default_media_delivery_method') != 'streaming') { $url = alter_protocol($url, 'http', 'rtsp'); } header('Content-Type: video/quicktime'); echo '<?xml version="1.0"?>' . "\n"; echo '<?quicktime type="application/x-quicktime-media-link"?>' . "\n"; echo '<embed src="' . $url . '" />'; }