<commit_before><?php
    
    require "../twilio-php-master/Services/Twilio.php";
        
    // ----------------------TWILIO------------------------------------
    
 
    // Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
    $AccountSid = "<KEY>";
    $AuthToken = "2f622c44c25755edc76f6da736feba45";
 
    // Step 3: instantiate a new Twilio Rest Client
    $client = new Services_Twilio($AccountSid, $AuthToken);



    if(empty($_POST['name'])  || 
       empty($_POST['phone']))
    {
        $errors .= "\n Error: all fields are required";
    }

    $name = $_POST['name']; 
    $phone = $_POST['phone']; 
 
    // Step 4: make an array of people we know, to send them a message. 
    // Feel free to change/add your own phone number and name here.
    $people = array(
        $phone => $name,
    );
 
    // Step 5: Loop over all our friends. $number is a phone number above, and 
    // $name is the name next to it
    foreach ($people as $number => $name) {
 
        $sms = $client->account->messages->sendMessage(
 
        // Step 6: Change the 'From' number below to be a valid Twilio number 
        // that you've purchased, or the (deprecated) Sandbox number
            "289-796-0748", 
 
            // the number we are sending to - Any phone number
            $number,
 
            // the sms body
            "Hey $name, Welcome to Spotter."
        );
        // Display a confirmation message on the screen
        $link_address = "index.html";
        echo "Sent message to $name";
        echo "<br><br>";
        echo "<a href='".$link_address."'>Back to Spotter</a>";
    }
        
        
    // ----------------------DATABASE------------------------------------
    $servername = "server36.000webhost.com";
    $username = "a2117997_FF";
    $password = "<PASSWORD>";
    $dbname = "a2117997_SDB";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    function convAddr($addr) {
        $curl = curl_init();
        // Set some options - we are passing in a useragent too here
        curl_setopt_array($curl, array(
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_URL => 'https://maps.googleapis.com/maps/api/geocode/json?address='+ $addr+'&region=ca&key=<KEY>',
            CURLOPT_USERAGENT => 'Codular Sample cURL Request'
        ));
        // Send the request & save response to $resp
        $resp = curl_exec($curl);
        // Close request to clear up some resources
        curl_close($curl);
        $obj = json_decode($resp);
        
        // https://developers.google.com/maps/documentation/geocoding/intro
        // Region Basing section
        $long = $obj['results']['location']['lng'];
        $lat = $obj['results']['location']['lat'];
        
        return array ($long, $lat);
    }
        
    $sql = 'INSERT INTO Spotter (SID, Longitude, Latitude)
    VALUES ($_GET["phone"], $long, $lat)';
        
    if ($conn->query($sql) === TRUE) {
        echo "Spotter added successfully!";
    } else {
        echo "Error adding spotter: " . $conn->error;
    }
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html><commit_msg>Database not working<commit_after><?php
    
    require "../twilio-php-master/Services/Twilio.php";
        
    // ----------------------TWILIO------------------------------------
    
 
    // Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
    $AccountSid = "<KEY>";
    $AuthToken = "2f622c44c25755edc76f6da736feba45";
 
    // Step 3: instantiate a new Twilio Rest Client
    $client = new Services_Twilio($AccountSid, $AuthToken);



    if(empty($_POST['name'])  || 
       empty($_POST['phone']))
    {
        $errors .= "\n Error: all fields are required";
    }

    $name = $_POST['name']; 
    $phone = $_POST['phone']; 
 
    // Step 4: make an array of people we know, to send them a message. 
    // Feel free to change/add your own phone number and name here.
    $people = array(
        $phone => $name,
    );
 
    // Step 5: Loop over all our friends. $number is a phone number above, and 
    // $name is the name next to it
    foreach ($people as $number => $name) {
 
        $sms = $client->account->messages->sendMessage(
 
        // Step 6: Change the 'From' number below to be a valid Twilio number 
        // that you've purchased, or the (deprecated) Sandbox number
            "289-796-0748", 
 
            // the number we are sending to - Any phone number
            $number,
 
            // the sms body
            "Hey $name, Welcome to Spotter."
        );
        // Display a confirmation message on the screen
        echo "Sent message to $name.";
        echo "<br><br>";
        echo "<a href='../index.html'>Back to Spotter</a>";
    }
        
        
    // ----------------------DATABASE------------------------------------
    $servername = "server36.000webhost.com";
    $username = "a2117997_FF";
    $password = "<PASSWORD>";
    $dbname = "a2117997_SDB";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $addr = $_POST['address'];
        
    //function convAddr($addr) {
        
    $curl = curl_init();
    // Set some options - we are passing in a useragent too here
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'https://maps.googleapis.com/maps/api/geocode/json?address='+ $addr+'&region=ca&key=<KEY>',
        CURLOPT_USERAGENT => 'Codular Sample cURL Request'
    ));
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    // Close request to clear up some resources
    curl_close($curl);
    $obj = json_decode($resp);

    // https://developers.google.com/maps/documentation/geocoding/intro
    // Region Basing section
    $long = $obj['results']['location']['lng'];
    $lat = $obj['results']['location']['lat'];

    return array ($long, $lat);
    //}
        
    $sql = 'INSERT INTO Spotter (SID, Longitude, Latitude)
    VALUES ($_GET["phone"], $long, $lat)';
        
    if ($conn->query($sql) === TRUE) {
        echo "Spotter added successfully!";
    } else {
        echo "Error adding spotter: " . $conn->error;
    }
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
{'fraction_non_alphanumeric': 0.17537537537537537, 'fraction_numerical': 0.018018018018018018, 'mean_word_length': 1.9657168299198575, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 47, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '481923', 'n_tokens_mistral': 2133, 'n_tokens_neox': 1967, 'n_words': 551}