From f02e132567f3404dd8191c8ad47779ea133421a5 Mon Sep 17 00:00:00 2001 From: Matt Diehl Date: Mon, 21 May 2018 22:04:44 -0600 Subject: [PATCH 1/2] Remove space from event string. "button press" to "button_press" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bfe3b2..b60e827 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ You will need an Apache web server set up to run PHP scripts and a MySQL databas ##BrightAuthor -The hearbeat-demo project shows a simple example of how to use the heartbeart plugin. Add it as a plugin under Files->Presentation Properties->Autorun. Then from a timer - or any action anywhere - you can 'Send' a plugin message. Whatever message text you use will be inserted as the 'event' string that goes into the database. DO NOT USE SPACES OR PUNCTUATION in that string - it can confuse things. Use a string like "timeout" or "button press" or something. This will allow you to have many different events trigger the 'heartbeat' and can track that in the database. +The hearbeat-demo project shows a simple example of how to use the heartbeart plugin. Add it as a plugin under Files->Presentation Properties->Autorun. Then from a timer - or any action anywhere - you can 'Send' a plugin message. Whatever message text you use will be inserted as the 'event' string that goes into the database. DO NOT USE SPACES OR PUNCTUATION in that string - it can confuse things. Use a string like "timeout" or "button_press" or something. This will allow you to have many different events trigger the 'heartbeat' and can track that in the database. You will need to create a user variable called "heartbeat_url" and set it to the URL of the PHP script on your server. You can also create a user variable called "heartbeat_tag" and put text there that you want to use to help make database queries. From 80cd3935cc370003dcde1f58f518c075853d697e Mon Sep 17 00:00:00 2001 From: Matt Diehl Date: Wed, 30 May 2018 12:57:33 -0600 Subject: [PATCH 2/2] Update php to use mysqli from deprecated mysql_* --- heartbeat.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/heartbeat.php b/heartbeat.php index 6873824..5232e87 100644 --- a/heartbeat.php +++ b/heartbeat.php @@ -8,25 +8,36 @@ $event = $_GET['event']; $ext_ip = $_SERVER['REMOTE_ADDR']; -$link = mysql_connect('localhost', 'REPLACE_USERNAME', 'REPLACE_PASSWORD'); -if (!$link) { - die('Not connected : ' . mysql_error()); -} +$mysqli = new mysqli('localhost', 'REPLACE_USERNAME', 'REPLACE_PASSWORD', 'brightsign'); -$db_selected = mysql_select_db('brightsign', $link); -if (!$db_selected) { - die ('Can\'t use foo : ' . mysql_error()); +/* Check Connection */ +if ($mysqli->connect_errno) { + printf("Connect failed: %s\n", $mysqli->connect_error); + exit(); } $sql1 = "DELETE FROM heartbeats WHERE snum='$serial';"; -$result1 = mysql_query($sql1) or die(mysql_error()); +if (!$mysqli->query($sql1)){ + printf("Error deleting from heartbeats: %s\n", $mysqli->error); + /* close connection */ + $mysqli->close(); + exit(); +} if ($tag=="") $tag="none"; if ($event=="") $event="none"; $sql2 = "INSERT INTO heartbeats (snum,version,fw,int_ip,ext_ip,tag,event) VALUES ('$serial','$version','$fw','$int_ip','$ext_ip','$tag','$event');"; -$result2 = mysql_query($sql2) or die(mysql_error()); +if (!$mysqli->query($sql2)){ + printf("Error inserting into heartbeats: %s\n", $mysqli->error); + /* close connection */ + $mysqli->close(); + exit(); +} + +/* close connection */ +$mysqli->close(); exit(header("Status: 200 OK"));