HRCodWar - Installation of the web

HRCodWar works either independently or managed from this web project in a more friendly way.

Through this PHP programmed website you are watching, pilots and commanders each side can check the front and all information related to the battle, clicking through here Campaign and entering the corresponding key. But how does it really works? And how is this web project installed? How does it communicates with the machine launching the mission...? Let us see.

WEB INSTALATION

WARNING! Minimal knowledge of PHP and general operation of a web server like Apache are assumed.

It should be noted that the web began as a circustancial support to the campaign and finally has become basic. The campaign could function without the web but it allows you to visually explore the battlefront and schedule orders and movements, which have become an almost indispensable tool. Therefore, because it was born as a simple unpretentious tool and was developed in a record time, it is not as complete as it should, and its development as a "web" is quite poor, as it is programmed with only 2 or 3 php modules without frameworks ... it is a shame for any professional web developer :)

First thing is to download the website from the download section here and uncompress it on your local htdocs root directory (if you have a home apache + php installation) or in any other place to understand what comes next.

Once it is decompressed, go to the proyects root directory and find a configuration file called:

config.inc.php

Open it and you will see a number of global variables that are used throughout the project. The variables that you can modify to suit your needs are:

  • $CFG_LANGS An array of available languages and their names.
  • $CFG_LANG String with default language.
  • $CFG_URL_HOME Absolute URL where the project is hosted, including the ending slash, for example: http://www.mydomain.com/hrcodwar/
  • $CFG_CLAVE_ACEPTA_ENVIOS The key used to communicate the IL2 Cliff of Dover game server and this website. It must be the same as the web_script_password of its conf.ini.
  • $CFG_DIR_DATOS_BATALLA This is the path that refers to the directory where all sensitive data referring to the current campaign are stored. Note that the directory should not be accessible via http because a simple typing change in the url could allow to download files and spy enemy data.
    Therefore, it is recommended that place it out of the htdocs root, something like "../battledata" should work. Anyway, sometimes we can not access the previous directory to htdocs, so the straight solution in naming it with a difficult to guess word, somethinig like this url:
    http://www.mydomain.com/hrcodwar/secretdirectorypleasenotaccessoriwillkillyouandyourfamily/0_bases.json
  • $CFG_DIR_ORDENES It is the path of the directory where the web programmed orders are stored. Obviously here we must have the same concern about security as before.
  • $CFG_CLAVE_ROOT It is the general admin password, the one who can enter the Campaign Configuration section here, and change the strategic map passwords both for troops and commanders.
  • $CFG_MAPA It is the name of the background picture of the strategic map, located in the web proyect directory /maps.
  • $CFG_MAPA_COORD_INI_X Battle Area initial "x axis" coordinates. It is the highlighted value in the BattleArea line in the hrcodwar.mis
    for example: BattleArea 200000 180000 130000 90000 2500
  • $CFG_MAPA_COORD_INI_Y Battle Area initial "y axis" coordinates. It is the highlighted value in:
    ej: BattleArea 200000 180000 130000 90000 2500
  • $CFG_MAPA_COORD_FIN_X Battle Area ending "x axis" coordinates, are the sum of CFG_MAPA_COORD_INI_X and the highlighted value in:
    ej: BattleArea 200000 180000 130000 90000 2500
  • $CFG_MAPA_COORD_FIN_Y Battle Area ending "y axis" coordinates, are the sum of CFG_MAPA_COORD_INI_Y and the highlighted value in:
    ej: BattleArea 200000 180000 130000 90000 2500
  • $CFG_MAPA_LONG_SECTOR It is the length of a single sector, as defined in the battle area, set by the value:
    ej: BattleArea 200000 180000 130000 90000 2500
  • $CFG_N_CENTRALES_POR_BANDO Required minimum number of power plants per side. Its value should match with numero_centrales in the conf.ini.
  • $CFG_N_TURNOS_REPARACION_FABRICAS Number of turns needed to rebuild factories and shipyards. Its value should match with reconstruccion_fabricas_jornadas in the conf.ini.
  • $CFG_N_TURNOS_REPARACION_REFINERIAS Number of turns needed to rebuild refineries, value set by reconstruccion_refinerias_jornadas.
  • $CFG_N_TURNOS_REPARACION_CENTRALES Number of turns needed to rebuild power plants, value set by reconstruccion_centrales_jornadas.
  • $CFG_PRECIO_PUNTO_CREACION Reference purchase price of Creation Points according to international markets, value set by mercado_reputacion.
  • $CFG_DISTANCIA_UNIDADES_CERCANAS The visibility in meters of each identity to make recons.

DIRECTORIES AND ACCESS PERMISSIONS

