Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tblUser
- userID INT
- userEmail VARCHAR(50)
- userMINThreholdVal FLOAT(4,2)
- userMAXThreholdVal FLOAT(4,2)
- tblTempReading
- userID INT
- thermID CHAR(3)
- tempTimeStamp TIMESTAMP
- temp FLOAT(4,2)
- <!DOCTYPE html?
- <html>
- <?php header("refresh: 300;");?>
- <head>
- <title>FYP — Intelligent Temperature Control</title>
- <style type ="text/css">
- body{
- margin:0;
- padding:0;
- font-family: Sans-Serif;
- line-height: 1.5em;
- }
- main {
- padding-bottom: 10010px;
- margin-bottom: -10000px;
- float: left;
- width: 100%;
- }
- #nav {
- float: left;
- width: 230px;
- margin-left: -100%;
- padding-bottom: 10010px;
- margin-bottom: -10000px;
- background: #eee;
- }
- #wrapper {
- overflow: hidden;
- }
- #content {
- margin-left: 230px; /* Same as 'nav' width */
- }
- .innertube{
- margin: 15px; /* Padding for content */
- margin-top: 0;
- }
- p {
- color: #555;
- }
- nav ul {
- list-style-type: none;
- margin: 0;
- padding: 0;
- }
- nav ul a {
- color: darkgreen;
- text-decoration: none;
- }
- </style>
- </head>
- <body>
- <div id="wrapper">
- <main>
- <div id = "content">
- <div class = "innertube">
- <h1>Intelligent Temperature Control</h1>
- <h2>User One</h2>
- <h3>Temperature Readings</h3>
- <?php date_default_timezone_set('Europe/Belfast');?>
- <?php echo "<p>Page Last Updated: " . date('d/m/Y h:i:s a',time()) . "</p>";?>
- <h3>Thermistor 1</h3>
- <?php include('thermReading1.php');?>
- <h3>Thermistor 2</h3>
- <?php include('thermReading2.php');?>
- <h3>Thermistor 3</h3>
- <?php include('thermReading3.php');?>
- </div>
- </div>
- </main>
- <nav id = "nav">
- <div class = "innertube">
- <h4>About</h4>
- <p> A project tasked with developing an affordable skin temperature logger
- that is accurate to 0.1° that is widely available to the public.</p>
- <p>This LAMP web server has been set up on a Raspberry Pi that will disaply
- the readings that has been sent by the Arduino and ESP8266</p>
- </div>
- </nav>
- </div>
- <?php exec('sudo -u www-data python /var/www/userEmailNotification.py');?>
- <?php exec('sudo -u www-data python /var/www/userTwitterNotification.py');?>
- </body>
- </html>
- <?php
- //thermReading1.php
- $servername = "localhost";
- $username = "myusername";
- $password = "mypassword";
- $dbname = "dbIntelligentTempControl";
- //create connection
- $db_handle = mysql_connect($servername,$username,$password);
- //**DEBUGGING**
- //echo "<p>connection to server opened</p>";
- $db_found = mysql_select_db($dbname,$db_handle);
- $thermID = "'T00'";
- $userID = "'1'";
- if($db_found)
- {
- $sql = "SELECT temp,tempTimeStamp FROM tblTempReading WHERE thermID=" . $thermID . " AND userID=" . $userID . " ORDER BY tempTimeStamp DESC LIMIT 1";
- $result = mysql_query($sql);
- while($db_field = mysql_fetch_assoc($result))
- {
- echo "<p>" . $db_field['temp'] . "</p>";
- echo "<p>" . $db_field['tempTimeStamp'] . "</p>";
- }
- }
- else
- {
- echo "<p>Database NOT Found</p>";
- }//endif
- mysql_close($db_handle);
- ?>
- #!/usr/bin/python
- import smtplib
- SMTP_SERVER = 'smtp.gmail.com'
- SMTP_PORT = 587
- GMAIL_USERNAME = 'mygmail@gmail.com'
- GMAIL_PASSWORD = 'myPW' #CAUTION: This is stored in plain text!
- recipient = 'recipemail@hotmail.co.uk'
- subject = 'Exceeding Threshold Notification'
- emailText = 'testing'
- emailText = "" + emailText + ""
- headers = ["From: " + GMAIL_USERNAME,
- "Subject: " + subject,
- "To: " + recipient,
- "MIME-Version: 1.0",
- "Content-Type: text/html"]
- headers = "rn".join(headers)
- session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
- session.ehlo()
- session.starttls()
- session.ehlo
- session.login(GMAIL_USERNAME, GMAIL_PASSWORD)
- session.sendmail(GMAIL_USERNAME, recipient, headers + "rnrn" + emailText)
- session.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement