Plugin Directory

Changeset 1297457


Ignore:
Timestamp:
11/30/2015 03:22:42 PM (10 years ago)
Author:
fherryfherry
Message:

update 2.0.1 file_get_contents bug

Location:
wpostgrabber/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wpostgrabber/trunk/readme.txt

    r1286272 r1297457  
    138138* Fix bug : blank content when manual / standard posting
    139139
     140= 2.0.1 =
     141* fix file_get_contents bug on some server
     142
    140143== Upgrade Notice ==
    141144
     
    189192* Add More URL Feed
    190193* Fix bug : blank content when manual / standard posting
     194
     195= 2.0.1 =
     196* fix file_get_contents bug on some server
  • wpostgrabber/trunk/wpg_function.php

    r1280675 r1297457  
    1111    }
    1212}
     13
     14function wpg_get($url)
     15{   
     16
     17    $curl = curl_init();   
     18    $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
     19    $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     20    $header[] = "Cache-Control: max-age=0";
     21    $header[] = "Connection: keep-alive";
     22    $header[] = "Keep-Alive: 300";
     23    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
     24    $header[] = "Accept-Language: en-us,en;q=0.5";
     25    $header[] = "Pragma: ";
     26    // browsers keep this blank.
     27    $referer = "http://www.google.com";
     28   
     29    $btext = rand(0,100000);
     30    $mozillav = rand(2,9);
     31    $wow = rand(20,80);
     32    $browser = "Mozilla/$mozillav.0 (Windows NT $mozillav.2; WOW$wow) AppleWebKit/$btext (KHTML, like Gecko) Chrome/$btext Safari/$btext";
     33   
     34    //Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36
     35 
     36    curl_setopt($curl, CURLOPT_URL, $url);
     37    curl_setopt($curl, CURLOPT_USERAGENT, $browser);
     38    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
     39    curl_setopt($curl, CURLOPT_REFERER, $referer);
     40    curl_setopt($curl, CURLOPT_AUTOREFERER, true);
     41    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     42    curl_setopt($curl, CURLOPT_TIMEOUT, 60);
     43    curl_setopt($curl, CURLOPT_MAXREDIRS, 14);
     44    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
     45
     46    $data = curl_exec($curl);
     47 
     48    curl_close($curl);     
     49    return $data;
     50}
     51
     52
    1353
    1454function wpg_get_rss($url,$offset,$limit) {     
     
    4989
    5090function wpg_verify_api($apikey) {
    51     $data = file_get_contents("http://websprogramming.com/wp-plugin/wpostgrabber/verifyapi.php?apikey=$apikey");
     91    $data = wpg_get("http://websprogramming.com/wp-plugin/wpostgrabber/verifyapi.php?apikey=$apikey");
    5292    $data = json_decode($data);
    5393    if($data->api_status == 0) {
     
    75115     curl_close ($Curl_Session);
    76116    return $result;
    77 }
     117} 
    78118
    79119function wpg_check_mime($url) {
Note: See TracChangeset for help on using the changeset viewer.