As you have read before, it is very important to name correctly the directories $CFG_DIR_DATOS_BATALLA and $CFG_DIR_ORDENES and its location. It is also a very common mistake in those web installations where external data is received, not to grant permissions for the anonymous user in the place where it is supposed to be stored. The web server (Apache or IIS or whatever) operates as an anonymous user when it runs the script and records the data in the directory. Therefore, you must ensure that the server directories allow writting to all users or the scripts will fail receiving data when the game ends.

THE MAP AND THE BATTLE AREA

As we have explained before, the map shown in the Running Campaign section here must be stored in the directory with the same name /mapas, wich is the same name you saved in $CFG_MAPA in the config.inc.php. The map is The map is closely related to the battle area defined in the hrcodwar.mis.
The lower left corner must match with the battle area coordinates you set in $CFG_MAPA_COORD_INI_X and $CFG_MAPA_COORD_INI_Y, and the upper right corner must match withe $CFG_MAPA_COORD_FIN_X and $CFG_MAPA_COORD_FIN_Y.
Creating the map shown in the running Campaign is very easy. Simply take screenshots of the map in the mission editor of the game (remember to always use the same zoom level!) covering the whole battle area, and merge them all into a single image using your favorite image editor program.
Using high zoom levels will produce accurate maps in your screen, but you will need several screenshots to assemble the puzzle. Using low zoom level will make it difficult to show accurate coordinates in your screen. You will have to decide it depending on the size of the battle area you have chosen.
No matter the zoom level you choose, the really important thing, is that the lower left corner and the upper right corner must match EXACTLY with the coordinates we have explained before, otherwise all the objects in the map as airfields, factories, etc... will be shown in a wrong place.

SYSTEM DATA

There is a directory named /datos_sistema. You must write there the same data you will have in the server computer, in a directory with the same name (missions/hrcodwar/datos_sistema). These are the json configuration files that, along with the conf.ini are used to run the campaign set its rules and conditions. Any change you want to make in a yet running campaign must be written here too, otherwise the web will show wrong information.

PASSWORDS AND PERMISSIONS

Passwords are stored in a .ini file in the $CFG_DIR_DATOS_BATALLA, called claves.ini. If you open it you will find something like this:

; Password to web access
CFG_PASS_ALIADO = 
CFG_PASS_EJE = 
CFG_PASS_ALIADO_COMANDANTE = 
CFG_PASS_EJE_COMANDANTE = 
Variable meaning:
  • $CFG_PASS_ALIADO Universal Allies Troop Password.
  • $CFG_PASS_EJE Universal Axis Troop Password.
  • $CFG_PASS_ALIADO_COMANDANTE The Commander Password defined by every allied squad must begin with their TAG and must be separated by commas so that it is possible to identify them. For example, two squads flying in using tags like SQUAD1 and SQUAD2, should have passwords like this: SQUAD1_password1, SQUAD2_password2
  • $CFG_PASS_EJE_COMANDANTE The same for the Axis.
As you have read before, these passwords are edited from the Campaign Configuration here, using the password stored in $CFG_CLAVE_ROOT in the config.inc.php.

Passwords are stored and sent using plain text format, so they are not very secure. Maybe, in future versions they will be encripted.

COMUNICATIONS WITH THE SERVER

The campaign system communicates with the web twice, first when loading the mission and later when it is over. Let us see what happens in each connection.

  • Starting the battle: The server computer interrogates a web script whether or not exists pending orders from each squad. If any, they will be downloaded and executed one by one, so that when pilots sit in their cockpits the orders have already been executed or are being executed.
  • Ending the battle: When the battle ends with a "battle stop" for any reason, both by the normal cycle of the game or in a manual procedure, the server attempts to communicate with the web page through the same script and sends the results of the battle. The script collects them, deletes any previous data and shows the updated results. Therefore there is no historical data and only the last received items are shown.

To allow communication between the server computer and this web, the following variables must be set:

  • In the web: Open again the file config.inc.php and edit the variable $CFG_CLAVE_ACEPTA_ENVIOS creating a password that shall be checked in every operation.
  • In the HRCodWar server: Open the conf.ini and edit the three variables in the [GENERAL] section. They control this communication:

    web_activa_soporte = true
    web_script_url = http://[ url to the web proyect ]/ajax/services.php?a=datos
    web_script_clave= the same password that the one stored in $CFG_CLAVE_ACEPTA_ENVIOS

And that is all. If a communication failure with the server happened, the game would continue without trouble, simply the pending orders would not be received nor the data would be sent at the end of the game. However, there is a manual way to refresh them.

At the end of the battle, all data to be sent to the web are saved by the campaign in /datos_batalla/web, The web administrator can manually upload them via FTP in his working directory, obtaining the same result. Easy! :)