-
Notifications
You must be signed in to change notification settings - Fork 0
/
open_latest_players.php
executable file
·56 lines (45 loc) · 1.42 KB
/
open_latest_players.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/php -q
<?php
#####
# Opens each player's files for the given turn in the web browser
#####
if( ! isset($argv[1]) )
{
echo "\nOpens each player's files for the given turn in the web browser\n\n";
echo "Called by:\n";
echo " ".$argv[0]." GAME_TURN\n\n";
exit(1);
}
$FILE_DIR = "./files/";
$BROWSER_PROGRAM = "firefox";
$LOCAL_DOMAIN = "vbsf.local";
include( "./objects/DataSheet.php" ); // So that we can get the function that decodes the data sheets
$files = scandir( $FILE_DIR );
$turn = (int) $argv[1];
foreach( $files as $key => $value )
{
// remove those files from the list that are not javascript files
if( substr( $value, -3 ) != ".js" )
{
unset( $files[$key] );
continue;
}
// remove those files where their ["game"]["turn"] does not match the input argument
$obj = new DataSheet( $FILE_DIR.$value, "", true ); // open the data file (read-only)
if( $obj === false )
{
echo "Could not open '".$FILE_DIR.$value."' for reading.\n";
unset( $files[$key], $obj );
continue;
}
$gameData = $obj->ReadGame ();
if( ! is_array($gameData) || $gameData["turn"] != $turn )
{
unset( $files[$key], $obj );
continue;
}
// reference each file to it's sheet
$files[$key] = "http://$LOCAL_DOMAIN/sheet/index.html?data=".substr( $value, 0, -3 );
unset( $obj ); // clean up the DataSheet object
}
shell_exec( $BROWSER_PROGRAM." ".implode( " ", $files ).' > /dev/null 2>&1 &' );