Here is a simple Perl program that you would upload to your server (see source code below). You can save it as "Save.pl" on the server. Let's say you have a domain name called
www.mygamecenter44.com and so you upload this perl script to the server.
You would call WGET to send data to the server in this manner:
SHELL "wget -q --output-document=D.TXT
http://www.mygamecenter44.com/Save.pl?055-33-DXW77"
And you would download the shared data from the server like this:
SHELL "wget -q --output-document=D.TXT
http://www.mygamecenter44.com/status.txt"
The first number after the ? mark tells the program which user you are. Whatever comes after that gets saved in the status.txt file. When you download status.txt file, the first number on each line is the number of seconds since Jan 1970. The second number is the IP address of the user who updated that status line.
Each user's data is stored on a different line in status.txt. The possible user codes are 0-9 and A-Z. So, there can be no more than 36 users playing at any given time using this program. The code is simple if you want to modify it. Perl is easy to learn. All it takes is a few hours to get familiar with it.
Save.pl file:
############################################
#!/usr/bin/perl -w
use strict;
use warnings;
my $FILENAME = 'status.txt';
my $IP = Trim($ENV{'REMOTE_ADDR'});
my $ARG = Trim($ENV{QUERY_STRING});
my $ROOT = Trim($ENV{'DOCUMENT_ROOT'});
print "Content-type: text/html\n\n<HTML><BODY>";
my $VALID = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
print '1'; defined $ARG or exit;
print '2'; length($ARG) >= 2 or exit;
print '3'; my $USER = uc(substr($ARG, 0, 1));
$USER = index($VALID, $USER);
$USER >= 0 or exit;
print '4'; $ARG = substr($ARG, 1, 2000);
my $F = $ROOT . $FILENAME;
my $PREVSIZE = -s $F;
print '5'; my @LINES = ReadTextFile($F, length($VALID));
print '6'; while (@LINES < $USER) { push(@LINES, ''); }
$LINES[$USER] = time . " $IP $ARG";
print '7'; WriteTextFile($F, @LINES);
print "\n<BR>FILE NAME: " . $FILENAME;
print "\n<BR>PREV SIZE: " . $PREVSIZE;
print "\n<BR>CURRENT SIZE: " . -s $F;
exit;
# This function removes leading and trailing spaces, tabs, and new-line characters from a string and returns a new string.
# Usage: STRING Trim(STRING)
sub Trim { my $STR = shift; return '' unless (defined $STR); return '' if (length($STR) == 0); my $j = 0; my $i = -1; for (my $x = 0; $x < length($STR); $x++) { if (ord(substr($STR, $x, 1)) > 32) { if ($i < 0) { $i = $x; } $j = $x - $i + 1; } } return substr($STR, $i, $j); }
# This function reads no more than N number of lines from a text file and returns the contents as an array.
# Usage: ARRAY ReadTextFile(FILENAME, N)
sub ReadTextFile { my $NAME = shift; my $N = shift; my $i = 0; my @DATA; return ('') unless (-f $NAME); open my $FILE, '<', $NAME or return @DATA; while (my $LINE = <$FILE>) { last if ($i >= $N); $DATA[$i++] = Trim($LINE); } close $FILE; return @DATA; }
# This function writes a list of lines to a text file. Returns 1 on success or 0 on failure.
# Usage: INTEGER WriteTextFile(FILENAME, STRINGS...)
sub WriteTextFile { my $NAME = shift; my $DATA = join("\n", @_); open(my $FILE, '>', $NAME) or return 0; print $FILE $DATA or return 0; close $FILE or return 0; return 1; }
__END__