I did it https://github.com/dmd2222 on 04.12.2020 at 18:21:17,72

This commit is contained in:
dmd2222 2020-12-04 18:21:17 +01:00
parent 75bc05113c
commit 8b2fedf630
6 changed files with 92 additions and 3 deletions

View File

@ -28,5 +28,11 @@ Search string/pattern = "Last update"
There is additional:
Best regards M.S.
You can also use the i=getall&iv=1 GET call,
it returns the status of all monitored index_values (or tokens).
Best regards
https://github.com/dmd2222

View File

@ -0,0 +1 @@
1607102400

View File

@ -0,0 +1 @@
1607102327

View File

@ -1 +0,0 @@
1607042212

View File

@ -71,6 +71,13 @@ switch ($index) {
throw new Exception('run_get function failed.');
}
break;
case "getall":
//GET_ALL
if (run_get_all($old_time_definition)==true){}else{
//Error
throw new Exception('run_get function failed.');
}
break;
case "set":
//SET
if (run_set($index_value)==true){}else{
@ -155,6 +162,78 @@ function run_get($index_value, $old_time_definition){
}
function run_get_all($old_time_definition){
//make HTML comment
echo "<!--Getting All....-->";
//Prepare result_text
$result_text="";
// generate file path for every file in folder
foreach(glob('data/*.txt') as $file) {
//Open File
$information_file = read_from_file($file);
//Get now timestamp
$date = new DateTime();
$timestamp_now = $date->getTimestamp();
//calculate time diff
$time_diff = $timestamp_now - $information_file ;
// Check if older than
if ($information_file + ($old_time_definition) < $timestamp_now){
//Last updtae is older than x time
$result_text= $result_text . $file . " Older than " . $old_time_definition . "sec. Timediff: " . $time_diff . " sec." . "<br>" ;
}
//Secure file
secure_file($file);
}
//Check if every index_value / token is up to date
if($result_text ==""){
//all up to date
// Last update is NOT older than x time
echo "Last update done. All index_values or tokens are up to date.";
}else{
//nor all are up to date
echo $result_text;
}
//giveback ok
return true;
}
function run_set($index_value){
//make HTML comment
echo "<!--Setting....-->";

View File

@ -29,7 +29,7 @@ include_once("config.php");
if (file_exists($filename)) {
$key = $_GET[$key_name];
$key = check_and_give_me_get_input($key_name);
//open file and read it
$myfile = fopen($filename, "r") or die("keyit.php: 1 Unable to open file!");
@ -188,4 +188,7 @@ function sendmailtorecipients($contacts_array,$subject,$message,$output=false){
return ((empty($_SERVER['HTTPS'])) ? 'http' : 'https') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
?>