-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNASK.php
More file actions
executable file
·526 lines (465 loc) · 22.3 KB
/
NASK.php
File metadata and controls
executable file
·526 lines (465 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<?php
function NASK_getConfigArray() {
$configArray = array(
"Host" => array(
"type" => "text",
"size" => "255",
"description" => _("Hostname with protocol to NASK server"),
"defaultValue" => "https://registry.dns.pl/registry/epp",
),
"Username" => array(
"type" => "text",
"size" => "20",
"description" => _("Enter your username here"),
),
"Password" => array(
"type" => "password",
"size" => "20",
"description" => _("Enter your password here"),),
"Prefix" => array(
"type" => "text",
"size" => "16",
"title" => _("Contact Id Prefix"),
"description" => _("Enter mandatory prefix provided by NASK, min 3 letters"),
),
"CACert" => array(
"type" => "text",
"size" => "255",
"title"=> _("CA Chain"),
"description" => _("Path to NASK CA chain. If starts with '/' is interpreted as absolute."),
"defaultValue" => "nask_root_ca.pem",
),
"Cert" => array(
"type" => "text",
"size" => "255",
"title" => _("Client Certificate"),
"description" => _("Path to client certificate issued by NASK"),
"defaultValue" => "certificate_prod.pem",
),
"PrivateKey" => array(
"type" => "text",
"size" => "255",
"title" => _("Private Key"),
"description" => _("Path to client certificate Private Key issued by NASK"),
"defaultValue" => "key_prod.pem",
),
"Debug" => array("type" => "yesno",)
);
return $configArray;
}
function NASK_RegisterNameservers($params) {
$return = array();
return $return;
}
function NASK_GetNameserversStatus($params) {
return array("completed" => true);
}
function NASK_GetNameservers($params) {
$return = array();
return $return;
}
function NASK_SaveNameservers($params) {
$return = array();
return $return;
}
function NASK_SaveRegistrarLock($params) {
$return = array();
if ($params["lockenabled"] == 'locked') {
} else {
}
return $return;
}
function NASK_IDProtectToggle($params) {
$return = array();
if ($params["protectenable"] == 'enable') {
} else {
}
return $return;
}
function NASK_SetDNSSEC($params) {
$return = array();
foreach ($params as $name => $value) {
$valtype = gettype($value);
if ($valtype != "array") {
pa_log("param: " . $name . " = " . $value . " of type: " . gettype($value), "INFO");
}
}
if (array_key_exists("dnsSecInfo", $params)) {
pa_log("enabling DNSSEC for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
$dnsSecInfo = $params["dnsSecInfo"];
$keys = $dnsSecInfo;
foreach ($keys as $key) {
pa_log("KSK key " . $key["digestAlg"] . " digest: " . $key["digest"], "INFO");
}
} else {
pa_log("disabling DNSSEC for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
}
return $return;
}
function NASK_SetLocalPresence($params) {
$return = array();
foreach ($params as $name => $value) {
$valtype = gettype($value);
if ($valtype != "array") {
pa_log("param: " . $name . " = " . $value . " of type: " . gettype($value), "INFO");
}
}
if ($params["localPresenceInfo"] == 'enable') {
pa_log("enabling LocalPresence for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
} else {
pa_log("disabling LocalPresence for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
}
return $return;
}
function NASK_RegisterDomain($params) {
if (array_key_exists('LOCAL_PRESENCE', $params['additionalfields'])) {
if ($params['additionalfields']['LOCAL_PRESENCE'] == 1) {
pa_log("enabling LocalPresence for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
}
}
$return = array(
"additionalfields" => array(
"Passwd" => "DUMMYREGSECRET", //"Passwd" name is recommended (it will be hidden from log files)
"dummyexpirydate" => date('Y-m-d', strtotime('+' . $params["regperiod"] . ' year'))
)
);
if ($params['TestMode'] == 'on') {
$return["lockenabled"] = 'locked';
}
return $return;
}
function NASK_Sync($params) {
if (array_key_exists('dummyexpirydate', $params['additionalfields'])) {
if(strpos($params["sld"], 'conflict') !== false) {
return array(
"expirydate" => date('Y-m-d', strtotime($params['additionalfields']['dummyexpirydate'])),
"completed" => true,
"conflictcode" => "103",
"conflictmessage" => "Domain has been transferred out!",
);
} else if(strpos($params["sld"], 'autorenew') !== false) {
$regAutoRenew = $params['additionalfields']['Subscription_IsAutoRenew'] == "1" ? "off" : "on"; //inverting result
$message = "Domain Auto Renewal is ".$regAutoRenew." on registrar side";
return array(
"expirydate" => date('Y-m-d', strtotime($params['additionalfields']['dummyexpirydate'])),
"completed" => true,
"conflictcode" => "102",
"conflictmessage" => $message,
);
} else {
return array(
"expirydate" => date('Y-m-d', strtotime($params['additionalfields']['dummyexpirydate'])),
"completed" => true,
);
}
} else { //upgrade from 6.5 case
$dummyexpirydate = date('Y-m-d', strtotime('+' . $params['additionalfields']['regperiod'] . ' year'));
return array(
"expirydate" => $dummyexpirydate,
"completed" => true
);
}
}
function NASK_TransferDomain($params) {
if (array_key_exists('LOCAL_PRESENCE', $params['additionalfields'])) {
if ($params['additionalfields']['LOCAL_PRESENCE'] == 1) {
pa_log("enabling LocalPresence for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
}
}
$return = array(
"additionalfields" => array(
"transfersecret" => "DUMMYTRANSFERSECRET", //"transfersecret" name is recommended (it will be hidden from log files)
"dummyexpirydate" => date('Y-m-d', strtotime('+' . $params["regperiod"] . ' year'))
)
);
return $return;
}
function NASK_TransferSync($params) {
return array(
"expirydate" => date('Y-m-d', strtotime($params['additionalfields']['dummyexpirydate'])),
"completed" => true
);
}
function NASK_RenewDomain($params) {
if (array_key_exists('dummyexpirydate', $params['additionalfields'])) {
$return = array(
"additionalfields" => array(
"dummyexpirydate" => date('Y-m-d', strtotime('+' . $params["regperiod"] . ' year', strtotime($params['additionalfields']['dummyexpirydate'])))
)
);
} else { //upgrade from 6.5 case
$dummyexpirydate = date('Y-m-d', strtotime('+' . strval(intval($params['additionalfields']['regperiod']) + intval($params["regperiod"])) . ' year'));
$return = array(
"additionalfields" => array(
"dummyexpirydate" => $dummyexpirydate,
)
);
}
if (array_key_exists('LOCAL_PRESENCE', $params['additionalfields'])) {
if ($params['additionalfields']['LOCAL_PRESENCE'] == 1) {
pa_log("enabling LocalPresence for domain: " . $params["sld"] . "." . $params["tld"], "INFO");
}
}
return $return;
}
function NASK_RenewSync($params) {
return array(
"expirydate" => date('Y-m-d', strtotime($params['additionalfields']['dummyexpirydate'])),
"completed" => true
);
}
function NASK_RegisterContacts($params) {
$return = array();
return $return;
}
function NASK_GetContactsStatus($params) {
return array(
"completed" => true,
"additionalfields" => array(
"ownerContactId" => "1",
"adminContactId" => "2",
"techContactId" => "3",
"billingContactId" => "4"
)
);
}
function NASK_GetContactDetails($params) {
$return = array();
return $return;
}
function NASK_SaveContactDetails($params) {
$return = array();
return $return;
}
function NASK_RequestDelete($params) {
$result = array();
return $result;
}
function NASK_RequestDeleteSync($params) {
return array("completed" => true);
}
function NASK_checkAvailability($params) {
pa_log("Enter checkAvailability" . print_r(json_encode($params), TRUE), "INFO");
$result = array();
foreach ($params["domainNames"] as $p) {
if ($params['TestMode'] == 'on') {
if ($p == "registered.tv" || $p == "test.cz") {
$result[$p] = array('status' => 2, 'msg' => _('This domain is not available'));
$result["newdomain.tv"] = array('status' => 1, 'msg' => _('This domain is available'));
} else {
$result[$p] = array('status' => 1, 'msg' => _('This domain is available'));
}
if ($params["Username"] == 'suggest_domains_test') {
$result["sugg1" . $p] = array('status' => 1, 'msg' => _('This domain is available'));
}
} else {
$result[$p] = array('status' => 1, 'msg' => _('This domain is available'));
}
}
pa_log("Exit checkAvailability with success. Result: ".print_r(json_encode($result), TRUE), "INFO");
return $result;
}
function NASK_checkTransfer($params) {
return array('status' => 1, 'renewRequired' => 0, 'msg' => _('This domain is available for transfer'));
}
function NASK_ValidateAdditionalFields($params) {
if ($params['TestMode'] == 'on') {
$validate_statuses = array(
'EDIS_OK' => 1,
'EDIS_FAILED' =>2
);
if($params['tld'] == 'de'){
$status = $validate_statuses['EDIS_OK'];
$field1 = array("type" => "text", "title" => _("Tax ID"), "description" => "", "defaultValue" => "", "required" => 1, "status" => $status);
$field2 = array("type" => "tickbox", "title" => _("Address Confirmation"), "description" => _("Please confirm you have a valid German address"), "defaultValue" => "0", "required" => 0, "status" => $status);
if($params['operationType'] == 1){ //process of registration
if(isset($params['additionalfields']['de_TaxID']) || isset($params['additionalfields']['de_AddressConfirmation'])){
if(!is_null($params['additionalfields']['de_TaxID']) && strlen($params['additionalfields']['de_TaxID']) > 1)
$field1["status"] = $validate_statuses['EDIS_OK'];
else {
$field1["status"] = $validate_statuses['EDIS_FAILED'];
$field1["message"] = _("You should fill Tax ID correctly");
}
$field2["status"] = $validate_statuses['EDIS_OK'];
}
}
$extFields = array(
"de_TaxID" => $field1,
"de_AddressConfirmation" => $field2,
);
}
if($params['tld'] == 'se'){
$status = $validate_statuses['EDIS_OK'];
$field1 = array("type" => "text", "title" => _("Company number"), "description" => "", "defaultValue" => "", "required" => 1, "status" => $status);
if($params['operationType'] == 1){ //process of registration
if(isset($params['additionalfields']['sereg_value'])){
if(!is_null($params['additionalfields']['sereg_value']) && strlen($params['additionalfields']['sereg_value']) > 1)
$field1["status"] = $validate_statuses['EDIS_OK'];
else {
$field1["status"] = $validate_statuses['EDIS_FAILED'];
$field1["message"] = _("You should to fill Company number correctly");
}
}
}
$extFields = array(
"sereg_value" => $field1,
);
}
if($params['tld'] == 'es'){ //fake handler for testing
$status = $validate_statuses['EDIS_OK'];
$extFields["entityType"] = array("type" => "dropdown",
"title" => "Entity Type",
"defaultValue" => "default",
"options" => "1|"._("Individual").",39|"._("Economic Interest Group").",47|"._("Association").",59|"._("Sports Association").",68|"._("Professional Association").",124|"._("Savings Bank").",150|"._("Community Property").",152|"._("Community of Owners").",164|"._("Order or Religious Institution").",181|"._("Consulate").",197|"._("Public Law Association").",203|"._("Embassy").",229|"._("Local Authority").",269|"._("Sports Federation").",286|"._("Foundation").",365|"._("Mutual Insurance Company").",434|"._("Regional Government Body").",436|"._("Central Government Body").",439|"._("Political Party").",476|"._("Trade Union").",510|"._("Farm Partnership").",524|"._("Public Limited Company").",525|"._("Sports Association").",554|"._("Civil Society").",560|"._("General Partnership").",562|"._("General and Limited Partnership").",566|"._("Cooperative").",608|"._("Worker-owned Company").",612|"._("Limited Company").",713|"._("Spanish Office").",717|"._("Temporary Alliance of Enterprises").",744|"._("Worker-owned Limited Company").",745|"._("Regional Public Entity").",746|"._("National Public Entity").",747|"._("Local Public Entity").",877|"._("Others").",878|"._("Designation of Origin Supervisory (only for contacts outsight of Spain) Council").",879|"._("Entity Managing Natural Areas").",default|"._("-- Select your entity type --"),
"description" => _("Choose your Entity Type. If legal registrant is a person outside of Spain choose 'Individual'. If legal registrant is a business outside of Spain choose 'Others'."),
"required" => 1,
"status" => $status);
$entType = $params['additionalfields']['entityType'];
if(isset($entType) && $entType != 'default'){
$options = "OTHER|Other form of ID (Those outside of Spain)";
$extFields["identificationType"] = array("type" => "dropdown",
"title" => "Identification Type",
"defaultValue" => "OTHER",
"options" => $options,
"description" => _("If legal registrant is a person from Spain choose NIF or NIE. If legal registrant is a business in Spain choose CIF. If legal registrant is a person or a business outside of Spain choose 'Other form of ID'."),
"required" => 1,
"status" => $status);
$identType = $params['additionalfields']['identificationType'];
pa_log("identType: " . $identType);
if ($entType == '1'){
$options = "CITIZEN|"._("NIF (Spanish citizen)").",RESIDENT|"._("NIE (Legal residents in Spain)").",OTHER|"._("Other form of ID (Those outside of Spain)");
$extFields["identificationType"]["options"] = $options;
if (isset($identType) && ($identType == 'CITIZEN')) {
$extFields["NIF"] = array("type" => "text",
"title" => "NIF",
"description" => "NIF (Spanish citizen)",
"required" => 1,
"status" => $status);
} else if(isset($identType) && ($identType == 'RESIDENT')){
$extFields["NIE"] = array("type" => "text",
"title" => "NIE",
"description" => "NIE (Legal residents in Spain)",
"required" => 1,
"status" => $status);
} else {
$extFields["OTHER"] = array("type" => "text",
"title" => "Other form of ID",
"description" => "Other form of ID (Those outside of Spain)",
"required" => 1,
"status" => $status);
}
} else if ($entType == '47') {
$options = "COMPANY|"._("CIF (Spanish company)").",OTHER|"._("Other form of ID (Those outside of Spain)");
$extFields["identificationType"]["options"] = $options;
if(isset($identType) && ($identType == 'COMPANY')){
$extFields["CIF"] = array("type" => "text",
"title" => "CIF",
"description" => "CIF (Spanish company)",
"required" => 1,
"status" => $status);
}
else {
$extFields["OTHER"] = array("type" => "text",
"title" => "Other form of ID",
"description" => "Other form of ID (Those outside of Spain)",
"required" => 1,
"status" => $status);
}
} else {
$options = "ID|"._("ID number (Foreign company)").",OTHER|"._("Other form of ID (Those outside of Spain)");
$extFields["identificationType"]["options"] = $options;
if(isset($identType) && ($identType == 'ID')){
$extFields["ID"] = array("type" => "text",
"title" => "ID number",
"description" => "ID number (Foreign company)",
"required" => 1,
"status" => $status);
} else {
$extFields["OTHER"] = array("type" => "text",
"title" => "Other form of ID",
"description" => "Other form of ID (Those outside of Spain)",
"required" => 1,
"status" => $status);
}
}
}
}
if($params['tld'] == 'cz') { //fake handler for testing
$status = $validate_statuses['EDIS_OK'];
$field1 = array("type" => "text", "title" => _("Tax ID"), "description" => "", "defaultValue" => "", "required" => 1, "status" => $status);
$field2 = array("type" => "tickbox", "title" => _("Address Confirmation"), "description" => _("Please confirm you have a valid German address"), "defaultValue" => "0", "required" => 0, "status" => $status);
$field3 = array("type" => "dropdown", "title" => _("Some random dropdown"), "description" => _("Select something"), "defaultValue" => "SUPER", "options" => "MEGA|"._("MEGA").",UBER|"._("UBER").",SUPER|"._("SUPER"), "required" => 0, "status" => $status);
$field5 = array("type" => "text", "title" => "one", "description" => "", "defaultValue" => "", "required" => 1, "status" => $status);
$field6 = array("type" => "text", "title" => "two", "description" => "", "defaultValue" => "", "required" => 1, "status" => $status);
$field7 = array("type" => "dropdown", "title" => _("Random dependant dropdown"), "description" => _("Select something"), "defaultValue" => "UBER", "options" => "", "required" => 0, "status" => $status);
if($params['operationType'] == 1){ //process of registration
if(isset($params['additionalfields']['cz_TaxID']) || isset($params['additionalfields']['cz_AddressConfirmation'])){
if(!is_null($params['additionalfields']['cz_TaxID']) && strlen($params['additionalfields']['cz_TaxID']) > 1)
$field1["status"] = $validate_statuses['EDIS_OK'];
else {
$field1["status"] = $validate_statuses['EDIS_FAILED'];
$field1["message"] = _("You should fill Tax ID correctly");
}
$field2["status"] = $validate_statuses['EDIS_OK'];
}
}
if (isset($params['additionalfields']['cz_AddressConfirmation']) && $params['additionalfields']['cz_AddressConfirmation'] == '1') {
$extFields = array(
"cz_TaxID" => $field1,
"cz_AddressConfirmation" => $field2,
"cz_SomeRandomDropdown" => $field3
);
if ((isset($params['additionalfields']['cz_SomeRandomDropdown']) && $params['additionalfields']['cz_SomeRandomDropdown'] == 'UBER') ||
(!isset($params['additionalfields']['cz_SomeRandomDropdown']) && $extFields['cz_SomeRandomDropdown']['defaultValue'] == 'UBER')) {
$field7["options"] = "MEGA|"._("MEGA").",UBER|"._("UBER").",SUPER|"._("SUPER").",SUPER1|"._("SUPER1");
$extFields = array(
"cz_TaxID" => $field1,
"cz_AddressConfirmation" => $field2,
"cz_SomeRandomDropdown" => $field3,
"cz_one" => $field5,
"cz_RandomDependantDropdown" => $field7
);
} else {
$field7["options"] = "MEGA|"._("MEGA").",UBER|"._("UBER").",SUPER|"._("SUPER").",SUPER2|"._("SUPER2");
$extFields = array(
"cz_TaxID" => $field1,
"cz_AddressConfirmation" => $field2,
"cz_SomeRandomDropdown" => $field3,
"cz_two" => $field6,
"cz_RandomDependantDropdown" => $field7
);
}
} else {
$extFields = array(
"cz_TaxID" => $field1,
"cz_AddressConfirmation" => $field2,
);
}
}
}
return $extFields;
}
function NASK_GetEPPCode($params) {
if ($params['TestMode'] == 'on') {
$domainName = $params["sld"] . "." . $params["tld"];
$eppCode = "dummy-code-for-" . $domainName;
if( strpos($params["sld"], 'test-asynchronous') !== false ) {
return array('eppcode' => "", 'msg' => _("Domain data has been inquired successfully."), 'pending'=>1);
}
return array('eppcode' => $eppCode, 'completed' => true, 'msg' => _("Domain data has been inquired successfully."), 'failed' => false);
} else {
return array('error' => _("This operation cannot be performed for this domain."));
}
}
function NASK_SetAutoRenew($params) {
$return = array();
if (array_key_exists("autorenew", $params)) {
pa_log("setting autorenew flag for domain: " . $params["sld"] . "." . $params["tld"] . ", new value: " . $params["autorenew"], "INFO");
} else {
pa_log("AutoRenew flag not found in incoming request: " . $params["sld"] . "." . $params["tld"], "INFO");
}
return $return;
}
function NASK_GetAutoRenewStatus($params) {
return array("completed" => true);
}