/** * Return a normalized, internal URL. * * @params string $url An internal URL. * @returns string Normalized internal URL. */ function transformInternalIdnaLink($url) { return \idna_link(\TransformInternalLinks($url)); }
/** * Stud.IP markup for images, audio, video and flash-films */ protected static function markupMedia($markup, $matches) { $tag = $matches[1]; $params = explode(":", $matches[2]); $url = $matches[3]; $whitespace = $matches[4]; foreach ($params as $key => $param) { if ($param) { if (is_numeric($param)) { $width = $param; } elseif (in_array($param, words("left center right"))) { $position = $param; } elseif ($key === 0 && $param[0] === "=") { $title = substr($param, 1); } elseif ($key < count($params) - 1) { $virtual_url = $param . ":" . $params[$key + 1]; if (isURL($virtual_url)) { $link = $virtual_url; } } } } $format_strings = array('img' => '<img src="%s" style="%s" title="%s" alt="%s">', 'audio' => '<audio src="%s" style="%s" title="%s" alt="%s" controls></audio>', 'video' => '<video src="%s" style="%s" title="%s" alt="%s" controls></video>'); $url = TransformInternalLinks($url); $pu = @parse_url($url); if (($pu['scheme'] == 'http' || $pu['scheme'] == 'https') && ($pu['host'] == $_SERVER['HTTP_HOST'] || $pu['host'] . ':' . $pu['port'] == $_SERVER['HTTP_HOST']) && strpos($pu['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0) { $intern = true; $checkpath = urldecode(substr($pu['path'], strlen($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']))); if (strpos($checkpath, '../') === false) { list($pu['first_target']) = explode('/', $checkpath); } else { $pu['first_target'] = false; } } $LOAD_EXTERNAL_MEDIA = Config::GetInstance()->getValue('LOAD_EXTERNAL_MEDIA'); if ($intern && !in_array($pu['first_target'], array('sendfile.php', 'download', 'assets', 'pictures')) && !($pu['first_target'] === 'dispatch.php' && strpos($pu['path'], 'dispatch.php/document/download') !== false)) { return $matches[0]; } elseif ((!$LOAD_EXTERNAL_MEDIA || $LOAD_EXTERNAL_MEDIA === 'deny') && !$intern) { return $matches[0]; } //Mediaproxy? if (!$intern && $LOAD_EXTERNAL_MEDIA === "proxy" && Seminar_Session::is_current_session_authenticated()) { $media_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/media_proxy?url=' . urlencode(decodeHTML(idna_link($url))); } else { $media_url = idna_link($url); } if ($tag === "flash") { $width = $width ? $width : 200; $height = round($width * 0.75); $flash_config = $width > 200 ? $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MAX'] : $GLOBALS['FLASHPLAYER_DEFAULT_CONFIG_MIN']; $media = '<object type="application/x-shockwave-flash" id="FlashPlayer" data="' . Assets::url() . 'flash/player_flv.swf" width="' . $width . '" height="' . $height . '"> <param name="movie" value="' . Assets::url() . 'flash/player_flv.swf"> <param name="allowFullScreen" value="true"> <param name="FlashVars" value="flv=' . urlencode(decodeHTML($media_url)) . '&startimage=' . $link . $flash_config . '"> <embed src="' . Assets::url() . 'flash/player_flv.swf" movie="$media_url" type="application/x-shockwave-flash" FlashVars="flv=' . urlencode(decodeHTML($media_url)) . '&startimage=' . $link . $flash_config . '"> </object>'; } else { $media = sprintf($format_strings[$tag], $media_url, isset($width) ? "width: " . $width . "px;" : "", $title, $title); } if ($tag === 'audio') { $random_id = 'audio-' . substr(md5(uniqid('audio', true)), -8); $media = str_replace('<audio ', '<audio id="' . $random_id . '" onerror="STUDIP.Audio.handle(this);" ', $media); } if ($link && $tag === "img") { $media = sprintf('<a href="%s"%s>%s</a>', $link, !isLinkIntern($link) ? ' target="_blank"' : "", $media); } if ($position) { $media = '<div style="text-align: ' . $position . '">' . $media . '</div>'; } $media .= $whitespace; return $media; }