Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <title>circumvent max_input_vars limit in PHP</title></head>
- <body>
- <a href="max_input_vars3.php">restart</a><br>
- <?php
- if(!empty($_REQUEST)) {
- echo count($_REQUEST,1)." num request variables
- <pre>";
- if(isset($_REQUEST['serialized_data'])){
- $params = array();
- parse_str(urldecode($_REQUEST['serialized_data']), $params);
- echo count($params,1)." serialized variables:";
- var_export($params);
- }else var_export($_REQUEST);
- echo "</pre>";
- }else {
- ?><h1>visible post form 1</h1>
- <form method="post" id="f" action=""><?
- for($i=0;$i<10;$i++) echo '<input type="hiddden" value="v'.$i.'<" name="v'.$i.'">';
- ?><input type="submit" name="sadosa">
- </form>
- <h1>hidden form 2 1100 vars</h1>
- <form method="post" id="f2">
- <input type="text" value="v"a" name="somequote"><?
- for($i=0;$i<1100;$i++) echo '<input type="hidden" value="v'.$i.'" name="v'.$i.'">';
- ?><textarea name="bla">blubb</textarea>
- <select name="bla"><option>test</select>
- <input type="submit">
- </form>
- <h1>multidimensional form</h1>
- <form method="post" id="m"><?
- for($i=0;$i<5;$i++){
- for($k=0;$k<2;$k++){
- echo '<input type="hidden" value="m'.$i.'_'.$k.'" name="m['.$i.']['.$k.']">';
- }
- }?><input type="submit">
- </form>
- <h1>get form</h1>
- <form method="get" id="g"><?
- for($i=0;$i<10;$i++) echo '<input type="hidden" value="v'.$i.'" name="v'.$i.'">';
- ?><input type="submit">
- </form>
- <?
- }
- ?>
- <script>
- // this disables all form elements and creates only one new element that contains all data serialized
- $('form[method=post]').click(function() {
- var data=$(this).serialize();
- var num_form_elements=$(this).find('input, select, textarea').not('[type="submit"]').length;
- var num_elements_already_disabled=$(this).find('input:disabled, select:disabled, textarea:disabled').length;
- $(this).find('input, select, textarea').not('[type="submit"]').attr("disabled", true);
- $(this).append(' <input type="hidden" name="num_form_elements" value="'+num_form_elements+'">'); // to mark request
- $(this).append(' <input type="hidden" name="num_elements_already_disabled" value="'+num_elements_already_disabled+'">'); // to mark request
- $(this).append(' <textarea style="display:true" name="serialized_data">'+(data)+'</textarea>'); // maybe .replace(/</g,'<')
- // or use instead of a hidden input:
- //$(this).append(' <input type="hidden" name="serialized_data" value="'+data+'">'); // maybe .replace(/"/g,'"')
- /*
- TODO: find submitbutton and clone it, somehow like var submitbutton = $(this).find("input[type=submit]").first();
- $( "form[method=post]" ).each(function( index ) {
- $(this).attr("uniqueID",index)
- });
- ...
- var uniqueID=$(this).attr("uniqueID");
- //var uniqueID = Math.floor( Math.random()*99999 );
- var action=$(this).attr("action");
- var actionstr='';
- if(action!=undefined) actionstr=' action="'+action+'"';
- alert($(this).attr("id"));
- $(this).append('<form method="post"'+actionstr+' id="generatedform'+uniqueID+'">');
- $(this).append(' <input type="submit">');
- $(this).append('</form>');
- */
- //t=setTimeout("$('#generatedform'+uniqueID).submit();",500);
- //return false;
- });
- </script>
- </body></html><?
Advertisement
Add Comment
Please, Sign In to add comment