Author Topic: Status Update by URL  (Read 15565 times)

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Status Update by URL
« on: July 09, 2012, 11:42:54 AM »
Hello
i was testing TD3.1 and very happy to see that my scanner bar code will works perfectly with the new features! TY Corey  :)
I saw something interesting, too!
We can now send Tournament status by URL! Wonderful !....but there is nothing to read the feed updated!

I m not a Dev ! but i tryed to do something in php and it works!!! ;D

I send datas from TD to a specific URL of my site (path of the status.php file in my website)
The php file read vars and and modify XML file (status.xml)
After, with the XML parser, we can read status of tournament! (view_status.html)

attention! it is a very simple php code!And HTML page is minimalist
there is no test to check if the variables are integers, if it exists ....
Code can be well improve

here, my contribution
you can test and enjoy ;)
(i added a little help text file to explain how to use- readme.txt)
« Last Edit: July 09, 2012, 05:26:36 PM by davidator »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #1 on: July 09, 2012, 04:19:52 PM »
Very cool.  Thanks for sharing.  I have a to-do item to add an example to be included with the software, but just haven't gotten to it yet.

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #2 on: July 09, 2012, 04:40:08 PM »
with pleasure  ;)
« Last Edit: July 09, 2012, 04:44:25 PM by davidator »

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #3 on: July 11, 2012, 01:03:37 PM »
i added some features :

1. securit the php file
2. Average Added
3. time after day of last upadtes
4. fixed "refresh" button on the view_status.html and i translated in english 

I dont use all fields, but you can add all field you need by editing view.php and view_status.htm

corey, why the playersleft and players are the same value?

numberofplayers=6
n=6
the same?
« Last Edit: July 11, 2012, 01:17:19 PM by davidator »

jodybingo

  • Hero Member
  • *****
  • Posts: 656
    • View Profile
    • Personal Web Site
Re: Status Update by URL
« Reply #4 on: July 11, 2012, 04:02:49 PM »
I'm looking for a bit of help on this. Google wasnt that fruitful for me. I am running my own server (SBS 2003 with IIS 6.0). I think I have set all permissions in every place I could think of. Both directly on the files and the folder and also on the files and folder through IIS both on my FTP sites directory and my Web Sites directory. Every attempt to update returned a Failed from TD3.
What a I missing??

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #5 on: July 11, 2012, 04:37:54 PM »
so sorry, i cant help u about this! i use mutual server and it works! maybe search around the php.ini file
« Last Edit: July 12, 2012, 12:39:53 AM by davidator »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #6 on: July 11, 2012, 05:50:32 PM »
corey, why the playersleft and players are the same value?

numberofplayers=6
n=6
the same?

buyins is the number of players who have bought into the tournament
numberofplayers and n are aliases of buyins

playersleft is the number of players still in the tournament (those who have not yet busted out)
players is an alias of playersleft


Since the user manual isn't updated yet, here is the list: http://www.thetournamentdirector.net/forums/index.php?topic=3336.0

Although it doesn't list all of the aliases.

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #7 on: July 11, 2012, 06:06:43 PM »
I'm looking for a bit of help on this. Google wasnt that fruitful for me. I am running my own server (SBS 2003 with IIS 6.0). I think I have set all permissions in every place I could think of. Both directly on the files and the folder and also on the files and folder through IIS both on my FTP sites directory and my Web Sites directory. Every attempt to update returned a Failed from TD3.
What a I missing??

My suggestion would be to start with the simplest of scripts to make sure PHP is working on IIS.  Put a file named "phpinfo.php" at the root of your web server.  The file contents should simply be:

<?php phpinfo(); ?>

Then using your browser go to http://your-web-server/phpinfo.php.  You should get a PHP page with your system info on it.  If that simple test doesn't work, Google "Configuring IIS 6 and php" to get IIS configured properly.  Once you've gotten PHP working on your web server, put davidator's script in place.  Then try to update using the "Attempt update now" button.  Whether it succeeds or fails, copy the "Destination" value (you should be able to highlight and copy it) and paste it into your browser to see what kind of response the TD got.  This should help you get to the next step.  For example, for mine before I've done any configuring (I'm using IIS7), I see:

Code: [Select]
Warning: Division by zero in C:\inetpub\wwwroot\status.php on line 20

Warning: fopen(status.xml) [function.fopen]: failed to open stream: Permission denied in C:\inetpub\wwwroot\status.php on line 28

Warning: fseek(): supplied argument is not a valid stream resource in C:\inetpub\wwwroot\status.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in C:\inetpub\wwwroot\status.php on line 30

Warning: fclose(): supplied argument is not a valid stream resource in C:\inetpub\wwwroot\status.php on line 31

I'll dig into it a little deeper tomorrow and hopefully what I find will be applicable to your situation as well.

mcfrojd

  • Full Member
  • ***
  • Posts: 120
    • View Profile
Re: Status Update by URL
« Reply #8 on: July 13, 2012, 08:35:18 AM »
Love this .php example.

