改写后的代码如下:

$url1 = $url.http_build_query($arr);

$context = stream_context_create([ "ssl" => [ "verify_peer" => true, "verify_peer_name" => true, "cafile" => "/path/to/cert.pem" //替换为证书路径 ] ]);

$data4 = json_decode(file_get_contents($url1, false, $context), true);

if($data4["result"] == "200") { $money1 = $db["money"] - $money; Db::name('user')->where('id',session("userid"))->update(['money' =>$money1]); if($data["cycle"] == "month") { $times = "2592000" * $data2["time"]; } if($data["cycle"] == "year") { $times = "31536000" * $data2["time"]; } if($data["cycle"] == "day") { $times = "86400" * $data2["time"]; } if($data["cycle"] == "unrestricted") { $times = "315360000" * $data2["time"]; } $data6 = Db::name('order')->insertGetId([ "user"=>$data2["user"], "password"=>$data2["password"], "userid"=>session("userid"), "cartid"=>$data["id"], "atime"=>time(), "ztime"=>time()+$times, "state"=>"1", ]); $array["code"] = "1"; $array["msg"] = "创建成功"; } else { $array["code"] = "-1"; $array["msg"] = "创建失败" . json_encode($data4); } } else { $array["code"] = "-1"; $array["msg"] = "账户余额不足!"; } } else { $array["code"] = "-2"; $array["msg"] = "请先登录!"; } return $array; } else { $this->redirect('/cart'); } } else { $this->redirect('/cart'); } return $this->fetch('product',[ "cart"=>$data, ]); }

public function announcement($id=null) { if($id) { $data = Db::name('announcement')->where("id",$id)->find(); if($data) { return $this->fetch('announcements',[ "announcement"=>$data, ]); } else { $this->redirect('/announcement'); } } else { $data = Db::name('announcement')->order('id desc')->paginate(10); return $this->fetch('announcement',[ "announcement"=>$data, ]); } }

public function cron() { $data = Db::name("order")->select(); $time = time(); for($i=0;$i<count($data);$i++) { if($data[$i]["ztime"] < $time) { if($data[$i]["ztime"] + 259200 > $time) { //过期三天内暂停 $rand = rand(1000, 9999); $data2 = Db::name('cart')->where("id",$data[$i]["cartid"])->find(); $data3 = Db::name('server')->where("id",$data2["serverid"])->find(); $url = "" . $data3["host"] . "/api/?"; $arr = [ 'c' => "whm", 'a' => 'update_vh', 'r' => $rand, 'init' => "1", 's' => md5("update_vh" . $data3["security"] . $rand), 'name' => $data[$i]["user"], 'status' => "1", 'json' => "1", ]; $context = stream_context_create([ "ssl" => [ "verify_peer" => true, "verify_peer_name" => true, "cafile" => "/path/to/cert.pem" //替换为证书路径 ] ]); $url1 = $url . http_build_query($arr); $data4 = json_decode(file_get_contents($url1, false, $context), true); $data5 = Db::name("order")->where("id",$data[$i]["id"])->update([ "state"=>"2", ]); } else { //过期三天后处理 if($data[$i]["ztime"] + 432000 > $time) { //过期五天内终止 $rand = rand(1000, 9999); $data2 = Db::name('cart')->where("id",$data[$i]["cartid"])->find(); $data3 = Db::name('server')->where("id",$data2["serverid"])->find(); $url = "" . $data3["host"] . "/api/?"; $arr = [ 'c' => "whm", 'a' => 'del_vh', 'r' => $rand, 'init' => "1", 's' => md5("del_vh" . $data3["security"] . $rand), 'name' => $data[$i]["user"], 'json' => "1", ]; $context = stream_context_create([ "ssl" => [ "verify_peer" => true, "verify_peer_name" => true, "cafile" => "/path/to/cert.pem" //替换为证书路径 ] ]); $url1 = $url . http_build_query($arr); $data4 = json_decode(file_get_contents($url1, false, $context), true); $data5 = Db::name("order")->where("id",$data[$i]["id"])->update([ "state"=>"3", ]); } } }

更换函数file_get_contents写法使用可以验证ssl证书的函数$url1=$urlhttp_build_query$arr;$data4=json_decodefile_get_contents$url1true;if$data4result==200$money1=$dbmoney-$money;Dbnameuser-whereidsessionuserid-updatemoney

原文地址: https://www.cveoy.top/t/topic/hqyE 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录