} if (!$smarty->is_cached($template, $cacheid)) { $db = NewADOConnection($GLOBALS['DSN']); $table = array(); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $images = $db->getAll("\n\tSELECT\n\t\tgridimage_id\n\tFROM\n\t\tgridimage \n\tWHERE\n\t\tuser_id = {$u}\n\tAND \n\t\tmoderation_status in ('geograph','accepted')\n\tAND\n\t\tviewpoint_eastings > 0 AND viewpoint_northings > 0\n\tAND\n\t\tviewpoint_eastings != nateastings AND viewpoint_northings != natnorthings\n\tLIMIT\n\t\t100\n\t"); foreach ($images as $i => $row) { $image = new GridImage(); $image->LoadFromId($row['gridimage_id']); $image->compact(); $line = array(); $line['Square'] = $image->grid_reference; $line['Title'] = "<a href=\"/photo/{$row['gridimage_id']}\">{$image->title}</a>"; $submore4 = $image->grid_square->nateastings > 0; $line['Photographer'] = $image->getPhotographerGridref(); $line['Subject'] = $image->getSubjectGridref(); $promore4 = $image->photographer_gridref_precision < 1000; //mimic the behaviour doen by getNatEastings to place the location in the center of the 1km square if (!$promore4) { $image->viewpoint_eastings += 500; $image->viewpoint_northings += 500; } $dist = sqrt(pow($image->grid_square->nateastings - $image->viewpoint_eastings, 2) + pow($image->grid_square->natnorthings - $image->viewpoint_northings, 2)); $line['Distance'] = sprintf("%0.3f", $dist / 1000); #$line['promore4'] = $promore4; #$line['submore4'] = $submore4; $angle = rad2deg(atan2($image->grid_square->nateastings - $image->viewpoint_eastings, $image->grid_square->natnorthings - $image->viewpoint_northings)); if ($angle < 0) { $angle += 360; } $jump = 360 / 16;
$isadmin = !$isowner && $USER->hasPerm('ticketmod') ? 1 : 0; if ($image->isValid()) { if ($image->moderation_status == 'rejected') { if ($isowner || $isadmin) { //ok, we'll let it lie... } else { header("Location: /photo/{$_REQUEST['id']}"); exit; } } if (isset($_GET['unlock'])) { $image->unlockThisImage($USER->user_id); die(1); } //get the grid references $image->getSubjectGridref(); $image->getPhotographerGridref(); //save these so can be used as title etc on the main image (when following link from search results, and redoing changes etc) $vars = get_object_vars($image); foreach ($vars as $name => $val) { if ($name != "db") { $image->{"current_{$name}"} = $image->{$name}; } } //do our thing! $smarty->assign('page_title', $image->grid_reference); $smarty->assign_by_ref('image', $image); $smarty->assign_by_ref('isowner', $isowner); $smarty->assign_by_ref('isadmin', $isadmin); if (!empty($_GET['thankyou'])) { $smarty->assign('thankyou', $_GET['thankyou']);