最新帝国cms主动推送插件(集所有搜索最全版)

优站网给大家分享一个帝国插件代码:
<br><?php
class zhanzhangPush {
    private $dbhost 'localhost:3306'// mysql服务器主机地址
    private $dbuser ''// mysql用户名
    private $dbpass ''// mysql用户名密码
    private $domain ''//不带www的域名
    private $zhanzhangToken ''//站长token
    private $xiongToken ''//熊掌号token
    private $xiongAppid ''//熊掌号appid
    private $shenmaUserName ''//神马username
    private $shenmaToken ''//神马token
    private $http "https"//协议请求 http  https
    private $database ''//数据库名
    private $www 'm'//域名前缀  www m
     
    public function init() {
        $this->shenma_push($urls);
        // $this->baidu_push($urls);
        // $this->real_push($urls);
        // $this->batch_push($urls);
        $this->sogouPush($urls);
    }
    /**
     * 获取网站url 代码来源 www.zjkweiqi.cn 这家软件站
     */
    public function get_site_urls($artId$vodId$limit = 800) {
        $limit $limit / 2;
        $conn = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass);
        if (!$conn) {
            die('连接失败: ' . mysqli_error($conn));
        }
        //var_dump($conn);die;
        mysqli_query($conn"set names utf8");
        mysqli_select_db($conn$this->database);
  
