Plugin Directory

Changeset 1319827


Ignore:
Timestamp:
01/02/2016 09:04:01 AM (10 years ago)
Author:
vividlteam
Message:

fix bug

Location:
thunder-port/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • thunder-port/trunk/simple_html_dom.php

    r1319802 r1319827  
    7171// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
    7272
     73function 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
    7392// get html dom from string
    7493function 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  
    1414add_action( 'admin_init', 'thunderport_settings_init' );
    1515
    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;
     16function 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
    3534}
    3635
     
    313312
    314313            if($page == 1) {
    315                 $html = file_get_html(''.$pluginurl.'/');
     314                // $html = file_get_html(''.$pluginurl.'/');
     315                $html = curl_file_get_html(''.$pluginurl.'/');
    316316               
    317317                foreach($html->find('td') as $article) {
     
    339339                for ($x = 1; $x <= $page; $x++) {
    340340
    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                   
    342344                    // get news block
    343345       
     
    410412            $pluginurl = sanitize_text_field($_POST['pluginurl']);
    411413            $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.'');
    413416            $ret = array();
    414417           
Note: See TracChangeset for help on using the changeset viewer.