rubo77

Untitled

Sep 30th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html><head>
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  3. <script src="http://www.x-non.com/json/jquery.json-2.4.min.js"> </script>
  4. <title>circumvent max_input_vars limit in PHP</title></head>
  5. <body>
  6. <a href="max_input_vars3.php">restart</a><br>
  7. <?php
  8. if(!empty($_REQUEST)) {
  9.     echo count($_REQUEST,1)." num request variables
  10.     <pre>";
  11.    
  12.     if(isset($_REQUEST['serialized_data'])){
  13.         #var_export($_REQUEST['serialized_data']);
  14.         $params=json_decode(urldecode($_REQUEST['serialized_data']),true);
  15.         echo count($params,1)." serialized variables:";
  16.         var_export($params);
  17.     }else var_export($_REQUEST);
  18.     echo "</pre>";
  19. }else {
  20.     ?><h1>visible post form 1</h1>
  21.     <form method="post" id="f" action=""><?
  22.         for($i=0;$i<10;$i++) echo '<input type="hiddden" value="v'.$i.'<" name="v'.$i.'">';
  23.         ?><input type="submit" name="sadosa">
  24.     </form>
  25.     <h1>hidden form 2 1100 vars</h1>
  26.     <form method="post" id="f2">
  27.         <input type="text" value="v&quot;a" name="somequote"><?
  28.         for($i=0;$i<1100;$i++) echo '<input type="hidden" value="v'.$i.'" name="v'.$i.'">';
  29.         ?><textarea name="bla">blubb</textarea>
  30. <select name="bla"><option>test</select>
  31. <input type="submit">
  32.     </form>
  33.     <h1>multidimensional form</h1>
  34.     <form method="post" id="m"><?
  35.         for($i=0;$i<5;$i++){
  36.             for($k=0;$k<2;$k++){
  37.                 echo '<input type="hidden" value="m'.$i.'_'.$k.'" name="m['.$i.']['.$k.']">';
  38.             }
  39.         }?><input type="submit">
  40.     </form>
  41.     <h1>get form</h1>
  42.     <form method="get" id="g"><?
  43.         for($i=0;$i<10;$i++) echo '<input type="hidden" value="v'.$i.'" name="v'.$i.'">';
  44.         ?><input type="submit">
  45.     </form>
  46.     <?
  47.  
  48.  
  49. }
  50. ?>
  51.     <script>
  52. $.fn.serializeObject = function(){
  53.     var o = {};
  54.     var a = this.serializeArray();
  55.     $.each(a, function() {
  56.         if (o[this.name]) {
  57.             if (!o[this.name].push) {
  58.                 o[this.name] = [o[this.name]];
  59.             }
  60.             o[this.name].push(this.value || '');
  61.         } else {
  62.             o[this.name] = this.value || '';
  63.         }
  64.     });
  65.     return o;
  66. };
  67.     // this disables all form elements and creates only one new element that contains all data serialized
  68.     $('form[method=post]').click(function() {
  69.         var data = "" + $.toJSON($(this).serializeObject());
  70.         var num_form_elements=$(this).find('input, select, textarea').not('[type="submit"]').length;
  71.         var num_elements_already_disabled=$(this).find('input:disabled, select:disabled, textarea:disabled').length;
  72.         $(this).find('input, select, textarea').not('[type="submit"]').attr("disabled", true);
  73.         $(this).append('    <input type="hidden" name="num_form_elements" value="'+num_form_elements+'">');  // to mark request
  74.         $(this).append('    <input type="hidden" name="num_elements_already_disabled" value="'+num_elements_already_disabled+'">');  // to mark request
  75.         $(this).append('    <textarea style="display:none" name="serialized_data">'+data+'</textarea>'); // maybe .replace(/</g,'&lt;')
  76.        
  77.     });
  78.     </script>
  79. </body></html><?
Advertisement
Add Comment
Please, Sign In to add comment