Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

If you ever need to cUrl into admin... here it is Rate Topic   - - - - -

 
  • TexasGuy
  • Senior Member
  • Members
  • Join Date: 18-Mar 10
  • 546 posts

Posted 19 May 2010 - 11:20 PM #1

Curling into admin is nothing to do (you must have some curl experience though). Once you log-in, keep the cookie file and browser agent for other interactions.

You may need to set a full path to your cookie file depending on your php setup.
Edit post data for your own login info, don't forget to urlencode it.



$url='https://mysite.com/admin.php';
$post_data='return_url=admin.php&user_login=user%40blah.com&password=letmein&dispatch%5Bauth.login%5D=Sign+in';
$cookie='my.c';
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$referrer='https://mysite.com/admin.php';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_REFERER, $referrer);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie);
$out = curl_exec($ch);
echo $out;


This should echo your admin page without css and pics.
PM me today for design/coding projects :P

 
  • TexasGuy
  • Senior Member
  • Members
  • Join Date: 18-Mar 10
  • 546 posts

Posted 19 May 2010 - 11:23 PM #2

I found an easy way to add options to items in bulk and this is the first step in my grand plan.

EDIT (here is the code):

Sure, you curl login first and keep cookie info.

$item - id of the product to which to add an option
$option - id of the option which to add
$times - how many times (useful if adding NOT as a link);
$g - Glogbal or not, must be 'Y' for yes


function add_option($item,$option,$times=1,$g='N'){
$post_data="product_id=$item&selected_section=options&global_option%5Bid%5D=$option&global_option%5Blink%5D=$g&dispatch%5Bproducts.apply_global_option%5D=Apply";
$url='https://yoursite.com/admin.php';
$cookie='my.c';
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$referrer='https://yoursite.com/admin.php?dispatch=products.update&product_id='.$item;
for($i=0;$i<$times;$i++){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_REFERER, $referrer);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie);
$out = curl_exec($ch);
unset($ch);
sleep(2);
}
}


PM me today for design/coding projects :P