| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- namespace app\admin\controller;
- use cmf\controller\AdminBaseController;
- use think\Db;
- use tree\Tree;
- class BaiduController extends AdminBaseController{
- // 百度链接自动提交
- public function baidu(){
- $param = $this->request->param();
- if (isset($param['ids'])) {
- $ids = $param['ids'];
- $where = [];
- $where[] = ['id','in', $ids];
-
- // $field = 'a.id,a.baidu,a.post_title,b.category_id,c.alias';
- // $artRes = Db::name('jiameng')->alias('a')->field($field)
- // ->join('brand_category_post b','a.id = b.post_id')
- // ->join('brand_category c','b.category_id = c.id')
- // ->where($where)
- // ->order('a.create_time', 'DESC')
- // ->select()->toArray();
- $artRes = Db::name('jiameng')->where($where)->select()->toArray();
-
- }
- // print_r($artRes);die;
- $urls = array();
- $dataRes = array();
- $local = $_SERVER['SERVER_NAME'];
- foreach ($artRes as $k => &$v) {
-
- $v['arcurl'] = 'http://'.$local.'/b'.$v['id']."/";
- if($v['baidu']==0){
- $urls[] = $v['arcurl'];
- $dataRes[$v['id']] = $v['post_title'];
- }
- }
- $site_info = cmf_get_option('site_info');
- // print_r($site_info);die;
- if($site_info['site_tj_pc'] == ''){
- $this->error("请设置百度提交参数!",'');
- }
- $site_baidu = $site_info['site_tj_pc'];
- $site_baidu = explode('&', $site_baidu);
- $site_baidu = implode('&', $site_baidu);
- $site_baidu = str_replace(PHP_EOL, '', $site_baidu);
- // dump($dataRes);die;
- if(count($urls)>0 && trim($site_baidu)!=''){
- $api = $site_baidu;
- $ch = curl_init();
- $options = array(
- CURLOPT_URL => $api,
- CURLOPT_POST => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POSTFIELDS => implode("\n", $urls),
- CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
- );
- curl_setopt_array($ch, $options);
- $curlresult = curl_exec($ch);
- $cuarray = json_decode($curlresult,true);
- // dump($cuarray);die;
- if($cuarray['success']>0){
- //如果提交过并且成功的将其状态标记为1
- foreach ($dataRes as $k => $v) {
- Db::name('brand_post')->where('id',$k)->update(['baidu' => '1']);
- }
- $this->success("共提交".$cuarray['success']."条。今日自动提交剩余".$cuarray['remain'].'条','');
-
- }else{
- $this->error("今天提交已经到上线,明天再来吧!",'');
- }
- }else{
- $this->success("没有新百度Pc连接提交",'');
- }
- }
-
- // 百度手机链接自动提交
- public function shouji(){
- $param = $this->request->param();
- if (isset($param['ids'])) {
- $ids = $param['ids'];
- $where[] = ['id','in', $ids];
-
- $artRes = Db::name('jiameng')->where($where)->select()->toArray();
- }
-
- $urls = array();
- $dataRes = array();
- $local = $_SERVER['SERVER_NAME'];
- $host = explode('.', $local);
- if(count($host)==3){
- $host = $host[1].'.'.$host[2];
- }else{
- $host = $host[1].'.'.$host[2].'.'.$host[3];
- }
- $local = 'm.'.$host;
-
- foreach ($artRes as $k => &$v) {
- $v['arcurl'] = 'http://'.$local.'/b'.$v['id']."/";
- if($v['shouji']==0){
- $urls[] = $v['arcurl'];
- $dataRes[$v['id']] = $v['post_title'];
- }
-
- }
-
- $site_info = cmf_get_option('site_info');
-
- if($site_info['site_tj_mobile'] == ''){
- $this->error("请设置百度提交参数!",'');
- }
-
- $site_shouji = $site_info['site_tj_mobile'];
- $site_shouji = explode('&', $site_shouji);
- $site_shouji = implode('&', $site_shouji);
- $site_shouji = str_replace(PHP_EOL, '', $site_shouji);
- // print_r($urls);exit;
- if(count($urls)>0 && trim($site_shouji)!=''){
- $api = $site_shouji;
- $ch = curl_init();
- $options = array(
- CURLOPT_URL => $api,
- CURLOPT_POST => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POSTFIELDS => implode("\n", $urls),
- CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
- );
- curl_setopt_array($ch, $options);
- $curlresult = curl_exec($ch);
- $cuarray = json_decode($curlresult,true);
- // dump($cuarray);die;
- if($cuarray['success']>0){
- //如果提交过并且成功的将其状态标记为1
- foreach ($dataRes as $k => $v) {
- Db::name('brand_post')->where('id',$k)->update(['shouji' => '1']);
- }
- $this->success("<br/>共提交".$cuarray['success']."条。今日自动提交剩余".$cuarray['remain'].'条<br/>','');
-
- }else{
- $this->error("今天提交已经到上线,明天再来吧!".'');
- }
- }else{
- $this->success("没有新手机百度连接提交",'');
- }
- }
-
- // 百度链接自动提交
- public function bear(){
- $param = $this->request->param();
- $param = $this->request->param();
- if (isset($param['ids'])) {
- $ids = $param['ids'];
- $where[] = ['id','in', $ids];
-
- $artRes = Db::name('jiameng')->where($where)->select()->toArray();
- }
- //dump($artRes);die;
- $urls = array();
- $dataRes = array();
- $local = $_SERVER['SERVER_NAME'];
- foreach ($artRes as $k => &$v) {
- $v['arcurl'] = 'http://'.$local.'/b'.$v['id']."/";
- if($v['xiongzhang']==0){
- $urls[] = $v['arcurl'];
- $dataRes[$v['id']] = $v['post_title'];
- }
- }
- // dump($urls);exit;
- $site_info = cmf_get_option('site_info');
-
- //dump($site_info);die;
- if($site_info['site_tj_xiongzhang'] == ''){
- $this->error("请设置熊掌号提交参数!",'');
- }
- $site_xiongzhang = $site_info['site_tj_xiongzhang'];
- $site_xiongzhang = explode('&', $site_xiongzhang);
- $site_xiongzhang = implode('&', $site_xiongzhang);
- $site_xiongzhang = str_replace(PHP_EOL, '', $site_xiongzhang);
-
- // dump($dataRes);die;
- if(count($urls)>0 && trim($site_xiongzhang)!=''){
- $api = trim($site_xiongzhang);
- $ch = curl_init();
- $options = array(
- CURLOPT_URL => $api,
- CURLOPT_POST => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POSTFIELDS => implode("\n", $urls),
- CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
- );
- curl_setopt_array($ch, $options);
- $curlresult = curl_exec($ch);
- $cuarray = json_decode($curlresult,true);
- // dump($cuarray);die;
- if($cuarray['success']>0){
- //如果提交过并且成功的将其状态标记为1
- foreach ($dataRes as $k => $v) {
- Db::name('brand_post')->where('id',$k)->update(['xiongzhang' => '1']);
- }
- $this->success("<br/>共提交".$cuarray['success']."条。今日自动提交剩余".$cuarray['remain'].'条<br/>','');
-
- }else{
- $this->error("今天提交已经到上线,明天再来吧!",'');
- }
- }else{
- $this->success("没有新熊掌天级连接提交",'');
- }
- }
- }
|