Mercurial > SimpleWebPresenter
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 75:5e76b6feb2ad | 76:fae4322d6c29 |
|---|---|
| 6 define(DEBUG,0); | 6 define(DEBUG,0); |
| 7 | 7 |
| 8 include_once 'CacheTimeCheck.inc'; | 8 include_once 'CacheTimeCheck.inc'; |
| 9 | 9 |
| 10 $scriptCache = ScriptIncludeCache::instance(__FILE__); | 10 $scriptCache = ScriptIncludeCache::instance(__FILE__); |
| 11 $scriptCache->includeOnce('Language.inc'); | 11 $scriptCache->includeOnce('Flag.inc'); |
| 12 $scriptCache->includeOnce('common-functions.inc'); | |
| 13 | 12 |
| 14 $active = $_GET['active']; | 13 $flag = new Flag($scriptCache); |
| 15 $lang = $_GET['lang']; | 14 print $flag->getPage(); |
| 16 | |
| 17 if(!$lang) { | |
| 18 $lang = "no"; | |
| 19 $langs = Language::accepted(); | |
| 20 foreach ($langs as $l => $val) { | |
| 21 if (file_exists($l)) { | |
| 22 $lang = $l; | |
| 23 break; | |
| 24 } | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 $name = "../img/flag-${lang}"; | |
| 29 if ($active) | |
| 30 $name .= "-active"; | |
| 31 $name .= ".png"; | |
| 32 | |
| 33 $cache = new CacheTimeCheck($name); | |
| 34 $cache->addParent($scriptCache); | |
| 35 $cache->cache_time($name); | |
| 36 $cache->CheckHttpModified(); | |
| 37 | |
| 38 $flag = loadFile($name); | |
| 39 | |
| 40 if (floatval($flag) < 0) { | |
| 41 errorPage('Resource not found', 404); | |
| 42 } | |
| 43 else { | |
| 44 header("Content-Type: image/png"); | |
| 45 print $flag; | |
| 46 } |
