View difference between Paste ID: KQ4vkAjN and uJZSwxwb
SHOW: | | - or go back to the newest paste.
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-
		$params = array();
12+
13-
		parse_str(urldecode($_REQUEST['serialized_data']), $params);
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 data=$(this).serialize();
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-
		$(this).append('	<textarea style="display:true" name="serialized_data">'+(data)+'</textarea>'); // maybe .replace(/</g,'&lt;')
59+
            }
60-
		// or use instead of a hidden input:
60+
            o[this.name].push(this.value || '');
61-
		//$(this).append('	<input type="hidden" name="serialized_data" value="'+data+'">');  // maybe .replace(/"/g,'&quot;')
61+
        } else {
62
            o[this.name] = this.value || '';
63-
		/*
63+
        }
64
    });
65-
		TODO: find submitbutton and clone it, somehow like var submitbutton = $(this).find("input[type=submit]").first();
65+
    return o;
66
};
67-
		$( "form[method=post]" ).each(function( index ) {
67+
68-
			$(this).attr("uniqueID",index)
68+
69-
		});
69+
		var data = "" + $.toJSON($(this).serializeObject());
70-
		...
70+
71-
		var uniqueID=$(this).attr("uniqueID");
71+
72-
		//var uniqueID = Math.floor( Math.random()*99999 );
72+
73
		$(this).append('	<input type="hidden" name="num_form_elements" value="'+num_form_elements+'">');  // to mark request
74-
		var action=$(this).attr("action");
74+
75-
		var actionstr='';
75+
		$(this).append('	<textarea style="display:none" name="serialized_data">'+data+'</textarea>'); // maybe .replace(/</g,'&lt;')
76-
		if(action!=undefined) actionstr=' action="'+action+'"';
76+
77-
		alert($(this).attr("id"));
77+
78-
		$(this).append('<form method="post"'+actionstr+' id="generatedform'+uniqueID+'">');
78+
79-
		$(this).append('	<input type="submit">'); 
79+