################################################################# # Games.pl (SP1) # ################################################################# # Concept and original code by KyleYankan (yankscrew@rcn.com) # # Rewritten by: michael (mrtorrent@yahoo.com) # # Last edit: 25.1.2001 # ################################################################# # The dir that the games are in (either absolute or relative path). $gamesdir = 'games' ; # Change this to what you want (without trailing "/"). # Leave this blank if you don't use a custom games directory. $gamesurl = ''; # Otherwise, set this to the URL of your games directory (without trailing "/") sub games{ my $game = $INFO{'game'}; my($item, $line); if($game) { # Display the game. if(!$gamesurl){ $gamesurl = "games"; } open(PARAMS, "$gamesdir/$game/$game.txt"); @params = ; close(PARAMS); chomp @params; if(@params[0]){ $yytitle = "@params[0]"; } else { $yytitle = "$game"; } $yymain .= qq~
~; if(@params[0]){ $yymain .= qq~

@params[0]

~; } else { $yymain .= qq~

$game

\n~; } if(@params[1]){ $yymain .= qq~

@params[1]

~; } $yymain .= qq~
\n~; if(@params[2] =~ /java/i) { if(!@params[3]){ @params[3] = "80%"; } if(!@params[4]){ @params[4] = "600"; } $yymain .= qq~~; } else { open(FILE, "$gamesdir/$game/$game.htm") || fatal_error("Error! There is no game file at $gamesdir/$game/$game.htm!"); @code = ; close(FILE); foreach $line(@code) { $line =~ s//$gamesurl/gi; $yymain .= $line; } } } else { # Show the games list. $yytitle = "Games!"; $yymain .= qq~

Games!

\n~; opendir(GAMES, "$gamesdir") || fatal_error("The directory $gamesdir does not exist!"); @contents = readdir(GAMES); closedir(GAMES); foreach $item(@contents) { if(-e "$gamesdir/$item/$item.htm" && $item ne '..' && $item ne '.') { push(@games, $item); } } foreach $game(sort @games) { open(PARAMS, "$gamesdir/$game/$game.txt"); @desc = ; close(PARAMS); chomp @desc; if(@desc[0]) { $yymain .= qq~

@desc[0] (@desc[2])~; } else { $yymain .= qq~

$game~; } if(@desc[1]){ $yymain .= qq~
@desc[1]~; } $yymain .= qq~

\n~; } $yymain .= qq~
~; } &template; exit; } 1;