Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 91
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2    $baseURL = "http://ajax.googleapis.com/ajax/libs/";
3    $libraries = array(
4        "Dojo" => array(
5            "versions" => array( "1.1.1", "1.2.0", "1.2.3", "1.3.0", "1.3.1", "1.3.2", "1.4.0", "1.4.1", "1.4.3", "1.5.0" ),
6            "url" => "dojo/XYZ/dojo/dojo.xd.js"
7        ),
8        "ExtCore" => array(
9            "versions" => array( "3.0.0", "3.1.0" ),
10            "url" => "ext-core/XYZ/ext-core.js"
11        ),
12        "jQuery" => array(
13            "versions" => array( "1.2.3", "1.2.6", "1.3.0", "1.3.1", "1.3.2", "1.4.0", "1.4.1", "1.4.2", "1.4.3", "1.4.4", "1.5.0" ),
14            "url" => "jquery/XYZ/jquery.min.js"
15        ),
16        "jQueryUI" => array(
17            "versions" => array( "1.5.2", "1.5.3", "1.6.0", "1.7.0", "1.7.1", "1.7.2", "1.7.3", "1.8.0", "1.8.1", "1.8.2", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9" ),
18            "url" => "jqueryui/XYZ/jquery-ui.min.js"
19        ),
20        "MooTools" => array(
21            "versions" => array( "1.1.1", "1.1.2", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.2.5", "1.3.0" ),
22            "url" => "mootools/XYZ/mootools-yui-compressed.js"
23        ),
24        "Prototype" => array(
25            "versions" => array( "1.6.0.2", "1.6.0.3", "1.6.1.0", "1.7.0.0" ),
26            "url" => "prototype/XYZ/prototype.js"
27        ),
28        "scriptaculous" => array(
29            "versions" => array( "1.8.1", "1.8.2", "1.8.3" ),
30            "url" => "scriptaculous/XYZ/scriptaculous.js"
31        ),
32        "SWFObject" => array(
33            "versions" => array( "2.1", "2.2" ),
34            "url" => "swfobject/XYZ/swfobject.js"
35        ),
36        "YUI" => array(
37            "versions" => array( "2.6.0", "2.7.0", "2.8.0r4", "2.8.1", "2.8.2", "3.3.0" ),
38            "url" =>    "yui/XYZ/build/yui/yui-min.js"
39        )
40    );
41
42    if( count($_POST) ) {
43        $includes = array();
44        foreach( $_POST as $name => $ver ){
45            if ( empty( $libraries[ $name ] )) {
46                echo "unsupported library ". $name;
47                exit;
48            }
49        
50            $url = $libraries[ $name ][ "url" ];
51            if( $name == "YUI" && $ver[0] == "2" ) {
52                $url = str_replace( "/yui", "/yuiloader", $url);
53            }
54            
55            if ( empty( $libraries[ $name ][ "versions" ][ $ver ] )) {
56                echo "library ". $name ." not supported in version ". $ver;
57                exit;
58            }
59            
60            $include = "<script src='$baseURL".str_replace("XYZ", $ver, $url)."'></script>\n";
61            if( $lib == "prototype" ) { // prototype must be included first
62                array_unshift( $includes, $include );
63            } else {
64                array_push( $includes, $include );
65            }
66        }
67
68        $includes = implode( "\n", $includes );
69        $suite = file_get_contents( "index.html" );
70        echo str_replace( "<!-- Includes -->", $includes, $suite );
71        exit;
72    }
73?>
74<!DOCTYPE html>
75<html>
76<head>
77    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
78    <title>Run jQuery Test Suite Polluted</title>
79    <style type="text/css">
80        .otherlibs fieldset {
81            width: 400px
82        }
83        .otherlibs label{
84            margin: 5px 0px 5px 20px;
85        }
86    </style>
87</head>
88
89<body id="body">
90    <h1 id="header">jQuery Test Suite</h1>
91    <h2 id="banner" class="fail"></h2>
92    <h2 id="userAgent">Choose other libraries to include</h2>
93
94    <form class="otherlibs" action="./polluted.php" method="POST">
95        <?php
96            foreach( $libraries as $name => $data ) {
97                echo "<fieldset><legend>$name</legend>";
98                $i = 0;
99                foreach( $data[ "versions" ] as $ver ) {
100                    $i++;
101                    echo "<label><input type='radio' name='$name' value='$ver' />$ver</label>";
102                    if( !($i % 4) ) echo "<br />";
103                }
104                echo "</fieldset>";
105            }
106        ?>
107        <input type="submit" value=" Run " class="submit" />
108    </form>
109</body>
110</html>