break; } } elseif (isset($_POST['savedata'])) { //Submit Step 3.. if (isset($_POST['goback'])) { $step = 2; } else { //preserve the upload id if ($uploadmanager->validUploadId($_POST['upload_id'])) { $smarty->assign('upload_id', $_POST['upload_id']); $uploadmanager->setUploadId($_POST['upload_id']); } $ok = true; //preserve the meta info $smarty->reassignPostedDate('imagetaken'); if ($smarty->get_template_vars('imagetaken') == '0000-00-00') { $ok = false; $error['imagetaken'] = "Please specify a date for when the photo was taken (even approximate)"; } elseif (datetimeToTimestamp($smarty->get_template_vars('imagetaken')) > datetimeToTimestamp(date("Y-m-d"))) { $ok = false; $error['imagetaken'] = "Time machines are not allowed on Planet Geograph"; } if (($_POST['imageclass'] == 'Other' || empty($_POST['imageclass'])) && !empty($_POST['imageclassother'])) { $imageclass = stripslashes($_POST['imageclassother']); } else { if ($_POST['imageclass'] != 'Other') { $imageclass = stripslashes($_POST['imageclass']); } } if (strlen($imageclass) == 0) { $ok = false;
//so get a new one... $square->_getDB(); } //find a possible place within 25km $smarty->assign('place', $square->findNearestPlace(25000)); if (!empty($_REQUEST['grid_reference'])) { $token = new Token(); $token->setValue("g", !empty($_REQUEST['grid_reference']) ? $_REQUEST['grid_reference'] : $square->grid_reference); $token->setValue("p", $_REQUEST['photographer_gridref']); $token->setValue("v", $_REQUEST['view_direction']); $smarty->assign('reopenmaptoken', $token->getToken()); $smarty->assign_by_ref('square', $square); } if ($_REQUEST['imagetaken'] && $_REQUEST['imagetaken'] != '0000-00-00') { $smarty->assign('imagetaken', stripslashes($_REQUEST['imagetaken'])); } elseif ($smarty->get_template_vars('imagetaken')) { //already set } elseif (isset($uploadmanager->exifdate)) { $smarty->assign('imagetaken', $uploadmanager->exifdate); //$smarty->assign('imagetakenmessage', ' ('.$uploadmanager->exifdate.' stated in exif header)'); } else { $smarty->assign('imagetaken', '--'); } if (isset($_SESSION['last_imagetaken'])) { $smarty->assign('last_imagetaken', $_SESSION['last_imagetaken']); } $smarty->assign('today_imagetaken', date("Y-m-d")); } //which step to display? $smarty->assign('step', $step); if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if (count($prefix)) { $x = $prefix['origin_x'] + $eastings; $y = $prefix['origin_y'] + $northings; $sql = "insert into gridsquare(x,y,percent_land,grid_reference,reference_index,point_xy) \n\t\t\t\t\t\tvalues({$x},{$y},-1,'{$gridref}',{$prefix['reference_index']},GeomFromText('POINT({$x} {$y})') )"; $db->Execute($sql); $gridsquare_id = $db->Insert_ID(); $smarty->assign('status', "New gridsquare {$gridref} created with new land percentage of {$percent} %"); $db->Execute("REPLACE INTO mapfix_log SET user_id = {$USER->user_id}, gridsquare_id = {$gridsquare_id}, new_percent_land='{$percent}', old_percent_land='{$sq['percent_land']}',created=now(),comment=" . $db->Quote($_GET['comment'])); require_once 'geograph/mapmosaic.class.php'; $mosaic = new GeographMapMosaic(); $mosaic->expirePosition($x, $y, 0, true); } } $smarty->assign('percent_land', $percent); } } else { $smarty->assign_by_ref('gridref', strip_tags($_GET['gridref'])); $smarty->assign('gridref_error', "Bad grid reference"); } $smarty->assign('gridref_ok', $ok ? 1 : 0); } if ($_GET['save'] == 'quick') { //return nice simple result $status = $smarty->get_template_vars('status'); echo "Status: {$status}"; } else { $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $unknowns = $db->GetAll("select gridsquare_id,grid_reference,imagecount,\n\t\tgroup_concat(comment order by mapfix_log_id SEPARATOR ' | ') as comments,\n\t\tgroup_concat(concat(old_percent_land,'>',new_percent_land) order by mapfix_log_id SEPARATOR ', ') as percents\t\t\n\tfrom gridsquare \n\t\tleft join mapfix_log using (gridsquare_id)\n\twhere percent_land=-1 \n\tgroup by gridsquare_id\n\torder by reference_index asc,imagecount desc"); $smarty->assign_by_ref('unknowns', $unknowns); $smarty->display('admin_mapfixer.tpl'); }