Skip to content

Commit

Permalink
5
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenefvdm committed Oct 27, 2021
1 parent 0d0bd3a commit 90b14d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `whmcs-api` will be documented in this file.

## v0.0.5 - 2021-10-27

- refactor to remove return statements in getclientbyphonenumber as return statement might lead to abnormal program termination via the include system

## v0.0.4 - 2021-10-27

- handling of space in telephone numbers
Expand Down
41 changes: 21 additions & 20 deletions src/getclientbyphonenumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if (!defined("WHMCS"))
die("This file cannot be accessed directly");

try {
try {
// First check for the actual number
$phoneNumber = $_REQUEST['phonenumber'];

Expand All @@ -20,40 +20,41 @@
->first();

if ($client) {

$apiresults = [
"result" => "success",
"message" => "ok",
'clientid' => $client->id,
];

return;
}
} else {
// ...then check for the number but without spaces
$phoneNumberWithoutSpaces = str_replace(' ', '', $_REQUEST['phonenumber']);

// ...then check for the number but without spaces
$phoneNumberWithoutSpaces = str_replace(' ', '', $_REQUEST['phonenumber']);
$client = Capsule::table('tblclients')->where("phonenumber", $phoneNumberWithoutSpaces)->first();

$client = Capsule::table('tblclients')->where("phonenumber", $phoneNumberWithoutSpaces)->first();
if ($client) {
$apiresults = [
"result" => "success",
"message" => "ok",
'clientid' => $client->id,
];

if ($client) {
$apiresults = [
"result" => "success",
"message" => "ok",
'clientid' => $client->id,
];
} else {

return;
$apiresults = [
"result" => "error",
"message" => "a client with number $phoneNumber was not found",
];
}

}

$apiresults = [
"result" => "error",
"message" => "a client with number $phoneNumber was not found",
];


} catch (Exception $e) {

$apiresults = [
"result" => "exception",
"result" => "error",
"message" => $e->getMessage(),
];

}

0 comments on commit 90b14d0

Please sign in to comment.