function ea_email_sent_shortcode() { ob_start(); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Reading from superglobals $tCallerSkypeNameSg = esc_sql($_POST["skype_name"]); // ..verifying that the skype name exists if (verifyUserNameExists($tCallerSkypeNameSg) === false) { echo "<h3><i><b>Incorrect Skype name</b> - email not sent. Please go back and try again.</i></h3>"; exit; } $tLengthNr = $_POST["length"]; if (is_numeric($tLengthNr) === false) { handleError("Length variable was not numeric - possible SQL injection attempt"); } // Setting up variables based on the superglobals $tCallerIdNr = getIdByUserName($tCallerSkypeNameSg); $tUniqueDbIdentifierSg = uniqid("id-", true); // http://php.net/manual/en/function.uniqid.php $tCallerDisplayNameSg = getDisplayNameById($tCallerIdNr); $tCallerEmailSg = getEmailById($tCallerIdNr); $tEmpathizerDisplayNameSg = getDisplayNameById(get_current_user_id()); // If this is the first call: reduce the donation amount. $tAdjustedLengthNr = $tLengthNr; if (isFirstCall($tCallerIdNr) == true) { $tAdjustedLengthNr = $tAdjustedLengthNr - Constants::initial_call_minute_reduction; } $tRecDonationNr = (int) round(get_donation_multiplier() * $tAdjustedLengthNr); // Create the contents of the email message. $tMessageSg = "Hi " . $tCallerDisplayNameSg . ",\n\nThank you so much for your recent empathy call! Congratulations on contributing to a more empathic world. :)\n\nYou talked with: {$tEmpathizerDisplayNameSg}\nYour Skype session duration was: {$tLengthNr} minutes\nYour recommended contribution is: \${$tRecDonationNr}\n\nPlease follow this link to complete payment within 24 hours: " . getBaseUrl() . pages::donation_form . "?recamount={$tRecDonationNr}&dbToken={$tUniqueDbIdentifierSg}\n\nSee you next time!\n\nThe Empathy Team\n\nPS\nIf you have any feedback please feel free to reply to this email and tell us your ideas or just your experience!\n"; // If the donation is greater than 0: send an email to the caller. if ($tRecDonationNr > 0) { ea_send_email($tCallerEmailSg, "Empathy App Payment", $tMessageSg); echo "<h3>Email successfully sent to caller.</h3>"; } else { echo "<h4>No email sent: first time caller and call length was five minutes or less.</h4>"; } // Add a new row to the db CallRecords table. db_insert(array(DatabaseAttributes::date_and_time => current_time('mysql', 1), DatabaseAttributes::recommended_donation => $tRecDonationNr, DatabaseAttributes::call_length => $tLengthNr, DatabaseAttributes::database_token => $tUniqueDbIdentifierSg, DatabaseAttributes::caller_id => $tCallerIdNr, DatabaseAttributes::empathizer_id => get_current_user_id())); $ob_content = ob_get_contents(); //+++++++++++++++++++++++++++++++++++++++++ ob_end_clean(); return $ob_content; }
function getCallerEmailByDbToken($iDbTokenSg) { global $wpdb; $tTableNameSg = getCallRecordTableName(); $tDbTokenColNameSg = DatabaseAttributes::database_token; $tCallerColumnSg = DatabaseAttributes::caller_id; $tQuerySg = "SELECT {$tCallerColumnSg} FROM {$tTableNameSg} WHERE {$tDbTokenColNameSg}='{$iDbTokenSg}'"; $tCallRecordsItemsMix = $wpdb->get_results($tQuerySg, ARRAY_N); $userId = $tCallRecordsItemsMix[0][0]; $rEmailSg = getEmailById($userId); return $rEmailSg; }
private function user_stats() { global $conn; // echo $this->params->email; die("--3333"); if ($this->params->user_id) { $user_id = $this->params->user_id; $email_user = getEmailById($user_id); $screen_name = getTwtScreenName($user_id); $sql2 = "SELECT COUNT(*) as total_teams FROM invites WHERE email='{$email_user}' AND is_accepted=1"; $result2 = mysqli_query($conn, $sql2); $row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC); $total_teams_joined = $row2['total_teams']; $sql = "SELECT (CASE\n\t\tWHEN (status = 0) THEN 'New' \n\t\tWHEN (status = 1) THEN 'Shared' \n\t\tWHEN (status = 2) THEN 'Declined' \n\t\tELSE 'Shared' \n\t\t END) as status, COUNT(*) as count_status FROM user_offers WHERE user_id = " . $user_id . " GROUP BY status"; //echo $sql; die; $result = mysqli_query($conn, $sql); $total_shared = '0'; $total_declined = '0'; $total_new = '0'; $total_received = '0'; if (!empty($screen_name)) { $total_impressions = $this->get_twitter_data($screen_name); } else { $total_impressions = "NA"; } while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { if ($row['status'] == 'Shared') { //$total_impressions = getTotalImpressions($screen_name); $total_shared = $row['count_status']; } elseif ($row['status'] == 'Declined') { $total_declined = $row['count_status']; } elseif ($row['status'] == 'New') { $total_new = $row['count_status']; } else { } } $total_received_offer = $total_shared + $total_declined + $total_new; //$count=mysqli_num_rows($result); if ($result) { $ret_array['success'] = '1'; $ret_array['message'] = 'User\'s'; $ret_array['total_shared'] = $total_shared; $ret_array['total_received'] = $total_received_offer; $ret_array['total_impressions'] = $total_impressions; $ret_array['total_teams_joined'] = $total_teams_joined; array_push($this->json_response, $ret_array); $this->success_failure_msgs(200, "User Stats", $this->json_response); } else { $msg = "No Record"; $ret_array['success'] = '0'; $ret_array['message'] = 'No Record found.'; array_push($this->json_response, $ret_array); //echo("Validation errors:<br/>"); $this->success_failure_msgs(200, $msg, $this->json_response); } } else { $msg = "Required Parameters Are Missing."; $this->json_response = ""; $this->success_failure_msgs(301, $msg, $this->json_response); } }