stanley-king 4 years ago
parent
commit
e801ad7b54

+ 86 - 0
conf/nginx/nginx-debug-http-8080.conf

@@ -0,0 +1,86 @@
+
+user nginx;
+worker_processes  1;
+error_log   /var/error.log  info;
+#pid        logs/nginx.pid;
+worker_rlimit_nofile 1024;
+
+events {
+    worker_connections  1024;
+}
+
+http 
+{
+    include       mime.types;
+    default_type  application/octet-stream;
+    fastcgi_buffer_size 32k;
+    fastcgi_buffers 8 32k;
+    underscores_in_headers on;
+    client_max_body_size 1024M;
+
+    sendfile            on;
+    keepalive_timeout   65;
+
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                      '$status $body_bytes_sent "$http_referer" '
+                      '"$http_user_agent" "$http_x_forwarded_for"';
+
+    server 
+    {
+    	listen       8080;
+        set  $folder_name /var/www/html;
+        server_name 192.168.1.200;
+        root $folder_name;
+        index index.html index.php; 
+    	client_max_body_size 100m;
+    	proxy_connect_timeout 500s;
+        proxy_read_timeout 500s;
+        proxy_send_timeout 500s;
+        fastcgi_connect_timeout 75;
+        fastcgi_read_timeout 600;   
+        fastcgi_send_timeout 600;   
+
+        charset utf-8;
+        
+        location /logs {
+            deny all;
+            return 403;
+        }
+
+        location /data/log {
+            deny all;
+            return 403;
+        }
+        location / {
+            index  index.html index.htm index.php;
+        }
+        
+        location /mshop {
+            root $folder_name;
+            autoindex on;        
+            index  index.html index.htm index.php;
+	        try_files $uri $uri/ /mshop/index.html;
+        }
+
+        location ~ /mobile/[/\w]+\.php$ {
+            root           $folder_name;
+            fastcgi_pass   tmobilesrv:9100;
+            fastcgi_index  index.php;
+            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
+            include fastcgi_params;
+        }
+
+        location ~ /mobile/[/\w]+\.html$ {
+            try_files $uri $uri/ /mobile/index.html;
+        }
+
+        location ~ \.php$ {
+	        add_header Cache-Control no-store;
+            root           $folder_name;
+            fastcgi_pass   tfpmsrv:9000;
+            fastcgi_index  index.php;
+            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
+            include        fastcgi_params;
+        }
+    }
+}

+ 86 - 0
conf/nginx/nginx-test-http.conf

@@ -0,0 +1,86 @@
+
+user nginx;
+worker_processes  1;
+error_log   /var/error.log  info;
+#pid        logs/nginx.pid;
+worker_rlimit_nofile 1024;
+
+events {
+    worker_connections  1024;
+}
+
+http 
+{
+    include       mime.types;
+    default_type  application/octet-stream;
+    fastcgi_buffer_size 32k;
+    fastcgi_buffers 8 32k;
+    underscores_in_headers on;
+    client_max_body_size 1024M;
+
+    sendfile            on;
+    keepalive_timeout   65;
+
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
+                      '$status $body_bytes_sent "$http_referer" '
+                      '"$http_user_agent" "$http_x_forwarded_for"';
+
+    server 
+    {
+    	listen       80;
+        set  $folder_name /var/www/html;
+        server_name www.xyzshops.cn;
+        root $folder_name;
+        index index.html index.php; 
+    	client_max_body_size 100m;
+    	proxy_connect_timeout 500s;
+        proxy_read_timeout 500s;
+        proxy_send_timeout 500s;
+        fastcgi_connect_timeout 75;
+        fastcgi_read_timeout 600;   
+        fastcgi_send_timeout 600;   
+
+        charset utf-8;
+        
+        location /logs {
+            deny all;
+            return 403;
+        }
+
+        location /data/log {
+            deny all;
+            return 403;
+        }
+        location / {
+            index  index.html index.htm index.php;
+        }
+        
+        location /mshop {
+            root $folder_name;
+            autoindex on;        
+            index  index.html index.htm index.php;
+	        try_files $uri $uri/ /mshop/index.html;
+        }
+
+        location ~ /mobile/[/\w]+\.php$ {
+            root           $folder_name;
+            fastcgi_pass   tmobilesrv:9100;
+            fastcgi_index  index.php;
+            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
+            include fastcgi_params;
+        }
+
+        location ~ /mobile/[/\w]+\.html$ {
+            try_files $uri $uri/ /mobile/index.html;
+        }
+
+        location ~ \.php$ {
+	        add_header Cache-Control no-store;
+            root           $folder_name;
+            fastcgi_pass   tfpmsrv:9000;
+            fastcgi_index  index.php;
+            fastcgi_param  SCRIPT_FILENAME  $folder_name$fastcgi_script_name;
+            include        fastcgi_params;
+        }
+    }
+}

