You are here

public static function handler::sendFeedbackEmail in OAuth2 Login 8

Sending feedback email to drupalsupport

2 calls to handler::sendFeedbackEmail()
miniorange_oauth_clientController::miniorange_oauth_client_feedback_func in src/Controller/miniorange_oauth_clientController.php
oauth2_loginController::oauth2_login_feedback_func in src/Controller/oauth2_loginController.php

File

src/handler.php, line 37

Class

handler

Namespace

Drupal\oauth2_login

Code

public static function sendFeedbackEmail() {
  $_SESSION['mo_other'] = "False";
  global $base_url;
  $reason = $_GET['deactivate_plugin'];
  $q_feedback = $_GET['query_feedback'];
  $message = 'Reason: ' . $reason . '<br>Feedback: ' . $q_feedback;
  $url = 'https://login.xecurify.com/moas/api/notify/send';
  $ch = \curl_init($url);
  $email = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_admin_email');
  if (empty($email)) {
    $email = $_GET['miniorange_feedback_email'];
  }
  $phone = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_admin_phone');
  $customerKey = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_id');
  $apikey = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_customer_api_key');
  if ($customerKey == '') {
    $customerKey = "16555";
    $apikey = "fFd2XcvTGDemZvbw1bcUesNJWEqKbbUq";
  }
  $controller = new miniorange_oauth_clientController();
  $currentTimeInMillis = $controller
    ->get_oauth_timestamp();
  $stringToHash = $customerKey . $currentTimeInMillis . $apikey;
  $hashValue = hash("sha512", $stringToHash);
  $customerKeyHeader = "Customer-Key: " . $customerKey;
  $timestampHeader = "Timestamp: " . $currentTimeInMillis;
  $authorizationHeader = "Authorization: " . $hashValue;
  $fromEmail = $email;
  $subject = "Drupal 8 OAuth Login Module Feedback";
  $query = '[Drupal 8 OAuth Login]: ' . $message;
  $content = '<div >Hello, <br><br>Company :<a href="' . $_SERVER['SERVER_NAME'] . '" target="_blank" >' . $_SERVER['SERVER_NAME'] . '</a><br><br>Phone Number :' . $phone . '<br><br>Email :<a href="mailto:' . $fromEmail . '" target="_blank">' . $fromEmail . '</a><br><br>Query :' . $query . '</div>';
  $fields = array(
    'customerKey' => $customerKey,
    'sendEmail' => true,
    'email' => array(
      'customerKey' => $customerKey,
      'fromEmail' => $fromEmail,
      'fromName' => 'miniOrange',
      'toEmail' => 'drupalsupport@xecurify.com',
      'toName' => 'drupalsupport@xecurify.com',
      'subject' => $subject,
      'content' => $content,
    ),
  );
  $field_string = json_encode($fields);
  \curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  \curl_setopt($ch, CURLOPT_ENCODING, "");
  \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  \curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  \curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  # required for https urls
  \curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  \curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    $customerKeyHeader,
    $timestampHeader,
    $authorizationHeader,
  ));
  \curl_setopt($ch, CURLOPT_POST, true);
  \curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
  $content = \curl_exec($ch);
  if (\curl_errno($ch)) {
    return json_encode(array(
      "status" => 'ERROR',
      'statusMessage' => curl_error($ch),
    ));
  }
  \curl_close($ch);
  if (!empty(\Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_base_url'))) {
    $baseUrlValue = \Drupal::config('oauth2_login.settings')
      ->get('miniorange_oauth_client_base_url');
  }
  else {
    $baseUrlValue = $base_url;
  }
  $uninstall_redirect = $baseUrlValue . '/admin/modules';
  return new RedirectResponse($uninstall_redirect);
}