Changeset 1458487
- Timestamp:
- 07/21/2016 07:12:47 PM (10 years ago)
- File:
-
- 1 edited
-
clickfunnels/trunk/clickfunnels.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clickfunnels/trunk/clickfunnels.php
r1458486 r1458487 93 93 public function get_page_content( $url ) { 94 94 $ch = curl_init(); 95 curl_setopt($ch, CURLOPT_URL, $url);96 95 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 97 96 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 98 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 99 100 // Get http header for cookies 101 curl_setopt($ch, CURLOPT_VERBOSE, 1); 97 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 102 98 curl_setopt($ch, CURLOPT_HEADER, 1); 103 99 … … 111 107 curl_setopt( $ch, CURLOPT_COOKIE, implode(';', $cookies) ); 112 108 113 // Stop session so curl can use the same session without conflicts 114 session_write_close(); 115 116 $response = curl_exec($ch); 109 $destination = $url; 110 111 while ($destination) { 112 session_write_close(); 113 curl_setopt($ch, CURLOPT_URL, $destination); 114 $response = curl_exec($ch); 115 $curl_info = curl_getinfo($ch); 116 $destination = $curl_info["redirect_url"]; 117 session_start(); 118 } 117 119 curl_close($ch); 118 120 119 // Session restart 120 session_start(); 121 122 // Seperate header and body 123 list($header, $body) = explode("\r\n\r\n", $response, 2); 124 125 // Extract cookies form curl and forward them to browser 126 preg_match_all('/^(Set-Cookie:\s*[^\n]*)$/mi', $header, $cookies); 121 $headers = substr($response, 0, $curl_info["header_size"]); 122 $body = substr($response, $curl_info["header_size"]); 123 124 // Extract cookies from curl and forward them to browser 125 preg_match_all('/^(Set-Cookie:\s*[^\n]*)$/mi', $headers, $cookies); 127 126 foreach($cookies[0] AS $cookie) { 128 127 header($cookie, false);
Note: See TracChangeset
for help on using the changeset viewer.