RecentUpload: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
Text replacement - "http://sandaysoft.com/forum/" to "https://cumulus.hosiene.co.uk/"
(Initial Version)
 
m (Text replacement - "http://sandaysoft.com/forum/" to "https://cumulus.hosiene.co.uk/")
 
(18 intermediate revisions by 4 users not shown)
{{AddOnBanner|name=RecentUpload|type=HTML & PHP|author=Jason Duncombe|contact=6719jason via Forum|updated=2023rd Aug 2009|version=1.23}}
 
<big>RecentUpload</big> shows a list of files on your webserver and the date and time of their last update. This is predominately useful for a system admin/website owner as a quick and convenient way to check that Cumulus has been able to upload the necessary data files and webpages to your site. It is not specific to Cumulus files so you could check other files on your webserver!
 
Unlike usual file "sniffers", this will tell you when a declared file is missing (eg. a file has been deleted but new upload has failed)
 
 
 
//config - define variables to match the files you are interested in
// format: "file nickname", "update frequency", "file url" - nickname may be "" (will be replaced by url)
// - nickname may be "" (will be replaced by url)
 
// - freq may be "" (will be replaced by 'Unknown')
$nickname[] = "Realtime.txt"; $freq[]="30 Seconds"; $file_url[]="./realtime.txt";
// - file url - valid filepath - COMPULSORY
$nickname[] = "Homepage"; $freq[]="5mins"; $file_url[]="./index.html";
$nickname[] = "Station Records'Realtime.txt"; $freq[]="5mins30 Seconds"; $file_url[]="./recordrealtime.htmltxt";
$nickname[] = "Station TrendsHomepage"; $freq[]="5mins2mins"; $file_url[]="./trendsindex.html";
$nickname[] = "HomepageStation Records"; $freq[]="5mins2mins"; $file_url[]="./indexrecord.html";
 
$nickname[] = "Realtime.txtStation Trends"; $freq[]="30 Seconds2mins"; $file_url[]="./realtimetrends.txthtml";
$nickname[] = "Today's Data Review"; $freq[]="2mins"; $file_url[]="./today.html";
$nickname[] = "Yesterday's Data Review"; $freq[]="2mins"; $file_url[]="./yesterday.html";
// ######### That's it, nothing else to do !
 
if(file_exists($file_url[$i])) { // cheap and cheerful existence check
$when=filemtime($file_url[$i]);
$this_output .= "<tr><td>" .($nickname[$i] ? $nickname[$i] : $file_url[$i]). "</td><td>" .($freq[$i] ? $freq[$i] : "Unknown"). "<td>" .date("m/d/y H:i:s T", $when). "</td><td>" .timediff($file_url[$i]). "</td></tr>\n";
} else { // the file is misnamed or not uploaded
$this_output .= "<tr><td>" .$file_url[$i]. "</td><td>" .($freq[$i] ? $freq[$i] : "Unknown"). "<td><b>NO SUCH FILE !</b></td><td><b>NO SUCH FILE !</b></td></tr>\n";
} // END existence check
} // END array loop
?>
</pre>
 
 
=Configuration=
{| class="wikitable" border="1"
|-
!style="width:80px90px" | Variable
!style="width:400px" | Description
!style="width:150px" | Example
|$nickname[]
|Describe the use of the file. If you leave this blank it will use the filename as the description
|"My Realtime data"
OR ""
|-
|$freq[]
|How often would you expect the file to be updated. This is for your information only and is displayed on the page but does not have any affect on the code, "" = "Unknown"
|"15 seconds"
OR ""
|-
|$file_url[]
|the path to where the file is, relative to where this code is running ('''REQUIRED''')
|"./realtime.txt"
OR "realtime.txt"
|}
 
A complete set of three variables is required for each file to be checked. Repeat as necessary; in the above example we are checking four files.
 
 
=Testing=
function file_data(phpurl) {
if (document.getElementById) {
var xx = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(phpurl);
}
if (xx) { // got something back
try { if (xx.readyState == 4 && xx.status == 200) {
document.getElementById('the_content').innerHTML=xx.responseText;
// var currdat = x.responseText.replace(/\r\n/g, ""); // this gets rid of any line ending
// var currdat = currdat.split(' '); // populate the array
document.getElementById('the_content').innerHTML=xx.responseText;
} // END if (xx.readyState == 4 && x.status == 200)
setTimeout("file_data(phpdatFile + '?' + new Date().getTime())", 1000); // get new data
// }
}
} // end file_data function
Your page will now refresh the data every one second.
 
To change the refresh rate adjust the figure 1000 in the setTimeout(" ... code above. This is the time in milliseconds. So to refresh every 30 seconds it would be 30000
 
=Example=
 
[http://www.weeleyweather.co.uk/index.php?page=serverstatus Server Status]
 
=Download Location=
 
You can download the latest and previous versions, directly from the forum [https://cumulus.hosiene.co.uk/viewtopic.php?f=14&t=1257&start=0 Sandaysoft Cumulus Forum]
=Example=
 
http://www.weeleyweatherstation.info/betel_ftpstatus.php
 
 
[[Category:AddOnsWebTools]]

Navigation menu