OK
As some of us now know, it is impossible to use the standard cron as we get "unauthorised access". I tried several options and as I couldn't find any errors in any log ... account nor server side ...
As Jachym proposed, let's then rework the file so it works without identification and see if we can use internal PHP to access the file .. that road also ended with quite some errors( my lack of coding skills for sure). Finally went back to use 'curl' in the cron command.
As I can't attach the modified file, I will post below the code. FTP in your account, create a new file, give it a name you only can imagine (let's say it is a limited security to avoid anyone else to call it, though it won't hurt)for ex. whatever.php and copy the code in it. Don't forget to give the correct permissions to the file (chmod 755)
This is the cron job I set on my cpanel driven server to call the file, it runs every 5 minutes.

- Screen Shot 2018-01-01 at 15.19.44.png (22.22 KiB) Viewed 22863 times
and this is de code, it includes some explanation on how to use the cron
Code: Select all
<?php
############################################################################
# Meteotemplate
# http://www.meteotemplate.com
# Free website template for weather enthusiasts
# Author: Jachym
# Brno, Czech Republic
# First release: 2015
#
############################################################################
#
# Offline notifications
# adapted to run via cron ; rename this file to whatever.php
# if you can use cron use : curl http://yourdomain/pathtometeoteplate/admin/whatever.php
# if you run a ssl certificate use https instead http
# if you don 't want a notification from your cron add >/dev/null 2>&1
# like this : curl http://yourdomain/pathtometeoteplate/admin/whatever.php >/dev/null 2>&1
# if you have meteotempalte on highest level of your account just delete pathtometeotemplate
#
###########################################################################
session_start();
include("../config.php");
include($baseURL."css/design.php");
include($baseURL."header.php");
if(!file_exists("offlineNotificationsSettings.txt")){
die("Missing notifications settings file");
}
// last station data
$data = file_get_contents("../meteotemplateLive.txt");
$data = json_decode($data, true);
$lastTime = $data['U'];
$notifyData = json_decode(file_get_contents("offlineNotificationsSettings.txt"), true);
$notifyInterval = $notifyData['period'] * 60; // convert to seconds
$notifyThreshold = time() - $notifyInterval;
if($lastTime < $notifyThreshold){
$online = false;
}
else{
$online = true;
}
if($online){
// back online?
if(file_exists("../cache/stationOffline.txt")){
unlink("../cache/stationOffline.txt");
mail($notifyData['email'],"Station back online","Your weather station is now back online.");
echo "Station back online.";
}
else{
echo "Station online.";
}
}
else{
if(!file_exists("../cache/stationOffline.txt")){
file_put_contents("../cache/stationOffline.txt",$lastTime);
mail($notifyData['email'],"Station offline","Your weather station is offline, last time data received: ".date($dateTimeFormat,$lastTime).".");
echo "Station now offline, email sent.";
}
else{
echo "Station still offline.";
}
}
die();
# }
if(isset($_GET['email'])){
$save['email'] = $_GET['email'];
$save['period'] = $_GET['period'];
file_put_contents("offlineNotificationsSettings.txt",json_encode($save));
}
if(file_exists("offlineNotificationsSettings.txt")){
$notifyData = json_decode(file_get_contents("offlineNotificationsSettings.txt"), true);
$notifyEmail = $notifyData['email'];
$notifyPeriod = $notifyData['period'];
}
else{
$notifyEmail = "email@gmail.com";
$notifyPeriod = 30;
}
?>
I hope I didn't forget anything. Hope it works well like it does for me since yesterday. I tested it by unplugging the datafeed from weatherdisplay and waited the time set in the original plugin.
Btw don't delete anything from the original plugin. It still uses that to work.
Enjoy
