Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<nowiki>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. </nowiki>

29 changes: 20 additions & 9 deletions heartbeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down