#!/usr/bin/php -qc/etc # -q for quiet and -c for where the config is b/c php.ini is in /etc \n"; $headers .= "Return-Path: <$email>\n"; $TUASubject = "THERMAL ALERT"; $TLASubject = "THERMAL EVENT"; $HUASubject = "HUMIDITY ALERT"; $HLASubject = "HUMIDITY EVENT"; $message = "T = $temperature\n"; $message .= "H = $humidity\n"; if ($temperature >= $TUpperAlarm){ if ($TUASent == 1){ if ($TUACount >= $CountLimit){ # send text alarm for Temperature Upper Alert mail($recipient, $TUASubject, $message, $headers,"-f <$email>"); mssql_query("UPDATE ITHXOptions SET TUACount = 0"); } else { $TUACount++; mssql_query("UPDATE ITHXOptions SET TUACount = $TUACount"); } } else { # send text alarm for Temperature Upper Alert mail($recipient, $TUASubject, $message, $headers,"-f <$email>"); $TUACount++; mssql_query("UPDATE ITHXOptions SET TUASent = 1, TUACount = $TUACount"); } } elseif ($temperature >= $TLowerAlarm){ if ($TLASent == 1){ if ($TLACount >= $CountLimit){ # send text alarm for Temperature Lower Alert mail($recipient, $TLASubject, $message, $headers,"-f <$email>"); mssql_query("UPDATE ITHXOptions SET TLACount = 0, TUACount = 0, TUASent = 0"); } else { $TLACount++; mssql_query("UPDATE ITHXOptions SET TLACount = $TLACount, TUACount = 0, TUASent = 0"); } } else { # send text alarm for Temperature Lower Alert mail($recipient, $TLASubject, $message, $headers,"-f <$email>"); $TLACount++; mssql_query("UPDATE ITHXOptions SET TLASent = 1, TLACount = $TLACount, TUACount = 0, TUASent = 0"); } } else { if (($TUACount > 0) or ($TUASent == 1)){ mssql_query("UPDATE ITHXOptions SET TUACount = 0, TUASent = 0"); } if (($TLACount > 0) or ($TLASent == 1)){ mssql_query("UPDATE ITHXOptions SET TLACount = 0, TLASent = 0"); } } if ($humidity >= $HUpperAlarm){ if ($HUASent == 1){ if ($HUACount >= $CountLimit){ # send text alarm for Humidity Upper Alert mail($recipient, $HUASubject, $message, $headers,"-f <$email>"); mssql_query("UPDATE ITHXOptions SET HUACount = 0"); } else { $HUACount++; mssql_query("UPDATE ITHXOptions SET HUACount = $HUACount"); } } else { # send text alarm for Humidity Upper Alert mail($recipient, $HUASubject, $message, $headers,"-f <$email>"); $HUACount++; mssql_query("UPDATE ITHXOptions SET HUASent = 1, HUACount = $HUACount"); } } elseif ($humidity >= $HLowerAlarm){ if ($HLASent == 1){ if ($HLACount >= $CountLimit){ # send text alarm for Humidity Lower Alert mail($recipient, $HLASubject, $message, $headers,"-f <$email>"); mssql_query("UPDATE ITHXOptions SET HLACount = 0, HUACount = 0, HUASent = 0"); } else { $HLACount++; mssql_query("UPDATE ITHXOptions SET HLACount = $HLACount, HUACount = 0, HUASent = 0"); } } else { # send text alarm for Humidity Lower Alert mail($recipient, $HLASubject, $message, $headers,"-f <$email>"); $HLACount++; mssql_query("UPDATE ITHXOptions SET HLASent = 1, HLACount = $HLACount, HUACount = 0, HUASent = 0"); } } else { if (($HUACount > 0) or ($HUASent == 1)){ mssql_query("UPDATE ITHXOptions SET HUACount = 0, HUASent = 0"); } if (($HLACount > 0) or ($HLASent == 1)){ mssql_query("UPDATE ITHXOptions SET HLACount = 0, HLASent = 0"); } } mssql_close($conn); ?>