复制代码
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/** * 查询xxx游戏是否下架 * linux crontab 每周1的3点到5点之间的每小时5分都进行游戏检测下架工作 * 5 3-5 * * 1 /usr/bin/curl http://xxx.com/v1/is_games_null * @Author wave * @DateTime 2019-04-28 17:00:09 * @return Null */ public function is_games_null() { set_time_limit(0); $data=Db::name('Cron')->find(1); /** * 查询当前时间是否大于存储的时间 * 如果当前时间大于数据库存储的时间, * 那么就执行 * 否则就没有到1周,不允许执行 */ if(isset($data['create_time']) && time() < $data['create_time']) { die; } $counts=$this->gameinfo->field("id")->where('platform','=',5)->where("state",'=',1)->count(); $counts=ceil($counts/10); if(!isset($data)) { /** * 如果没有定时的任务,那么添加进去 */ $data['limit']=0; $data['count']=$counts; $data['create_time']=time(); $data['id']=Db::name('Cron')->insertGetId($data); } /** * 如果有定时的任务那么取出来。 */ $gameModel=$this->gameinfo; $count=$data['limit']+5; for($i=$data['limit'];$i<=$count;$i++) { $games=[]; $games=$gameModel->field("id,androiddownload")->where('platform','=',5)->where("state",'=',1)->limit($i,10)->select()->toArray(); $shelf=array(); $index=0; foreach($games as $key=>$val) { if(strpos($val['androiddownload'],'99maiyou') !== false) { $is_apk_status=$this->is_apk_status($val['androiddownload']); if($is_apk_status === 3 ) { $gameModel->where('id',$val['id'])->update(['state' =>0]); $shelf[$index]['gid']=$val['id']; $shelf[$index]['create_time']=time(); } }else{ continue; } $index++; } Db::name('Shelf')->insertAll($shelf); } /** * 如果,任务跟总数一样或者大于总数,那么就是执行完了。 */ if($data['limit']>=$data['count']) { $data1['limit']=0; $data1['create_time']=time()+86400*7; }else{ $data1['limit']=$count; } $data1['count']=$counts; Db::name('Cron')->where("id",$data['id'])->update($data1); } /** * 检测链接的APK文件什么状态 * @Author wave * @DateTime 2019-04-28T16:59:50+0800 * @return 1 正在运行的游戏 * @return 2 没有分包的游戏 * @return 3 下架的游戏 */ protected function is_apk_status($url) { $headers=get_headers($url,true); //判断Location是否存在,如果Location存在,并且是数组,那么就是已经上线的游戏 return isset($headers['Location']) ? (is_array($headers['Location']) ? 1 : 2 ) : 3; }
最后
以上就是忧伤钢笔最近收集整理的关于PHP检测链接是否为有效的APK文件的全部内容,更多相关PHP检测链接是否为有效内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复