        //var_dump($artId);die;
        //var_dump($urls);die;
        //查找电影--------------------------------------------------
        $sql "SELECT titleurl,id   FROM www_96kaifa_com_ecms_news where id > {$artId} limit $limit";
        $retval = mysqli_query($conn$sql);
        if (!$retval) {
            die('无法读取数据: ' . mysqli_error($conn));
        }
        $urls = [];
        while ($row = mysqli_fetch_assoc($retval)) {
            $artId $row['id'];
            // echo 'vod'.$vodId.'<br>';
            array_push($urls$this->http . "://m." $this->domain . $row['titleurl']);
        }
        $data = ['urls' => $urls'art_id' => $artId'vod_id' => $vodId];
        return $data;
    }
    /**
     * 获取api接口
     */
    public function get_api($zhanzhang) {
        switch ($zhanzhang) {
            case 'shenma':
                return "http://data.zhanzhang.sm.cn/push?site=".$this->www."." $this->domain . "&user_name=" $this->shenmaUserName . "&resource_name=mip_add&token=" $this->shenmaToken;
            case 'realtime':
                return "http://data.zz.baidu.com/urls?appid=" $this->xiongAppid . "&token=" $this->xiongToken . "&type=realtime";
            case 'batch':
                return "http://data.zz.baidu.com/urls?appid=" $this->xiongAppid . "&token=" $this->xiongToken . "&type=batch";
            case 'baidu':
                return "http://data.zz.baidu.com/urls?site=".$this->www."." $this->domain . "&token=" $this->zhanzhangToken;
        }
    }
    /**
     * 推送
     */
    public function push($api$urls) {
        // var_dump($urls);die;
        $ch = curl_init();
        $options array(CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
        // CURLOPT_POSTFIELDS => implode("\n", array_slice($urls,0,10)),
        CURLOPT_POSTFIELDS => implode("\n"$urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),);
        curl_setopt_array($ch$options);
        $res = curl_exec($ch);
        return $res;
    }
    /**
     * 神马站长推送
     */
    public function shenma_push($urls) {
        $configData $this->get_config();
        $data $this->get_site_urls($configData['shenma']['art_id'], $configData['shenma']['vod_id']);
        $urls $data['urls'];
        $configData['shenma']['art_id'] = $data['art_id'];
        $configData['shenma']['vod_id'] = $data['vod_id'];
        //推送接口
        $api $this->get_api('shenma');
        $res $this->push($api$urls);
        $jsonres = json_decode($res);
        if ($jsonres->errorMsg == '') {
            $this->log("神马站长成功推送" count($urls) . "条");
            $this->update_config($configData);
        else {
            $this->log("神马站长推送失败:" $res);
        }
        // echo "<pre>";var_dump($configData);die;
        var_dump($res);
    }
    /**
     * 百度站长推送
     */
    public function baidu_push($urls) {
        $configData $this->get_config();
        $data $this->get_site_urls($configData['baidu']['art_id'], $configData['baidu']['vod_id']);
        $urls $data['urls'];
        $configData['baidu']['art_id'] = $data['art_id'];
        $configData['baidu']['vod_id'] = $data['vod_id'];
        $api $this->get_api('baidu');
        $res $this->push($api$urls);
        $jsonres = json_decode($res);
        if ($jsonres->error >= 400) {
            $this->log("百度站长推送失败:" $res);
        else {
            $this->log("百度站长成功推送" $jsonres->success . "条,今日还可推送:" $jsonres->remain . "条");
            $this->update_config($configData);
        }
        var_dump($urls);die;
        echo "<pre> 百度站长推送";
        var_dump($res);
    }
    /**
     * 熊掌号天级推送
     */
    public function real_push($urls) {
        $configData $this->get_config();
        $data $this->get_site_urls($configData['realtime']['art_id'], $configData['realtime']['vod_id'], 10);
        $urls $data['urls'];
        $configData['realtime']['art_id'] = $data['art_id'];
        $configData['realtime']['vod_id'] = $data['vod_id'];
        $api $this->get_api('realtime');
        $res $this->push($api$urls);
        $jsonres = json_decode($res);
        if ($jsonres->error >= 400) {
            $this->log("熊掌号天级推送失败:" $res);
        else {
            $this->log("熊掌号天级成功推送" $jsonres->success . "条,今日还可推送:" $jsonres->remain . "条");
            $this->update_config($configData);
        }
        // var_dump($urls);die;
        echo "<pre>";
        var_dump($res);
    }
    /**
     * 熊掌号周级推送
     */
    public function batch_push($urls) {
        $configData $this->get_config();
        $data $this->get_site_urls($configData['batch']['art_id'], $configData['batch']['vod_id']);
        $urls $data['urls'];
        $configData['batch']['art_id'] = $data['art_id'];
        $configData['batch']['vod_id'] = $data['vod_id'];
        $api $this->get_api('batch');
        $res $this->push($apiarray_slice($urls, 0, 1));
        $jsonres = json_decode($res);
        if ($jsonres->error >= 400) {
            $this->log("熊掌号周级推送失败:" $res);
        else {
            $this->log("熊掌号周级成功推送" $jsonres->success . "条,今日还可推送:" $jsonres->remain . "条");
            $this->update_config($configData);
        }
        // var_dump($urls);die;
        echo "<pre>";
        var_dump($res);
    }
    /**
     *搜狗推送
     */
    public function sogouPush($urls) {
        $configData $this->get_config();
        $data $this->get_site_urls($configData['sougou']['art_id'], $configData['sougou']['vod_id'], 10);
        $urls $data['urls'];
        $configData['sougou']['art_id'] = $data['art_id'];
        $configData['sougou']['vod_id'] = $data['vod_id'];
        echo ("<pre>");
        // var_dump($data);die;
        for ($i = 0;$i count($urls);$i++) {
            $postUrl 'http://fankui.help.sogou.com/index.php/web/web/addShoulu';
            $postData array("source" => "1""site_type" => "1""Shoulu" => array("webAdr" => $urls[$i], "email" => "103@qq.com""reason" => ""));
            $postData = http_build_query($postData);
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $postUrl);
            curl_setopt($curl, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
            curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
            $res = curl_exec($curl);
            curl_close($curl);
            $jsonres = json_decode($res);
            if ($jsonres->success == 'true') {
                $this->log("搜狗推送成功:" $urls[$i]);
            else {
                $this->log("搜狗推送失败:" $urls[$i]);
            }
        }
        $this->update_config($configData);
    }
    /**
     * 获取配置信息
     */
    public function get_config() {
        $configPath 'push_config.txt';
        if (file_exists($configPath)) {
            $data file_get_contents($configPath);
            return unserialize($data);
        else {
            $myfile fopen($configPath"w");
             $configData = [
                'shenma' => [
                    'art_id' => 0,
                    'vod_id' => 0
                    ],
                'baidu' => [
                    'art_id' => 0,
                    'vod_id' => 0
                    ],
                'realtime' => [
                    'art_id' => 0,
                    'vod_id' => 0
                    ],
                'batch' => [
                    'art_id' => 0,
                    'vod_id' => 0
                    ],
                'sougou' => [
                    'art_id' => 0,
                    'vod_id' => 0
                    ],
                ];
            fwrite($myfile, serialize($configData));
            fclose($myfile);
            return $configData;
        }
    }
    /**
     * 修改配置信息
     */
    public function update_config($configData) {
        $configPath 'push_config.txt';
        $myfile fopen($configPath"w");
        fwrite($myfile, serialize($configData));
        fclose($myfile);
    }
    public function log($data) {
        file_put_contents('zhanzhang_push.log'date('Y-m-d H:i:s') . " " $data . PHP_EOL, FILE_APPEND);
    }
}
$obj new zhanzhangPush();
$obj->init();
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

免责声明   ⚠️ 1. 本站所有资源来源于网络收集,若资源侵犯了您的合法权益, 请来信通知我们(Email: 1427707223@qq.com),我们会及时删除,给您带来的不便,我们深表歉意! 2. 分享目的仅供大家学习和交流,若使用商业用途,请购买正版授权! 否则产生的一切后果将由下载用户自行承担! 3. 会员不得使用于非法商业用途,不得违反国家法律。否则后果自负! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 6. 因源码具有可复制性,一经购买 ,不得以任何形式退款。 7.更多详情请点击查看

优站网 其他插件 最新帝国cms主动推送插件(集所有搜索最全版) https://www.zhanceo.com/12480.html

诚乃立身之本、信为道德之基

常见问题
  • 如果付款后没有弹出下载页面,多刷新几下,有问题联系客服!
查看详情
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情

相关文章

联系官方客服

为您解决烦忧 - 24小时在线 专业服务

最新帝国cms主动推送插件(集所有搜索最全版)-海报