Welcome to Islandnet.com  
Locally owned and operated since 1993  
Live Help
LOG IN:  Username:    Password:    

Web Gadget: inFlag


inFlag is a gadget that displays an image of a country's flag in the size you request.


Current Version

2009-05-25 16:04:04 NEW

Download it now

Note that you can check the version of a web gadget by loading it directly in your browser with the "version" keyword. For example, loading "inflag.php?version" will display the current version and tell you if there is a newer version available.


Installation

To install this web gadget, place a copy of inflag.php in your web space. You can change the name to anything you'd like, as long as it ends with ".php". Note that this is an encoded and encrypted PHP file. It will look like gibberish to you, but the web server will know what to do with it. If you make any changes to this file it will cease to function, so be careful to upload it to your site in BINARY mode.


Configuration

When this web gadget runs it will expect to find a configuration file to load settings from. The filename depends on the name that you gave to the web gadget itself. If you named it "inflag.php" then the configuration file must be named "flag_config.php" (that's an underscore in the middle). If you named it "fl.php" then the configuration file must be named "fl_config.php", and so on.

The configuration file is a PHP script that contains a list of values in the "CONFIG" array. It will look something like this (but normally with many more settings):

<?php
   $CONFIG['Size'] = 100;
   $CONFIG['Border'] = 1;
?>

Please note that this is a PHP file, and as such it must start with the <?php tag and end with the ?> tag and there must be nothing else before or after these tags and each setting must be terminated with a semicolon. String values need to be enclosed in quotes, numeric values do not need quotes. Putting any other PHP code in this file may cause the web gadget to function incorrectly.

Configuration Settings

$CONFIG['Size']
This controls the size of the generated flag image. Either the height or the width (or both) of the flag will be this long (in pixels).

$CONFIG['CacheDirectory']
This is the name of a directory where the web gadget can save copies of the generated flags, which speeds things up significantly. The gadget is smart enough to know when an image has been updated, though, and a new flag will be generated. This value must be set to a directory that exists and is writable, otherwise the web gadget will not run.

$CONFIG['CacheTime']
This controls how long cached flags are kept. It can be 0 (zero) to keep them forever, but usually you would use something like "3 days" or "1 month" to keep your cache directory from growing indefinitely.


Usage:

To display a specific country's flag you must know the country's ISO code. You can use either the 2 character code, the 3 character code, or the numeric code. For example, Canada's ISO codes are CA, CAN, and 124. To display Canada's flag you can use any of the following:

<img src="inflag.php?a2=ca">
<img src="inflag.php?a3=can">
<img src="inflag.php?n=124">

Alternatively you can provide a hostname or IP address, and the country code will be deduced. For example:

<img src="inflag.php?host=aol.com">

If you don't specify a country code or a hostname/IP then it will choose a country code based on the IP address of the browser that is viewing the page. For example, your country's flag is:

<img src="inflag.php">


Example:

To view the configuration file used in this example, click here.