$PAGE->set_url($url); // Override wanted URL, we do not want to end up here again if user clicks "Login" $SESSION->wantsurl = $home; // Prevent registering when already logged in if (isloggedin()) { echo $OUTPUT->header(); echo $OUTPUT->box_start(); $logout = new single_button(new moodle_url($CFG->httpswwwroot . '/local/obu_application/logout.php', array('sesskey' => sesskey(), 'loginpage' => 1)), get_string('logout'), 'post'); $continue = new single_button($home, get_string('cancel'), 'get'); echo $OUTPUT->confirm(get_string('cannotsignup', 'error', fullname($USER)), $logout, $continue); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; } include './signup_form.php'; $counties = get_counties(); $parameters = ['counties' => $counties]; $mform = new registration_form(null, $parameters); if ($mform->is_cancelled()) { redirect($login); } else { if ($user = $mform->get_data()) { if (strpos($user->email, '@brookes.ac.uk') !== false) { $message = get_string('preregistered', 'local_obu_application'); } else { $message = ''; $user->confirmed = 0; $user->lang = current_language(); $user->firstaccess = time(); $user->timecreated = time(); $user->mnethostid = $CFG->mnet_localhost_id;
<?php include 'get_connection.php'; //the following code goes into the db and retrieves all of the counties in the state //this will be used in the register page try { if (PHP_SAPI === 'cli') { $state = $argv[1]; } else { $state = $_GET['state']; } get_counties($conn, $state); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); return; } $conn = null; function get_counties($conn, $state) { $state = strtolower($state); $stmt = "SELECT counties.name, counties.id FROM counties JOIN states ON counties.state_id = states.id WHERE states.name = :state"; $sth = $conn->prepare($stmt); $sth->bindparam(':state', $state); $sth->execute(); $result = $sth->fetchAll(); $length = count($result); for ($i = 0; $i < $length; $i++) { $county = $result[$i][0]; $county_id = $result[$i][1]; $county = str_replace("_", " ", $county); $county = ucwords($county);
$max_records = 10; // only used for testing if ($run_environment == 'dev') { error_reporting(E_ALL); ini_set('display_errors', 'On'); require 'scraperwiki.php'; } require 'scraperwiki/simple_html_dom.php'; // $states = array("AL","AK","AZ","AR","CA","CO","CT","DC","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MO"); // these ones finished // array("GU", "PR", "MP"); // it choked on these, so I'm removing them $states = array("MS", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"); $county_directory_url = "http://www.uscounties.org/cffiles_web/counties/"; foreach ($states as $state) { global $county_directory_url; $url = $county_directory_url . 'state.cfm?statecode=' . $state; $counties = get_counties($url); foreach ($counties as $county) { $alldata[] = get_county_data($state, $county['county_name'], $county['county_data_url']); } if ($run_environment == 'prod') { sleep(10); // this is required on scraperwiki.com } } // if testing if ($run_environment == 'dev') { header('Content-type: application/json'); print json_encode($alldata); } function get_counties($url) {