polluted.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. if( count($_POST) ) {
  42. $includes = array();
  43. foreach( $_POST as $name => $ver ){
  44. if ( empty( $libraries[ $name ] )) {
  45. echo "unsupported library ". $name;
  46. exit;
  47. }
  48. $url = $libraries[ $name ][ "url" ];
  49. if( $name == "YUI" && $ver[0] == "2" ) {
  50. $url = str_replace( "/yui", "/yuiloader", $url);
  51. }
  52. if ( empty( $libraries[ $name ][ "versions" ][ $ver ] )) {
  53. echo "library ". $name ." not supported in version ". $ver;
  54. exit;
  55. }
  56. $include = "<script src='$baseURL".str_replace("XYZ", $ver, $url)."'></script>\n";
  57. if( $lib == "prototype" ) { // prototype must be included first
  58. array_unshift( $includes, $include );
  59. } else {
  60. array_push( $includes, $include );
  61. }
  62. }
  63. $includes = implode( "\n", $includes );
  64. $suite = file_get_contents( "index.html" );
  65. echo str_replace( "<!-- Includes -->", $includes, $suite );
  66. exit;
  67. }
  68. ?>
  69. <!DOCTYPE html>
  70. <html>
  71. <head>
  72. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  73. <title>Run jQuery Test Suite Polluted</title>
  74. <style type="text/css">
  75. .otherlibs fieldset {
  76. width: 400px
  77. }
  78. .otherlibs label{
  79. margin: 5px 0px 5px 20px;
  80. }
  81. </style>
  82. </head>
  83. <body id="body">
  84. <h1 id="header">jQuery Test Suite</h1>
  85. <h2 id="banner" class="fail"></h2>
  86. <h2 id="userAgent">Choose other libraries to include</h2>
  87. <form class="otherlibs" action="./polluted.php" method="POST">
  88. <?php
  89. foreach( $libraries as $name => $data ) {
  90. echo "<fieldset><legend>$name</legend>";
  91. $i = 0;
  92. foreach( $data[ "versions" ] as $ver ) {
  93. $i++;
  94. echo "<label><input type='radio' name='$name' value='$ver' />$ver</label>";
  95. if( !($i % 4) ) echo "<br />";
  96. }
  97. echo "</fieldset>";
  98. }
  99. ?>
  100. <input type="submit" value=" Run " class="submit" />
  101. </form>
  102. </body>
  103. </html>