• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • Upgrade Your Account
    Hello Guest! Upgrade your account to download all VIP Resource here

Giúp sửa plugin WP

Joined
Nov 27, 2016
Messages
6
Chủ thớt
#1
mình có plugin leech truyện hiện tại không leech được, bạn nào rảnh sửa hộ mình với
truyenngan.com.vn leech được mỗi ở truyện ngắn (1 post) còn ở tiểu thuyết thì không leech đc
santruyen thì không leech được trang con (vidu: http://danhtac.com/ong-trum-quyen-luc-cuoi-cung/)
demo web: danhtac.com

PHP:
<?php
class ZenLeech
{
    private $ua = 'Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0';
    private $error = array();
    private $success = array();
    public function setUA($UA) {
        $this->ua = $UA;
    }
    public function error($msg = null) {
        if ($msg) echo '<div class="alert alert-danger">' . $msg . '</div>';
        else {
            if ($this->error) foreach ($this->error as $msg) {
                echo '<div class="alert alert-danger">' . $msg . '</div>';
            }
        }
    }
    public function success($msg = null) {
        if ($msg) echo '<div class="alert alert-success">' . $msg . '</div>';
        else {
            if ($this->success) foreach ($this->success as $msg) {
                echo '<div class="alert alert-success">' . $msg . '</div>';
            }
        }
    }
    public function is_ajax() {
        if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            return true;
        }
        return false;
    }
    public function detect_driver($url) {
        if (preg_match('/^http:\/\/(www\.)?kenhtruyen\.com/is', $url)) {
            return 'kenhtruyen';
        }
        if (preg_match('/^http:\/\/(www\.)?doctruyen360\.com/is', $url)) {
            return 'doctruyen360';
        }
        if (preg_match('/^http:\/\/(www\.)?truyenngan\.com\.vn/is', $url)) {
            return 'truyenngancomvn';
    
        }
        if (preg_match('/^http:\/\/(www\.)?santruyen\.com/is', $url)) {
            return 'santruyen';
        }
        if (preg_match('/^http:\/\/(www\.)?webtruyen\.com/is', $url)) {
            return 'webtruyen';
        }
        return false;
    }
    public function downloadContent($url) {
        if (!function_exists('curl_init')) {
            $content = file_get_contents($url);
            return $content;
        }
        $options = array(
            CURLOPT_CUSTOMREQUEST  =>"GET",        //set request type post or get
            CURLOPT_POST           =>false,        //set to GET
            CURLOPT_USERAGENT      => $this->ua, //set user agent
            CURLOPT_COOKIEFILE     =>"cookie.txt", //set cookie file
            CURLOPT_COOKIEJAR      =>"cookie.txt", //set cookie jar
            CURLOPT_RETURNTRANSFER => true,     // return web page
            CURLOPT_HEADER         => false,    // don't return headers
            CURLOPT_FOLLOWLOCATION => true,     // follow redirects
            CURLOPT_ENCODING       => "",       // handle all encodings
            CURLOPT_AUTOREFERER    => true,     // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
            CURLOPT_TIMEOUT        => 120,      // timeout on response
            CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
        );
        $ch      = curl_init( $url );
        curl_setopt_array( $ch, $options );
        $content = curl_exec( $ch );
        curl_close( $ch );
        return $content;
    }
    public function post_exist($title) {
        global $wpdb;
        $return = $wpdb->get_row("SELECT ID FROM wp_posts WHERE post_title = '" . $title . "' && post_status = 'publish' && post_type = 'post' ", 'ARRAY_N');
        if (empty($return)) {
            return false;
        }
        return true;
    }
    public function full_link($id) {
        return get_permalink($id);
    }
    public function insert_post($cat, $data) {
        if ($this->post_exist($data['title'])) {
            $this->error[] = 'Đã tồn tại bài viết này';
        } else {
            include 'ZenSEO.lib.php';
            $seo = new ZenSEO();
            $link = sanitize_title_with_dashes($seo->url($data['title']),'','save');
            $post_id = wp_insert_post(array(
                'post_title' => wp_strip_all_tags($data['title']),
                'post_name' => $link,
                'post_content' => $data['content'],
                'post_status' => 'publish',
                'post_parent' => 14,
                'post_author' => get_current_user_id(),
                'post_category' => array($cat)
            ));
            if (!empty($data['icon'])) {
                update_post_meta($post_id, '_nelioefi_url', strip_tags($data['icon']));
            }
            return $post_id;
        }
        return false;
    }
    public function media_sideload_image( $file, $post_id, $desc = null ) {
        if ( ! empty( $file ) ) {
            // Set variables for storage, fix file filename for query strings.
            preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
            $file_array = array();
            $file_array['name'] = basename( $matches[0] );
            // Download file to temp location.
            $file_array['tmp_name'] = download_url( $file );
            // If error storing temporarily, return the error.
            if ( is_wp_error( $file_array['tmp_name'] ) ) {
                return $file_array['tmp_name'];
            }
            // Do the validation and storage stuff.
            $id = media_handle_sideload( $file_array, $post_id, $desc );
            // If error storing permanently, unlink.
            if ( is_wp_error( $id ) ) {
                @unlink( $file_array['tmp_name'] );
                return $id;
            }
            $src = wp_get_attachment_url( $id );
        }
        // Finally check to make sure the file has been saved, then return the HTML.
        if ( ! empty( $src ) ) {
            return $src;
        }
        return false;
    }
    public function detect_image_url($str = '', $unique = TRUE)
    {
        $matches = array();

        preg_match_all('/(http|https):\/\/[^\s]+(\.gif|\.jpg|\.jpeg|\.png)/is', $str, $matches);

        if ($unique == TRUE) {

            $list = array_unique($matches[0]);

        } else {
            $list = $matches[0];
        }
        return $list;
    }
    public function detect_link_inside($str, $exam_url, $accept_img = false, $not_allow_link = array()) {
        if (!$exam_url || !$str) return array();
        preg_match_all('/^https?:\/\/(www\.)?[^\/]+/is', $exam_url, $match);
        $home_url = trim($match[0][0]);
        $home_url = trim($home_url, '/');
        $home_url_quote = preg_quote($home_url, '/');
        $home_url_quote = str_replace('www\.', '(www\.)?', $home_url_quote);
        preg_match_all('/href="((http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)"/is', $str, $match);
        $list = array_unique($match[1]);
        $list = array_filter($list, function($val) use ($home_url_quote, $accept_img, $exam_url, $not_allow_link) {
            if (!preg_match('/^' . $home_url_quote . '\/?/i', $val) || trim($exam_url, '/') == trim($val, '/')) {
                return false;
            }
            if ($not_allow_link) {
                if (in_array($val, $not_allow_link)) {
                    return false;
                }
            }
            if (!$accept_img) {
                $img_ext = array('jpg', 'jpeg', 'png', 'gif', 'bmp');
                $info = pathinfo($val);
                if (in_array($info['extension'], $img_ext)) {
                    return false;
                }
            }
            return true;
        });
        return $list;
    }
    public function _leech_image($post_id, $content) {
        $list_replace = array();
        $list_image = $this->detect_image_url($content);
        foreach ($list_image as $k => $src) {
            $newSrc = $this->media_sideload_image($src, $post_id);
            $list_replace[$src] = $newSrc;
        }
        if ($list_replace) {
            $content = strtr($content, $list_replace);
        }
        return $content;
    }

    public function leech_kenhtruyen($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1\s+class="title"\s+style="[^"]*">\s*<a\s+class="description"\s+title="([^"]+)"\s+href=/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        if (!$data['title']) {
            $this->error[] = 'Không lấy được tiêu đề bài này';
            return false;
        }
        preg_match_all('/<div class="eMessage">\s*(<a\s+class="[^"]+"\s+href="[^"]+"\s+title="[^"]+"\s*>\s*<center>\s*<h2>\s*[^<]+\s*<\/h2>\s*<\/center>\s*<\/a>\s*<br\/>)?\s*<div\s+style="[^"]+"\s*>(.*)<center>\s*<!\-\-[^\-]+\-\->/is', $content, $match);
        $data['content'] = trim($match[2][0]);
        if (!$data['content']) {
            $this->error[] = 'Không lấy được nội dung bài này';
            return false;
        }
        return $data;
    }
    public function leech_doctruyen360($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1>\s*<a\s+href="[^"]+"\s+rel="bookmark"\s+title="[^"]+">(.*)<\/a>\s*<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<div\s+class="dtct[^"]+">(.*)<div\s+class="fb\-like"/is', $content, $match);
        if (empty($match[1][0])) {
            preg_match_all('/<div\s+class="entry">(.*)<div\s+class="fb\-like"/is', $content, $match);
            if (!empty($match[1][0])) {
                $data['content'] = $match[1][0];
            }
        } else $data['content'] = $match[1][0];
        if (empty($data['content']) || empty($data['title'])) {
            return false;
        }
        $link_inside = $this->detect_link_inside($data['content'], $url);
        if ($link_inside) $data['link_inside'] = array_reverse($link_inside);
        return $data;
    }
    public function leech_kenh14($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1\s+class="title">\s*(.*)\s*<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<h2\s+class="sapo">(.*)<\/h2>\s*<div\s+class="content">(.*)<\/div>\s*<style>.*<\/style>\s*<div\s+class="source\-wrap"/is', $content, $match);
        $h2 = trim($match[1][0]);
        $content = trim($match[2][0]);
        $data['content'] = '<h2>' . $h2 . '</h2>' . $content;
        if (!$data['title'] || !$data['content']) return false;
        //$data['content'] = preg_replace('/<a[">]*>([^<]*)<\/a>/is', '{1}', $data['content']);
        return $data;
    }
    public function leech_mlogyan($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1\s+class="postContenttitle">(.*)<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<div\s+class="postContent"\s+id="dvPostContent">(.*)<\/div>\s*<br\s*\/?>\s*<div>.*<\/div>\s*<\/div>\s*<div\s+class="clear">/is', $content, $match);
        $data['content'] = trim($match[1][0]);
        preg_match_all('/(<p\s+style="[^"]+">\s*<span\s+style="[^"]+">\s*<strong>[^<]+<\/strong>\s*<\/span>\s*<\/p>\s*<ul>.*<\/ul>)\s*<p/is', $data['content'], $match);
        $data['content'] = preg_replace('/<p\s+style="[^"]+">\s*<span\s+style="[^"]+">\s*<strong>[^<]+<\/strong>\s*<\/span>\s*<\/p>\s*<ul>.*<\/ul>\s*<p/is', '<p', $data['content']);
        $data['content'] = preg_replace('/<ul>.*<\/ul>\s*<table.*<\/table>/is', '', $data['content']);
        $data['content'] = preg_replace('/<div\s+style="[^"]+"><script.*<\/script>\s*<\/div>/is', '', $data['content']);
        if (!$data['title'] || !$data['content']) return false;
        return $data;
    }
    public function leech_guu($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1\s+class="small\-image\-title"\s+itemprop="name">(.*)<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<em>\s*<span\s+itemprop="description">(.*)<\/span>\s*<\/em>/is', $content, $match);
        $h2 = trim($match[1][0]);
        preg_match_all('/<div\s+class="guu\-article\-body"\s*itemprop="articleBody">(.*)<\/div>\s*<p[^>]+>.+<\/p>\s*<div\s+class="social\-share">/is', $content, $match);
        $c = trim($match[1][0]);
        $c = preg_replace('/<p>\s*<strong>.+<\/strong>\s*\-\s*<em>.*<\/em>\s*<\/p>/is', '', $c);
        $data['content'] = '<h2>' . $h2 . '</h2>' . $c;
        if (!$data['title'] || !$data['content']) return false;
        return $data;
    }
    public function leech_truyenngancomvn($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1>(.*)<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<div\s+class="maincontent"\s*>(.*)<\/div>\s*<div\s+class="wrap\-details">/is', $content, $match);
        $data['content'] = trim($match[1][0]);
        $data['content'] = str_replace('<img src="', '<img src="http://www.truyenngan.com.vn/', $data['content']);
        if (!$data['title'] || !$data['content']) return false;
        return $data;
    }
    public function leech_userapkvn_old($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<title>(.*)<\/title>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<dd\s+class="detail_baseinfo_other">([^<]+)<\/dd>/is', $content, $match);
        $by = trim($match[1][0]);
        preg_match_all('/<span\s+class="fr">([^<]+)<\/span>/is', $content, $match);
        $size = trim($match[1][0]);
        preg_match_all('/data\-hover="btn_detail_download_hover"\s*data\-name="[^"]+"\s*data\-href="([^"]+)"/is', $content, $match);
        $link = trim($match[1][0]);
        preg_match_all('/https?:\/\/(www\.)?[^\.]+\.apk\.vn/is', $url, $match);
        $base = trim($match[0][0]);
        $link = $base . $link;
        preg_match_all('/class="detail_item_cnt\s+detail_item_cnt_more"\s+data\-id="J\-description">(.*)<p\s+class="btn_detail_view">\s*<i\s+class="icon_arror_up">\s*<\/i>\s*<\/p>/is', $content, $match);
        $c = $match[1][0];
        $data['content'] = '<div class="zen-game-desc"><div class="zen-game-author">Phát hành bởi: ' . $by . '</div><div class="zen-game-size">Dung lượng: ' . $size . '</div><div class="zen-game-link-down">Tải về: <a href="' . $link . '" target="_blank">Download</a></div></div>' . $c . '<div class="zen-game-link-down"><b><a href="' . $link . '" target="_blank">Tải về máy (' . $size . ')</a></b></div>';
        preg_match_all('/<img\s*src="(.*)"\s*class="img_baseinfo"\s*\/?>/is', $content, $match);
        $data['thumbnail'] = trim($match[1][0]);
        if (!$data['title'] || !$data['content']) return false;
        return $data;
    }
    public function leech_userapkvn($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<title>(.*)<\/title>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<i\s+class="icon_list_info">\s*<\/i>([^<]+)<dd\s+class="detail_baesinfo_speed">/is', $content, $match);
        $size = trim($match[1][0]);
        preg_match_all('/data\-href="([^"]+)"\s+onclick="return\s*market_download\(this\)"\s*class="btn_detail_download"/is', $content, $match);
        $link = trim($match[1][0]);
        preg_match_all('/<div\s+class="desc_app">(.*)<\/div>\s*<div\s+class="btn_view_all">/is', $content, $match);
        $c = $match[1][0];
        $data['content'] = '<div class="zen-game-desc"><div class="zen-game-size">Dung lượng: ' . $size . '</div><div class="zen-game-link-down">Tải về: <a href="' . $link . '" target="_blank">Download</a></div></div>' . $c . '<div class="zen-game-link-down"><b><a href="' . $link . '" target="_blank">Tải về máy (' . $size . ')</a></b></div>';
        preg_match_all('/<img\s*src="(.*)"\s*class="img_baseinfo"\s*\/?>/is', $content, $match);
        $data['thumbnail'] = trim($match[1][0]);
        if (!$data['title'] || !$data['content']) return false;
        return $data;
    }
    public function leech_santruyen($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<h1>\s*<a\s+href="[^"]+"\s+title="[^"]+">([^<]+)<\/a>\s*<\/h1>/is', $content, $match);
        $data['title'] = trim($match[1][0]);
        if (!$data['title']) {
            /**
             * is chapter
             */
            preg_match_all('/<title>(.*)<\/title>/is', $content, $match);
            $data['title'] = trim($match[1][0]);
            preg_match_all('/<div\s+class="contents\-comic">(.*)<\/div>\s*<\/div>\s*<\/div>\s*<\!\-\-\/\s*thong\s+tin\s+truyen\s*\-\->/is', $content, $match);
            $data['content'] = trim($match[1][0]);
            preg_match_all('/<div\s+class="(flr\s+)?chap\-select\-dropdown">(.*)<\/div>\s*((<div>\s*<div\s+class="fb\-like")|(<\/div>\s*<\!\-\-\s*comment\s*\-\->))/is', $content, $match);
            $nav = trim($match[2][0]);
            $data['content'] = $data['content'] . '<div class="zen-post-nav">' . $nav . '</div>';
        } else {
            preg_match_all('/<div\s+class="desc\-story">(.+)<\/div>\s*<div\s+class="box\-chap\s+last\-chap">/is', $content, $match);
            $data['content'] = trim($match[1][0]);
            preg_match_all('/<div\s+class="list\-chap"\s+id="[^"]+">(.*)<div\s+class="clr">\s*<\/div>\s*<script/is', $content, $match);
            $list_chap = trim($match[1][0]);
            if ($list_chap) $data['content'] = $data['content'] . '<div class="zen-list-chapter">' . $list_chap . '</div>';
        }
        if (!$data['title'] || !$data['content']) return false;
        $data['content'] = str_replace('<a href="http://santruyen.com"', '<a href="' . get_home_url() . '"', $data['content']);
        $link_inside = $this->detect_link_inside($data['content'], $url, false, array('http://santruyen.com'));
        if ($link_inside) $data['link_inside'] = $link_inside;
        return $data;
    }
    public function leech_topkute($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<title>(.*)<\/title>/Uis', $content, $match);
        $data['title'] = trim($match[1][0]);
        preg_match_all('/<div\s+class="forumtxt">\s*<span\s+style="[^"]+">\s*<b>\s*<big>(.*)(<\/big>\s*)?(<\/b>\s*)?(<\/span>\s*)?<\/div>/Uis', $content, $match);
        $data['content'] = trim($match[1][0]);
        $data['content'] = preg_replace('/href\s*=\s*"\s*\//i', 'href="http://topkute.net/', $data['content']);
        $data['content'] = str_replace('_trang-1.html"', '.html"', $data['content']);
        if (empty($data['content']) || empty($data['title'])) {
            return false;
        }
        $link_inside = $this->detect_link_inside($data['content'], $url);
        if ($link_inside) $data['link_inside'] = array_reverse($link_inside);
        return $data;
    }

    public function leech_webtruyen($url) {
        $content = $this->downloadContent($url);
        preg_match_all('/<a\s+class="description"\s+title=".+"\s+href=".*">(.*)<\/a>/Uis', $content, $match);
        if (!empty($match[1][0])) {
            $data['title'] = trim($match[1][0]);
        } else {
            preg_match_all('/<h3\s+class="detailchapter">(.*)<\/h3>/Uis', $content, $match);
            $data['title'] = trim($match[1][0]);
        }
        if (empty($data['title'])) {
            return false;
        }
        preg_match_all('/<div\s+class="mota">\s*<h3\s+class="shot">.*<\/h3>\s*<span>(.*)<\/span>(\s*<div\s+style="[^"]+">\s*<a\s+class="more">[^<]+<\/a>\s*<\/div>)?\s*<\/div>/Uis', $content, $match);
        if (!empty($match[1][0])) {
            $match[1][0] = preg_replace('/<br\s*\/?>/Uis', '[break]', $match[1][0]);
            $post_content = trim(strip_tags($match[1][0]));
            $post_content = str_replace('[break]', '<br/>', $post_content);

            preg_match_all('/<span\s+class="numbpage">Trang\s+[0-9]+\s*\/\s*([0-9]+)<\/span>/Uis', $content, $match);
            $number_page = !empty($match[1][0]) ? $match[1][0] : 0;
            preg_match_all('/<input\s+type="hidden"\s+id="hiddenID"\s+value="([0-9]+)"\/>/Uis', $content, $match);
            $storyID = !empty($match[1][0]) ? $match[1][0] : 0;
            $chapter_content = '';
            if ($storyID && $number_page) {
                for ($i = 1; $i <= $number_page; $i++) {
                    $content = $this->downloadContent('http://webtruyen.com/story/Paging_listbook/' . $storyID . '/' . $i);
                    preg_match_all("/<td\s+class='tdchapter1'>(.*)<\/td>\s*<td>\s*<a\s+title='.*'\s+href='(.*)'\s*>(.*)<\/a>\s*<\/td>(\s*<td\s+class='tdchapter1'>(.*)<\/td>\s*<td\s+class='tdchapter'>(.*)<\/td>)?/Uis", $content, $match);
                    if (is_array($match[2])) {
                        foreach ($match[2] as $k=>$link) {
                            if (!empty($match[5][$k])) {
                                $ele = '<a href="' . trim($link) . '"><span class="zen-bchapter">' . $match[5][$k] . '</span> - <span class="zen-chapter">' . $match[1][$k] . '</span>: <span class="zen-chapter-name">' . $match[3][$k] . '</span>';
                            } else {
                                $ele = '<a href="' . trim($link) . '"><span class="zen-chapter">' . $match[1][$k] . '</span>: <span class="zen-chapter-name">' . $match[3][$k] . '</span>';
                            }
                            $chapter_content .= '<li class="zen-list-chapter-item">' . $ele . '</a></li>';
                        }
                    }
                }
            }
            if ($chapter_content) {
                $chapter_content = '<ul class="zen-list-chapter">' . $chapter_content . '</ul>';
            }

            $post_content = $post_content . $chapter_content;
        } else {
            preg_match_all('/<div\s+id="detailcontent"\s+class="detailcontent\s+dtail">(.*)<\/div>\s*<div\s+class="setfontsize">/Uis', $content, $match);
            $match[1][0] = preg_replace('/<div\s+class="clearfix">\s*<\/div>\s*<div\s*align="left">.*<\/div>/is', '', $match[1][0]);
            $post_content = $match[1][0];
            preg_match_all("/<div\s+class=\"arowread\">(\s*<a\s+id='prechap'\s+title='(.*)'\s+href='(.*)'>&laquo;\s*(.+)<\/a>)?(\s*<a\s+id='nextchap'\s+title='(.*)'\s+href='(.*)'>(.+)\s+&raquo;<\/a>)?\s*<div\s+class=\"clearfix\">\s*<\/div>\s*<\/div>/Uis", $content, $match);
            $paging = '';
            if (!empty($match[1][0])) {
                $paging .= '<a class="zen-prechap" href="' . $match[3][0] . '" title="' . $match[2][0] . '">&laquo; Chương trước</a>';
            }
            if (!empty($match[5][0])) {
                $paging .= '<a class="zen-nextchap" href="' . $match[7][0] . '" title="' . $match[6][0] . '">Chương sau &raquo;</a>';
            }
            if ($paging) {
                $paging = '<div class="zen-paging">' . $paging . '</div>';
            }
            $post_content = $post_content . $paging;
        }
        if (empty($post_content)) {
            return false;
        }
        $data['content'] = $post_content;
        $link_inside = $this->detect_link_inside($data['content'], $url);
        if ($link_inside) $data['link_inside'] = array_reverse($link_inside);
        return $data;
    }
    public function leech_googleplay($url) {
        $url = 'http://services.zenthang.com/api/googleplay.php?g=' . urlencode($url);
        $data = $this->downloadContent($url);
        $data = json_decode($data, true);
        $out['title'] = trim($data['title']);
        $out['thumbnail'] = trim($data['icon']);
        if ($data['content_trans']) $out['content'] = $data['content_trans'];
        else $out['content'] = $data['content'];
        if (!$out['title'] || !$out['content']) return false;

        if ($data['list_image'] && is_array($data['list_image'])) {
            $out['content'] .= '<div class="zen-game-list-image" style="text-align: center">';
            $i = 0;
            foreach ($data['list_image'] as $item) {
                $i++;
                $out['content'] .= '<p><img class="zen-game-img" src="' . trim($item) . '" alt="' . $out['title'] . '"/></p>';
                if ($i > 3) {
                    break;
                }
            }
            $out['content'] .= '</div>';
        }
        $link_down = $data['link_down'];
        if ($this->_leech_googleplay_exists_acc_adflex()) {
            $this->_leech_googleplay_adflex_login();
            $l = $this->_leech_googleplay_adflex_ads($link_down);
            if ($l) {
                $link_down = $l;
            }
        }
        $out['content'] = '<p class="zen-game-link-down"><b>Link download:</b> <a href="' . $link_down . '">' . $link_down . '</a></p>' . $out['content'] . '<p class="zen-game-link-down"><b>Link download:</b> <a href="' . $link_down . '">' . $link_down . '</a></p>';
        return $out;
    }
    public $adflex;
    public function _leech_googleplay_exists_acc_adflex() {
        if (!empty($_COOKIE['username-adflex']) && !empty($_COOKIE['username-adflex'])) {
            return true;
        }
        return false;
    }
    public function _leech_googleplay_adflex_login($username = '', $password = '') {
        $login_url = 'http://pub.adflex.vn/login.html';
        $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6';
        $username = $username ? $username : (!empty($_COOKIE['username-adflex']) ? $_COOKIE['username-adflex'] : '');
        $password = $password ? $password : (!empty($_COOKIE['password-adflex']) ? $_COOKIE['password-adflex'] : '');
        if (!$username || !$password) return false;
        $postdata = "username=".$username."&password=".$password . '&submit_login=1';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_NOBODY, false);
        curl_setopt($ch, CURLOPT_URL, $login_url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
        //set the cookie the site has for certain features, this is optional
        curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
        curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $result = curl_exec ($ch);
        $this->adflex = $ch;
        if (preg_match('/href="\/login\.html\?do=logout"/is', $result)) {
            return true;
        } else return false;
    }
    public function _leech_googleplay_adflex_ads($link) {
        $request_url = 'http://pub.adflex.vn/?mod=ajax&col=index&act=get_google_play&link=' . urlencode($link);
        curl_setopt($this->adflex, CURLOPT_URL, $request_url);
        $response = curl_exec ($this->adflex);
        $response = json_decode($response, true);
        if (!$response || $response['error']) {
            return false;
        } else {
            $request_url = 'http://pub.adflex.vn/page/download_apk.html?download_file_apk=true&name=' . urlencode($response['name']);
            curl_setopt($this->adflex, CURLOPT_URL, $request_url);
            $response = curl_exec ($this->adflex);
            $response = json_decode($response, true);
            if (!$response || $response['status'] != true) {
                return false;
            } else {
                $post_url = 'http://pub.adflex.vn/page/wrapper.html?type=wap';
                $postData = 'wapper-file-source=link&link_apk=' . urlencode($link) . 'config_ads_custom[]=start&config_ads_custom[]=close&config_ads_custom[]=app&config_ads_small=1&config_ads_custom_app=app_bottom&file_rename_apk=';
                curl_setopt($this->adflex, CURLOPT_URL, $post_url);
                curl_setopt($this->adflex, CURLOPT_POST, 2);
                curl_setopt($this->adflex, CURLOPT_POSTFIELDS, $postData);
                curl_setopt($this->adflex, CURLOPT_FOLLOWLOCATION, true);
                curl_setopt($this->adflex, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec ($this->adflex);
                $response = json_decode($response, true);
                if (!$response || !$response['url']) {
                    return false;
                } else {
                    curl_setopt($this->adflex, CURLOPT_URL, $response['url']);
                    $response = curl_exec ($this->adflex);
                    preg_match_all('/<a\s+class="btn\s+btn\-large\s+btn\-success\s+btn\-block"\s+style="[^"]+"\s+href="([^"]+)"\s*>/is', $response, $match);
                    if (!$match[1][0]) {
                        return false;
                    } else return trim($match[1][0]);
                }
            }
        }
    }
}
Code:
<?php
/*
Plugin Name: Zen Smart Leech PRO
Plugin URI: http://zenthang.com
Description: Leech nội dung từ tất cả các website thông dụng hiện nay
Version: 3.3
Author: Zen Thắng
Author URI: http://zenthang.com
*/
include 'ZenLeech.lib.php';

function ZenLeech_ajax_load_scripts() {
    wp_enqueue_script( "zen-leech-ajax",  plugins_url( '/ZenLeech.js', __FILE__ ), array( 'jquery' ) );
    wp_localize_script( 'zen-leech-ajax', 'ZenLeechAjax', array( 'AjaxURL' => admin_url( 'admin-ajax.php' ) ) );
}
add_action('wp_print_scripts', 'ZenLeech_ajax_load_scripts');

function zen_save_account_adflex() {
    if (isset($_POST['submit-save-account-adflex'])) {
        $zen = new ZenLeech();
        $username = $_POST['username'];
        $password = $_POST['password'];
        if ($zen->_leech_googleplay_adflex_login($username, $password)) {
            setcookie('username-adflex', $username, time()+(7*24*3600));
            setcookie('password-adflex', $password, time()+(7*24*3600));
        }
    }
}
add_action('init', 'zen_save_account_adflex');

function zen_leech_ajax_handler() {
    $zen = new ZenLeech();

    if (isset($_POST['submit-leech']) || isset($_POST['submit-save'])) {
        $enable_edit = empty($_POST['enable-edit']) ? false : true;
        $recursive_leech = empty($_POST['recursive-leech']) ? false : true;
        $leech_img = empty($_POST['leech-img']) ? 0 : 1;
        $error = false;
        if (!empty($_POST['url'])) {
            $url = $_POST['url'];
            $cat = (int) $_POST['cat'];
            $driver = $zen->detect_driver($url);
            if (!$driver) {
                $zen->error('Zen Smart Leech chưa hỗ trợ leech từ trang này');
                $error = true;
            } else {
                if (!$cat) {
                    $zen->error('Bạn chưa chọn thể loại để leech vào');
                    $error = true;
                } else {
                    $name = 'leech_' . $driver;
                    $data = $zen->$name($url);
                    $data['cat'] = $cat;
                    if (!$data) {
                        $zen->error();
                        $error = true;
                    }
                }
            }
        } else {
            if (!empty($_POST['title']) || !empty($_POST['content']) || !empty($_POST['cat'])) {
                $data['cat'] = $_POST['cat'];
                $data['title'] = $_POST['title'];
                $data['content'] = $_POST['content'];
                $data['thumbnail'] = isset($_POST['thumbnail']) ? $_POST['thumbnail'] : '';
                $data['link_inside'] = isset($_POST['link_inside']) ? $_POST['link_inside'] : '';
            } else {
                $zen->error('Không tồn tại tiêu đề hoặc nội dung hoặc thể loại để lưu bài viết');
                $error = true;
            }
        }
        //return;
        if (!$error && !empty($data)) {
            if($zen->is_ajax() && $enable_edit) {
                $response = $data;
                $response['leech-img'] = $leech_img;
                echo json_encode($response);
                wp_die();
            } else {
                $post_id = $zen->insert_post($data['cat'], $data);
                if (!$post_id) {
                    $zen->error();
                } else {
                    $id = $post_id;
                    if ($data['thumbnail']) {
                        $id2 = $post_id;
                        $thumbnail = $zen->media_sideload_image($data['thumbnail'], $id2);
                        if (!$thumbnail || !is_string($thumbnail)) $thumbnail = $data['thumbnail'];
                        // Add Featured Image to Post
                        update_post_meta($id, '_nelioefi_url', $thumbnail);
                    }
                    if (!empty($_POST['leech-img'])) {
                        $update['ID'] = $post_id;
                        $update['post_content'] = $zen->_leech_image($post_id, $data['content']);
                        wp_update_post($update);
                    }
                    if (!empty($data['link_inside']) && is_array($data['link_inside'])) {
                        $ele_link_inside = json_encode($data['link_inside']);
                    } else $ele_link_inside = '';
                    $zen->success('Đã leech thành công <a href="http://Danhtac.com">Xem</a>');
                }
            }
        }
        if ($zen->is_ajax()) {
            wp_die();
        }
    }

    if (isset($_POST['submit-update-content'])) {
        $id = isset($_POST['id']) ? $_POST['id'] : 0;
        $matchListSearch = isset($_POST['matchListSearch']) ? $_POST['matchListSearch'] : '';
        $matchListReplace = isset($_POST['matchListReplace']) ? $_POST['matchListReplace'] : '';
        if ($id && is_array($matchListSearch) && is_array($matchListReplace)) {
            $arr = array_combine($matchListSearch, $matchListReplace);
            $post = get_post($id, ARRAY_A);
            if ($post && !empty($post['post_content'])) {
                $post['post_content'] = strtr ($post['post_content'], $arr);
                if ($post['post_content']) {
                    $post_update['ID'] = $id;
                    $post_update['post_content'] = $post['post_content'];
                    wp_update_post($post_update);
                    echo $id;
                }
            }
        }
        wp_die();
    }
}

add_action( 'wp_ajax_zen_leech_ajax_handler', 'zen_leech_ajax_handler' );
add_action( 'wp_ajax_nopriv_zen_leech_ajax_handler', 'zen_leech_ajax_handler' );

function ZenLeechInit() {

    echo '<div class="ZenLeech">
    <div class="row">
    <div class="col-sm-12 left-panel">
    <div class="panel panel-primary">
    <div class="panel-heading">Danhtac.com - Leech</div>
    <div class="panel-body">';

    zen_leech_ajax_handler();

    echo '<form name="ZenLeech" method="POST" class="form-horizontal">
        <div id="result-leech"></div>
        <div class="form-group">
        <label class="control-label col-sm-3">Nhập URL cần leech (VD: http://danhtac.com/bieu-tuong-that-truyen/)</label>
        <div class="col-sm-6"><input type="text" name="url" class="form-control"/></div>
        </div>
        <div class="form-group">
        <label class="control-label col-sm-3">Chọn truyện</label>
        <div class="col-sm-6">' . wp_dropdown_categories(array('echo' => false, 'hide_empty' => false, 'class' => 'form-control')) . '</div>
        </div>
        <div class="form-group">
        <label class="control-label col-sm-3"></label>
        <div class="col-sm-6"><label><input type="checkbox" name="edit" value="1" style="margin-top: -4px;"/> Sửa trước khi lưu</label></div>
        </div>
        <div class="form-group">
        <label class="control-label col-sm-3"></label>
        <div class="col-sm-6"><label><input type="checkbox" name="recursive-leech" value="1" style="margin-top: -4px;" checked/> Leech các trang con</label></div>
        </div>
        <div class="form-group">
        <label class="control-label col-sm-3"></label>
        <div class="col-sm-6"><label><input type="checkbox" name="leech-img" value="1" style="margin-top: -4px;"/> Lấy ảnh về host</label></div>
        </div>
        <div class="form-group">
        <label class="control-label col-sm-3"></label>
        <div class="col-sm-6"><button type="submit" name="submit-leech" class="btn btn-primary">Leech</button></div>
       </div>
    </form>';
    echo '</div>
    </div><!-- end panel -->';
    echo '<div class="panel panel-primary">
    <div class="panel-heading">Đã hỗ trợ</div>
    <div class="panel-body">
    <div class="list-group">
    <div class="list-group-item"><a href="http://Webtruyen.com" target="_blank">Webtruyen.com</a></div>
    <div class="list-group-item"><a href="http://Santruyen.com" target="_blank">Santruyen.com (hỗ trợ full trang)</a></div>
    <div class="list-group-item"><a href="http://Doctruyen360.com" target="_blank">Doctruyen360.com (hỗ trợ full trang)</a></div>
    <div class="list-group-item"><a href="http://TruyenNgan.com.vn" target="_blank">TruyenNgan.com.vn</a></div>
    </div>
    </div>
    </div>';
    echo '</div><!-- end col -->';
    echo '<div class="col-sm-8 editor-panel">
    <div class="panel panel-primary">
    <div class="panel-heading">Nội dung đã lấy</div>
    <div class="panel-body">
    <div id="result-after-save"></div>
    <form name="zen-leech-result" method="POST">
    <div class="form-group">
    <label>Chuyên mục</label>
    ' . wp_dropdown_categories(array('echo' => false, 'hide_empty' => false, 'class' => 'form-control', 'id' => 'cat2')) . '
    </div>';
    echo '<input type="hidden" name="thumbnail" value=""/>';
    echo '<div class="form-group">
    <label>Tiêu đề</label>
    <input type="text" name="title" class="form-control"/>
    </div>';
    echo '<div class="form-group">
    <label>Nội dung</label>
    <label><input type="checkbox" name="leech-img" value="1" style="margin-top: -4px;"/> Lấy ảnh về host</label>';
    wp_editor( '', 'content', $settings = array('editor_height' => 300) );
    echo '</div>';
    echo '<div class="form-group">
    <input type="submit" name="submit-save" value="Lưu lại" class="btn btn-primary"/>
    <input type="button" value="Đóng lại" class="btn btn-default close-result"/>
    </div>';
    echo '</form>
    </div>
    </div>
    </div>';

    echo '<div class="col-sm-8 process-panel">
    <div class="panel panel-primary">
    <div class="panel-heading">Quá trình leech</div>
    <div class="panel-body">
    <div class="process-close text-center"><input type="button" name="close" value="Đóng lại" class="btn btn-default"/></div>
    <h3 class="leech-process-text text-center"><span class="process-label">Đang diễn ra</span> <span class="process-control">(<span class="process-current">0</span>/<span class="process-total">0</span>)...</span></h3>
    <div class="leech-process-bar">
        <div class="progress">
          <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0">
            <span class="sr-only">0% Complete</span>
          </div>
        </div>
    </div>
    <div class="process-wrapper">
    <ul class="process-list list-group"></ul>
    </div>
    </div>
    </div>
    </div>';
    echo '</div><!-- end row -->
    <div class="zen-footer">Share By <a href="http://danhtac.com" target="_blank" rel="dofollow">Những tác phẩm văn học kinh điển</a></div>
    </div>';
}

function ZenLeech_add_action() {
    add_posts_page("ZEN SMART LEECH", "ZEN SMART LEECH", 'manage_options', "zen-leech", "ZenLeechInit");
}
add_action('admin_menu', 'ZenLeech_add_action');

add_action('admin_head', 'my_custom_fonts');

function my_custom_fonts() {
    echo '<style>';
    include 'ZenLeech.css';
    echo '</style>';
}
 

Đinh Quốc Hân

Đinh Quốc Hân
Staff member
Joined
Dec 11, 2015
Messages
6,000
#2
Kêu thằng tác giả ZenThang vào sửa chứ ai rảnh đi đọc code tìm hiểu mà sửa bạn -_- cả vấn đề ây.
 
Joined
Dec 12, 2015
Messages
94
#4
Nếu plugin này bạn mua thì bạn có thể liên hệ người bán plugin này để fix, mà hình như mình thấy giờ các trang đều chặn leech cả rồi hay sao ấy
 

Facebook Comment

Similar threads

New posts New resources Most viewed threads Threads with more replies