view flag.php @ 71:218a58bb2f34

Cleanup
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Thu, 11 Oct 2012 23:46:32 +0200
parents dd4ddedca4c5
children fae4322d6c29
line wrap: on
line source

<?php
/**
 * @file
 * Displays a flag, in an active or disabled state, depending on parameters
 */
define(DEBUG,0);

include_once 'CacheTimeCheck.inc';

$scriptCache = ScriptIncludeCache::instance(__FILE__);
$scriptCache->includeOnce('Language.inc');
$scriptCache->includeOnce('common-functions.inc');

$active = $_GET['active'];
$lang = $_GET['lang'];

if(!$lang) {
  $lang = "no";
  $langs = Language::accepted();
  foreach ($langs as $l => $val) {
    if (file_exists($l)) {
      $lang = $l;
      break;
    }
  }
}

$name = "../img/flag-${lang}";
if ($active)
  $name .= "-active";
$name .= ".png";

$cache = new CacheTimeCheck($name);
$cache->addParent($scriptCache);
$cache->cache_time($name);
$cache->CheckHttpModified();

$flag = loadFile($name);

if (floatval($flag) < 0) {
  errorPage('Resource not found', 404);
}
else {
  header("Content-Type: image/png");
  print $flag;
}