+ 12 - 4
data/config/dev/pay.ini.php

@@ -20,10 +20,18 @@ define('OPENWX_APPSECRET',   '41f93fef3207e917e742b9ebcd540cb2');
 define('OPENWX_SSLCERT_PATH', '../cert/panda_cert.pem');
 define('OPENWX_SSLKEY_PATH',  '../cert/panda_key.pem');
 
-define('SIGN_APPID',       'wx6b42e00ecaade538');
-define('SIGN_APPSECRET',   'ee64233b3144d76217161666f8cb4c86');
-define('AUTHOR_APPID',       'wx6b42e00ecaade538');
-define('AUTHOR_APPSECRET',   'ee64233b3144d76217161666f8cb4c86');
+
+define('SIGN_APPID',       'wx4139a76ccb1f74b3');
+define('SIGN_APPSECRET',   '708ce8faa4ec48ba689b03e8fa7e592c');
+
+define('AUTHOR_APPID',       'wx4139a76ccb1f74b3');
+define('AUTHOR_APPSECRET',   '708ce8faa4ec48ba689b03e8fa7e592c');
+
+//define('SIGN_APPID',       'wx38f1d15c5337e89b');
+//define('SIGN_APPSECRET',   '93a258cb6b2f8baed8788e8035cd8205');
+//
+//define('AUTHOR_APPID',       'wx38f1d15c5337e89b');
+//define('AUTHOR_APPSECRET',   '93a258cb6b2f8baed8788e8035cd8205');
 
 //for panda
 //define(ALIPAY_PATH, BASE_DATA_PATH . '/api/alipay');

+ 4 - 4
data/config/prod/pay.ini.php

@@ -20,7 +20,7 @@ define('OPENWX_APPSECRET',   '41f93fef3207e917e742b9ebcd540cb2');
 define('OPENWX_SSLCERT_PATH', '../cert/panda_cert.pem');
 define('OPENWX_SSLKEY_PATH',  '../cert/panda_key.pem');
 
-define('SIGN_APPID',       'wx6b42e00ecaade538');
-define('SIGN_APPSECRET',   'ee64233b3144d76217161666f8cb4c86');
-define('AUTHOR_APPID',       'wx6b42e00ecaade538');
-define('AUTHOR_APPSECRET',   'ee64233b3144d76217161666f8cb4c86');
+define('SIGN_APPID',       'wx38f1d15c5337e89b');
+define('SIGN_APPSECRET',   '93a258cb6b2f8baed8788e8035cd8205');
+define('AUTHOR_APPID',       'wx38f1d15c5337e89b');
+define('AUTHOR_APPSECRET',   '93a258cb6b2f8baed8788e8035cd8205');

+ 118 - 0
docker-compose-devt.yml

