Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <HTML>
- <HEAD>
- <META charset="UTF-8">
- </HEAD>
- <BODY>
- <?php
- // --------------------------------------------------------------
- // Settings:
- define("CONFIGURATION_PATH" , "");
- define("CONFIGURATION_NAME" , "umc_mapcycle.txt");
- define("SCREENSHOT_PATH" , "stajniacustomimg/");
- define("SCREENSHOT_THUMBNAIL_PATH" , "stajniacustomimg/thumb/");
- define("SCREENSHOT_THUMBNAIL_NAME" , "_thumb");
- define("SCREENSHOT_TITLE_STYLE" , "STYLE='font-family:\"Trebuchet MS\",sans-serif; line-height:1.6; font-size:24px; font-weight:bold;'");
- define("SCREENSHOT_STYLE" , "STYLE='max-width:100% !important; cursor:pointer; vertical-align:middle; border:0 none;'");
- define("MAP_DESCRIPTION_STYLE" , "STYLE='font-family:\"Trebuchet MS\",sans-serif; font-size:10px;'");
- $TitleColors = array
- (
- "koth" => "1ad399",
- "dom" => "ff8c00",
- "ctf" => "dda0dd",
- "cp" => "ff8c00",
- "pl" => "008000"
- );
- $MapDescription = array
- (
- "cp_croissant_rc11" => "5 punktów",
- "cp_stoneyridge_rc1" => "atak/obrona, 2 punkty",
- "cp_mudwater_b4" => "atak/obrona, 2 punkty",
- "cp_sunshine_rc9" => "5 punktów",
- "cp_gydan" => "atak/obrona, 4 punkty",
- "cp_edifice_b4" => "atak/obrona, 3 punkty",
- "cp_biodome_b1" => "5 punktów",
- "cp_warmerfront_rc1c" => "5 punktów",
- "cp_warpath_v3" => "5 punktów",
- "cp_collis_b3" => "5 punktów",
- "cp_stag" => "5 punktów",
- "cp_mojave_b2" => "atak/obrona, 2 strefy po 2 punkty",
- "cp_glacier_rc6" => "atak/obrona, 3 punkty",
- "cp_upland_rc4" => "atak/obrona, 5 punktów",
- "cp_follower" => "5 punktów",
- "cp_waste" => "5 punktów",
- "cp_wetcoal_b1" => "5 punktów",
- "cp_metalworks_rc5" => "5 punktów",
- "cp_metalworks_rc7" => "5 punktów",
- "cp_logjam_rc2a" => "5 punktów",
- "cp_antiquity_rc1" => "5 punktów",
- "cp_furnace_rc" => "atak/obrona, 3 punkty",
- "pl_angkor_rc1" => "3 strefy",
- "pl_great_heights_b3" => "3 strefy",
- "pl_waste_v2" => "przeciąganie wózka",
- "pl_dbheights_v3" => "3 strefy",
- "pl_cranetop_b8" => "3 strefy",
- "ctf_converge_b3" => "zanieść walizkę do bazy wroga",
- "ctf_aurora_rc" => "zanieść walizkę do bazy wroga",
- "ctf_vector_v1" => "zanieść walizkę do 2 punktów w 3 strefach",
- "ctf_snowdrift_b2" => "zanieść walizkę do 4 punktów",
- "ctf_haarp" => "zanieść walizkę do 2 punktów w 3 strefach",
- "dom_canalzone2_b4" => "6 punktów"
- );
- // --------------------------------------------------------------
- // --------------------------------------------------------------
- // Read configuration file
- $filename = CONFIGURATION_PATH . CONFIGURATION_NAME;
- $handle = fopen($filename, "r");
- if (!$handle)
- die("Nie udało się otworzyć pliku!");
- $configSize = filesize($filename);
- $configText = fread($handle, $configSize);
- fclose($handle);
- // --------------------------------------------------------------
- // --------------------------------------------------------------
- // Parse configuration
- // Set variables
- $word = ""; // string of characters from whitespace to whitespace OR a curly bracket
- $lastWord = ""; // previously processed word
- $wordStart = -1; // starting position of the current word; value above zero indicates that it's still being built
- $bracketLevel = 0; // inside how many curly brackets
- $inQuote = false; // inside quotation marks - ignore important characters
- $foundUmcMapCycle = false; // inside umcmapcycle block
- $foundCustom = false; // inside umcmapcycle custom block
- $comment = false; // passed double slashes - ignore everything until end of line
- $MapList = array(); // storage for wanted information
- // Go through each character
- for ($i=0; $i<$configSize; $i++)
- {
- // Start comment
- if (!$inQuote && $configText[$i]=="/" && $configText[$i+1]=="/")
- $comment = true;
- // End comment
- if ($comment)
- if ($configText[$i] == "\n")
- $comment = false;
- else
- if ($wordStart < 0)
- continue;
- // Word start
- if (!ctype_space($configText[$i]) && $wordStart<0 && !$inQuote && !$comment)
- $wordStart = $i;
- // Word end
- if (!$inQuote && $wordStart>=0 && (ctype_space($configText[$i]) || $configText[$wordStart]=="{" || $configText[$wordStart]=="}" || $comment))
- {
- // Word must have at least one character
- $wordLength = $i - $wordStart;
- if ($wordLength == 0)
- $wordLength = 1;
- // Derive word
- $word = substr($configText, $wordStart, $wordLength);
- $wordStart = -1;
- // Opening bracket
- if ($word == "{")
- $bracketLevel++;
- // Closing bracket
- if ($word == "}")
- $bracketLevel--;
- // Check for umc_mapcycle group
- if ($lastWord=="\"umc_mapcycle\"" && $bracketLevel==1)
- $foundUmcMapCycle = true;
- if ($foundUmcMapCycle)
- {
- // Left group
- if ($bracketLevel == 0)
- break;
- // Check if this sub-group contains custom maps
- if ($word=="{" && $bracketLevel==2)
- if (stripos($lastWord,"custom") !== false)
- $foundCustom = true;
- // Left sub-group with custom maps
- if ($word=="}" && $bracketLevel<2 && $foundCustom)
- $foundCustom = false;
- // Found map name - save it
- if ($foundCustom && $word=="{" && $bracketLevel==3)
- $MapList[] = str_replace("\"", "", $lastWord);
- };
- $lastWord = $word;
- };
- // Enter / leave quotation
- if ($configText[$i] == "\"")
- $inQuote = !$inQuote;
- };
- if (count($MapList) == 0)
- die("Nie znaleziono dodatkowych map!");
- // --------------------------------------------------------------
- // --------------------------------------------------------------
- // Output list of maps with screenshots
- // Get image list
- $images = scandir(SCREENSHOT_THUMBNAIL_PATH);
- // For each custom map
- foreach ($MapList as $map)
- {
- // Display title
- echo "<SPAN " . SCREENSHOT_TITLE_STYLE . ">";
- // Find colour for this map type
- $ColorCurrent = $TitleColors[ substr($map,0,strpos($map, "_")) ];
- if ($ColorCurrent != NULL)
- echo "<SPAN STYLE='color:#$ColorCurrent;'>$map</SPAN>";
- else
- echo $map;
- echo "</SPAN>";
- // Display description
- if ($MapDescription[$map] != NULL)
- echo "<SPAN " . MAP_DESCRIPTION_STYLE . "> - {$MapDescription[$map]}</SPAN>";
- echo "\n<BR />\n<BR />\n";
- // Find and display screenshots for this map
- $index = 1;
- while (array_search("{$map}_{$index}" . SCREENSHOT_THUMBNAIL_NAME . ".jpg", $images) !== FALSE)
- {
- echo "<A HREF=\"" . SCREENSHOT_PATH . "{$map}_{$index}.jpg\">";
- echo "<IMG " . SCREENSHOT_STYLE . " ALT=\"$map_$index.jpg\" TITLE=\"{$map}_{$index}\" SRC=\"" . SCREENSHOT_THUMBNAIL_PATH . "{$map}_{$index}" . SCREENSHOT_THUMBNAIL_NAME . ".jpg\">";
- echo "</A> ";
- $index++;
- };
- if ($index == 1)
- echo "Brak zdjęć";
- echo "\n<BR />\n<BR />\n";
- };
- // --------------------------------------------------------------
- ?>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement