<?php
/*
    This script, "difficulty maker" is inspired by a script named "diff_custom helper" created by thomasfischer.biz,
    but based on the code from "diff_custom maker" which is made by myself.
    More information about his script and sources, you find here: http://wiki.openttd.org/Diff_custom
    
    This script was made to be easy to include in other documents and for other use if possible/wished,
    and also it's valid for XHTML1.1.
    
    It is also up to date with the options, some things was missing in the other script and even at wiki.

    Whatsoever, feel free to copy, modify, use, whatever with this script.
    http://ottd.gidderikke.no/difficulty_maker.phps is directly linked to the script used on the page.

    "difficulty maker" is created by Ole-Henrik Jakobsen <ole [at] gidderikke [dot] no>
    http://ottd.gidderikke.no - http://gidderikke.no

    Last updated: 2009-11-18 15:30 [YYYY-MM-DD HH:mm]
*/

// Some diff_custom variables
    
$diff_easier  "0,1,4,500000,2,0,0,0,0,0,0,0,0,0,0,0"// custom easy - easier than original
    
$diff_easy    "2,2,4,300000,2,0,2,1,2,0,1,0,0,0,0,0"// original easy
    
$diff_med     "4,2,3,150000,3,1,3,2,1,1,2,1,1,1,1,1"// original medium
    
$diff_hard    "7,3,3,100000,4,1,3,2,0,2,3,2,1,1,1,2"// original hard
    
$diff_harder  "7,3,1,100000,4,2,4,2,2,2,3,3,1,1,1,2"// custom hard - harder than original
    
$diff_lowval  "0,0,0,100000,2,0,0,0,0,0,0,0,0,0,0,0"// nothing else than just the lowest value for everything, just used for default setting
    
// Specify wich settings to display as default
    
if(!$diff_custom && !$_POST["make_diff_custom"] && !$_POST["load_diff_custom"] && !$_POST["load_diff_custom_config"] && !$_GET["diff_custom"]) {
        
$diff_custom $diff_lowval;
    }
// Load and make custom diff_custom
    
if($_POST["make_diff_custom"] || $_POST["load_diff_custom"]) {
        
$diff_settings .= "[difficulty]<br />\n";
        if(
$_POST["make_diff_custom"]) {
            for(
$i 0$i <= 15$i++) {
                
$diff_custom .= "" $_POST["option" $i ""] . "";
                
$diff_settings .= "" get_diff_custom($i$_POST["option" $i ""], CONFIG) . " = " $_POST["option" $i ""] . "\n<br />";
                if(
$i != 15) { $diff_custom .= ","; }
            }
        }
        else if(
$_POST["load_diff_custom"]) {
            if(
$_POST["load_diff_custom_easier"]) { $diff_custom $diff_easier; }
            if(
$_POST["load_diff_custom_easy"])   { $diff_custom $diff_easy; }
            if(
$_POST["load_diff_custom_med"])    { $diff_custom $diff_med; }
            if(
$_POST["load_diff_custom_hard"])   { $diff_custom $diff_hard; }
            if(
$_POST["load_diff_custom_harder"]) { $diff_custom $diff_harder; }
            
            
$split_dc explode(","$diff_custom);
            
$i 0;
            while(
$i count($split_dc)) {
                
$diff_settings .= "" get_diff_custom($i$split_dc[$i], CONFIG) . " = " $split_dc[$i] . "\n<br />";
                
$i++;
            }
        }
        
$diff_settings .= "diff_level = " diff_custom_value($diff_custom) . "\n<br />";
    }

// Default variables for currency to display, may be several.
    
$cur100 "" currency_specs(100000,GBP) . " / " currency_specs(100000,USD) . " / " currency_specs(100000,NOK) . "";
    
$cur150 "" currency_specs(150000,GBP) . " / " currency_specs(150000,USD) . " / " currency_specs(150000,NOK) . "";
    
$cur200 "" currency_specs(200000,GBP) . " / " currency_specs(200000,USD) . " / " currency_specs(200000,NOK) . "";
    
$cur250 "" currency_specs(250000,GBP) . " / " currency_specs(250000,USD) . " / " currency_specs(250000,NOK) . "";
    
$cur300 "" currency_specs(300000,GBP) . " / " currency_specs(300000,USD) . " / " currency_specs(300000,NOK) . "";
    
$cur350 "" currency_specs(350000,GBP) . " / " currency_specs(350000,USD) . " / " currency_specs(350000,NOK) . "";
    
$cur400 "" currency_specs(400000,GBP) . " / " currency_specs(400000,USD) . " / " currency_specs(400000,NOK) . "";
    
$cur450 "" currency_specs(450000,GBP) . " / " currency_specs(450000,USD) . " / " currency_specs(450000,NOK) . "";
    
$cur500 "" currency_specs(500000,GBP) . " / " currency_specs(500000,USD) . " / " currency_specs(500000,NOK) . "";
    
// Prepare currency POST
    
if($_POST["sel_currency"]) {
        
$post_currency $_POST["sel_currency"];
        
$cur100 currency_specs(100000,$post_currency);
        
$cur150 currency_specs(150000,$post_currency);
        
$cur200 currency_specs(200000,$post_currency);
        
$cur250 currency_specs(250000,$post_currency);
        
$cur300 currency_specs(300000,$post_currency);
        
$cur350 currency_specs(350000,$post_currency);
        
$cur400 currency_specs(400000,$post_currency);
        
$cur450 currency_specs(450000,$post_currency);
        
$cur500 currency_specs(500000,$post_currency);
    }
// Get custom currency variables
    
if($_POST["make_custom_currency"]) {
        
$custom_currency_rate $_POST["custom_currency_rate"];
        
$custom_currency_separator $_POST["custom_currency_separator"];
        
$custom_currency_prefix $_POST["custom_currency_prefix"];
        
$custom_currency_postfix $_POST["custom_currency_postfix"];
    }
// A function to figure out the diff_level
    
function diff_custom_value($diff_custom) {
        global 
$diff_easy$diff_med$diff_hard;
    
        if     (
$diff_custom == $diff_easy) { $diff_custom_value 0; }
        else if(
$diff_custom == $diff_med)  { $diff_custom_value 1; }
        else if(
$diff_custom == $diff_hard) { $diff_custom_value 2; }
        else if(
$diff_custom)               { $diff_custom_value 3; }
        
        return 
$diff_custom_value;
    }
// A function who makes the custom currency
    
function make_custom_currency($rate$separator$prefix$postfix$output) {
        
// $rate = The rate of the currency: $rate * 100000, ex: 2 * 100000 = 200000
        // $separator = What to separate the number with, ex: with . or ,: 200.000 / 200,000
        // $prefix = What to put in front of the money, ex: $ ($200.000)
        // $postfix = What to put in behind of the money, ex: ,- (200.000,-)
        // $output = What to give out as a result: TEXT: gives output for specifying custom currency options. HIDDEN: gives the same output as TEXT, but only in hidden forms. FUNCTION: gives variables in an array.

        
global $post_currency$custom_currency_rate$custom_currency_separator$custom_currency_prefix$custom_currency_postfix;
        
        
$rate $custom_currency_rate;
        
$separation $custom_currency_separation;
        
$prefix $custom_currency_prefix;
        
$postfix $custom_currency_postfix;

        if(!
$rate) { $rate 1; }
        if(!
$separator) { $separator "."; }
        if(!
$prefix) { $prefix "&curren;"; }
        if(!
$postfix) { $postfix ",-"; }
            
        if(
$output == "TEXT" && $post_currency == "CUSTOM") {
            
$html "
                Rate: <input type=\"text\" name=\"custom_currency_rate\" value=\"" 
$rate "\" style=\"width: 45px;\" />
                Separator: <input type=\"text\" name=\"custom_currency_separator\" value=\"" 
$separator "\" style=\"width: 15px;\" />
                Prefix: <input type=\"text\" name=\"custom_currency_prefix\" value=\"" 
$prefix "\" style=\"width: 15px;\" />
                Postfix: <input type=\"text\" name=\"custom_currency_postfix\" value=\"" 
$postfix "\" style=\"width: 15px;\" />
                <input type=\"hidden\" name=\"make_custom_currency\" value=\"1\" />
            "
;
            return 
$html;
        }

        if(
$output == "HIDDEN" && $post_currency == "CUSTOM") {
            
$html "
                <input type=\"hidden\" name=\"custom_currency_rate\" value=\"" 
$rate "\" />
                <input type=\"hidden\" name=\"custom_currency_separator\" value=\"" 
$separator "\" />
                <input type=\"hidden\" name=\"custom_currency_prefix\" value=\"" 
$prefix "\" />
                <input type=\"hidden\" name=\"custom_currency_postfix\" value=\"" 
$postfix "\" />
                <input type=\"hidden\" name=\"make_custom_currency\" value=\"1\" />
            "
;
            return 
$html;
        }

        if(
$output == "FUNCTION") {
            
$curr["rate"]         = $rate;
            
$curr["separator"]     = $separator;
            
$curr["prefix"]     = $prefix;
            
$curr["postfix"]     = $postfix;
            return 
$curr;
        }
    }
