فهرست منبع

Merge branch 'master' of https://git.97admin.com:433/chendeben/taoqu

chendeben 6 سال پیش
والد
کامیت
f99556cdc7
4فایلهای تغییر یافته به همراه80 افزوده شده و 2 حذف شده
  1. 23 0
      App/Api/Controller.php
  2. 13 2
      App/Api/Controller/Category.php
  3. 18 0
      App/Api/Controller/Sitemap.php
  4. 26 0
      Config/Redis/Core.php

+ 23 - 0
App/Api/Controller.php

@@ -6,6 +6,7 @@ namespace Heanup\App\Api;
 use Exception;
 use Heanup\App\Api\Controller\Search;
 use Heanup\Library\Memcached;
+use Heanup\Library\Redis;
 
 abstract class Controller extends \Heanup\Frame\Controller
 {
@@ -18,6 +19,28 @@ abstract class Controller extends \Heanup\Frame\Controller
     protected function main()
     {
 
+    }
+    public function addSitemap($url){
+        $urls = array(
+            $url,
+        );
+        $api = 'http://data.zz.baidu.com/urls?site=www.taoqu88.com&token=pKgc8vvoowMXccMI';
+        $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);
+        $result = curl_exec($ch);
+        file_put_contents(APP_DIR."/baidu.log", $result);
+//        $hashKey="sitemap:".md5($url);
+//        $exist=Redis::instance()->get($hashKey);
+//        if (!$exist){
+//            Redis::instance()->set($hashKey, $url,86400*3);
+//        }
     }
 
     /**

+ 13 - 2
App/Api/Controller/Category.php

@@ -28,11 +28,22 @@ class Category extends Controller
         if ($original_id) {
             $request['original_id'] = $original_id;
         }
-        if ($page){
-            $request['page']=$page;
+        if ($page) {
+            $request['page'] = $page;
         }
         $url = Site::getData('site_url') . "/tao.php?" . http_build_query($request);
         echo Dataoke::parse(file_get_contents($url));
     }
 
+    protected function after()
+    {
+        $id = $this->getQuery()->string("args_0");
+        $page = $this->getQuery()->string("args_1");
+        if ($page) {
+            $site_url = Site::getData('site_url') . "/category/" . $id . "/page_" . $page . ".html";
+        } else {
+            $site_url = Site::getData('site_url') . "/category/" . $id . "/index.html";
+        }
+        $this->addSitemap($site_url);
+    }
 }

+ 18 - 0
App/Api/Controller/Sitemap.php

@@ -0,0 +1,18 @@
+<?php
+
+
+namespace Heanup\App\Api\Controller;
+
+
+use Heanup\App\Api\Config\Site;
+use Heanup\App\Api\Controller;
+use Heanup\App\Api\Model\Dataoke;
+
+class Sitemap extends Controller
+{
+    protected function main()
+    {
+        
+    }
+
+}

+ 26 - 0
Config/Redis/Core.php

@@ -0,0 +1,26 @@
+<?php
+
+
+namespace Heanup\Config\Redis;
+
+
+use Heanup\Frame\Config;
+
+class Core extends Config
+{
+    protected static $data = [
+        "master" => [
+            "host" => "redis",
+            "port" => "6379",
+            "timeout" => 3
+        ],
+        "slave_list" => [
+            [
+                "host" => "redis",
+                "port" => "6379",
+                "timeout" => 3
+            ]
+        ]
+    ];
+
+}