Jump to content

Curl Problem


Evergreen

Recommended Posts

Hello guys, it's my first post here.... :happy-04:

 

Here is the code I got for now(changed the domain and subdomain names):

<?php
$agent = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16";
$headers = "Expect:";
$postdata = "username=test&password=test&ref=".base64_encode(md5(time().".com"))."&session=s".md5(time());
$login="http://subdomain.mydomain.com/login.php";
$grab="http://subdomain.mydomain.com/index.php";
function login($url,$data){
   $fp = fopen("cookie.txt", "w");
   fclose($fp);
   $login = curl_init();
   curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
   curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
   curl_setopt($login, CURLOPT_TIMEOUT, 40000);
   curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($login, CURLOPT_URL, $url);
   curl_setopt($login, CURLOPT_USERAGENT, $agent);
   curl_setopt($login, CURLOPT_COOKIESESSION, true);
   curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
   curl_setopt($login, CURLOPT_POST, TRUE);
   curl_setopt($login, CURLOPT_POSTFIELDS, $data);
   ob_start();
   return curl_exec ($login);
   ob_end_clean();
   curl_close ($login);
unset($login);
}				 
function grab_page($site){
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_USERAGENT, $agent);
   curl_setopt($ch, CURLOPT_TIMEOUT, 40000);
   curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
   curl_setopt($login, CURLOPT_COOKIESESSION, true);
   curl_setopt($ch, CURLOPT_URL, $site);
   ob_start();
   return curl_exec ($ch);
   ob_end_clean();
   curl_close ($ch);
}
function grab_subpage($site){
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_USERAGENT, $agent);
   curl_setopt($ch, CURLOPT_TIMEOUT, 40000);
   curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
   curl_setopt($login, CURLOPT_COOKIESESSION, true);
   curl_setopt($ch, CURLOPT_URL, $site);
   ob_start();
   return curl_exec ($ch);
   ob_end_clean();
   curl_close ($ch);
}
function post_data($site,$data){
   $datapost = curl_init();
   curl_setopt($datapost, CURLOPT_URL, $site);
   curl_setopt($datapost, CURLOPT_TIMEOUT, 40000);
   curl_setopt($datapost, CURLOPT_HEADER, TRUE);
   curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers);
   curl_setopt($datapost, CURLOPT_USERAGENT, $agent);
   curl_setopt($datapost, CURLOPT_POST, TRUE);
   curl_setopt($datapost, CURLOPT_POSTFIELDS, $data);
   curl_setopt($datapost, CURLOPT_COOKIEFILE, "cookie.txt");
   ob_start();
   return curl_exec ($datapost);
   ob_end_clean();
   curl_close ($datapost);
   unset($datapost);
}
login($login, $postdata);
echo grab_page($grab);
?>

 

OK , so ... this code works fine if i navigate any page from http://subdomain.mydomain.com/ but if i try to grab a page from http://anothersubdomain.mydomain.com/ it drops and shows me a white page. var_dump(grab_page($grab)); echoes me string(0) "" . I can't figure out what is the problem and why I can't access that page. I'm googling for a week now and tryied tons of metods and nothing worked, maybe you guys can help me...

 

Thanks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.