From e607c120c4064c74ad078b1099f37032c13169d0 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Fri, 23 Jun 2017 15:50:11 -0600 Subject: [PATCH] Add sendLoginAlertEmail() function --- lib/login.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/login.php b/lib/login.php index aeeead2..1a92bdc 100644 --- a/lib/login.php +++ b/lib/login.php @@ -227,6 +227,31 @@ function doLoginUser($username) { } } +function sendLoginAlertEmail($username) { + $client = new GuzzleHttp\Client(); + + $response = $client + ->request('POST', PORTAL_API, [ + 'form_params' => [ + 'key' => PORTAL_KEY, + 'action' => "alertemail", + 'username' => $username, + 'appname' => SITE_TITLE + ] + ]); + + if ($response->getStatusCode() > 299) { + return "An unknown error occurred."; + } + + $resp = json_decode($response->getBody(), TRUE); + if ($resp['status'] == "OK") { + return true; + } else { + return $resp['msg']; + } +} + function simLogin($username, $password) { $client = new GuzzleHttp\Client();