Localisation updates for core messages from translatewiki.net (2009-09-10 22:35 UTC)
[lhc/web/wiklou.git] / js2 / mwEmbed / php / mv_embed_iframe.php
1 <?php
2 /*
3 mv_embed_iframe.php
4 This allows for remote embedding, without exposing the hosting site to remote JavaScript.
5 */
6
7 mv_embed_iframe();
8
9 function mv_embed_iframe() {
10 if ( !function_exists( 'filter_input' ) ) {
11 die( 'your version of PHP lacks <b>filter_input()</b> function<br />' );
12 }
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'; //
18
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:
23 output_page( array(
24 'roe_url' => $roe_url,
25 'width' => $width,
26 'height' => $height,
27 ) );
28 }
29 function output_page( $params ) {
30 extract( $params );
31 ?>
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">
34 <head>
35 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
36 <title>mv_embed iframe</title>
37 <style type="text/css">
38 <!--
39 body {
40 margin-left: 0px;
41 margin-top: 0px;
42 margin-right: 0px;
43 margin-bottom: 0px;
44 }
45 -->
46 </style>
47 <script type="text/javascript" src="mv_embed.js"></script>
48 </head>
49 <body>
50 <video roe="<?php echo $roe_url ?>" width="<?php echo htmlspecialchars( $width ) ?>"
51 height="<?php echo htmlspecialchars( $height ) ?>"></video>
52 </body>
53 </html>
54 <?php
55 }
56
57 /**
58 * JS escape function copied from MediaWiki's Xml::escapeJsString()
59 */
60 function escapeJsString( $string ) {
61 // See ECMA 262 section 7.8.4 for string literal format
62 $pairs = array(
63 "\\" => "\\\\",
64 "\"" => "\\\"",
65 '\'' => '\\\'',
66 "\n" => "\\n",
67 "\r" => "\\r",
68
69 # To avoid closing the element or CDATA section
70 "<" => "\\x3c",
71 ">" => "\\x3e",
72
73 # To avoid any complaints about bad entity refs
74 "&" => "\\x26",
75
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
82 );
83 return strtr( $string, $pairs );
84 }