Changeset 1319827
- Timestamp:
- 01/02/2016 09:04:01 AM (10 years ago)
- Location:
- thunder-port/trunk
- Files:
-
- 2 edited
-
simple_html_dom.php (modified) (1 diff)
-
thunder_port.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
thunder-port/trunk/simple_html_dom.php
r1319802 r1319827 71 71 // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1. 72 72 73 function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) 74 { 75 // We DO force the tags to be terminated. 76 $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); 77 // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done. 78 $contents = file_get_contents($url, $use_include_path, $context, $offset); 79 80 81 // Paperg - use our own mechanism for getting the contents as we want to control the timeout. 82 //$contents = retrieve_url_contents($url); 83 if (empty($contents) || strlen($contents) > MAX_FILE_SIZE) 84 { 85 return false; 86 } 87 // The second parameter can force the selectors to all be lowercase. 88 $dom->load($contents, $lowercase, $stripRN); 89 return $dom; 90 } 91 73 92 // get html dom from string 74 93 function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) -
thunder-port/trunk/thunder_port.php
r1319806 r1319827 14 14 add_action( 'admin_init', 'thunderport_settings_init' ); 15 15 16 function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT) 17 { 18 // We DO force the tags to be terminated. 19 $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText); 20 // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done. 21 // $contents = file_get_contents($url, $use_include_path, $context, $offset); 22 23 $contents = wp_remote_get($url); 24 $contents = wp_remote_retrieve_body( $contents ); 25 26 // Paperg - use our own mechanism for getting the contents as we want to control the timeout. 27 //$contents = retrieve_url_contents($url); 28 if (empty($contents) || strlen($contents) > MAX_FILE_SIZE) 29 { 30 return false; 31 } 32 // The second parameter can force the selectors to all be lowercase. 33 $dom->load($contents, $lowercase, $stripRN); 34 return $dom; 16 function curl_file_get_html($base) { 17 18 $curl = curl_init(); 19 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); 20 curl_setopt($curl, CURLOPT_HEADER, false); 21 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 22 curl_setopt($curl, CURLOPT_URL, $base); 23 curl_setopt($curl, CURLOPT_REFERER, $base); 24 curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 25 $str = curl_exec($curl); 26 curl_close($curl); 27 28 // Create a DOM object 29 $html_base = new simple_html_dom(); 30 // Load HTML from a string 31 $html_base->load($str); 32 return $html_base; 33 35 34 } 36 35 … … 313 312 314 313 if($page == 1) { 315 $html = file_get_html(''.$pluginurl.'/'); 314 // $html = file_get_html(''.$pluginurl.'/'); 315 $html = curl_file_get_html(''.$pluginurl.'/'); 316 316 317 317 foreach($html->find('td') as $article) { … … 339 339 for ($x = 1; $x <= $page; $x++) { 340 340 341 $html = file_get_html(''.$pluginurl.'/page/'.$x.'/'); 341 // $html = file_get_html(''.$pluginurl.'/page/'.$x.'/'); 342 $html = curl_file_get_html(''.$pluginurl.'/page/'.$x.'/'); 343 342 344 // get news block 343 345 … … 410 412 $pluginurl = sanitize_text_field($_POST['pluginurl']); 411 413 $pluginname = sanitize_text_field($_POST['pluginname']); 412 $html = file_get_html(''.$pluginurl.''); 414 // $html = file_get_html(''.$pluginurl.''); 415 $html = curl_file_get_html(''.$pluginurl.''); 413 416 $ret = array(); 414 417
Note: See TracChangeset
for help on using the changeset viewer.