diff flag.php @ 76:fae4322d6c29

Refactored Flag into a separate class.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Fri, 12 Oct 2012 01:54:51 +0200
parents dd4ddedca4c5
children 9d766788f0bc 7c68015b211a
line wrap: on
line diff
--- a/flag.php	Fri Oct 12 01:19:23 2012 +0200
+++ b/flag.php	Fri Oct 12 01:54:51 2012 +0200
@@ -8,39 +8,7 @@
 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;
-    }
-  }
-}
+$scriptCache->includeOnce('Flag.inc');
 
-$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;
-}
\ No newline at end of file
+$flag = new Flag($scriptCache);
+print $flag->getPage();
\ No newline at end of file