@@ -0,0 +1,118 @@
+version: "3.7"
+
+services:
+  tnginxsrv:
+    image: nginx:alpine
+    ports:
+      - "8080:8080"
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/nginx/cert:/etc/nginx/cert
+      - $PWD/conf/nginx/nginx-debug-http-8080.conf:/etc/nginx/nginx.conf:ro
+    links:
+      - tmobilesrv
+      - tfpmsrv
+    container_name: "loctest-nginx"
+    command: [nginx,'-g','daemon off;']
+
+  tredisrv:
+    image: redis:alpine
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD/conf/redis/6379.conf:/usr/local/etc/redis/redis.conf
+      - $PWD/conf/redis:/var/redis
+    container_name: "loctest-redis"
+    command: [ "redis-server"]
+
+  tmobilesrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - $PWD/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/docker-php-spwan-start:/usr/local/bin/docker-php-spwan-start
+    links:
+      - tredisrv
+    container_name: "loctest-mobile"
+    command: ['docker-php-spwan-start']
+    depends_on:
+      - "tredisrv"
+      - "tSearchSrv"
+
+  tfpmsrv:
+      image: php-fpm:alpine
+      volumes:
+        - $PWD/conf/etc/localtime:/etc/localtime:ro
+        - $PWD:/var/www/html
+        - /Volumes/Transcend/upload:/var/www/html/data/upload
+        - $PWD/conf/php-fpm/php-debug.ini:/usr/local/etc/php/php.ini
+        - $PWD/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
+        - $PWD/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
+      container_name: "loctest-web"
+      command: [docker-php-fpm-start]
+      depends_on:
+        - "tredisrv"
+        - "tSearchSrv"
+
+  tphpcli:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - $PWD:/var/www/html
+    links:
+      - tredisrv
+    container_name: "loctest-php"
+    depends_on:
+      - "tredisrv"
+      - "tfpmsrv"
+      - "tSearchSrv"
+
+  tQueueSrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/queue/docker-queue-start:/usr/local/bin/docker-queue-start
+    links:
+      - tredisrv
+    container_name: "loctest-queue"
+    command: [docker-queue-start]
+    depends_on:
+      - "tredisrv"
+
+  tSearchSrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/searcher/docker-search-start:/usr/local/bin/docker-start
+    links:
+      - tredisrv
+    container_name: "loctest-searcher"
+    command: [docker-start]
+    depends_on:
+      - "tredisrv"
+
+  tcrontabsrv:
+      image: php-zts-debug:7.3.18
+      volumes:
+        - $PWD/conf/etc/localtime:/etc/localtime:ro
+        - $PWD:/var/www/html
+        - /Volumes/Transcend/upload:/var/www/html/data/upload
+        - $PWD/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+        - $PWD/conf/crontab/debug-root:/var/spool/cron/crontabs/root
+        - $PWD/conf/crontab/docker-start:/usr/local/bin/docker-start
+      links:
+        - tredisrv
+      container_name: "loctest-crontab"
+      command: [docker-start]
+      depends_on:
+        - "tredisrv"

+ 134 - 0
docker-compose-test.yml

@@ -0,0 +1,134 @@
+version: "3.7"
+
+services:
+  tnginxsrv:
+    image: nginx:alpine
+    ports:
+      - "80:80"
+    volumes:
+      - $PWD:/var/www/html
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - /mnt/upload:/var/www/html/data/upload
+      - $PWD/conf/nginx/cert:/etc/nginx/cert
+      - $PWD/conf/nginx/nginx-test-http.conf:/etc/nginx/nginx.conf:ro
+    links:
+      - tmobilesrv
+      - tfpmsrv
+    container_name: "xyztest-nginx"
+    command: [nginx,'-g','daemon off;']
+
+  tredisrv:
+    image: redis:alpine
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD/conf/redis/6379.conf:/usr/local/etc/redis/redis.conf
+      - $PWD/conf/redis:/var/redis
+    container_name: "xyztest-redis"
+    command: [ "redis-server"]
+
+  tmobilesrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - $PWD/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - /mnt/upload:/var/www/html/data/upload
+      - $PWD/conf/php/docker-php-start:/usr/local/bin/docker-php-start
+    links:
+      - tredisrv
+    container_name: "xyztest-mobile"
+    command: ['docker-php-start']
+    depends_on:
+      - "tredisrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"
+
+  tfpmsrv:
+    image: php-fpm:alpine
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /mnt/upload:/var/www/html/data/upload
+      - $PWD/conf/php-fpm/php.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
+      - $PWD/conf/php-fpm/docker-php-fpm-start:/usr/local/bin/docker-php-fpm-start
+    container_name: "xyztest-web"
+    command: [docker-php-fpm-start]
+    depends_on:
+      - "tredisrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"
+
+  tqueuesrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/queue/docker-queue-start:/usr/local/bin/docker-queue-start
+    links:
+      - tredisrv
+    container_name: "xyztest-queue"
+    command: [docker-queue-start]
+    depends_on:
+      - "tredisrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"
+
+  tsearchsrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/searcher/docker-search-start:/usr/local/bin/docker-start
+    links:
+      - tredisrv
+    container_name: "xyztest-searcher"
+    command: [docker-start]
+    depends_on:
+      - "tredisrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"
+
+  tcrontabsrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD:/var/www/html
+      - /Volumes/Transcend/upload:/var/www/html/data/upload
+      - $PWD/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - $PWD/conf/crontab/root:/var/spool/cron/crontabs/root
+      - $PWD/conf/crontab/docker-start:/usr/local/bin/docker-start
+    links:
+      - tredisrv
+    container_name: "xyztest-crontab"
+    command: [docker-start]
+    depends_on:
+      - "tredisrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"
+
+  tphpcli:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - $PWD/conf/etc/localtime:/etc/localtime:ro
+      - $PWD/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - $PWD:/var/www/html
+    links:
+      - tredisrv
+    container_name: "xyztest-php"
+    depends_on:
+      - "tredisrv"
+      - "tfpmsrv"
+      - "tsearchsrv"
+    extra_hosts:
+      - "docker.hostip:172.17.0.1"
+      - "eth.hostip:172.26.105.125"

