Plugin Directory

Changeset 1259823


Ignore:
Timestamp:
10/05/2015 02:17:01 PM (10 years ago)
Author:
fherryfherry
Message:

improve grab function

Location:
wpostgrabber/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wpostgrabber/trunk/readme.txt

    r1259216 r1259823  
    122122* fix problem images uploaded wheter post publish or not
    123123
     124= 1.1.1 =
     125* improve grab function
     126
    124127== Upgrade Notice ==
    125128
     
    164167* add alternate function to prevent create images thumbnail
    165168* fix problem images uploaded wheter post publish or not
     169
     170= 1.1.1 =
     171* improve grab function
  • wpostgrabber/trunk/wpg_function.php

    r1257633 r1259823  
    4040}
    4141
    42 function wpg_get_content($url) {   
    43     $html = wpg_gethtml($url,"html");       
    44    
    45     $readability = new Readability($html,$url);
    46     $result = $readability->init();
    47        
    48     $content = $readability->getContent()->innerHTML;       
    49    
    50     if (function_exists('tidy_parse_string')) {
    51         $tidy = tidy_parse_string($content,
    52             array('indent'=>true, 'show-body-only'=>true),
    53             'UTF8');
    54         $tidy->cleanRepair();
    55         $content = $tidy->value;
    56     }
    57     $title = $readability->getTitle()->textContent;
    58     $title = str_ireplace($title_keyword,"",$title);       
    59     $content = str_ireplace($content_keyword,"",$content);
    60     $tag = strtolower(preg_replace("/[^A-Za-z ]/", "",$title));
    61     $tag = str_replace(" ",",",$tag);
    62    
    63     return array(
    64     "title"=>$title,
    65     "content"=>$content,
    66     "tag"=>$tag
    67     );
     42function wpg_get_content($url) {           
     43    $array = array();
     44    $array['domain'] = $_SERVER['SERVER_NAME'];
     45    $array['useragent'] = $_SERVER['HTTP_USER_AGENT'];
     46    $array['ip'] = $_SERVER['REMOTE_ADDR'];
     47    $array['url'] = $url;   
     48    $data = wpg_posthtml($array,"http://websprogramming.com/wp-plugin/wpostgrabber/api.php");
     49    return json_decode($data,true);
     50}
     51
     52function wpg_posthtml($array,$url) {
     53     foreach($array as $a => $b) {
     54        $newarray[] = $a."=".$b;
     55     }
     56     $newarr = implode('&',$newarray);
     57     $Curl_Session = curl_init($url);
     58     
     59     curl_setopt($Curl_Session, CURLOPT_POST, 1);
     60     curl_setopt($Curl_Session, CURLOPT_POSTFIELDS, $newarr);
     61     curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, true);
     62     $result = curl_exec ($Curl_Session);
     63     curl_close ($Curl_Session);
     64    return $result;
    6865}
    6966
  • wpostgrabber/trunk/wpostgrabber.php

    r1259216 r1259823  
    22/**
    33 * @package WPostGrabber
    4  * @version 1.1.0
     4 * @version 1.1.1
    55 */
    66/*
     
    99Description: WPostGrabber, this plugin will help you to get your content on the website that you want instantly.
    1010Author: Ferry Ariawan
    11 Version: 1.1.0
     11Version: 1.1.1
    1212Author URI: http://websprogramming.com/
    1313*/
    1414
    1515define('WPG_ROOT', dirname(__FILE__));
    16 include(dirname(__FILE__)."/wpg_readability.php");
    1716include(dirname(__FILE__)."/wpg_function.php");
    1817include(dirname(__FILE__)."/wpg_settings.php");
Note: See TracChangeset for help on using the changeset viewer.