4 This allows for remote embedding, without exposing the hosting site to remote JavaScript.
9 function mv_embed_iframe() {
10 if ( !function_exists( 'filter_input' ) ) {
11 die( 'your version of PHP lacks <b>filter_input()</b> function<br />' );
13 // Default to null media if not provided
14 $stream_name = ( isset( $_GET['sn'] ) ) ?
$_GET['sn'] : die( 'no stream name provided' );
15 $time = ( isset( $_GET['t'] ) ) ?
$_GET['t']: '';
16 $width = ( isset( $_GET['width'] ) ) ?
intval( $_GET['width'] ) : '400';
17 $height = ( isset( $_GET['height'] ) ) ?
intval( $_GET['height'] ) : '300'; //
19 $roe_url = 'http://metavid.org/wiki/Special:MvExportStream?feed_format=roe' .
20 '&stream_name=' . htmlspecialchars( $stream_name ) .
21 '&t=' . htmlspecialchars( $time );
22 // Everything good, output page:
24 'roe_url' => $roe_url,
29 function output_page( $params ) {
32 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
33 <html xmlns
="http://www.w3.org/1999/xhtml">
35 <meta http
-equiv
="Content-Type" content
="text/html; charset=iso-8859-1" />
36 <title
>mv_embed iframe
</title
>
37 <style type
="text/css">
47 <script type
="text/javascript" src
="mv_embed.js"></script
>
50 <video roe
="<?php echo $roe_url ?>" width
="<?php echo htmlspecialchars( $width ) ?>"
51 height
="<?php echo htmlspecialchars( $height ) ?>"></video
>
58 * JS escape function copied from MediaWiki's Xml::escapeJsString()
60 function escapeJsString( $string ) {
61 // See ECMA 262 section 7.8.4 for string literal format
69 # To avoid closing the element or CDATA section
73 # To avoid any complaints about bad entity refs
76 # Work around https://bugzilla.mozilla.org/show_bug.cgi?id=274152
77 # Encode certain Unicode formatting chars so affected
78 # versions of Gecko don't misinterpret our strings;
79 # this is a common problem with Farsi text.
80 "\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
81 "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
83 return strtr( $string, $pairs );