+ 0 - 1
docker-compose.yml

@@ -4,7 +4,6 @@ services:
   nginxsrv:
     image: nginx:alpine
     ports:
-      - "80:80"
       - "443:443"
     volumes:
       - $PWD:/var/www/html

+ 19 - 0
helper/third_author/signaturer.php

@@ -6,8 +6,12 @@
  * Time: 上午10:25
  */
 
+
 namespace thrid_author;
 
+require_once(BASE_CORE_PATH . "/framework/function/http.php");
+
+use bonus\parameters;
 use Log;
 
 
@@ -18,6 +22,8 @@ class signaturer
 
     const access_token_url = "https://api.weixin.qq.com/cgi-bin/token";
     const ticket_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
+    const createwxaqrcode_url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode";
+    const getwxacode_url = "https://api.weixin.qq.com/wxa/getwxacode";
 
     const prefix = 'signaturer';
     const try_sleep = 5;
@@ -55,6 +61,19 @@ class signaturer
         return ["appid" => signaturer::appid,"noncestr" => $nonceStr,"timestamp" => $timestamp,"signature" => $signature];
     }
 
+    public function minicode($path,$width)
+    {
+        $token = $this->access_token();
+        if($token == false) return false;
+
+        $access_token = $token['token'];
+        $param = ['path' => $path,'width' => $width];
+        $url = self::getwxacode_url . "?access_token={$access_token}";
+        $resp = http_post_data($url,json_encode($param));
+
+        return $resp;
+    }
+
     private function noncestr($length = 16)
     {
         $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

+ 20 - 4
test/TestQRcode.php

@@ -1,18 +1,35 @@
 <?php
+declare(strict_types=1);
 
+use PHPUnit\Framework\TestCase;
 /**
  * Created by PhpStorm.
  * User: stanley-king
  * Date: 2017/5/20
  * Time: 下午4:09
  */
-define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
-require_once(BASE_ROOT_PATH . '/fooder.php');
 
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/third_author/signaturer.php');
 
-class TestQRcode extends PHPUnit_Framework_TestCase
+class TestQRcode extends TestCase
 {
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+    }
+
+    public function testMiniCode()
+    {
+        $resp = thrid_author\signaturer::instance()->minicode('/pages/index/index?relay_id=52620&channel=0',430);
+        file_put_contents('x.png',$resp);
+    }
+
     public function testPgenA()
     {
         for ($i = 0; $i < 1000;$i++) {
@@ -42,7 +59,6 @@ class TestQRcode extends PHPUnit_Framework_TestCase
         }
     }
 
-
     public function testPgenD()
     {
         $roomid = 37;