更新内容在DzzOffice 笔记中查看

主要更新内容:
1.优化评论时获取的浏览器操作系统平台信息
2.同步官方修复机构用户排序问题和优化应用权限检测功能
3.增加缓存调用特征参数
This commit is contained in:
小胡
2024-04-27 17:10:00 +08:00
Unverified
parent 6d654c69a4
commit 7b83833823
4 changed files with 86 additions and 50 deletions

View File

@@ -137,6 +137,11 @@ class Client extends GuzzleClient {
return $this->signature->createPresignedUrl($request, $expires);
}
public function getthumwaterUrl($method, $args=array(), $expires = null){
$command = $this->getCommand($method, $args);
$request = $this->commandToRequestTransformer($command);
return $this->createPresignedUrl($request, $expires);
}
public function getPresignetUrl($method, $args, $expires = null) {
$command = $this->getCommand($method, $args);
$request = $this->commandToRequestTransformer($command);

View File

@@ -1,45 +1,80 @@
<?php
namespace Qcloud\Cos;
use Psr\Http\Message\RequestInterface;
class Signature {
private $accessKey; // string: access key.
private $secretKey; // string: secret key.
public function __construct($accessKey, $secretKey, $token=null) {
$this->accessKey = $accessKey;
$this->secretKey = $secretKey;
$this->token = $token;
date_default_timezone_set("PRC");
}
public function __destruct() {
}
public function signRequest(RequestInterface $request) {
$authorization = $this->createAuthorization($request);
return $request->withHeader('Authorization', $authorization);
}
public function createAuthorization(RequestInterface $request, $expires = "+30 minutes") {
$signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires));
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getUri()->getPath()) .
"\n\nhost=" . $request->getHeader("Host")[0]. "\n";
$sha1edHttpString = sha1($httpString);
$stringToSign = "sha1\n$signTime\n$sha1edHttpString\n";
$signKey = hash_hmac('sha1', $signTime, $this->secretKey);
$signature = hash_hmac('sha1', $stringToSign, $signKey);
$authorization = 'q-sign-algorithm=sha1&q-ak='. $this->accessKey .
"&q-sign-time=$signTime&q-key-time=$signTime&q-header-list=host&q-url-param-list=&" .
"q-signature=$signature";
return $authorization;
}
public function createPresignedUrl(RequestInterface $request, $expires = "+30 minutes") {
$authorization = $this->createAuthorization($request, $expires);
$uri = $request->getUri();
$query = "sign=".urlencode($authorization);
if ($this->token != null) {
$query = $query."&x-cos-security-token=".$this->token;
namespace Qcloud\Cos;
use Psr\Http\Message\RequestInterface;
class Signature
{
private $accessKey; // string: access key.
private $secretKey; // string: secret key.
public function __construct($accessKey, $secretKey, $token = null)
{
$this->accessKey = $accessKey;
$this->secretKey = $secretKey;
$this->token = $token;
date_default_timezone_set("PRC");
}
public function __destruct()
{
}
public function signRequest(RequestInterface $request)
{
$authorization = $this->createAuthorization($request);
return $request->withHeader('Authorization', $authorization);
}
public function createAuthorization(RequestInterface $request, $expires = "+30 minutes")
{
$signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires));
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getUri()->getPath()) .
"\n\nhost=" . $request->getHeader("Host")[0] . "\n";
$sha1edHttpString = sha1($httpString);
$stringToSign = "sha1\n$signTime\n$sha1edHttpString\n";
$signKey = hash_hmac('sha1', $signTime, $this->secretKey);
$signature = hash_hmac('sha1', $stringToSign, $signKey);
$authorization = 'q-sign-algorithm=sha1&q-ak=' . $this->accessKey .
"&q-sign-time=$signTime&q-key-time=$signTime&q-header-list=host&q-url-param-list=&" .
"q-signature=$signature";
return $authorization;
}
public function createPresignedUrl(RequestInterface $request, $expires = "+30 minutes")
{
$authorization = $this->createAuthorization($request, $expires);
$uri = $request->getUri();
$query = "sign=" . urlencode($authorization);
if ($this->token != null) {
$query = $query . "&x-cos-security-token=" . $this->token;
}
$uri = $uri->withQuery($query);
return $uri;
}
public function createThumbWaterAuthorization($request, $expires){
$signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires));
$httpString = $request->geturi()->getQuery()."\n".strtolower($request->getMethod()) . "\n" . urldecode($request->getUri()->getPath()) .
"\n\nhost=" . $request->getHeader("Host")[0] . "\n";
$sha1edHttpString = sha1($httpString);
$stringToSign = "sha1\n$signTime\n$sha1edHttpString\n";
$signKey = hash_hmac('sha1', $signTime, $this->secretKey);
$signature = hash_hmac('sha1', $stringToSign, $signKey);
$authorization = 'q-sign-algorithm=sha1&q-ak=' . $this->accessKey .
"&q-sign-time=$signTime&q-key-time=$signTime&q-header-list=host&q-url-param-list=&" .
"q-signature=$signature";
return $authorization;
}
public function createThumbWatersignedUrl(RequestInterface $request, $expires = "+30 minutes")
{
$authorization = $this->createThumbWaterAuthorization($request, $expires);
$uri = $request->getUri();
$query = "sign=" . urlencode($authorization);
if ($this->token != null) {
$query = $query . "&x-cos-security-token=" . $this->token;
}
$uri = $uri->withQuery($query);
return $uri;
}
$uri = $uri->withQuery($query);
return $uri;
}
}

View File

@@ -195,8 +195,6 @@ class dzz_app extends dzz_base{
$_G['browser']=helper_browser::getbrowser();
$_G['platform']=helper_browser::getplatform();
$this->var = & $_G;
}
private function is_HTTPS(){
if($_SERVER['HTTPS'] === 1){ //Apache

View File

@@ -27,12 +27,10 @@ if (empty($_G['uid']) && !in_array($do, $guests)) {
}
}
if (submitcheck('replysubmit')) {
foreach ($_G['platform'] as $key => $value) {
$os= $key;
}
foreach ($_G['browser'] as $key => $value) {
$outputer= $key;
}
$os= get_os();
foreach ($_G['browser'] as $key => $value) {
$outputer= $key;
}
$message = censor($_GET['message']);
if (empty($message)) {