Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Global variables.
- $client_count = 15; // should be 15 clients
- function LoadConfig() {
- $cfg = fopen("VacForce.txt","r");
- // all that's in this file is the function that client software needs to decode
- if ($cfg) {
- // we now have the id
- $fcn_id = fscanf($cfg, "%d");
- }
- fclose($cfg);
- }
- function SaveConfig() {
- $cfg = fopen("VacForce.txt","w");
- // all that's in this file is the function that client software needs to decode
- if ($cfg) {
- fprintf($cfg,"%d",$fcn_id);
- }
- fclose($cfg);
- }
- function WriteWinner() {
- $winners = fopen("VacKeys.txt","a+");
- if ($winners) {
- // print out the key
- fprintf($winners,"%s\n",$_GET['result_key']);
- }
- fclose($winners);
- }
- function CheckClients() {
- // Update clients by checking the IDs.
- // If one hasn't responded within two minutes we tell other clients to suspend
- // until it is back up and running.
- }
- /******************** ENTRY POINT ************************/
- // Setup list of functions we're decoding, and ones we need to decode
- $fcn_list = array( '0', '1', '2', '3', '4', '5', '6', );
- // Load config (which is just the function # in a file somewhere)
- LoadConfig();
- // Refresh to see if a client isn't responding. If one of our clients isn't responding,
- // we assume a client has dropped, in which case we tell other clients to save the state.
- CheckClients();
- if ( isset( $_GET['result_key'] ) ) {
- // Write the winning key out
- WriteWinner();
- // Now what we need to do is update the function id,
- // by sorting through the array and using the next number in line.
- // If we can't find it, we use -1 to tell the clients that we're done.
- }
- // Now format a simple text document containing the ID of the function
- // that we're looking for the key with.
- echo
Add Comment
Please, Sign In to add comment