This is the form code

<form method="post" action="update-core.php?action=do-plugin-upgrade" name="upgrade-plugins" class="upgrade"> 
<input type="hidden" id="_wpnonce" name="_wpnonce" value="ab9d3a18e5" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/update-core.php" /><p><input id="upgrade-plugins" class="button" type="submit" value="Update Plugins" name="upgrade" /></p> 
<table class="widefat" cellspacing="0" id="update-plugins-table"> 
	<thead> 
	<tr> 
		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th> 
		<th scope="col" class="manage-column"><label for="plugins-select-all">Select All</label></th> 
	</tr> 
	</thead> 

<tfoot> 
<tr> 
	<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th> 
	<th scope="col" class="manage-column"><label for="plugins-select-all-2">Select All</label></th> 
</tr> 
</tfoot> 
<tbody class="plugins"> 

<tr class='active'> 
	<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='akismet/akismet.php' /></th> 
	<td class='plugin-title'><strong>Akismet</strong>You have version 2.4.0 installed. Update to 2.5.1.<br />Compatibility with WordPress 3.0.3: 100% (according to its author)</td> 
</tr> 
<tr class='active'> 
	<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='all-in-one-seo-pack/all_in_one_seo_pack.php' /></th> 
	<td class='plugin-title'><strong>All in One SEO Pack</strong>You have version 1.6.12.2 installed. Update to 1.6.13.<br />Compatibility with WordPress 3.0.3: 100% (according to its author)</td> 
</tr>	</tbody> 
</table> 
<p><input id="upgrade-plugins-2" class="button" type="submit" value="Update Plugins" name="upgrade" /></p> 
</form>

I Can't seem to properly submit the checked[] array values. Other fields are fine.

    bradgrafelman;10971317 wrote:

    What have you tried?

    I got all the form values with DOM except the checked[] array used regex so I have all the values in variables but couldn't insert the array into the post request. It doesn't get accepted.

    I just want curl post request to insert the variables along with the checked[] array.

    Here is what I ended up with. which doesn't work at the moment.

    if (preg_match_all("/name='checked\[\]' value='(.*)'/im", $html1, $plugins)) {
    	$plugins=$plugins[1];
    foreach($plugins as $plugin)	
    {
    if (strpos($plugin, '.php')) {
    $checked=$plugin . ',';
    } // verified plugin
    }	// plugins loop
    } // regex
    
    
                $ch3 = curl_init($redirect);
                $post3['action']='do-plugin-upgrade';
                $post3['_wpnonce']=$wp_nonce;
                $post3['_wp_http_referer']=$referrer;
                $post3['upgrade-plugins']='Update+Plugins';
                $post3['checked']=$checked;
    
    
                curl_setopt($ch3, CURLOPT_POST, true);
                curl_setopt($ch3, CURLOPT_HEADER, false);
    			curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch3, CURLOPT_TIMEOUT, 15);
    			curl_setopt($ch3, CURLOPT_COOKIEFILE, 'cookies.txt');
    			curl_setopt($ch3, CURLOPT_COOKIEJAR, 'cookies.txt');
    			curl_setopt($ch3, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");
    			curl_setopt($ch3, CURLOPT_REFERER, $redirect);
                curl_setopt($ch3, CURLOPT_POSTFIELDS, $post3);
                curl_setopt($ch3, CURLOPT_HTTPHEADER, array('Expect: '));
                $html3 = curl_exec($ch3);
    

    And here is how a manual successful post looks like

    //POST /wp-admin/update-core.php?action=do-plugin-upgrade _wpnonce=eefba3eb0e&_wp_http_referer=%2Fwp-admin%2Fupdate-core.php&checked%5B%5D=akismet%2Fakismet.php&upgrade=Update+Plugins
    

      Look at the successful POST string you posted; the field name isn't "checked" (which is what your script is attempting to use) but rather "checked[]" (properly URL-encoded, of course). Furthermore, if you had checked multiple checkboxes you would have seen that same field name repeated for each value, e.g. "foo[]=bar&foo[]=baz&..." etc.

      I'm not sure what the proper way to do this using cURL would be, so either try setting the array index 'checkbox[]' equal to an array of values (and hope that cURL is smart enough to understand what you're intending to do) or else build the POST string yourself manually.

        Write a Reply...