Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
- curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // remove Expect header to avoid 100 Continue situations
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla [abbreviated]');
- curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/cacert.pem');
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.hq.txt'); // write cookies
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.hq.txt'); // read cookies
- curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
- curl_setopt($ch, CURLOPT_URL, 'https://the_url.jsp');
- $data = curl_exec($ch);
- $error= curl_error($ch);
- if(!empty($error))
- echo '<p>'.$error.'</p>';
- else
- echo '<p>ok</p>';
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $options);
- $data = curl_exec($ch);
- $error=curl_error($ch);
- $options.=urlencode($fieldName).'='.urlencode($element->getAttribute('value'));
- $options.=urlencode($fieldName).'='.urlencode($element->getAttribute('value'));
- <?php
- echo curl_grab_page("https://www.example.net/login.php", "https://www.example.net/", "username=foo&password=bar", "true", "null", "false");
- // $url = page to POST data
- // $ref_url = tell the server which page you came from (spoofing)
- // $login = true will make a clean cookie-file.
- // $proxy = proxy data
- // $proxystatus = do you use a proxy ? true/false
- function
- curl_grab_page($url,$ref_url,$data,$login,$proxy,$proxystatus){
- if($login == 'true') {
- $fp = fopen("cookie.txt", "w");
- fclose($fp);
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
- curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
- curl_setopt($ch, CURLOPT_TIMEOUT, 40);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- if ($proxystatus == 'true') {
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
- curl_setopt($ch, CURLOPT_PROXY, $proxy);
- }
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_REFERER, $ref_url);
- curl_setopt($ch, CURLOPT_HEADER, TRUE);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- ob_start();
- return curl_exec ($ch); // execute the curl command
- ob_end_clean();
- curl_close ($ch);
- unset($ch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement