File tree Expand file tree Collapse file tree 2 files changed +25
-20
lines changed Expand file tree Collapse file tree 2 files changed +25
-20
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to ` whmcs-api ` will be documented in this file.
4
4
5
+ ## v0.0.5 - 2021-10-27
6
+
7
+ - refactor to remove return statements in getclientbyphonenumber as return statement might lead to abnormal program termination via the include system
8
+
5
9
## v0.0.4 - 2021-10-27
6
10
7
11
- handling of space in telephone numbers
Original file line number Diff line number Diff line change 11
11
if (!defined ("WHMCS " ))
12
12
die ("This file cannot be accessed directly " );
13
13
14
- try {
14
+ try {
15
15
// First check for the actual number
16
16
$ phoneNumber = $ _REQUEST ['phonenumber ' ];
17
17
20
20
->first ();
21
21
22
22
if ($ client ) {
23
+
23
24
$ apiresults = [
24
25
"result " => "success " ,
25
26
"message " => "ok " ,
26
27
'clientid ' => $ client ->id ,
27
28
];
28
29
29
- return ;
30
- }
30
+ } else {
31
+ // ...then check for the number but without spaces
32
+ $ phoneNumberWithoutSpaces = str_replace (' ' , '' , $ _REQUEST ['phonenumber ' ]);
31
33
32
- // ...then check for the number but without spaces
33
- $ phoneNumberWithoutSpaces = str_replace (' ' , '' , $ _REQUEST ['phonenumber ' ]);
34
+ $ client = Capsule::table ('tblclients ' )->where ("phonenumber " , $ phoneNumberWithoutSpaces )->first ();
34
35
35
- $ client = Capsule::table ('tblclients ' )->where ("phonenumber " , $ phoneNumberWithoutSpaces )->first ();
36
+ if ($ client ) {
37
+ $ apiresults = [
38
+ "result " => "success " ,
39
+ "message " => "ok " ,
40
+ 'clientid ' => $ client ->id ,
41
+ ];
36
42
37
- if ($ client ) {
38
- $ apiresults = [
39
- "result " => "success " ,
40
- "message " => "ok " ,
41
- 'clientid ' => $ client ->id ,
42
- ];
43
+ } else {
43
44
44
- return ;
45
+ $ apiresults = [
46
+ "result " => "error " ,
47
+ "message " => "a client with number $ phoneNumber was not found " ,
48
+ ];
49
+ }
50
+
45
51
}
46
52
47
- $ apiresults = [
48
- "result " => "error " ,
49
- "message " => "a client with number $ phoneNumber was not found " ,
50
- ];
51
-
53
+
52
54
} catch (Exception $ e ) {
53
55
54
56
$ apiresults = [
55
- "result " => "exception " ,
57
+ "result " => "error " ,
56
58
"message " => $ e ->getMessage (),
57
59
];
58
-
59
60
}
You can’t perform that action at this time.
0 commit comments