Works like a charm when i implement it on our wordpress site http://poker.grantek.se

Now if only the "export to html" for the stats and summary could get a bit html responsive (adapt appearence depending on wich device viewing it) from some one with some html experience it would be great.
« Last Edit: July 13, 2012, 08:37:05 AM by mcfrojd »

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #9 on: July 13, 2012, 09:41:46 AM »
Nice job mcfrojd !
Happy to see it works for u!

For the stats, i use a very nice joomla component for my web site ( to see the compnent in action on my site, http://pokerplayer13.fr , in the navbar: "CLASSEMENT")
with this joomla component, u just export the xml file built by TD and after, i upload it in my joomla admin.
the component is http://www.thepokerleaderboard.com/

Otherwise, why don't you use a wrapper to integrate your  stats pages ? http://wordpress.org/extend/plugins/wp-wrapper/
« Last Edit: July 13, 2012, 10:10:56 AM by davidator »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #10 on: July 13, 2012, 12:11:38 PM »
davidator, you inspired me to get off my butt and create the example to support this feature.  So here is the first pass at it.  This will be included in the next version of the software.

Your website needs to be able to support PHP (I can't imagine a hosting service that doesn't).  As davidator demonstrated, there are basically two pages: (1) the "listener" page that the TD sends the data to, and (2) the "viewer" page that one can point their browser at and see live information from the tournament.  I've divided the viewer page out into HTML, CSS, and Javascript files.  This should make it very easy to adapt and extend.

Attached is a ZIP file containing 4 files:

statusListener.php
This is the "listener" page.  Once installed on your site, you'll need to configure the Status Updates feature in the TD to point to this page.

TournamentStatus.html
This is the "viewer" page.  Once installed on your site, point your browser to it to see the current tournament status.

TournamentStatus.css
The stylesheet for the viewer page.

TournamentStatus.js
The Javascript supporting the viewer page.

The listener page will need to be able to write a file locally.  You may have to configure your web site to allow this.  You may need to modify the URLStatus variable in TournamentStatus.js, depending on where you install statusListener.php and TournamentStatus.html.  By default, if the two are installed in the same folder on your web site, it should work out of the box.

The page automatically updates itself, so once you point your browser to it, you don't have to do anything else.  The page will continually refresh.  The page uses the JQuery Javascript library to make the values fade in and out (among other things).  I did this to convey the idea that the page isn't "real-time" and to make it obvious when something on the page changes.  The TournamentStatus.js file has some options at the top you can change yourself.  The Javascript is basically self-contained, so it shouldn't interfere with any other script you may have on your site.

The code isn't written to handle odd situations, like a request to update the page taking a long time or failing entirely.  So you may get strange behavior should something out of the ordinary happen.

The refresh rate by default is 3 seconds.  This means that the page will request an update from the web server, and once that update is received, the page waits 3 seconds before issuing another update request.  If the request from the server takes 3 seconds to arrive, the effective refresh rate will end up being 6 seconds.

On a local server, I set the TD to send updates once per second, and had the page refresh every 2 or 3 seconds and it has a nice effect.  Might make a (potentially big) difference when updating to and viewing from an internet web site.
« Last Edit: December 04, 2012, 12:10:56 PM by Corey Cooper »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #11 on: July 13, 2012, 12:16:05 PM »
btw, jodybingo, I'm running Windows 7 Professional (so IIS7), and I dropped the files into the wwwroot folder.  I had to modify the permissions on the folder, giving Modify and Write permission to  the local IIS_IUSRS account to make this work.  There's probably a much better and safer method, but I was just trying to make it work.

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #12 on: July 13, 2012, 12:54:00 PM »
woaw!
full optimization of php code!
 
Question: the length of an url is not it limited? (I thought of the GET method)
« Last Edit: July 13, 2012, 01:07:20 PM by davidator »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5402
    • View Profile
Re: Status Update by URL
« Reply #13 on: July 13, 2012, 01:27:22 PM »
Question: the length of an url is not it limited? (I thought of the GET method)

Probably, but frankly I don't know what the limit is and regardless I doubt the TD's Status Updates feature will reach it.  But this is a good point, and brings up something I forgot to mention: the Status Updates feature has a bug, in that it does not send a "Content-type" header when using the POST method.  I've already fixed this for the next version.  What it means for now is that when using the POST method, languages like PHP may not automatically parse the variables for you.  The data is still available in the $HTTP_RAW_POST_DATA variable, for example, but not in the $_POST array.

The example I previously posted will accept the data from the TD using either the GET or POST method, but until the next version of the TD is released (and this bug fixed), it won't work unless you use the GET method.

davidator

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Status Update by URL
« Reply #14 on: July 13, 2012, 01:35:06 PM »
ok

i made a litle video to show how script works!

http://screencast.com/t/d9KvcEYrT

And the script on my cell:


 
you are a boss corey!
« Last Edit: July 14, 2012, 01:35:33 PM by davidator »