}
    if (isset($data['SelectedCity']['id_city']) && isset($data['SelectedCountry']['id_country'])) {
        $tidCity = $data['SelectedCity']['id_city'];
    } else {
        $tidCity = 'NULL';
    }
    $tInvite = $data['invite'];
    $sql = "UPDATE invites SET STATUS =  '1', date_status_ = CURDATE( ) WHERE invite =  {$tInvite} AND status = '0';";
    $res = $mysqli->query($sql);
    $sql = "INSERT INTO users values (NULL, '{$tLogin}', '{$tPassword}', '{$tPhone}', {$tidCity} , '{$tInvite}');";
    $res = $mysqli->query($sql);
    // file_put_contents('log_POST.log',$data['SelectedCity']['id_city'].'----'.json_encode($data), FILE_APPEND);
    file_put_contents('log_POST.log', '======== ' . $sql, FILE_APPEND);
}
if (file_exists('log_POST.log')) {
    unlink('log_POST.log');
}
//Getting JSON request
$answer = json_decode(file_get_contents('php://input'), true);
if (isset($answer['get']) && $answer['get'] != '') {
    // echo json_encode($answer);
    if (getInvite($mysqli, $answer['get'])) {
        if (isset($answer['post']) && $answer['post'] != '') {
            // echo json_encode($answer);
            addUser($mysqli, $answer['post']);
        }
    }
}
if ($mysqli) {
    $mysqli->close();
}
Beispiel #2
0
<?php

require_once 'common.php';
$token = $db->escape_string($_GET['token']);
$email = $db->escape_string($_GET['email']);
logRequest('invite', 'token: ' . $token . '; email: ' . $email);
$invite = getInvite($token);
if ($invite && $invite['freeInvites'] > 0) {
    $newToken = generateToken();
    $sql = "INSERT INTO garage_invites SET token = '{$newToken}', email = '{$email}', referredBy = '{$token}'";
    if (!good_query($sql)) {
        $error = $db->error;
        // Check if error is only due to duplicate email (person already invited)
        if (stripos($error, "Duplicate") !== FALSE && stripos($error, "'email'") !== FALSE) {
            $newToken = good_query_value("SELECT token FROM garage_invites WHERE email = '{$email}'");
            // If the person was already invited, invite him again using his old token
            if (empty($newToken)) {
                respond(json_encode(array('status' => 'error', 'message' => "Invitation wasn't found")));
            }
        } else {
            // There is a minor chance that the token would already exist
            respond(json_encode(array('status' => 'error', 'message' => 'Invitation didn\'t go through. Please try again.')));
        }
    } else {
        good_query("UPDATE garage_invites SET freeInvites = (freeInvites - 1) WHERE token = '{$token}'");
    }
    $name = $invite['name'];
    $link = 'http://elisaxslush.com/garage/?t=' . $newToken;
    $message .= "Hi!\n\n" . $name . " just registered for Elisa Garage Chillax and invites you to join the fun, too.\n\n**Elisa Garage Chillax takes place on the first day of Slush, November 18th at 6-9pm**, in our garage (Ratavartijankatu 5, Helsinki), just a 5-minute walk from the Slush venue.\n\nOur garage space is huge but has a guest limit! So sign up with your personal link right now: " . $link . " .\n\nThe program includes free food & drinks, music, dev comps, playing with facial recognition, and relaxing in big couches.\n\nFor the Slush participants, the night will continue at the official Slush after party in Messukeskus.\n\nWe look forward to having you here,\n\nHilla & Albert\nTeam behind Elisa X Slush\n\n\n--\nwww.elisa.com\nYou received this message because somebody sent an invite to your email.\n[" . date('Y-m-d G:i:s') . "]\n";
    //  $message = str_replace("\n", "\r\n", $message);
    $header = "From: Elisa X Slush <*****@*****.**>\r\n";