Author Topic: Status update working, but blank TournamentStatus.html  (Read 1221 times)

rakrul

  • Newbie
  • *
  • Posts: 37
    • View Profile
Status update working, but blank TournamentStatus.html
« on: September 22, 2021, 07:10:56 AM »
So I had this working earlier, but made some changes on my web-server which receives these updates.

I can see that tdstatus.txt is updated correctly every minute, but the web-page still draws a blank. Meaning the fields/text is there, but the values from the tournament isn't (i.e. Clock: but no text after that, Round:, etc).
This is running on a linux server and I made sure that the php-file has write permission, and since the tdstatus is fine this shouldn't be a problem. I modified your html file earlier and it worked before, and I also tested with the original in the examples folder with the same results.
TournamentStatus.js is in the same folder as the php script. I figured this to be all my restructuring could cause issues with, but apparently not. I'm a bit stumped now, so any suggestions? (I know this isn't related to your software as it does what it's supposed to.)

rakrul

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Status update working, but blank TournamentStatus.html
« Reply #1 on: September 22, 2021, 08:29:33 AM »
I noticed that my statusListener.php and TournamentStatus.js were quite old and compared to the ones in the example folder and noticed differences, so I started using the ones from the example-folder instead. Now it writes to tdstatus.txt every minute but the file is 0 bytes...

Edit:

Old listener that writes ~7kB to tdstatus.txt:
Code: [Select]
<?php

// Receives a POST in JSON format from the TD and writes out the object.
// It's up to the viewer page to interpret those; we do no validation here.
// kFileOutput will probably need to be an absolute path.  The web server must have write access to the file.

$kFileOutput "tdstatus.txt";

$handle fopen($kFileOutput"w");

fputs($handlefile_get_contents("php://input"));

fclose($handle);

?>


New one from example-folder that gives me 0B tdstatus.txt every minute:
Code: [Select]
<?php

// receives a POST or GET request from the TD and writes out the included variables
// it's up to the viewer page to interpret those; we do no validation here

$kFileOutput "tdstatus.txt";

$handle fopen($kFileOutput"w");

foreach(
$_GET as $key => $val)
  
fputs($handle"$key=" $val "\n");

foreach(
$_POST as $key => $val)
  
fputs($handle"$key=" $val "\n");

fclose($handle);

?>

« Last Edit: September 22, 2021, 08:55:37 AM by rakrul »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6220
    • View Profile
Re: Status update working, but blank TournamentStatus.html
« Reply #2 on: September 23, 2021, 10:21:51 AM »
The earlier version ready from "php://input", which is php-slang for the for the request body.  In other words, the contents of a "post" from a browser or application connecting to a web site.  The newer version does the same thing by reading from $_POST.  It also reads from $_GET, which is the part of the URL (location) that has variables.  For example:

http://my-website.com/statusListener-JSON.php?level=1&secondsLeft=125

Everything past the ? will be contained in $_GET.  So essentially the new version does the same as the old version (allows the variables to be sent in the POST body), but also reads the variables from the URL (they're referred to here as "query variables"), allowing the sender the flexibility to put them in either place.

If the tdstatus.txt file is created, it implies the status listener script has write access.  You might delete tdstatus.txt and see if it is recreated.  That would let you know if that is a permissions issue.

If tdstatus.txt is created and has nothing in it, well, I'm not sure what that means.  Make sure if you have JSON selected in the Status Updates Preferences, that you are sending it to statusListener-JSON.php and not statusListener-FormulaVariables.php.  That's the only thing I can think of that would end up with no data in tdstatus.txt.  statusListener-FormulaVariables.php will attempt to parse the data as variables in the format above.  It won't understand JSON and will likely write nothing.

rakrul

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Status update working, but blank TournamentStatus.html
« Reply #3 on: September 30, 2021, 07:00:19 PM »
I realized I had been a bit retarded and never checked the browser console, so the reason the webpage was blank was because it was served on https and the html page had this line
Code: [Select]
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>which obviously browsers aren't happy with. So once I changed that to https, I got some data on the webpage, but all the values are undefined or NaN.

I then started looking at the examples files and I think I downloaded some old ones as I thought your manual (http://www.thetournamentdirector.net/userguide/docs370.html#_Toc493847226) was up to date (*cough*). ;)

Anyways, since I had to replace my C: drive in the PC, I reinstalled win10 and TD so I had a fresh install. Copied the files in that example folder over, modified html to use https, gave write permission to the listener-json.php and tested. Now it creates a 7kB tdstatus.txt file which seem fine to me but the web-page still has no correct values, only "undefined" and "NaN".

I'm a bit stumped. tdstatus.txt is updated every 60 seconds and I'm guessing it's the JS-file which is failing here. But I don't understand why or where to look.

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6220
    • View Profile
Re: Status update working, but blank TournamentStatus.html
« Reply #4 on: October 03, 2021, 10:32:50 PM »
What does the contents of tdstatus.txt look like?