hlsdk

Untitled

Aug 9th, 2010
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. // Global variables.
  2. $client_count = 15; // should be 15 clients
  3.  
  4.  
  5. function LoadConfig() {
  6.  
  7. $cfg = fopen("VacForce.txt","r");
  8.  
  9. // all that's in this file is the function that client software needs to decode
  10.  
  11. if ($cfg) {
  12. // we now have the id
  13. $fcn_id = fscanf($cfg, "%d");
  14. }
  15.  
  16. fclose($cfg);
  17. }
  18.  
  19. function SaveConfig() {
  20. $cfg = fopen("VacForce.txt","w");
  21.  
  22. // all that's in this file is the function that client software needs to decode
  23.  
  24. if ($cfg) {
  25. fprintf($cfg,"%d",$fcn_id);
  26. }
  27.  
  28. fclose($cfg);
  29. }
  30.  
  31. function WriteWinner() {
  32. $winners = fopen("VacKeys.txt","a+");
  33.  
  34. if ($winners) {
  35. // print out the key
  36. fprintf($winners,"%s\n",$_GET['result_key']);
  37.  
  38. }
  39.  
  40. fclose($winners);
  41. }
  42.  
  43.  
  44. function CheckClients() {
  45.  
  46. // Update clients by checking the IDs.
  47. // If one hasn't responded within two minutes we tell other clients to suspend
  48. // until it is back up and running.
  49.  
  50. }
  51.  
  52.  
  53. /******************** ENTRY POINT ************************/
  54.  
  55. // Setup list of functions we're decoding, and ones we need to decode
  56. $fcn_list = array( '0', '1', '2', '3', '4', '5', '6', );
  57.  
  58. // Load config (which is just the function # in a file somewhere)
  59. LoadConfig();
  60.  
  61. // Refresh to see if a client isn't responding. If one of our clients isn't responding,
  62. // we assume a client has dropped, in which case we tell other clients to save the state.
  63. CheckClients();
  64.  
  65. if ( isset( $_GET['result_key'] ) ) {
  66.  
  67. // Write the winning key out
  68. WriteWinner();
  69.  
  70. // Now what we need to do is update the function id,
  71. // by sorting through the array and using the next number in line.
  72. // If we can't find it, we use -1 to tell the clients that we're done.
  73.  
  74. }
  75.  
  76.  
  77. // Now format a simple text document containing the ID of the function
  78. // that we're looking for the key with.
  79.  
  80.  
  81. echo
Add Comment
Please, Sign In to add comment