分类 默认 下的文章

原因是curl没有https协议 该协议需要证书。可以用以下方法解决:

1.打开 https://curl.se/docs/caextract.html 下载【cacert.pem】
7.png

2.打开php所在的版本位置,找到php.ini 配置证书,比如我的路径在:E:phpstudy_proExtensionsphpphp7.3.4nts

3.php.ini 查找CTRL+F 【curl.cainfo】 将签名的;去掉注释,并将【cacert.pem】的绝对路径填上

curl.cainfo = E:\phpstudy_pro\Extensions\cacert.pem;

重启Apache、php服务即可

代码片段

$now=time()#代表当前
$expire_time = 1640864585;#2021-12-30 19:43:05
$day=floor(abs(($expire_time-$now)/86400));

在实际的开发中,因为缺乏对下单并发场景的认识,后端逻辑没有对重复请求进行过滤,就会出现重复订单(严重的业务漏洞)、产生经济损失和退单的售后成本。所以我们十分有必要进行对重复订单进行处理。

常见的方法有以下几种:

【锁-机制】
在数据库中建立锁表

CREATE TABLE `TradeLock` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` int(11) NOT NULL COMMENT '锁类型',
`lockId` int(11) NOT NULL DEFAULT '0' COMMENT '业务ID',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '锁状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='Trade锁机制';

每次request进来则往表里面插入数据:

成功--获得锁--继续操作
失败-->返回错误

在应对高并发场景,频繁请求数据不是明智的方法,这里我们就想到用redis做队列控制。
原理:入队---扣库存--执行(在原队列有逻辑没处理完成即返回库存不足!)

【计数器】

每次请求+1 利用cache缓存、设定失效时间30s(具有根据业务场景)。假如里面有请求则返回不要重复下单。以下是利用tp5里面的redis的cache驱动做计数器。

use thinkCache;

#缓存计数器 解决并发重复订单问题
$request =Cache('request_'.$user_id);
$request =$request+1;
Cache('request_'.$user_id,$request,30);
if($request>1){
    $response['code'] =0;
    $response['msg'] ='请勿重复操作';
    $response['data']='';
    return json($response);
}

引用
【防重复请求处理方案】
https://www.jianshu.com/p/a8655bdd73cd?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

1.特定用户下通过crontab -e命令编辑crontab任务,比如www
命令应该为:

crontab -e -u www

进入定时任务编辑界面:
701.png

英文键盘, 按【i】进入编辑模式
750.png

写入定时任务规则,比如我这里是给定时任务插件执行脚本

          • /usr/bin/php /home/wwwroot/www.kinmor.com/public/index.php /addons/crontab/autotask/index > /dev/null 2>&1 &

按【ESC】退出编辑模式
907.png
英文键盘,按【:wq】 保存退出

2.常用命令

启动服务

/bin/systemctl restart crond.service 

重新载入配置

/bin/systemctl reload  crond.service  

查看crontab服务状态

/bin/systemctl status  crond.service 

3.crontab相关命令

语法:crontab -u <用户名称> 或 crontab -u <用户名称>

参数:
-e  编辑该用户的计时器设置。
-l  列出该用户的计时器设置。
-r  删除该用户的计时器设置。
-u<用户名称>  指定要设定计时器的用户名称。

命令  svn up

Conflict discovered in 'test.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:
svn detects that theres a conflict here and require you to take some kind of action.

If you type 's' here you will get a list of the commands and meaning
如果你输入s选项,则会列出所有svn解决冲突的选项,如下所示:

(e) edit - change merged file in an editor #直接进入编辑
(df) diff-full - show all changes made to merged file #显示更改至目标文件的所有变化
(r) resolved - accept merged version of file

(dc) display-conflict - show all conflicts (ignoring merged version) #显示所有冲突
(mc) mine-conflict - accept my version for all conflicts (same) #冲突以本地为准
(tc) theirs-conflict - accept their version for all conflicts (same) #冲突以服务器为准

(mf) mine-full - accept my version of entire file (even non-conflicts)#完全以本地为准
(tf) theirs-full - accept their version of entire file (same) #完全以服务器为准

(p) postpone - mark the conflict to be resolved later #标记冲突,稍后解决
(l) launch - launch external tool to resolve conflict
(s) show all - show this list #显示所有

今天登陆linux服务器 发现var/log下的日志很大 其中包括btmp、message都很大!猜测是被人密码字典猜测后台root了。为规避风险对危险IP进行屏蔽

利用命令进行筛选IP

lastb | awk '{ print $3}' | sort | uniq -c | sort -n

999.png

扩展

将筛选结果导出来 放在home目录下以ips命名

  lastb | awk '{ print $3}' | sort | uniq -c | sort -n > /home/ips.txt

2.删除日志

rm -rf /var/log/btmp

touch /var/log/btmp