Skip to content

Commit 98ef106

Browse files
committed
添加基于users.json控制的分用户定时推送设置
1 parent cc841af commit 98ef106

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Umbrella
22
一个PHP的小程序,可以设置定时发送邮件提醒带伞
33

4-
当前版本:Ver.3,已实现的功能有:多用户,可选雨天单独推送
4+
当前版本:Ver.3,已实现的功能有:多用户,可以控制的推送时间选择,可选雨天单独推送
55

66
https://console.heweather.com/ 申请好KEY后
77

@@ -47,7 +47,8 @@ $smtppass = "yourpassword"; //SMTP服务器的用户密码
4747
您可以部署于WEB服务器或
4848
`php /home/umb/umbrellaV3.php`
4949
直接运行
50-
亦可设置crontab做定时任务
50+
51+
亦可设置crontab做定时任务,自V3.1.0后,建议设置为每小时一次的定时任务或自动访问url。
5152

5253
~~喜欢请star,虽然我知道我只是写了一坨shit~~
5354

UmbrellaV3.PHP

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ foreach ($userarr['users'] as $userkey => $userval) { //遍历用户json生成
1818
$usermail = ($userval['usermail']);
1919
$userid = ($userval['userid']);
2020
$usersunflag = ($userval['usersunflag']);
21-
echo ($usersunflag);
21+
$usertime = ($userval['usertime']);
22+
$usertemp = ($userval['usertemp']);
2223
$jsonadd = "https://free-api.heweather.com/s6/weather/forecast?location={$location}&key={$Hekey}"; //json地址
2324
$weatherjson = file_get_contents($jsonadd);
2425
$weatherarr = json_decode($weatherjson, TRUE);
2526
$usercity = ($weatherarr['HeWeather6']['0']['basic']['location']);
2627
$weathertime = ($weatherarr['HeWeather6']['0']['update']['loc']);
28+
if ($usertime == date('H')){
2729
foreach ($weatherarr['HeWeather6'][0]['daily_forecast'] as $weatherkey => $weatherval) { //确定城市后循环遍历天气数据
2830
$data[] = "日期:" . $weatherval['date'];
2931
$txt_d[] = "{$weatherval['cond_txt_d']}";
@@ -216,7 +218,8 @@ LABELSS;
216218
$txt_n = "";
217219
$winds = "";
218220
$tmps = "";
219-
//print_r($mailstr);//web预览邮件样式
221+
print_r($mailstr);//web预览邮件样式
222+
}
220223
}
221224
?>
222225

users.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
"users":[
33
{
44
"location": "shanghai",
5-
"usermail": "584121960@qq.com",
5+
"usermail": "example@qq.com",
66
"usersunflag": "true",
7-
"userid": "Nchyn"
7+
"userid": "Nchyn",
8+
"usertemp": "true",
9+
"usertime": "17"
810
},
911
{
1012
"location": "taiyuan",
11-
"usermail": "mail@nchyn.com",
13+
"usermail": "example@163.com",
1214
"usersunflag": "false",
13-
"userid": "Nchyn2"
15+
"userid": "Nchyn2",
16+
"usertemp": "false",
17+
"usertime": "16"
1418
}
1519
]
1620
}

0 commit comments

Comments
 (0)