function setup() { //Grab the user if (isset($_GET['cid'])) { $confirm_id = $_GET['cid']; } else { header("HTTP/1.0 404 Not Found"); exit; } $user = new user(); if ($user->load_from_confirm_id($confirm_id)) { //Grab the postcode and area $this->postcode = $user->postcode; $this->alert_area_size = alert_size_to_meters($user->alert_area_size); //delete the user $user->delete(); } else { header("HTTP/1.0 404 Not Found"); exit; } }
function setup() { //Grab the user if (isset($_GET['cid'])) { $confirm_id = $_GET['cid']; } else { header("HTTP/1.0 404 Not Found"); exit; } $user = new user(); if ($user->load_from_confirm_id($confirm_id)) { //Update the confirmed flag $user->confirmed = true; //delete any other active alerts for this postcode $user->remove_existing(); $user->save(false); //Grab the postcode and area $this->postcode = $user->postcode; $this->alert_area_size = alert_size_to_meters($user->alert_area_size); } else { header("HTTP/1.0 404 Not Found"); exit; } }
function setup_old() { //Grab the postcode and area size from the get string if (!isset($_GET['area_size'])) { //check is_numeric and isn't too big array_push($this->warnings, "No area size specified"); } if (sizeof($this->warnings) == 0) { //Get OS ref from postcode if (isset($_GET['postcode'])) { $xy = postcode_to_location($_GET['postcode']); $this->easting = $xy[0]; $this->northing = $xy[1]; } else { $latlng = new LatLng($_GET['lat'], $_GET['lng']); $xy = $latlng->toOSRef(); $this->easting = $xy->easting; $this->northing = $xy->northing; } $this->area_size = $_GET['area_size']; $this->applications = Applications::query($this->easting, $this->northing, alert_size_to_meters($this->area_size)); } }
function populate_new($email, $postcode, $alert_area_size) { //Set email, postcode and size $this->email = $email; $this->postcode = $postcode; $this->alert_area_size = $alert_area_size; //cleanup postcode $this->postcode = str_replace(" ", "", $this->postcode); $this->postcode = strtolower($this->postcode); //Get xy of the postcode $xy = postcode_to_location($postcode); //if we couldent find the XY, throw an exception if ($xy == false) { //throw new exception("Something bad happened when trying to convert postcode to X 'n Y"); } //Get actual size of zone $area_size_meters = alert_size_to_meters($this->alert_area_size); //Work out bounding box + buffer area (assumes OSGB location == meters) $area_buffered_meters = $area_size_meters + $area_size_meters / 100 * ZONE_BUFFER_PERCENTAGE; $this->bottom_left_x = $xy[0] - $area_buffered_meters / 2; $this->bottom_left_y = $xy[1] - $area_buffered_meters / 2; $this->top_right_x = $xy[0] + $area_buffered_meters / 2; $this->top_right_y = $xy[1] + $area_buffered_meters / 2; //Make a confirmation ID for them (no unique check, ho hum) $this->confirm_id = substr(md5(rand(5, 15) . time()), 0, 20); $this->confirmed = false; //Set last sent date to yesterday $this->last_sent = mysql_date(time() - 24 * 60 * 60); }