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