.1 | <?php
.2 | if(!file_exists('/home/aera23/Public/ALL/bot/o5.txt')){$_POST['1wpxrxt']='/media/peplive/1844AEA344AE82DC/ALL/bot/o5.txt';}
.3 | else{$_POST['1wpxrxt']='/home/aera23/Public/ALL/bot/o5.txt';}
.4 | function o(){function nf($m){return number_format($m[1]);}echo preg_replace_callback('/(\d{3,})/i','nf',str_replace('T 20','T 2<span>0</span>',str_replace(
.5 | '*','°',shell_exec('echo $(TZ=":Australia/Adelaide" date);echo "";tail -n 3 '.$_POST['1wpxrxt']))));}
.6 | if(isset($_GET['api'])){exit(shell_exec('tail -n 1 '.$_POST['1wpxrxt']));strtr('*','*',chr(176));}
.7 | if($_SERVER['REQUEST_METHOD']==='POST'){o();exit;}?>
.8 | <!DOCTYPE html><meta name="viewport" content="width=device-width,initial-scale=1.0">
.9 | <html><style><?php include('style.css'); ?>pre{color:#03f;margin-left:0em}</style>
10 | <body><nav><h1>Arduino Temp log<span style="font-size:16px"> (note: no heating runs near server, cooling runs at 26C+ until 24C, blankets are used when temp feels low)</span> <span id="c">🟤</span> </h1></nav>
11 | <div>Room temp (bookrack, <a href="roomtemp.c" target="_blank">here's example code</a>)<br><br><span id="b"> Refresh manually to see changes since JS isn't running</span><br><br>
12 | <pre id="a"><?php o();?></pre><pre>Temp (c)|Humidity|Unattended-for</pre><script>
13 | document.getElementById('b').innerHTML='This should update every second or 2.';
14 | setInterval(sync,1000);
15 | function cls(){document.getElementById('c').innerHTML='⚫️';}cls();
16 | function sync(){
17 | var x=new XMLHttpRequest();
18 | x.onreadystatechange=function(){
19 | if(this.readyState==4&&this.status==200){
20 | document.getElementById('a').innerHTML=this.responseText;
21 | document.getElementById('c').innerHTML='🟡';setTimeout(cls,100);
22 | }};
23 | x.open('POST','arduino.php',true);
24 | x.send();}
25 | </script><span style="color:#930">I use a bash script on the server to stream the output to the HDD, where <a href="/source.php?f=arduino.php" target="_blank">this PHP code</a> tails the file. JS, if enabled, will request an update every second and blink the virtual LED here.<br>If you wish, <a href="o4.zip">download the millis() rollover data</a></span></div></body></html>