// A function who defines information about different currencies, and also exchange them
    
function currency_specs($pounds,$newcurrency) {
        
// $pounds = pounds to exchange
        // $newcurrency = in wich currency to output (ALL = returning all currencies in <option>, else specify with currency name ex. GBP, USD, EUR...)
        
        
global $post_currency;
        
        
$add_selected[$post_currency] = " selected=\"selected\" ";

        if(
$newcurrency == "GBP" || $newcurrency == "ALL") { $curr "GBP";    $rate =     1;     $separator ","$prefix "&pound;";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">British Pounds (GBP)</option>"; }
        if(
$newcurrency == "USD" || $newcurrency == "ALL") { $curr "USD";    $rate =     2;     $separator ","$prefix "$";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">US Dollars (USD)</option>"; }
        if(
$newcurrency == "EUR" || $newcurrency == "ALL") { $curr "EUR";    $rate =     2;     $separator ","$prefix "&euro;";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Euro (EUR)</option>"; }
        if(
$newcurrency == "YEN" || $newcurrency == "ALL") { $curr "YEN";    $rate =   220;     $separator ","$prefix "&yen;";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Yen (YEN)</option>"; }
        if(
$newcurrency == "ATS" || $newcurrency == "ALL") { $curr "ATS";    $rate =    20;     $separator ","$prefix "";        $postfix " S.";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Austrian Schilling (ATS)</option>"; }
        if(
$newcurrency == "BEF" || $newcurrency == "ALL") { $curr "BEF";    $rate =    59;     $separator ","$prefix "BEF ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Belgian Franc (BEF)</option>"; }
        if(
$newcurrency == "CHF" || $newcurrency == "ALL") { $curr "CHF";    $rate =     2;     $separator ","$prefix "CHF ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Swiss Franc (CHF)</option>"; }
        if(
$newcurrency == "CZK" || $newcurrency == "ALL") { $curr "CZK";    $rate =    41;     $separator ","$prefix "";        $postfix " Kč";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Czech Koruna (CZK)</option>"; }
        if(
$newcurrency == "DEM" || $newcurrency == "ALL") { $curr "DEM";    $rate =     3;     $separator "."$prefix "DM ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Deutschmark (DEM)</option>"; }
        if(
$newcurrency == "DKK" || $newcurrency == "ALL") { $curr "DKK";    $rate =    11;     $separator "."$prefix "";        $postfix " kr";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Danish Krone (DKK)</option>"; }
        if(
$newcurrency == "ESP" || $newcurrency == "ALL") { $curr "ESP";    $rate =   245;     $separator "."$prefix "Pts ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Peseta (ESP)</option>"; }
        if(
$newcurrency == "FIM" || $newcurrency == "ALL") { $curr "FIM";    $rate =     9;     $separator ","$prefix "";        $postfix " mk";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Finnish Markka (FIM)</option>"; }
        if(
$newcurrency == "FRF" || $newcurrency == "ALL") { $curr "FRF";    $rate =    10;     $separator "."$prefix "FF ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Franc (FRF)</option>"; }
        if(
$newcurrency == "GRD" || $newcurrency == "ALL") { $curr "GRD";    $rate =   500;     $separator ","$prefix "";        $postfix "Dr.";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Greek Drachma (GRD)</option>"; }
        if(
$newcurrency == "HUF" || $newcurrency == "ALL") { $curr "HUF";    $rate =   378;     $separator ","$prefix "";        $postfix " Ft";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Hungarian Forint (HUF)</option>"; }
        if(
$newcurrency == "ISK" || $newcurrency == "ALL") { $curr "ISK";    $rate =   130;     $separator "."$prefix "";        $postfix " Kr";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Icelandic Krona (ISK)</option>"; }
        if(
$newcurrency == "ITL" || $newcurrency == "ALL") { $curr "ITL";    $rate =  2850;     $separator ","$prefix "";        $postfix " L.";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Italian Lira (ITL)</option>"; }
        if(
$newcurrency == "NLG" || $newcurrency == "ALL") { $curr "NLG";    $rate =     3;     $separator ","$prefix "NLG ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Dutch Guilder (NLG)</option>"; }
        if(
$newcurrency == "NOK" || $newcurrency == "ALL") { $curr "NOK";    $rate =    12;     $separator "."$prefix "";        $postfix " Kr";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Norwegian Krone (NOK)</option>"; }
        if(
$newcurrency == "PLN" || $newcurrency == "ALL") { $curr "PLN";    $rate =     6;     $separator " "$prefix "";        $postfix " zl";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Polish Zloty (PLN)</option>"; }
        if(
$newcurrency == "ROL" || $newcurrency == "ALL") { $curr "ROL";    $rate =     5;     $separator "."$prefix "";        $postfix " Lei";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Romanian Leu (ROL)</option>"; }
        if(
$newcurrency == "RUR" || $newcurrency == "ALL") { $curr "RUR";    $rate =    50;     $separator " "$prefix "";        $postfix " p";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Russian Rubel (RUR)</option>"; }
        if(
$newcurrency == "SIT" || $newcurrency == "ALL") { $curr "SIT";    $rate =   352;     $separator "."$prefix "";        $postfix " SIT";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Slovenian Tolar (SIT)</option>"; }
        if(
$newcurrency == "SEK" || $newcurrency == "ALL") { $curr "SEK";    $rate =    13;     $separator "."$prefix "";        $postfix " Kr";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Swedish Krona (SEK)</option>"; }
        if(
$newcurrency == "YTL" || $newcurrency == "ALL") { $curr "YTL";    $rate =     3;     $separator "."$prefix "";        $postfix " YTL";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Turkish Lira (YTL)</option>"; }
        if(
$newcurrency == "SKK" || $newcurrency == "ALL") { $curr "SKK";    $rate =    52;     $separator ","$prefix "";        $postfix " Sk";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Slovak Koruna (SKK)</option>"; }
        if(
$newcurrency == "BRL" || $newcurrency == "ALL") { $curr "BRL";    $rate =     4;     $separator ","$prefix "R$ ";    $postfix "";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Brazilian Real (BRL)</option>"; }
        if(
$newcurrency == "EEK" || $newcurrency == "ALL") { $curr "EEK";    $rate =    20;     $separator "."$prefix "";        $postfix " EEK";
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Estonian Krooni (EEK)</option>"; }
        
        
$custom_currency make_custom_currency(0000"FUNCTION");

        if(
$newcurrency == "CUSTOM" || $newcurrency == "ALL") {
            
$curr "CUSTOM";
            
$rate $custom_currency["rate"];
            
$separator $custom_currency["separator"];
            
$prefix $custom_currency["prefix"];
            
$postfix $custom_currency["postfix"];
            
$option .= "<option value=\"" $curr "\"" $add_selected[$curr] . ">Custom Currency...</option>";
        }

        if(
$newcurrency == "ALL") {
            return 
$option;
        }
        else if(
$newcurrency && $pounds) {
            
$cash $rate $pounds// * 1000; // not in use after the new difficulty settings type in config
            
$cash number_format($cash0""$separator);
            return 
"" $prefix "" $cash "" $postfix " (" $curr ")";
        }
        else {
            return 
"error";
        }
    }

// A function who keeps all data for the options
    
function get_diff_custom($option$setting$output) {
        
// $option: specifies wich main option to get information from
        // $setting: specifies wich setting in the $option to get information from
        // $output: specifies if $output should be given in a VALUE, CONFIG, TEXT, or DESCRIPTION
        
        
global $cur100$cur150$cur200$cur250$cur300$cur350$cur400$cur450$cur500;
        
        if(
$option == 0) {
            
// 0-7
            
$description "Maximum no. of competitors (AI)";
            
$config "max_no_competitors";
            if(
$setting) {        $value $setting;    $text $setting; }
            else {            
$value 0;        $text 0; }
        }
        if(
$option == 1) {
            
$description "Number of towns";
            
$config "number_towns";
            if(
$setting == 0) {    $value $setting;    $text "Very low"; }
            if(
$setting == 1) {    $value $setting;    $text "Low"; }
            if(
$setting == 2) {    $value $setting;    $text "Normal"; }
            if(
$setting == 3) {    $value $setting;    $text "High"; }
        }
        if(
$option == 2) {
            
$description "Number of industries";
            
$config "number_industries";
            if(
$setting == 0) {    $value $setting;    $text "None"; }
            if(
$setting == 1) {    $value $setting;    $text "Very low"; }
            if(
$setting == 2) {    $value $setting;    $text "Low"; }
            if(
$setting == 3) {    $value $setting;    $text "Normal"; }
            if(
$setting == 4) {    $value $setting;    $text "High"; }
        }
        if(
$option == 3) {
            
$description "Maximum initial loan";
            
$config "max_loan";
            if(
$setting == 0) {    $value 100000;    $text $cur100; }
            if(
$setting == 1) {    $value 150000;    $text $cur150; }
            if(
$setting == 2) {    $value 200000;    $text $cur200; }
            if(
$setting == 3) {    $value 250000;    $text $cur250; }
            if(
$setting == 4) {    $value 300000;    $text $cur300; }
            if(
$setting == 5) {    $value 350000;    $text $cur350; }
            if(
$setting == 6) {    $value 400000;    $text $cur400; }
            if(
$setting == 7) {    $value 450000;    $text $cur450; }
            if(
$setting == 8) {    $value 500000;    $text $cur500; }
        }
        if(
$option == 4) {
            
// 2-4
            
$config "initial_interest";
            
$description "Initial interest rate";
            if(
$setting) {        $value $setting;    $text "" $setting "%"; }
        }
        if(
$option == 5) {
            
$description "Vehicle running costs";
            
$config "vehicle_costs";
            if(
$setting == 0) {    $value $setting;    $text "Low"; }
            if(
$setting == 1) {    $value $setting;    $text "Medium"; }
            if(
$setting == 2) {    $value $setting;    $text "High"; }
        }
        if(
$option == 6) {
            
$description "Construction speed of competitors";
            
$config "competitor_speed";
            if(
$setting == 0) {    $value $setting;    $text "Very slow"; }
            if(
$setting == 1) {    $value $setting;    $text "Slow"; }
            if(
$setting == 2) {    $value $setting;    $text "Medium"; }
            if(
$setting == 3) {    $value $setting;    $text "Fast"; }
            if(
$setting == 4) {    $value $setting;    $text "Very fast"; }
        }
        if(
$option == 7) {
            
$description "Vehicle breakdowns";
            
$config "vehicle_breakdowns";
            if(
$setting == 0) {    $value $setting;    $text "None"; }
            if(
$setting == 1) {    $value $setting;    $text "Reduced"; }
            if(
$setting == 2) {    $value $setting;    $text "Normal"; }
        }
        if(
$option == 8) {
            
$description "Subsidy multiplier";
            
$config "subsidy_multiplier";
            if(
$setting == 0) {    $value $setting;    $text "x1.5"; }
            if(
$setting == 1) {    $value $setting;    $text "x2"; }
            if(
$setting == 2) {    $value $setting;    $text "x3"; }
            if(
$setting == 3) {    $value $setting;    $text "x4"; }
        }
        if(
$option == 9) {
            
$description "Cost of construction";
            
$config "construction_cost";
            if(
$setting == 0) {    $value $setting;    $text "Low"; }
            if(
$setting == 1) {    $value $setting;    $text "Medium"; }
            if(
$setting == 2) {    $value $setting;    $text "High"; }
        }
        if(
$option == 10) {
            
$description "Terrain type";
            
$config "terrain_type";
            if(
$setting == 0) {    $value $setting;    $text "Very flat"; }
            if(
$setting == 1) {    $value $setting;    $text "Flat"; }
            if(
$setting == 2) {    $value $setting;    $text "Hilly"; }
            if(
$setting == 3) {    $value $setting;    $text "Mountainous"; }
        }
        if(
$option == 11) {
            
$description "Quantity of sea/lakes";
            
$config "quantity_sea_lakes";
            if(
$setting == 0) {    $value $setting;    $text "Very low"; }
            if(
$setting == 1) {    $value $setting;    $text "Low"; }
            if(
$setting == 2) {    $value $setting;    $text "Medium"; }
            if(
$setting == 3) {    $value $setting;    $text "High"; }
        }
        if(
$option == 12) {
            
$description "Economy";
            
$config "economy";
            if(
$setting == 0) {    $value $setting;    $text "Steady"; }
            if(
$setting == 1) {    $value $setting;    $text "Fluctuating"; }
        }
        if(
$option == 13) {
            
$description "Train reversing";
            
$config "line_reverse_mode";
            if(
$setting == 0) {    $value $setting;    $text "At end of line, and at stations"; }
            if(
$setting == 1) {    $value $setting;    $text "At end of line only"; }
        }
        if(
$option == 14) {
            
$description "Disasters";
            
$config "disasters";
            if(
$setting == 0) {    $value $setting;    $text "Off"; }
            if(
$setting == 1) {    $value $setting;    $text "On"; }
        }
        if(
$option == 15) {
            
$description "City council's attitude towards area restructuring";
            
$config "town_council_tolerance";
            if(
$setting == 0) {    $value $setting;    $text "Permissive"; }
            if(
$setting == 1) {    $value $setting;    $text "Tolerant"; }
            if(
$setting == 2) {    $value $setting;    $text "Hostile"; }
        }
        if(
$output == "VALUE") {
            return 
$value;
        }
        if(
$output == "CONFIG") {
            return 
$config;
        }
        else if(
$output == "TEXT") {
            return 
$text;
        }
        else if(
$output == "DESCRIPTION") {
            return 
$description;
        }
        else {
            return 
"error";
        }
    }
    
// A function who makes tables of the informations it gets
    
function make_diff_custom_tables($diff_custom) {
        
$num_settings_per_opt "0-7,0-3,0-4,0-8,2-4,0-2,0-4,0-2,0-3,0-2,0-3,0-3,0-1,0-1,0-1,0-2";
        
// $num_settings_per_opt = here you specify the setting number for each option, separated with comma for each option, and stroke for each setting
        //                         (ex.: 0-7,0-3,0-4,0-8,2-4,0-2,0-4,0-2,0-3,0-2,0-3,0-3,0-1,0-1,0-1,0-2)
        //                         This means: 0-7 = [Option1 setting 0 1 2 ... 6 7], 0-3 = [Option2 setting 0 1 2 3], ...
        //                         
        // $diff_custom          = here you specify the diff_custom line (ex.: 0,0,0,100,2,0,0,0,0,0,0,0,0,0,0,0)
        
        
$num_settings explode(","$num_settings_per_opt);
        
$split_diff_custom explode(","$diff_custom);
        
        
$i 0;
        while(
$i <= count($num_settings)-1) {
            
$split_num explode("-"$num_settings[$i]);
            
            for(
$fi $split_num[0]; $fi <= $split_num[1]; $fi++) {
                if(
$split_diff_custom[$i] == get_diff_custom($i$fi"VALUE")) {
                    
$add_selected " selected=\"selected\" ";
                }
                
$options .= "
                    <option value=\"" 
get_diff_custom($i$fi"VALUE") . "\"" $add_selected ">" get_diff_custom($i$fi"TEXT") . "</option>
                "
;
                
$add_selected "";
            }
            
            if(
get_diff_custom($i$fi"OPTSETTING") != "hidden") {
                
$table .= "
                        <tr>
                            <td class=\"conf\">
                                " 
get_diff_custom($i$fi"DESCRIPTION") . "
                            </td>
                            <td align=\"right\" class=\"conf\">
                                <select name=\"option" 
$i "\" style=\"width: 220px;\">
                                    $options
                                </select>
                            </td>
                        </tr>
                "
;
            }
            
            
$options "";
            
$i++;
        }
        
        if(
$table) {
            return 
$table;
        }
        else {
            return 
"error";
        }
    }

    
$pagecontent "
        <p class=\"big\">
            difficulty maker
        </p>
        <form action=\"" 
$REQUEST_URI "\" method=\"post\">
            <p>
                <b>Here you can choose a currency to use:</b>
            </p>
            <p>
                <select name=\"sel_currency\" style=\"width: 220px;\">
                    <option value=\"\">Script default</option>
                    " 
currency_specs(0"ALL") . "
                </select>
                " 
make_custom_currency($custom_currency_rate$custom_currency_separator$custom_currency_prefix$custom_currency_postfix"TEXT") . "
                <input type=\"hidden\" name=\"custom_config_values\" value=\"" 
$diff_custom "\" />
                <input type=\"hidden\" name=\"load_diff_custom_config\" value=\"1\" />
                <input type=\"submit\" name=\"load_currency\" value=\"Submit\" style=\"width: 100px;\" />
            </p>
        </form>
        <form action=\"" 
$REQUEST_URI "\" method=\"post\">
            <p>
                <b>You can load some settings before modifying them by clicking one of the buttons below:</b>
            </p>
            <p>
                <input type=\"submit\" name=\"load_diff_custom_easier\" value=\"Easier\" style=\"width: 100px;\" />
                <input type=\"submit\" name=\"load_diff_custom_easy\" value=\"Easy\" style=\"width: 100px;\" />
                <input type=\"submit\" name=\"load_diff_custom_med\" value=\"Medium\" style=\"width: 100px;\" />
                <input type=\"submit\" name=\"load_diff_custom_hard\" value=\"Hard\" style=\"width: 100px;\" />
                <input type=\"submit\" name=\"load_diff_custom_harder\" value=\"Harder\" style=\"width: 100px;\" />
                <input type=\"hidden\" name=\"sel_currency\" value=\"" 
$post_currency "\" />
                <input type=\"hidden\" name=\"load_diff_custom\" value=\"1\" />
                " 
make_custom_currency($custom_currency_rate$custom_currency_separator$custom_currency_prefix$custom_currency_postfix"HIDDEN") . "
            </p>
            <p>
                \"Easier\" and \"Harder\" is custom made, while \"Easy\", \"Medium\" and \"Hard\" is original from game.
            </p>
        </form>
        <table cellspacing=\"20\">
            <tr>
                <td class=\"tablebg\" valign=\"top\">
                    <form action=\"" 
$REQUEST_URI "\" method=\"post\">
                        <table>
                            " 
make_diff_custom_tables($diff_custom) . "
                            <tr>
                                <td class=\"conf\" style=\"background : $css_subheader; text-align : center;\" colspan=\"2\">
                                    <input type=\"submit\" name=\"make_diff_custom\" value=\"Make difficulty section\" />
                                    " 
make_custom_currency($custom_currency_rate$custom_currency_separator$custom_currency_prefix$custom_currency_postfix"HIDDEN") . "
                                    <input type=\"hidden\" name=\"sel_currency\" value=\"" 
$post_currency "\" />
                                </td>
                            </tr>
                        </table>
                    </form>
                </td>
                <td class=\"conf\" valign=\"top\" style=\"text-align : left;\">
                    <code style=\"font-size: medium\">" 
$diff_settings "</code>
                </td>
            </tr>
        </table>
        <p>
            <a href=\"http://ottd.gidderikke.no/difficulty_maker.phps\">View the source of this script</a>
        </p>
    "
;

    
// Uncomment next line if you want to print this side directly, or leave it if you want to include this side in a webpage with the variable: $pagecontent
    //print($pagecontent);
?>