Changeset 1458486
- Timestamp:
- 07/21/2016 07:12:28 PM (10 years ago)
- File:
-
- 1 edited
-
clickfunnels/trunk/clickfunnels.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clickfunnels/trunk/clickfunnels.php
r1458485 r1458486 56 56 57 57 $posts = get_posts($query_args); 58 $cf_page = $posts[0];58 $cf_page = current($posts); 59 59 60 60 if ($cf_page) { … … 93 93 public function get_page_content( $url ) { 94 94 $ch = curl_init(); 95 $timeout = 10;96 95 curl_setopt($ch, CURLOPT_URL, $url); 97 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);98 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);96 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 97 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); 99 98 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 100 $data = curl_exec($ch); 99 100 // Get http header for cookies 101 curl_setopt($ch, CURLOPT_VERBOSE, 1); 102 curl_setopt($ch, CURLOPT_HEADER, 1); 103 104 // Forward current cookies to curl 105 $cookies = array(); 106 foreach ($_COOKIE as $key => $value) { 107 if ($key != 'Array') { 108 $cookies[] = $key . '=' . $value; 109 } 110 } 111 curl_setopt( $ch, CURLOPT_COOKIE, implode(';', $cookies) ); 112 113 // Stop session so curl can use the same session without conflicts 114 session_write_close(); 115 116 $response = curl_exec($ch); 101 117 curl_close($ch); 102 return $data; 118 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); 127 foreach($cookies[0] AS $cookie) { 128 header($cookie, false); 129 } 130 131 return $body; 103 132 } 104 133
Note: See TracChangeset
for help on using the changeset viewer.