-
Notifications
You must be signed in to change notification settings - Fork 16
/
ispapi.php
executable file
·2993 lines (2673 loc) · 106 KB
/
ispapi.php
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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* ISPAPI Registrar Module
*
* @author HEXONET GmbH <support@hexonet.net>
*/
$module_version = "1.11.1";
use WHMCS\Domains\DomainLookup\ResultsList;
use WHMCS\Domains\DomainLookup\SearchResult;
use WHMCS\Module\Registrar\Registrarmodule\ApiClient;
use WHMCS\Module\Server;
use WHMCS\Module\Addon;
use WHMCS\Module\Widget;
use WHMCS\Module\Addon\Setting;
use WHMCS\Database\Capsule;
/**
* Check the availability of domains using HEXONET's fast API
*
* @param array $params common module parameters
*
* @return \WHMCS\Domains\DomainLookup\ResultsList An ArrayObject based collection of \WHMCS\Domains\DomainLookup\SearchResult results
*/
function ispapi_CheckAvailability($params)
{
//GET AN ARRAY OF ALL TLDS CONFIGURED WITH HEXONET
$pdo = Capsule::connection()->getPdo();
$stmt = $pdo->prepare("SELECT extension FROM tbldomainpricing WHERE autoreg REGEXP '^(ispapi|hexonet)$'");
$stmt->execute();
$ispapi_tlds = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
//GET ALL CURRENCIES EXISTING IN WHMCS
$whmcs_existing_currencies = localAPI('GetCurrencies', array());
if ($params['isIdnDomain']) {
$label = empty($params['punyCodeSearchTerm']) ? strtolower($params['searchTerm']) : strtolower($params['punyCodeSearchTerm']);
} else {
$label = strtolower($params['searchTerm']);
}
$tldslist = $params['tldsToInclude'];
$premiumEnabled = (bool) $params['premiumEnabled'];
$domainslist = array();
$results = new ResultsList();
foreach ($tldslist as $tld) {
if (!empty($tld[0])) {
if ($tld[0] != '.') {
$tld = ".".$tld;
}
$domain = $label.$tld;
if (!in_array($domain, $domainslist["all"])) {
$domainslist["all"][] = $domain;
$domainslist["list"][] = array("sld" => $label, "tld" => $tld);
}
}
}
//ONLY FOR SUGGESTIONS
if (isset($params["suggestions"]) && !empty($params["suggestions"])) {
$domainslist["all"] = array();
$domainslist["list"] = array();
foreach ($params["suggestions"] as $suggestion) {
if (!in_array($suggestion, $domainslist["all"])) {
$domainslist["all"][] = $suggestion;
$suggested_domain = preg_split("/\./", $suggestion, 2);
$domainslist["list"][] = array("sld" => $suggested_domain[0], "tld" => ".".$suggested_domain[1]);
}
}
}
$command = array(
"COMMAND" => "CheckDomains",
"DOMAIN" => $domainslist["all"],
"PREMIUMCHANNELS" => "*"
);
$check = ispapi_call($command, ispapi_config($params));
if ($check["CODE"] == 200) {
$index=0;
foreach ($domainslist["list"] as $domain) {
$registerprice = $renewprice = $currency = $status = "";
$searchResult = new SearchResult($domain['sld'], $domain['tld']);
if (preg_match('/549/', $check["PROPERTY"]["DOMAINCHECK"][$index])) {
//TLD NOT SUPPORTED AT HEXONET USE A FALLBACK TO THE WHOIS LOOKUP.
$whois = localAPI("DomainWhois", array("domain" => $domain['sld'].$domain['tld']));
if ($whois["status"] == "available") {
//DOMAIN AVAILABLE
$status = SearchResult::STATUS_NOT_REGISTERED;
} else {
//DOMAIN TAKEN
$status = SearchResult::STATUS_REGISTERED;
}
} elseif (preg_match('/210/', $check["PROPERTY"]["DOMAINCHECK"][$index])) {
//DOMAIN AVAILABLE
$status = SearchResult::STATUS_NOT_REGISTERED;
} elseif (!empty($check["PROPERTY"]["PREMIUMCHANNEL"][$index]) || !empty($check["PROPERTY"]["CLASS"][$index])) { //IT IS A PREMIUMDOMAIN
//IF PREMIUM DOMAIN ENABLED IN WHMCS - DISPLAY AVAILABLE + PRICE
if ($premiumEnabled) {
//CHECK IF HEXONET IS CONFIGURED AS REGISTRAR FOR THIS EXTENSION
if (!in_array($domain['tld'], $ispapi_tlds)) {
//PREMIUM DOMAIN BUT NOT REGISTERED WITH HEXONET - RETURN TAKEN
$status = SearchResult::STATUS_REGISTERED;
} else {
//GET THE REGISTER PRICE
if (isset($check["PROPERTY"]["PRICE"][$index]) && is_numeric($check["PROPERTY"]["PRICE"][$index])) {
$registerprice = $check["PROPERTY"]["PRICE"][$index];
}
if (isset($check["PROPERTY"]["CURRENCY"][$index]) && !empty($check["PROPERTY"]["CURRENCY"][$index])) {
$currency = $check["PROPERTY"]["CURRENCY"][$index];
}
//GET ALL CURRENCIES EXISTING IN WHMCS AND THE PREMIUM DOMAIN CURRENCY
$currency_id = 0;
$currency_list = array();
foreach ($whmcs_existing_currencies["currencies"]["currency"] as $cur) {
$currency_list[] = $cur["code"];
if ($cur["code"] == $currency) {
$currency_id = $cur["id"];
}
}
if (!in_array($currency, $currency_list) || empty($registerprice)) {
//IF CURRENCY OF THE DOMAIN NOT IN WHMCS OR PRICE NOT FOUND, RETURN TAKEN BECAUSE IT'S NOT POSSIBLE TO CALCULATE THE PRICE.
$status = SearchResult::STATUS_REGISTERED;
} else {
//AFTERMARKET OR REGISTRY PREMIUM DOMAIN
$renewprice = ispapi_getRenewPrice($params, $check["PROPERTY"]["CLASS"][$index], $currency_id, ltrim($domain['tld'], '.'));
if (isset($registerprice) && isset($currency) && !empty($renewprice)) {
$status = SearchResult::STATUS_NOT_REGISTERED;
$searchResult->setPremiumDomain(true);
$premiuminformation = array('register' => $registerprice,
'renew' => $renewprice,
'CurrencyCode' => $currency);
$searchResult->setPremiumCostPricing($premiuminformation);
} else {
//PROBLEM, COULD NOT GET REGISTRATION OR RENEW PRICES -> DISPLAY THE DOMAIN AS TAKEN
$status = SearchResult::STATUS_REGISTERED;
}
}
}
} else {
//PREMIUM DOMAIN NOT ENABLED IN WHMCS -> DISPLAY THE DOMAIN AS TAKEN
$status = SearchResult::STATUS_REGISTERED;
}
} else {
//DOMAIN TAKEN
$status = SearchResult::STATUS_REGISTERED;
}
$searchResult->setStatus($status);
$index++;
if (isset($params["suggestions"])) {
//ONLY RETURNS AVAILABLE DOMAINS FOR SUGGESTIONS
if ($status != SearchResult::STATUS_REGISTERED) {
$results->append($searchResult);
}
} else {
$results->append($searchResult);
}
}
}
return $results;
}
/**
* Provide domain suggestions based on the domain lookup term provided
*
* @param array $params common module parameters
*
* @return \WHMCS\Domains\DomainLookup\ResultsList An ArrayObject based collection of \WHMCS\Domains\DomainLookup\SearchResult results
*/
function ispapi_GetDomainSuggestions($params)
{
//return;
//GET THE TLD OF THE SEARCHED VALUE
if (isset($_REQUEST["domain"]) && preg_match('/\./', $_REQUEST["domain"])) {
$search = preg_split("/\./", $_REQUEST["domain"], 2);
$searched_zone = $search[1];
}
//RETURN EMPTY ResultsList OBJECT WHEN SUGGESTIONS ARE DEACTIVATED
if (empty($params['suggestionSettings']['suggestions'])) {
return new ResultsList();
}
if ($params['isIdnDomain']) {
$label = empty($params['punyCodeSearchTerm']) ? strtolower($params['searchTerm']) : strtolower($params['punyCodeSearchTerm']);
} else {
$label = strtolower($params['searchTerm']);
}
$tldslist = $params['tldsToInclude'];
$zones = array();
foreach ($tldslist as $tld) {
#IGNORE 3RD LEVEL TLDS - NOT FULLY SUPPORTED BY QueryDomainSuggestionList
if (!preg_match("/\./", $tld)) {
$zones[] = $tld;
}
}
//IF SEARCHED VALUE CONTAINS TLD THEN ONLY DISPLAY SUGGESTIONS WITH THIS TLD
//$zones_for_suggestions = isset($searched_zone) ? array($searched_zone) : $zones;
$command = array(
"COMMAND" => "QueryDomainSuggestionList",
"KEYWORD" => $label,
"ZONE" => $zones,
"SOURCE" => "ISPAPI-SUGGESTIONS",
);
$suggestions = ispapi_call($command, ispapi_config($params));
$domains = array();
if ($suggestions["CODE"] == 200) {
$domains = $suggestions["PROPERTY"]["DOMAIN"];
}
$params["suggestions"] = $domains;
return ispapi_CheckAvailability($params);
}
/**
* Define the settings relating to domain suggestions
*
* @param array an array with different settings
*/
function ispapi_DomainSuggestionOptions($params)
{
if ($params['whmcsVersion'] < 7.6) {
$marginleft = '60px';
} else {
$marginleft = '220px';
}
return array(
'information' => array(
'FriendlyName' => '<b>Don\'t have a HEXONET Account yet?</b>',
'Description' => 'Get one here: <a target="_blank" href="https://www.hexonet.net/sign-up">https://www.hexonet.net/sign-up</a><br><br>
<b>The HEXONET Lookup Provider provides the following features:</b>
<ul style="text-align:left;margin-left:'.$marginleft.';margin-top:5px;">
<li>High Performance availability checks using our fast API</li>
<li>Suggestion Engine</li>
<li>Aftermarket and Registry Premium Domains support</li>
<li>Fallback to WHOIS Lookup for non-supported TLDs</li>
</ul>
',
),
'suggestions' => array(
'FriendlyName' => '<b style="color:#FF6600;">Suggestion Engine based on search term:</b>',
'Type' => 'yesno',
'Description' => 'Tick to activate (recommended)',
),
);
}
/**
* Calculate the domain renew price
*
* @param array $params common module parameters
* @param string $class the class of the domain name
* @param integer $cur_id the currency of the domain name
* @param string $tld the tld of the domain name
*
* @return integer/bool the renew price, false if not found
*/
function ispapi_getRenewPrice($params, $class, $cur_id, $tld)
{
session_start();
if (empty($class)) {
//NO PREMIUM RENEW, RETURN THE PRICE SET IN WHMCS
$pdo = Capsule::connection()->getPdo();
$stmt = $pdo->prepare("select * from tbldomainpricing tbldp, tblpricing tblp where tbldp.extension = ? and tbldp.id = tblp.relid and tblp.type = 'domainrenew' and tblp.currency=?");
$stmt->execute(array(".".$tld, $cur_id));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($data) && !in_array($data["msetupfee"], array("-1", "0"))) {
return $data["msetupfee"];
} else {
return false;
}
//API COMMAND GetTLDPricing IS TRIGERING JS ERROR AND IS UNUSABLE.
// $gettldpricing_res = localAPI('GetTLDPricing', array('currencyid' => $cur_id));
// $renewprice = $gettldpricing_res["pricing"][$tld]["renew"][1];
//return !empty($renewprice) ? $renewprice : false;
}
if (!preg_match('/\:/', $class)) {
//REGISTRY PREMIUM DOMAIN (e.g. PREMIUM_DATE_F)
$class = "PRICE_CLASS_DOMAIN_".$class."_ANNUAL";
$type = "PREMIUM";
} else {
//VARIABLE FEE PREMIUM DOMAINS (e.g. PREMIUM_TOP_CNY:24:2976)
$p = preg_split("/\:/", $class);
$type = "VARIABLEPREMIUM";
}
if ($type == "VARIABLEPREMIUM") {
//HANDLE VARIABLE FEE PREMIUM DOMAINS
$cl = preg_split("/_/", $p[0]);
$premiummarkupfix_value = ispapi_getUserRelationValue($params, "PRICE_CLASS_DOMAIN_".$cl[0]."_".$cl[1]."_*_ANNUAL_MARKUP_FIX");
$premiummarkupvar_value = ispapi_getUserRelationValue($params, "PRICE_CLASS_DOMAIN_".$cl[0]."_".$cl[1]."_*_ANNUAL_MARKUP_VAR");
if ($premiummarkupfix_value && $premiummarkupvar_value) {
$renewprice = $p[1] * (1 + $premiummarkupvar_value/100) + $premiummarkupfix_value;
return $renewprice;
}
} else {
//HANDLE REGISTRY PREMIUM DOMAINS
return ispapi_getUserRelationValue($params, $class);
}
return false;
}
/**
* Get the value for a given user relationtype
*
* @param array $params common module parameters
* @param string $relationtype the name of the user relationtype
*
* @return integer/bool the user relationvalue, false if not found
*/
function ispapi_getUserRelationValue($params, $relationtype)
{
$relations = ispapi_getUserRelations($params);
$i=0;
foreach ($relations["RELATIONTYPE"] as $relation) {
if ($relation == $relationtype) {
return $relations["RELATIONVALUE"][$i];
}
$i++;
}
return false;
}
/**
* Generate and return the user relations (StatusUser)
* The user relations are stored in a session ($_SESSION["ISPAPICACHE"]["RELATIONS"]) and are regenerated after 600 seconds.
*
* @param array $params common module parameters
*
* @return array/bool the user relations, false if not found
*/
function ispapi_getUserRelations($params)
{
$date = new DateTime();
if ((!isset($_SESSION["ISPAPICACHE"])) || ($_SESSION["ISPAPICACHE"]["TIMESTAMP"] + 600 < $date->getTimestamp() )) {
$command["COMMAND"] = "StatusUser";
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$_SESSION["ISPAPICACHE"] = array("TIMESTAMP" => $date->getTimestamp() , "RELATIONS" => $response["PROPERTY"]);
return $_SESSION["ISPAPICACHE"]["RELATIONS"];
} else {
return false;
}
} else {
return $_SESSION["ISPAPICACHE"]["RELATIONS"];
}
}
/**
* Initialize the version of the module
*
* @param string $version the version of the module
*
*/
function ispapi_InitModule($version)
{
global $ispapi_module_version;
$ispapi_module_version = $version;
}
/**
* Return the version of the module
*
* @return string $version the version of the module
*/
function ispapi_GetISPAPIModuleVersion()
{
global $ispapi_module_version;
return $ispapi_module_version;
}
/**
* Return the configuration array of the module (Setup > Products / Services > Domain Registrars > ISPAPI > Configure)
*
* @param array $params common module parameters
*
* @return array $configarray configuration array of the module
*/
function ispapi_getConfigArray($params)
{
$version = ispapi_GetISPAPIModuleVersion();
$configarray = array(
"FriendlyName" => array("Type" => "System", "Value"=>"ISPAPI v".$version),
"Description" => array("Type" => "System", "Value"=>"The Official ISPAPI Registrar Module. <a target='blank_' href='https://www.hexonet.net'>www.hexonet.net</a>"),
"Username" => array( "Type" => "text", "Size" => "20", "Description" => "Enter your ISPAPI Login ID", ),
"Password" => array( "Type" => "password", "Size" => "20", "Description" => "Enter your ISPAPI Password ", ),
"UseSSL" => array( "Type" => "yesno", "Description" => "Use HTTPS for API Connections" ),
"TestMode" => array( "Type" => "yesno", "Description" => "Connect to OT&E (Test Environment)" ),
"ProxyServer" => array( "Type" => "text", "Description" => "Optional (HTTP(S) Proxy Server)" ),
"ConvertIDNs" => array( "Type" => "dropdown", "Options" => "API,PHP", "Default" => "API", "Description" => "Use API or PHP function (idn_to_ascii)" ),
"DNSSEC" => array( "Type" => "yesno", "Description" => "Display the DNSSEC Management functionality in the domain details" ),
"TRANSFERLOCK" => array( "Type" => "yesno", "Description" => "Locks automatically a domain after a new registration" ),
);
if (!function_exists('idn_to_ascii')) {
$configarray["ConvertIDNs"] = array( "Type" => "dropdown", "Options" => "API", "Default" => "API", "Description" => "Use API (PHP function idn_to_ascii not available)" );
}
if (!empty($params["Username"])) {
//Check authentication
$command = array(
"COMMAND" => "CheckAuthentication",
"SUBUSER" => $params["Username"],
"PASSWORD" => $params["Password"]
);
$response = ispapi_call($command, ispapi_config($params));
$mode_text = ($params["TestMode"]=="on") ? "to OT&E environment" : "to PRODUCTION environment";
$state = ($response["CODE"] == 200) ?
"<div style='color:white;font-weight:bold;background-color:green;padding:3px;width:400px;text-align:center;'>Connected ".$mode_text."</div>" :
"<div style='color:white;font-weight:bold;background-color:red;padding:3px;width:400px;text-align:center;'>Disconnected (Verify Username and Password)<br/>".$response["CODE"]." " .$response["DESCRIPTION"]."</div>";
$configarray[""] = array( "Description" => $state );
}
//Save information about module versions in the environment
if ($response["CODE"] == 200) {
//workarround to call that only 1 time.
static $included = false;
if (!$included) {
$included = true;
$values = array(
"whmcs" => $params["whmcsVersion"],
"updated_date" => (new DateTime("now", new DateTimeZone('UTC')))->format('Y-m-d H:i:s')." (UTC)",
"ispapiwhmcs" => $version,
"phpversion" => phpversion(),
"os" => php_uname("s")
);
// get addon module versions
global $CONFIG;
$activemodules = array_filter(explode(",", $CONFIG["ActiveAddonModules"]));
$addon = new WHMCS\Module\Addon();
foreach ($addon->getList() as $module) {
if (in_array($module, $activemodules) && preg_match("/^ispapi/i", $module) && !preg_match("/\_addon$/i", $module)) {
$d = WHMCS\Module\Addon\Setting::module($module)->pluck("value", "setting");
$values[$module] = $d["version"];
}
}
// get server module versions
$server = new WHMCS\Module\Server();
foreach ($server->getList() as $module) {
if (preg_match("/^ispapi/i", $module)) {
$server->load($module);
$v = $server->getMetaDataValue("MODULEVersion");
$values[$module] = empty($v) ? "old" : $v;
}
}
// get widget module versions
$widget = new WHMCS\Module\Widget();
foreach ($widget->getList() as $module) {
if (preg_match("/^ispapi/i", $module)) {
$widget->load($module);
$tmp = explode("_", $module);
$widgetClass = "\\ISPAPI\\" . ucfirst($tmp[0]) . ucfirst($tmp[1]) . "Widget";
$mname=$tmp[0]."widget".$tmp[1];
if (class_exists($widgetClass) && defined("$widgetClass::VERSION")) {
$values[$mname] = $widgetClass::VERSION;
} else {
$values[$mname] = "n/a";
}
}
}
$command = array(
"COMMAND" => "SetEnvironment",
);
$i=0;
foreach ($values as $key => $value) {
$command["ENVIRONMENTKEY$i"] = "middleware/whmcs/".$_SERVER["HTTP_HOST"];
$command["ENVIRONMENTNAME$i"] = $key;
$command["ENVIRONMENTVALUE$i"] = $value;
$i++;
}
ispapi_call($command, ispapi_config($params));
}
}
return $configarray;
}
/**
* Check if a domain is PREMIUM (required in combination with ISPAPI DomainCheck Addon)
* Will be deprecated with the new Lookup Feature which will support Premium Domains
*
* @param array $params common module parameters
*
* @return array an array with a template name
*/
function ispapi_ClientArea($params)
{
if (isset($params["original"])) {
$params = $params["original"];
}
global $smarty;
$domain = $params["sld"].".".$params["tld"];
$premium = false;
$result = mysql_query("select g.name from tblproductgroups g, tblproducts p, tblhosting h where p.id = h.packageid and p.gid = g.id and h.domain = '".$domain."'");
$data = mysql_fetch_array($result);
if (!empty($data) && $data["name"]=="PREMIUM DOMAIN") {
$premium = true;
}
if ($premium) {
$command = array(
"COMMAND" => "StatusDomain",
"DOMAIN" => $domain
);
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$smarty->assign("statusdomain", $response["PROPERTY"]);
}
return array(
'templatefile' => 'clientarea_premium'
);
}
}
/**
* Provide custom buttons (whoisprivacy, DNSSEC Management) for domains and change of registrant button for certain domain names on client area
*
* @param array $params common module parameters
*
* @return array $buttonarray an array custum buttons
*/
function ispapi_ClientAreaCustomButtonArray($params)
{
$buttonarray = array();
if (isset($params["domainid"])) {
$domainid = $params["domainid"];
} elseif (!isset($_REQUEST["id"])) {
$params = $GLOBALS["params"];
$domainid = $params["domainid"];
} else {
$domainid = $_REQUEST["id"];
}
$result = select_query('tbldomains', 'idprotection,domain', array ('id' => $domainid));
$data = mysql_fetch_array($result);
if ($data && ($data["idprotection"])) {
$buttonarray["WHOIS Privacy"] = "whoisprivacy";
}
if ($data && (preg_match('/[.]ca$/i', $data["domain"]))) {
$buttonarray[".CA Registrant WHOIS Privacy"] = "whoisprivacy_ca";
}
if ($data && (preg_match('/[.]ca$/i', $data["domain"]))) {
$buttonarray[".CA Change of Registrant"] = "registrantmodification_ca";
}
if ($data && (preg_match('/[.]it$/i', $data["domain"]))) {
$buttonarray[".IT Change of Registrant"] = "registrantmodification_it";
}
if ($data && (preg_match('/[.]ch$/i', $data["domain"]))) {
$buttonarray[".CH Change of Registrant"] = "registrantmodification_tld";
}
if ($data && (preg_match('/[.]li$/i', $data["domain"]))) {
$buttonarray[".LI Change of Registrant"] = "registrantmodification_tld";
}
if ($data && (preg_match('/[.]se$/i', $data["domain"]))) {
$buttonarray[".SE Change of Registrant"] = "registrantmodification_tld";
}
if ($data && (preg_match('/[.]sg$/i', $data["domain"]))) {
$buttonarray[".SG Change of Registrant"] = "registrantmodification_tld";
}
if ($params["DNSSEC"] == "on") {
$buttonarray["DNSSEC Management"] = "dnssec";
}
return $buttonarray;
}
/**
* Handle the DNSSEC management page of a domain
*
* @param array $params common module parameters
*
* @return array an array with a template name
*/
function ispapi_dnssec($params)
{
$origparams = $params;
if (isset($params["original"])) {
$params = $params["original"];
}
$error = false;
$successful = false;
$domain = $params["sld"].".".$params["tld"];
if (isset($_POST["submit"])) {
$command = array(
"COMMAND" => "ModifyDomain",
"DOMAIN" => $domain,
"SECDNS-MAXSIGLIFE" => $_POST["MAXSIGLIFE"],
//"SECDNS-URGENT" => $_POST["URGENT"]
);
//add DS records
$command["SECDNS-DS"] = array();
if (isset($_POST["SECDNS-DS"])) {
foreach ($_POST["SECDNS-DS"] as $dnssecrecord) {
$everything_empty = true;
foreach ($dnssecrecord as $attribute) {
if (!empty($attribute)) {
$everything_empty = false;
}
}
if (!$everything_empty) {
array_push($command["SECDNS-DS"], implode(" ", $dnssecrecord));
}
}
}
//remove DS records - bugfix
if (empty($command["SECDNS-DS"])) {
unset($command["SECDNS-DS"]);
$secdnsds = array();
$command2 = array(
"COMMAND" => "StatusDomain",
"DOMAIN" => $domain
);
$response = ispapi_call($command2, ispapi_config($params));
if ($response["CODE"] == 200) {
$secdnsds = (isset($response["PROPERTY"]["SECDNS-DS"])) ? $response["PROPERTY"]["SECDNS-DS"] : array();
}
$command["DELSECDNS-DS"] = array();
foreach ($secdnsds as $item) {
array_push($command["DELSECDNS-DS"], $item);
}
}
//add KEY records
$command["SECDNS-KEY"] = array();
if (isset($_POST["SECDNS-KEY"])) {
foreach ($_POST["SECDNS-KEY"] as $dnssecrecord) {
$everything_empty = true;
foreach ($dnssecrecord as $attribute) {
if (!empty($attribute)) {
$everything_empty = false;
}
}
if (!$everything_empty) {
array_push($command["SECDNS-KEY"], implode(" ", $dnssecrecord));
}
}
}
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$successful = $response["DESCRIPTION"];
} else {
$error = $response["DESCRIPTION"];
}
}
$secdnsds = array();
$secdnskey = array();
$maxsiglife = "";
$command = array(
"COMMAND" => "StatusDomain",
"DOMAIN" => $domain
);
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$maxsiglife = (isset($response["PROPERTY"]["SECDNS-MAXSIGLIFE"])) ? $response["PROPERTY"]["SECDNS-MAXSIGLIFE"][0] : "";
$secdnsds = (isset($response["PROPERTY"]["SECDNS-DS"])) ? $response["PROPERTY"]["SECDNS-DS"] : array();
$secdnskey = (isset($response["PROPERTY"]["SECDNS-KEY"])) ? $response["PROPERTY"]["SECDNS-KEY"] : array();
//delete empty KEY records
$secdnskeynew = array();
foreach ($secdnskey as $k) {
if (!empty($k)) {
$secdnskeynew[] = $k;
}
}
$secdnskey = $secdnskeynew;
} else {
$error = $response["DESCRIPTION"];
}
//split in different fields
$secdnsds_newformat = array();
foreach ($secdnsds as $ds) {
list($keytag, $alg, $digesttype, $digest) = preg_split('/\s+/', $ds);
array_push($secdnsds_newformat, array("keytag" => $keytag, "alg" => $alg, "digesttype" => $digesttype, "digest" => $digest));
}
$secdnskey_newformat = array();
foreach ($secdnskey as $key) {
list($flags, $protocol, $alg, $pubkey) = preg_split('/\s+/', $key);
array_push($secdnskey_newformat, array("flags" => $flags, "protocol" => $protocol, "alg" => $alg, "pubkey" => $pubkey));
}
return array(
'templatefile' => "dnssec",
'vars' => array('error' => $error, 'successful' => $successful, 'secdnsds' => $secdnsds_newformat, 'secdnskey' => $secdnskey_newformat, 'maxsiglife' => $maxsiglife )
);
}
/**
* Return a special page for the registrant modification of a .IT domain
*
* @param array $params common module parameters
*
* @return array an array with a template name and some variables
*/
function ispapi_registrantmodification_it($params)
{
global $additionaldomainfields;
$origparams = $params;
if (isset($params["original"])) {
$params = $params["original"];
}
$error = false;
$successful = false;
$domain = $params["sld"].".".$params["tld"];
$values = array();
$command = array(
"COMMAND" => "StatusDomain",
"DOMAIN" => $domain
);
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$values["Registrant"] = ispapi_get_contact_info($response["PROPERTY"]["OWNERCONTACT"][0], $params);
}
//handle additionaldomainfields
//------------------------------------------------------------------------------
ispapi_include_additionaladditionalfields();
$myadditionalfields = array();
if (is_array($additionaldomainfields) && isset($additionaldomainfields[".".$params["tld"]])) {
$myadditionalfields = $additionaldomainfields[".".$params["tld"]];
}
foreach ($myadditionalfields as $field_index => $field) {
if (!is_array($field["Ispapi-Replacements"])) {
$field["Ispapi-Replacements"] = array();
}
if (isset($field["Ispapi-Options"]) && isset($field["Options"])) {
$options = explode(",", $field["Options"]);
foreach (explode(",", $field["Ispapi-Options"]) as $index => $new_option) {
$option = $options[$index];
if (!isset($field["Ispapi-Replacements"][$option])) {
$field["Ispapi-Replacements"][$option] = $new_option;
}
}
}
$myadditionalfields[$field_index] = $field;
}
//------------------------------------------------------------------------------
if (isset($_POST["submit"])) {
if (empty($_POST["additionalfields"]["Section 3 Agreement"]) || empty($_POST["additionalfields"]["Section 5 Agreement"]) || empty($_POST["additionalfields"]["Section 6 Agreement"]) || empty($_POST["additionalfields"]["Section 7 Agreement"])) {
$error = "You have to accept the agreement section 3, 5, 6 and 7.";
} else {
$newvalues["Registrant"] = $_POST["contactdetails"]["Registrant"];
$values = $newvalues;
$command = array(
"COMMAND" => "TradeDomain",
"DOMAIN" => $domain
);
$map = array(
"OWNERCONTACT0" => "Registrant",
"ADMINCONTACT0" => "Registrant",
);
foreach ($map as $ctype => $ptype) {
if (isset($_POST["contactdetails"][$ptype])) {
$p = $_POST["contactdetails"][$ptype];
$command[$ctype] = array(
"FIRSTNAME" => html_entity_decode($p["First Name"], ENT_QUOTES),
"LASTNAME" => html_entity_decode($p["Last Name"], ENT_QUOTES),
"ORGANIZATION" => html_entity_decode($p["Company Name"], ENT_QUOTES),
"STREET" => html_entity_decode($p["Address"], ENT_QUOTES),
"CITY" => html_entity_decode($p["City"], ENT_QUOTES),
"STATE" => html_entity_decode($p["State"], ENT_QUOTES),
"ZIP" => html_entity_decode($p["Postcode"], ENT_QUOTES),
"COUNTRY" => html_entity_decode($p["Country"], ENT_QUOTES),
"PHONE" => html_entity_decode($p["Phone"], ENT_QUOTES),
"FAX" => html_entity_decode($p["Fax"], ENT_QUOTES),
"EMAIL" => html_entity_decode($p["Email"], ENT_QUOTES),
);
if (strlen($p["Address 2"])) {
$command[$ctype]["STREET"] .= " , ".html_entity_decode($p["Address 2"], ENT_QUOTES);
}
}
}
if (isset($params["additionalfields"]["Local Presence"])) {
if (!empty($_POST["additionalfields"]["Local Presence"])) {
$params["additionalfields"]["Local Presence"] = "1";
} else {
unset($params["additionalfields"]["Local Presence"]);
}
}
$params["additionalfields"]["PIN"] = $_POST["additionalfields"]["PIN"];
$params["additionalfields"]["Section 3 Agreement"] = "1";
$params["additionalfields"]["Section 5 Agreement"] = "1";
$params["additionalfields"]["Section 6 Agreement"] = "1";
$params["additionalfields"]["Section 7 Agreement"] = "1";
ispapi_use_additionalfields($params, $command);
$response = ispapi_call($command, ispapi_config($origparams));
if ($response["CODE"] == 200) {
$successful = $response["DESCRIPTION"];
} else {
$error = $response["DESCRIPTION"];
}
}
}
return array(
'templatefile' => "registrantmodification_it",
'vars' => array('error' => $error, 'successful' => $successful, 'values' => $values, 'additionalfields' => $myadditionalfields),
);
}
/**
* Return a page for the registrant modification of a domain name
*
* @param array $params common module parameters
*
* @return array an array with a template name and some variables
*/
function ispapi_registrantmodification_tld($params)
{
global $additionaldomainfields;
$origparams = $params;
if (isset($params["original"])) {
$params = $params["original"];
}
$error = false;
$successful = false;
$domain = $params["sld"].".".$params["tld"];
$values = array();
$command = array(
"COMMAND" => "StatusDomain",
"DOMAIN" => $domain
);
$response = ispapi_call($command, ispapi_config($params));
if ($response["CODE"] == 200) {
$values["Registrant"] = ispapi_get_contact_info($response["PROPERTY"]["OWNERCONTACT"][0], $params);
}
if (isset($_POST["submit"])) {
$newvalues["Registrant"] = $_POST["contactdetails"]["Registrant"];
$values = $newvalues;
$command = array(
"COMMAND" => "TradeDomain",
"DOMAIN" => $domain
);
$map = array(
"OWNERCONTACT0" => "Registrant",
"ADMINCONTACT0" => "Registrant",
);
foreach ($map as $ctype => $ptype) {
if (isset($_POST["contactdetails"][$ptype])) {
$p = $_POST["contactdetails"][$ptype];
$command[$ctype] = array(
"FIRSTNAME" => html_entity_decode($p["First Name"], ENT_QUOTES),
"LASTNAME" => html_entity_decode($p["Last Name"], ENT_QUOTES),
"ORGANIZATION" => html_entity_decode($p["Company Name"], ENT_QUOTES),
"STREET" => html_entity_decode($p["Address"], ENT_QUOTES),
"CITY" => html_entity_decode($p["City"], ENT_QUOTES),
"STATE" => html_entity_decode($p["State"], ENT_QUOTES),
"ZIP" => html_entity_decode($p["Postcode"], ENT_QUOTES),
"COUNTRY" => html_entity_decode($p["Country"], ENT_QUOTES),
"PHONE" => html_entity_decode($p["Phone"], ENT_QUOTES),
"FAX" => html_entity_decode($p["Fax"], ENT_QUOTES),
"EMAIL" => html_entity_decode($p["Email"], ENT_QUOTES),
);
if (strlen($p["Address 2"])) {
$command[$ctype]["STREET"] .= " , ".html_entity_decode($p["Address 2"], ENT_QUOTES);
}
}
}
if (preg_match('/[.]se$/i', $domain)) {
//check if the checkbox has been checked.
if (!$_POST['se-checkbox'] == "on") {
$error = "Please confirm that you will send the form back to complete the process";
}
}
if (!$error) {
ispapi_use_additionalfields($params, $command);
$response = ispapi_call($command, ispapi_config($origparams));
if ($response["CODE"] == 200) {
$successful = $response["DESCRIPTION"];
} else {
$error = $response["DESCRIPTION"];
}
}
}
return array(
'templatefile' => "registrantmodification_tld",
'vars' => array('error' => $error, 'successful' => $successful, 'values' => $values, 'additionalfields' => $myadditionalfields),
);
}
/**
* Return a special page for the registrant modification of a .CA domain name
*
* @param array $params common module parameters
*
* @return array an array with a template name and some variables
*/
function ispapi_registrantmodification_ca($params)
{
global $additionaldomainfields;
$origparams = $params;
if (isset($params["original"])) {
$params = $params["original"];
}
$error = false;
$successful = false;
$domain = $params["sld"].".".$params["tld"];
$values = array();
//handle additionaldomainfields
//------------------------------------------------------------------------------
ispapi_include_additionaladditionalfields();
$myadditionalfields = array();
if (is_array($additionaldomainfields) && isset($additionaldomainfields[".".$params["tld"]])) {
$myadditionalfields = $additionaldomainfields[".".$params["tld"]];
}
foreach ($myadditionalfields as $field_index => $field) {
if (!is_array($field["Ispapi-Replacements"])) {
$field["Ispapi-Replacements"] = array();
}
if (isset($field["Ispapi-Options"]) && isset($field["Options"])) {
$options = explode(",", $field["Options"]);
foreach (explode(",", $field["Ispapi-Options"]) as $index => $new_option) {
$option = $options[$index];
if (!isset($field["Ispapi-Replacements"][$option])) {
$field["Ispapi-Replacements"][$option] = $new_option;
}
}
}
$myadditionalfields[$field_index] = $field;
}
//delete "Contact Language" and "Trademark Number"
$i = 0;
foreach ($myadditionalfields as $item) {
if (in_array($item["Name"], array("Contact Language", "Trademark Number"))) {
unset($myadditionalfields[$i]);
}
$i++;
}
//------------------------------------------------------------------------------
$command = array(