diff --git a/docs/_sidebar.md b/docs/_sidebar.md index d6e4950..8bfce49 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -84,9 +84,11 @@ - [使用的第三方接口](/manual/about/third-party-interface) -- **七、内部开发文档** +- **七、背Ta单词内部开发文档** - - [安装升级向导](/manual/internal/deployment-wizard) + - [安装升级向导 官网接口](/manual/internal/deployment-wizard) + - [官网首页伪静态配置规则](/manual/internal/pseudo-static) + - [检查SSL证书过期时间[PHP]](/manual/internal/check-cert) - **八、其他** diff --git a/docs/index.html b/docs/index.html index 38e888e..8193b47 100644 --- a/docs/index.html +++ b/docs/index.html @@ -137,7 +137,7 @@ hook.beforeEach(function(content) { var url = 'https://gitee.com/tawords/tawords-docs/blob/master/docs/' + vm.route.file; - var editHtml = '\n[📝 在Gitee上编辑当前文档](' + url + ')\n'; + var editHtml = '\n\n[📝 在Gitee上编辑当前文档](' + url + ')\n\n'; var updateTimeHtml = '\n\n' + '

更新时间:{docsify-updated}

' + '\n\n'; diff --git a/docs/manual/internal/check-cert.md b/docs/manual/internal/check-cert.md new file mode 100644 index 0000000..51c65e8 --- /dev/null +++ b/docs/manual/internal/check-cert.md @@ -0,0 +1,93 @@ +> 2021.08.18更新 + +certcheck.php + +```php +"; +} + + +//检测证书信息 +function check($domain){ + $stream_option = array( + "ssl" => array( + "capture_peer_cert_chain" => true + ) + ); + $stream = stream_context_create($stream_option); + $stream_client = stream_socket_client("ssl://".$domain.":443", $errno, $errstr, 20, STREAM_CLIENT_CONNECT, $stream); + if(!$stream_client){ + return "发生错误,错误代码:".$errno; + } + $stream_info = stream_context_get_params($stream_client); + stream_socket_shutdown($stream_client, STREAM_SHUT_WR); + + foreach ($stream_info["options"]["ssl"]["peer_certificate_chain"] as $cert) { + $cerInfo = openssl_x509_parse($cert); + if(strstr($cerInfo["extensions"]["subjectAltName"],"DNS:".$domain) != false){ + return expireLeft($cerInfo['validTo_time_t']); + if($cerInfo['validTo_time_t'] - time() < 86400){ + sendFTQQ($domain); + } + }else{ + return "未发现该证书对应的域名:".$cerInfo["extensions"]["subjectAltName"]; + } + } +} + +//证书到期时间格式化 +function expireLeft($exp_time){ + $sec = $exp_time - time(); + switch ($sec) + { + case $sec<0: + return "已过期"; + break; + case $sec > 0 and $sec < 61: + return $c."秒"; + break; + case $sec < 3600 and $sec > 60: + return round($c/60,0)."分钟"; + break; + case $sec < 86401 and $sec > 3600: + return round($c/3600,0)."小时"; + break; + case $sec > 86400: + return floor($sec/86400)."天"; + break; + } +} + +//方糖通知 +//申请地址:http://sc.ftqq.com/3.version +function sendFTQQ($domain){ +// $SCKEY = "方糖KEY"; +// $url = 'https://sc.ftqq.com/'.$SCKEY.'.send?desp='.urlencode($domain).'&text='.urlencode("域名证书到期通知"); +// $ch = curl_init(); +// curl_setopt($ch, CURLOPT_URL, $url); +// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); +// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); +// curl_setopt($ch, CURLOPT_SSLVERSION , CURL_SSLVERSION_DEFAULT); +// curl_setopt($ch, CURLOPT_POST, TRUE); +// curl_setopt($ch, CURLOPT_POSTFIELDS, $data); +// curl_setopt($ch, CURLOPT_TIMEOUT, 10); +// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +// $result = curl_exec($ch); +// curl_close($ch); + return; +} +?> +``` + diff --git a/docs/manual/internal/pseudo-static.md b/docs/manual/internal/pseudo-static.md new file mode 100644 index 0000000..374c8dc --- /dev/null +++ b/docs/manual/internal/pseudo-static.md @@ -0,0 +1,68 @@ +> 使用宝塔配置 + +## 配置文件 + +删除 `|LICENSE|README.md` : + +```nginx +#禁止访问的文件或目录 +# location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) # 修改这一行 +location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project) # 为这一行 +{ + return 404; +} +``` + + + +## 伪静态 + +> 2021.08.18更新 + +http跳转https;www跳转@;访问二级域名指向网站的二级路径 + +```nginx +# http跳转https +if ($server_port !~ 443){ + rewrite ^(/.*)$ https://$host$1 permanent; +} + +# 👇www跳转@ +if ($host ~* "^www\.(.*?\..*?)$") # if ($host = 'www.reciteword.com') +{ + # $host = www.reciteword.com + # $1 = reciteword.com + return 301 https://$1; # https://reciteword.com$request_uri; +} + +location ~ { + index index.php index.html index.htm; + + # 👇访问二级域名指向网站的二级路径 + # 定义一个变量,用于保存正则表达式的匹配值(Nginx不允许嵌套if) + set $param ""; + if ($http_host ~* "^(.*?)\..*?\..*?$") # if ($http_host ~* "^(.*?)\.reciteword\.com$") + { + set $param $1; # $param 是正则表达式的匹配值 + } + # 定义默认指向二级路径(需要考虑首页) + set $domain "@"; + if ($param != "") # 非首页 + { + set $domain $param; # 指向网站的二级路径 + } + # 到目前为止,已经完成获取 xx.reciteword.com 的 xx 信息了(如果是 reciteword.com 则为@) + + # 接下来是设置网站的 root(需要考虑文档 docs 是独立的目录) + if ($domain != "docs") + { + root /www/wwwroot/tawords-server-side/$domain; + } + if ($domain = "docs") + { + root /www/wwwroot/tawords-docs/docs; # docs 为仓库 docs/ 文件夹 + } +} +# autoindex on; # 自动索引(测试时使用,线上环境勿开) +``` +