caching = 2; // lifetime is per cache //initialise mosaic $mosaic=new GeographMapMosaic; $overview=new GeographMapMosaic('overview'); if (isset($_GET['o'])) $overview->setToken($_GET['o']); if (isset($_GET['t'])) { $ok = $mosaic->setToken($_GET['t']); if (!$ok) die("Invalid Token"); } else { die("Missing Token"); } if ($mosaic->pixels_per_km == 80) { $smarty->cache_lifetime = 3600*24*7; //7 day cache } elseif ($mosaic->mosaic_factor == 4) { } else { die("Invalid Parameter"); } //get token, we'll use it as a cache id $token=$mosaic->getToken(); //regenerate html? $cacheid='maplarge|'.$token; //regenerate? if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad(); //assign overview to smarty if ($mosaic->type_or_user > 0) { $overview->type_or_user = $mosaic->type_or_user; $profile=new GeographUser($mosaic->type_or_user); $smarty->assign('realname', $profile->realname); $smarty->assign('user_id', $mosaic->type_or_user); } if ($mosaic->pixels_per_km >= 40) { //largeoverview $overview->setScale(1); list ($x,$y) = $mosaic->getCentre(); $overview->setCentre($x,$y); //does call setAlignedOrigin } $overview->assignToSmarty($smarty, 'overview'); $smarty->assign('marker', $overview->getBoundingBox($mosaic)); //assign main map to smarty $mosaic->assignToSmarty($smarty, 'mosaic'); //assign all the other useful stuff $gridref = $mosaic->getGridRef(-1,-1); $smarty->assign('gridref', $gridref); $smarty->assign('mapwidth', round($mosaic->image_w /$mosaic->pixels_per_km ) ); preg_match("/([A-Z]+\d)5(\d)5$/",$gridref,$matches); $smarty->assign('gridref2',$matches[1].$matches[2] ); if ($mosaic->pixels_per_km >= 40) { $left=$mosaic->map_x; $bottom=$mosaic->map_y; $right=$left + floor($mosaic->image_w/$mosaic->pixels_per_km)-1; $top=$bottom + floor($mosaic->image_h/$mosaic->pixels_per_km)-1; $rectangle = "'POLYGON(($left $bottom,$right $bottom,$right $top,$left $top,$left $bottom))'"; $sql="SELECT user_id,credit_realname,realname, COUNT(*) AS count, DATE_FORMAT(MAX(submitted),'%D %b %Y') as last_date, count(distinct imagetaken) as days, count(distinct imageclass) as categories FROM gridimage_search WHERE CONTAINS(GeomFromText($rectangle),point_xy) AND moderation_status = 'geograph' AND ftf = 1 GROUP BY user_id,realname ORDER BY count DESC,last_date DESC "; $db=NewADOConnection($GLOBALS['DSN']); if (!$db) die('Database connection failed'); $users=&$db->GetAll($sql); $smarty->assign_by_ref('users', $users); } } $smarty->display($template, $cacheid); ?>