<?php $dbconn = mysql_connect('198.71.227.93', 'tanyavdc', 'Lubeto111'); header('Content-Type: application/json'); perform_operation($_POST["operation"]); function perform_operation($op) { if ($op == 'login') { validate_user($_POST["useremail"], $_POST["userpassword"]); } else { if ($op == 'getyaks') { get_yaks($_POST["longitude"], $_POST["latitude"]); } else { if ($op == 'post_yak') { post_yak($_POST["postedyak"], $_POST["latitude"], $_POST["longitude"]); } else { if ($op == 'banned_user') { banned_user($_POST["useremail"]); } else { if ($op == 'add_user') { add_user($_POST["useremail"], $_POST["userpassword"]); } else { if ($op == 'send_email') { send_email($_POST["email"]); } else { if ($op == 'getHot_yaks') { getHot_yaks(); } else { if ($op == 'getCold_yaks') { getCold_yaks(); } else {
case "perform_op": $operation = strtolower($_POST['operation']); $buffer_dist = $_POST['buffer_dist']; $layer2 = null; $layer1 = new Submission_Layer($_POST['layer1']); if ($_POST['layer2'] != "") { $layer2 = new Submission_Layer($_POST['layer2']); } // make sure all backslashes inserted // while transporting the json are // replaced. otherwise, json_decode // will not work. $layer1_attrs = json_decode(str_replace("\\", "", $_POST['l1_attrs']), true); $layer2_attrs = json_decode(str_replace("\\", "", $_POST['l2_attrs']), true); // call method to perform the operation $output = perform_operation($layer1, $layer2, $layer1_attrs, $layer2_attrs, $buffer_dist, $operation); // extract the results as a shapefile $zipfile = ""; if ($output != null) { $zipfile = export_to_shapefile($output, $output); } // note that the output name is saved // as a session variable so that when // the user wishes to download the // resultant file, the name of the file // is checked. this prevents the user // from supplying any file path and // arbitrarily downloading a file $_SESSION['output_file'] = $zipfile; // drop the table that was created drop_table($output);