*   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include_once $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($TRP_id, $DataEntryAccess);
/* create a new profile for a person.  get their block group and save it according to their address. */
include $_SERVER['DOCUMENT_ROOT'] . "/include/block_group_finder.php";
$this_address = $_POST['address_num'] . " " . $_POST['address_dir'] . " " . $_POST['address_name'] . " " . $_POST['address_type'] . " " . $_POST['city'] . " " . $_POST['state'] . " " . $_POST['zip'];
// We don't have to SQL-sanitize the inputs to do_it_all() because
// it's just calling the Google Maps geocoder and returning us the
// result.  If there's a problem with the inputs, that's Google's
// problem, not ours (from a security point of view, at least).
$block_group_sqlsafe = do_it_all($this_address, $map);
include "../include/dbconnopen.php";
if ($_POST['action'] == 'new' && $_POST['subject'] == 'la_casa') {
    $reformat_date = explode('/', $_POST['dob_add']);
    $dob_format = $reformat_date[2] . '-' . $reformat_date[0] . '-' . $reformat_date[1];
    include "../include/dbconnopen.php";
    $create_new_participant_lc = "INSERT INTO Participants (\n               First_Name,\n               Last_Name,\n               Address_City,\n               Address_State,\n               Address_Zipcode,\n               Phone,\n               Email,\n               Mobile_Phone,\n               Email_2,\n               Gender,\n               DOB,\n               Race) VALUES\n               (\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['first_add']) . "', \n               '" . mysqli_real_escape_string($cnnTRP, $_POST['last_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['city_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['state_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['zip_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['phone_add']) . "', \n               '" . mysqli_real_escape_string($cnnTRP, $_POST['email1']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['mobile_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['email2_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['gender_add']) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $dob_format) . "',\n               '" . mysqli_real_escape_string($cnnTRP, $_POST['race_add']) . "')";
    mysqli_query($cnnTRP, $create_new_participant_lc);
    $new_id = mysqli_insert_id($cnnTRP);
    //returns the new participant ID
    $connect_to_program = "INSERT INTO Participants_Programs (Participant_ID," . "Program_ID) VALUES ('" . $new_id . "', '" . $_POST['program'] . "')";
    mysqli_query($cnnTRP, $connect_to_program);
    //insert new college, if one created
    if ($_POST['college_name'] != '') {
        $insert_new_college = "INSERT INTO Colleges (College_Name, College_Type) VALUES ('" . mysqli_real_escape_string($cnnTRP, $_POST['college_name']) . "', '" . mysqli_real_escape_string($cnnTRP, $_POST['college_type']) . "')";
        mysqli_query($cnnTRP, $insert_new_college);
Example #2
0
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/dbconnopen.php";
include $_SERVER['DOCUMENT_ROOT'] . "/core/include/setup_user.php";
user_enforce_has_access($Enlace_id, $DataEntryAccess);
/*add new event, either to a campaign or to the Little Village-wide events*/
include $_SERVER['DOCUMENT_ROOT'] . "/include/block_group_finder.php";
/*find the block group for the entered address */
$this_address = $_POST['address_num'] . " " . $_POST['address_dir'] . " " . $_POST['address_street'] . " " . $_POST['address_suffix'] . " Chicago IL";
$block_group = do_it_all($this_address, $map);
echo $block_group;
include "../include/dbconnopen.php";
$event_name_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['event_name']);
$campaign_id_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['campaign_id']);
$date_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['date']);
$address_num_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_num']);
$address_dir_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_dir']);
$address_street_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_street']);
$address_suffix_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['address_suffix']);
$event_type_sqlsafe = mysqli_real_escape_string($cnnEnlace, $_POST['event_type']);
$new_event = "INSERT INTO Campaigns_Events (Event_Name, Campaign_ID, Event_Date,\r\n    Address_Num, Address_Dir, Address_Street, Address_Suffix, Block_Group, Type)\r\n        VALUES ('" . $event_name_sqlsafe . "',\r\n            '" . $campaign_id_sqlsafe . "',\r\n                '" . $date_sqlsafe . "',\r\n            '" . $address_num_sqlsafe . "',\r\n            '" . $address_dir_sqlsafe . "',    \r\n            '" . $address_street_sqlsafe . "',    \r\n            '" . $address_suffix_sqlsafe . "',\r\n                '{$block_group}',\r\n            '" . $event_type_sqlsafe . "')";
mysqli_query($cnnEnlace, $new_event);
include "../include/dbconnclose.php";
            $get_url = 'http://data.fcc.gov/api/block/find?format=json&latitude=' . $lat . '&longitude=' . $lon . '&showall=true';
            //echo $get_url;
            $handle = fopen($get_url, "r");
            if ($handle) {
                while (!feof($handle)) {
                    $buffer = fgets($handle, 4096);
                    $api_result .= $buffer;
                }
                fclose($handle);
            } else {
                echo "Nothing to open";
            }
            /*decode results from this API now: */
            $result_array = json_decode($api_result, true);
            /*return block group*/
            return $result_array[Block][FIPS];
        } else {
            return false;
        }
    } else {
        return false;
    }
}
//test call
echo do_it_all("0", $map);
?>