These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * /classes/DomainMOD/Api.php |
||
4 | * |
||
5 | * This file is part of DomainMOD, an open source domain and internet asset manager. |
||
6 | * Copyright (c) 2010-2017 Greg Chetcuti <[email protected]> |
||
7 | * |
||
8 | * Project: http://domainmod.org Author: http://chetcuti.com |
||
9 | * |
||
10 | * DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
||
11 | * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later |
||
12 | * version. |
||
13 | * |
||
14 | * DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
||
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License along with DomainMOD. If not, see |
||
18 | * http://www.gnu.org/licenses/. |
||
19 | * |
||
20 | */ |
||
21 | //@formatter:off |
||
22 | namespace DomainMOD; |
||
23 | |||
24 | class Api |
||
25 | { |
||
26 | public $assets; |
||
27 | public $error; |
||
28 | public $log; |
||
29 | public $system; |
||
30 | |||
31 | public function __construct() |
||
32 | { |
||
33 | $this->assets = new Assets(); |
||
34 | $this->error = new Error(); |
||
35 | $this->log = new Log('api.class'); |
||
36 | $this->system = new System(); |
||
37 | } |
||
38 | |||
39 | public function getKey($account_id) |
||
1 ignored issue
–
show
|
|||
40 | { |
||
41 | $pdo = $this->system->db(); |
||
42 | |||
43 | $stmt = $pdo->prepare(" |
||
44 | SELECT api_key |
||
45 | FROM registrar_accounts |
||
46 | WHERE id = :account_id"); |
||
47 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
48 | $stmt->execute(); |
||
49 | $result = $stmt->fetchColumn(); |
||
50 | |||
51 | if (!$result) { |
||
52 | |||
53 | $log_message = 'Unable to retrieve API Key'; |
||
54 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
55 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
56 | $this->log->error($log_message, $log_extra); |
||
57 | return $log_message; |
||
58 | |||
59 | } else { |
||
60 | |||
61 | return $result; |
||
62 | |||
63 | } |
||
64 | } |
||
65 | |||
66 | public function getKeySecret($account_id) |
||
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
67 | { |
||
68 | $pdo = $this->system->db(); |
||
69 | |||
70 | $stmt = $pdo->prepare(" |
||
71 | SELECT api_key, api_secret |
||
72 | FROM registrar_accounts |
||
73 | WHERE id = :account_id"); |
||
74 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
75 | $stmt->execute(); |
||
76 | $result = $stmt->fetch(); |
||
77 | |||
78 | if (!$result) { |
||
79 | |||
80 | $log_message = 'Unable to retrieve API Key & API Secret'; |
||
81 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
82 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
83 | $this->log->error($log_message, $log_extra); |
||
84 | return array($log_message, $log_message); |
||
85 | |||
86 | } else { |
||
87 | |||
88 | return array($result->api_key, $result->api_secret); |
||
89 | |||
90 | } |
||
91 | } |
||
92 | |||
93 | public function getUserKey($account_id) |
||
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
94 | { |
||
95 | $pdo = $this->system->db(); |
||
96 | |||
97 | $stmt = $pdo->prepare(" |
||
98 | SELECT username, api_key |
||
99 | FROM registrar_accounts |
||
100 | WHERE id = :account_id"); |
||
101 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
102 | $stmt->execute(); |
||
103 | $result = $stmt->fetch(); |
||
104 | |||
105 | if (!$result) { |
||
106 | |||
107 | $log_message = 'Unable to retrieve Username & API Key'; |
||
108 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
109 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
110 | $this->log->error($log_message, $log_extra); |
||
111 | return array($log_message, $log_message); |
||
112 | |||
113 | } else { |
||
114 | |||
115 | return array($result->username, $result->api_key); |
||
116 | |||
117 | } |
||
118 | } |
||
119 | |||
120 | View Code Duplication | public function getUserAppSecret($account_id) |
|
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
121 | { |
||
122 | $pdo = $this->system->db(); |
||
123 | |||
124 | $stmt = $pdo->prepare(" |
||
125 | SELECT username, api_app_name, api_secret |
||
126 | FROM registrar_accounts |
||
127 | WHERE id = :account_id"); |
||
128 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
129 | $stmt->execute(); |
||
130 | $result = $stmt->fetch(); |
||
131 | |||
132 | if (!$result) { |
||
133 | |||
134 | $log_message = 'Unable to retrieve Username, API App Name, & API Secret'; |
||
135 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
136 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
137 | $this->log->error($log_message, $log_extra); |
||
138 | return array($log_message, $log_message, $log_message); |
||
139 | |||
140 | } else { |
||
141 | |||
142 | return array($result->username, $result->api_app_name, $result->api_secret); |
||
143 | |||
144 | } |
||
145 | } |
||
146 | |||
147 | View Code Duplication | public function getUserKeyIp($account_id) |
|
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
148 | { |
||
149 | $pdo = $this->system->db(); |
||
150 | |||
151 | $stmt = $pdo->prepare(" |
||
152 | SELECT ra.username, ra.api_key, ip.ip |
||
153 | FROM registrar_accounts AS ra, ip_addresses AS ip |
||
154 | WHERE ra.api_ip_id = ip.id |
||
155 | AND ra.id = :account_id"); |
||
156 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
157 | $stmt->execute(); |
||
158 | $result = $stmt->fetch(); |
||
159 | |||
160 | if (!$result) { |
||
161 | |||
162 | $log_message = 'Unable to retrieve Username, API Key, & IP Address'; |
||
163 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
164 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
165 | $this->log->error($log_message, $log_extra); |
||
166 | return array($log_message, $log_message, $log_message); |
||
167 | |||
168 | } else { |
||
169 | |||
170 | return array($result->username, $result->api_key, $result->ip); |
||
171 | |||
172 | } |
||
173 | } |
||
174 | |||
175 | public function getReselleridKey($account_id) |
||
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
176 | { |
||
177 | $pdo = $this->system->db(); |
||
178 | |||
179 | $stmt = $pdo->prepare(" |
||
180 | SELECT reseller_id, api_key |
||
181 | FROM registrar_accounts |
||
182 | WHERE id = :account_id"); |
||
183 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
184 | $stmt->execute(); |
||
185 | $result = $stmt->fetch(); |
||
186 | |||
187 | if (!$result) { |
||
188 | |||
189 | $log_message = 'Unable to retrieve Reseller ID & API Key'; |
||
190 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
191 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
192 | $this->log->error($log_message, $log_extra); |
||
193 | return array($log_message, $log_message); |
||
194 | |||
195 | } else { |
||
196 | |||
197 | return array($result->reseller_id, $result->api_key); |
||
198 | |||
199 | } |
||
200 | } |
||
201 | |||
202 | public function getUserPass($account_id) |
||
1 ignored issue
–
show
The parameter $account_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
203 | { |
||
204 | $pdo = $this->system->db(); |
||
205 | |||
206 | $stmt = $pdo->prepare(" |
||
207 | SELECT username, `password` |
||
208 | FROM registrar_accounts |
||
209 | WHERE id = :account_id"); |
||
210 | $stmt->bindValue('account_id', $account_id, \PDO::PARAM_INT); |
||
211 | $stmt->execute(); |
||
212 | $result = $stmt->fetch(); |
||
213 | |||
214 | if (!$result) { |
||
215 | |||
216 | $log_message = 'Unable to retrieve Username & Password'; |
||
217 | $log_extra = array('Account ID' => $account_id, 'Registrar' => $this->assets->getRegistrarByAcc($account_id), |
||
218 | 'Account Username' => $this->assets->getUsername($account_id)); |
||
219 | $this->log->error($log_message, $log_extra); |
||
220 | return array($log_message, $log_message); |
||
221 | |||
222 | } else { |
||
223 | |||
224 | return array($result->username, $result->password); |
||
225 | |||
226 | } |
||
227 | } |
||
228 | |||
229 | View Code Duplication | public function getApiRegistrarName($api_registrar_id) |
|
1 ignored issue
–
show
The parameter $api_registrar_id is not named in camelCase.
This check marks parameter names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes
Loading history...
|
|||
230 | { |
||
231 | $pdo = $this->system->db(); |
||
232 | |||
233 | $stmt = $pdo->prepare(" |
||
234 | SELECT `name` |
||
235 | FROM api_registrars |
||
236 | WHERE id = :api_registrar_id"); |
||
237 | $stmt->bindValue('api_registrar_id', $api_registrar_id, \PDO::PARAM_INT); |
||
238 | $stmt->execute(); |
||
239 | $result = $stmt->fetchColumn(); |
||
240 | |||
241 | if (!$result) { |
||
242 | |||
243 | $log_message = 'Unable to retrieve API Registrar Name'; |
||
244 | $log_extra = array('API Registrar ID' => $api_registrar_id); |
||
245 | $this->log->error($log_message, $log_extra); |
||
246 | return $log_message; |
||
247 | |||
248 | } else { |
||
249 | |||
250 | return $result; |
||
251 | |||
252 | } |
||
253 | } |
||
254 | |||
255 | } //@formatter:on |
||
256 |
This check marks parameter names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.