Index.php
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
namespace app\api\controller;
use app\common\controller\Api;
use Upyun\Config as UpyunConfig;
use Upyun\Upyun as UpyunClient;
/**
* 首页接口
*/
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 首页
*
*/
public function index()
{
$this->success('请求成功');
}
public function hhh(){
set_time_limit(0);
$config = get_addon_config('upyun');
$config = new UpyunConfig($config['bucket'], 'lishuqiang', 'y5qImWlqIUZwqS3BLe5XEooadnM8TWqI');
$upyun = new UpyunClient($config);
$vote_player = db('vote_player');
$selct = $vote_player->where('subject_id',3)->select();
foreach ($selct as $k=>$v){
$applydata = $v['applydata'];
$applydata = json_decode($applydata,true);
$video = $applydata['video'];
$video = str_replace('http://newmatch.posedu.cn/','',$video);
$videos = pathinfo($video);
if ($videos['extension'] != 'jpg'){
$path = $videos['dirname'].'/'.$videos['basename'];
// $text = explode($videos['basename'],'.')[0];
$saveAs = $videos['dirname'].'/'.$videos['filename'].'.jpg';
$ret = $upyun->snapshot($path , "/images/{$saveAs}",'00:00:01','','jpg');
if ($ret['status_code'] == 200){
$applydata['video'] = 'http://newmatch.posedu.cn/'.$ret['save_as'];
$vote_player->where('id',$v['id'])->update(['applydata'=>json_encode($applydata,JSON_UNESCAPED_UNICODE)]);
}
}
}
}
public function check()
{
$http_code_arr = ['400'=> '[错误的请求或不存在的域名]','404'=> '[找不到页面]','500'=> '[服务器接口异常]','302'=> '[请求重定向]','0'=> '[域名无法访问]','502'=> '[接口报502错误]'];
$http_code = [400,404,502,302,0,500];
$urls = [
'位来足迹'=>"https://weilai.job3.posedu.cn/api/ems/test",
'学习平台'=>"https://jltc.mooc.posedu.cn/admin/index/login",
'简历营地'=>'https://resume.posedu.cn/admin/index/login',
'视聘空间'=>'https://hr.posedu.cn/admin/index/login',
'位来领航'=>'http://emptest.posedu.com.cn/admin/index/login',
'马院思政'=>'http://marx.wlzhumeng.com/public/',
'大赛平台'=>'http://pk.wlzjedu.com/cms',
'正式库服务中心'=> 'http://api.posedu.com.cn/api/evaluate/question_DISC',
'小位服务中心'=> 'http://qhdflpj.posedu.com.cn/api/evaluate/question_DISC',
'咨询台后台管理系统'=> 'http://wlzjcloud.posedu.com.cn/captcha/captchaImage?type=math',
'大赛平台'=> 'https://api.match.posedu.com.cn/support/time/getCurrentTime'
];
foreach ($urls as $title=>$url){
$checkArr = $this->checkUrl($url);
db('check_data')->insert(['title'=> $title , 'url'=> $url , 'code'=> $checkArr['http_code'], 'createtime'=> date('Y-m-d H:i:s',time())]);
if (in_array($checkArr['http_code'],$http_code) || $checkArr['total_time'] > 10){
$obj = \app\common\library\Email::instance();
$code_str = $http_code_arr[$checkArr['http_code']];
$result = $obj
->to('chenjie@posedu.cn,yangdongming@posedu.cn,lishuqiang@posedu.cn') //
->subject('网站检测故障通知')
->message("【{$title}】已出现问题,状态码为{$checkArr['http_code']},原因:{$code_str} , 响应时间为{$checkArr['total_time']}秒")
->send();
}
}
}
public function checkUrl($url){
$ch = curl_init ();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_exec($ch);
return $httpCode = curl_getinfo($ch);
}
}